From: Atari Ace

Hi mamedev,

This patch eliminates global/static variables in a number of
Taito/Irem drivers by introducing/using driver_device classes.

~aa
This commit is contained in:
Aaron Giles 2011-02-03 10:38:15 +00:00
parent f534d245c0
commit 659dc8ac6e
87 changed files with 2576 additions and 2086 deletions

View File

@ -34,17 +34,6 @@
/*************************************
*
* Statics
*
*************************************/
static UINT8 ay8910_latch_1;
static UINT8 ay8910_latch_2;
/*************************************
*
* Read Alert analog sounds
@ -87,6 +76,7 @@ WRITE8_HANDLER( redalert_audio_command_w )
static WRITE8_DEVICE_HANDLER( redalert_AY8910_w )
{
redalert_state *state = device->machine->driver_data<redalert_state>();
/* BC2 is connected to a pull-up resistor, so BC2=1 always */
switch (data & 0x03)
{
@ -96,7 +86,7 @@ static WRITE8_DEVICE_HANDLER( redalert_AY8910_w )
/* BC1=1, BDIR=0 : read from PSG */
case 0x01:
ay8910_latch_1 = ay8910_r(device, 0);
state->ay8910_latch_1 = ay8910_r(device, 0);
break;
/* BC1=0, BDIR=1 : write to PSG */
@ -104,7 +94,7 @@ static WRITE8_DEVICE_HANDLER( redalert_AY8910_w )
case 0x02:
case 0x03:
default:
ay8910_data_address_w(device, data, ay8910_latch_2);
ay8910_data_address_w(device, data, state->ay8910_latch_2);
break;
}
}
@ -112,13 +102,15 @@ static WRITE8_DEVICE_HANDLER( redalert_AY8910_w )
static READ8_HANDLER( redalert_ay8910_latch_1_r )
{
return ay8910_latch_1;
redalert_state *state = space->machine->driver_data<redalert_state>();
return state->ay8910_latch_1;
}
static WRITE8_HANDLER( redalert_ay8910_latch_2_w )
{
ay8910_latch_2 = data;
redalert_state *state = space->machine->driver_data<redalert_state>();
state->ay8910_latch_2 = data;
}
@ -150,8 +142,9 @@ ADDRESS_MAP_END
static SOUND_START( redalert_audio )
{
state_save_register_global(machine, ay8910_latch_1);
state_save_register_global(machine, ay8910_latch_2);
redalert_state *state = machine->driver_data<redalert_state>();
state_save_register_global(machine, state->ay8910_latch_1);
state_save_register_global(machine, state->ay8910_latch_2);
}
@ -297,52 +290,55 @@ WRITE8_HANDLER( demoneye_audio_command_w )
static WRITE8_DEVICE_HANDLER( demoneye_ay8910_latch_1_w )
{
ay8910_latch_1 = data;
redalert_state *state = device->machine->driver_data<redalert_state>();
state->ay8910_latch_1 = data;
}
static READ8_DEVICE_HANDLER( demoneye_ay8910_latch_2_r )
{
return ay8910_latch_2;
redalert_state *state = device->machine->driver_data<redalert_state>();
return state->ay8910_latch_2;
}
static WRITE8_DEVICE_HANDLER( demoneye_ay8910_data_w )
{
redalert_state *state = device->machine->driver_data<redalert_state>();
device_t *ay1 = device->machine->device("ay1");
device_t *ay2 = device->machine->device("ay2");
switch (ay8910_latch_1 & 0x03)
switch (state->ay8910_latch_1 & 0x03)
{
case 0x00:
if (ay8910_latch_1 & 0x10)
if (state->ay8910_latch_1 & 0x10)
ay8910_data_w(ay1, 0, data);
if (ay8910_latch_1 & 0x20)
if (state->ay8910_latch_1 & 0x20)
ay8910_data_w(ay2, 0, data);
break;
case 0x01:
if (ay8910_latch_1 & 0x10)
ay8910_latch_2 = ay8910_r(ay1, 0);
if (state->ay8910_latch_1 & 0x10)
state->ay8910_latch_2 = ay8910_r(ay1, 0);
if (ay8910_latch_1 & 0x20)
ay8910_latch_2 = ay8910_r(ay2, 0);
if (state->ay8910_latch_1 & 0x20)
state->ay8910_latch_2 = ay8910_r(ay2, 0);
break;
case 0x03:
if (ay8910_latch_1 & 0x10)
if (state->ay8910_latch_1 & 0x10)
ay8910_address_w(ay1, 0, data);
if (ay8910_latch_1 & 0x20)
if (state->ay8910_latch_1 & 0x20)
ay8910_address_w(ay2, 0, data);
break;
default:
logerror("demoneye_ay8910_data_w called with latch %02X data %02X\n", ay8910_latch_1, data);
logerror("demoneye_ay8910_data_w called with latch %02X data %02X\n", state->ay8910_latch_1, data);
break;
}
}
@ -393,8 +389,9 @@ static const pia6821_interface demoneye_pia_intf =
static SOUND_START( demoneye )
{
state_save_register_global(machine, ay8910_latch_1);
state_save_register_global(machine, ay8910_latch_2);
redalert_state *state = machine->driver_data<redalert_state>();
state_save_register_global(machine, state->ay8910_latch_1);
state_save_register_global(machine, state->ay8910_latch_2);
}

View File

@ -145,40 +145,41 @@ static ADDRESS_MAP_START( bking_audio_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_END
#if 0
static UINT8 port_a_in,port_a_out,ddr_a;
static READ8_HANDLER( bking3_68705_port_a_r )
{
//printf("port_a_r = %02X\n",(port_a_out & ddr_a) | (port_a_in & ~ddr_a));
return (port_a_out & ddr_a) | (port_a_in & ~ddr_a);
bking_state *state = space->machine->driver_data<bking_state>();
//printf("port_a_r = %02X\n",(state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a));
return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
}
static WRITE8_HANDLER( bking3_68705_port_a_w )
{
port_a_out = data;
bking_state *state = space->machine->driver_data<bking_state>();
state->port_a_out = data;
// printf("port_a_out = %02X\n",data);
}
static WRITE8_HANDLER( bking3_68705_ddr_a_w )
{
ddr_a = data;
bking_state *state = space->machine->driver_data<bking_state>();
state->ddr_a = data;
}
static UINT8 port_b_in,port_b_out,ddr_b;
static READ8_HANDLER( bking3_68705_port_b_r )
{
return (port_b_out & ddr_b) | (port_b_in & ~ddr_b);
bking_state *state = space->machine->driver_data<bking_state>();
return (state->port_b_out & state->ddr_b) | (state->port_b_in & ~state->ddr_b);
}
static WRITE8_HANDLER( bking3_68705_port_b_w )
{
bking_state *state = space->machine->driver_data<bking_state>();
// if(data != 0xff)
// printf("port_b_out = %02X\n",data);
if (~data & 0x02)
{
port_a_in = from_main;
state->port_a_in = from_main;
if (main_sent) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
main_sent = 0;
}
@ -186,19 +187,20 @@ static WRITE8_HANDLER( bking3_68705_port_b_w )
if (~data & 0x04)
{
/* 68705 is writing data for the Z80 */
from_mcu = port_a_out;
from_mcu = state->port_a_out;
mcu_sent = 1;
}
if(data != 0xff && data != 0xfb && data != 0xfd)
printf("port_b_w = %X\n",data);
port_b_out = data;
state->port_b_out = data;
}
static WRITE8_HANDLER( bking3_68705_ddr_b_w )
{
ddr_b = data;
bking_state *state = space->machine->driver_data<bking_state>();
state->ddr_b = data;
}
static READ8_HANDLER( bking3_68705_port_c_r )

View File

@ -19,10 +19,6 @@
#include "includes/crbaloon.h"
static UINT8 *pc3092_data;
/*************************************
*
* PC3092 custom chip
@ -56,15 +52,17 @@ static void pc3092_reset(void)
static void pc3092_update(running_machine *machine)
{
flip_screen_set(machine, (pc3092_data[1] & 0x01) ? TRUE : FALSE);
crbaloon_state *state = machine->driver_data<crbaloon_state>();
flip_screen_set(machine, (state->pc3092_data[1] & 0x01) ? TRUE : FALSE);
}
static WRITE8_HANDLER( pc3092_w )
{
pc3092_data[offset] = data & 0x0f;
crbaloon_state *state = space->machine->driver_data<crbaloon_state>();
state->pc3092_data[offset] = data & 0x0f;
if (LOG_PC3092) logerror("%04X: write PC3092 #%d = 0x%02x\n", cpu_get_pc(space->cpu), offset, pc3092_data[offset]);
if (LOG_PC3092) logerror("%04X: write PC3092 #%d = 0x%02x\n", cpu_get_pc(space->cpu), offset, state->pc3092_data[offset]);
pc3092_update(space->machine);
}
@ -72,10 +70,11 @@ static WRITE8_HANDLER( pc3092_w )
static CUSTOM_INPUT( pc3092_r )
{
crbaloon_state *state = field->port->machine->driver_data<crbaloon_state>();
UINT32 ret;
/* enable coin & start input? Wild guess!!! */
if (pc3092_data[1] & 0x02)
if (state->pc3092_data[1] & 0x02)
ret = input_port_read(field->port->machine, "PC3092");
else
ret = 0x00;
@ -121,7 +120,7 @@ static READ8_HANDLER( pc3259_r )
UINT8 ret = 0;
UINT8 reg = offset >> 2;
UINT16 collision_address = crbaloon_get_collision_address();
UINT16 collision_address = crbaloon_get_collision_address(space->machine);
int collided = (collision_address != 0xffff);
switch (reg)
@ -164,7 +163,7 @@ static WRITE8_HANDLER( port_sound_w )
/* D0 - interrupt enable - also goes to PC3259 as /HTCTRL */
cpu_interrupt_enable(space->machine->device("maincpu"), (data & 0x01) ? TRUE : FALSE);
crbaloon_set_clear_collision_address((data & 0x01) ? TRUE : FALSE);
crbaloon_set_clear_collision_address(space->machine, (data & 0x01) ? TRUE : FALSE);
/* D1 - SOUND STOP */
space->machine->sound().system_enable((data & 0x02) ? TRUE : FALSE);
@ -201,8 +200,8 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7fff) /* A15 is not decoded */
AM_RANGE(0x0000, 0x3fff) AM_ROM /* not fully populated */
AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x0400) AM_RAM
AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0x0400) AM_RAM_WRITE(crbaloon_videoram_w) AM_BASE(&crbaloon_videoram)
AM_RANGE(0x5000, 0x53ff) AM_MIRROR(0x0400) AM_RAM_WRITE(crbaloon_colorram_w) AM_BASE(&crbaloon_colorram)
AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0x0400) AM_RAM_WRITE(crbaloon_videoram_w) AM_BASE_MEMBER(crbaloon_state, videoram)
AM_RANGE(0x5000, 0x53ff) AM_MIRROR(0x0400) AM_RAM_WRITE(crbaloon_colorram_w) AM_BASE_MEMBER(crbaloon_state, colorram)
AM_RANGE(0x5800, 0x7fff) AM_NOP
ADDRESS_MAP_END
@ -223,10 +222,10 @@ static ADDRESS_MAP_START( main_io_map, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x00, 0x00) AM_WRITENOP /* not connected */
AM_RANGE(0x01, 0x01) AM_WRITENOP /* watchdog */
AM_RANGE(0x02, 0x04) AM_WRITEONLY AM_BASE(&crbaloon_spriteram)
AM_RANGE(0x02, 0x04) AM_WRITEONLY AM_BASE_MEMBER(crbaloon_state, spriteram)
AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", crbaloon_audio_set_music_freq)
AM_RANGE(0x06, 0x06) AM_WRITE(port_sound_w)
AM_RANGE(0x07, 0x0b) AM_WRITE(pc3092_w) AM_BASE(&pc3092_data)
AM_RANGE(0x07, 0x0b) AM_WRITE(pc3092_w) AM_BASE_MEMBER(crbaloon_state, pc3092_data)
AM_RANGE(0x0c, 0x0c) AM_WRITENOP /* MSK - to PC3259 */
AM_RANGE(0x0d, 0x0d) AM_WRITENOP /* schematics has it in a box marked "NOT USE" */
AM_RANGE(0x0e, 0x0f) AM_WRITENOP
@ -358,7 +357,7 @@ static MACHINE_RESET( crballoon )
*
*************************************/
static MACHINE_CONFIG_START( crbaloon, driver_device )
static MACHINE_CONFIG_START( crbaloon, crbaloon_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, CRBALOON_MASTER_XTAL / 3)

View File

@ -29,16 +29,12 @@ TODO:
#include "audio/t5182.h"
#include "includes/darkmist.h"
static UINT8 * darkmist_workram;
int darkmist_hw;
static WRITE8_HANDLER(darkmist_hw_w)
{
darkmist_hw=data;
memory_set_bankptr(space->machine, "bank1",&space->machine->region("maincpu")->base()[0x010000+((data&0x80)?0x4000:0)]);
darkmist_state *state = space->machine->driver_data<darkmist_state>();
state->hw=data;
memory_set_bankptr(space->machine, "bank1",&space->machine->region("maincpu")->base()[0x010000+((data&0x80)?0x4000:0)]);
}
static READ8_HANDLER(t5182shared_r)
@ -59,19 +55,19 @@ static ADDRESS_MAP_START( memmap, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc802, 0xc802) AM_READ_PORT("P2")
AM_RANGE(0xc803, 0xc803) AM_READ_PORT("START")
AM_RANGE(0xc804, 0xc804) AM_WRITE(darkmist_hw_w)
AM_RANGE(0xc805, 0xc805) AM_WRITEONLY AM_BASE(&darkmist_spritebank)
AM_RANGE(0xc805, 0xc805) AM_WRITEONLY AM_BASE_MEMBER(darkmist_state, spritebank)
AM_RANGE(0xc806, 0xc806) AM_READ_PORT("DSW1")
AM_RANGE(0xc807, 0xc807) AM_READ_PORT("DSW2")
AM_RANGE(0xc808, 0xc808) AM_READ_PORT("UNK")
AM_RANGE(0xd000, 0xd3ff) AM_RAM AM_BASE_GENERIC(paletteram)
AM_RANGE(0xd400, 0xd41f) AM_RAM AM_BASE(&darkmist_scroll)
AM_RANGE(0xd400, 0xd41f) AM_RAM AM_BASE_MEMBER(darkmist_state, scroll)
AM_RANGE(0xd600, 0xd67f) AM_READWRITE(t5182shared_r, t5182shared_w)
AM_RANGE(0xd680, 0xd680) AM_WRITE(t5182_sound_irq_w)
AM_RANGE(0xd681, 0xd681) AM_READ(t5182_sharedram_semaphore_snd_r)
AM_RANGE(0xd682, 0xd682) AM_WRITE(t5182_sharedram_semaphore_main_acquire_w)
AM_RANGE(0xd683, 0xd683) AM_WRITE(t5182_sharedram_semaphore_main_release_w)
AM_RANGE(0xd800, 0xdfff) AM_RAM AM_BASE_MEMBER(darkmist_state, videoram)
AM_RANGE(0xe000, 0xefff) AM_RAM AM_BASE(&darkmist_workram)
AM_RANGE(0xe000, 0xefff) AM_RAM AM_BASE_MEMBER(darkmist_state, workram)
AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
ADDRESS_MAP_END

View File

@ -40,15 +40,6 @@ TODO:
#include "includes/exzisus.h"
/***************************************************************************
Variables
***************************************************************************/
static UINT8 *exzisus_sharedram_ab;
static UINT8 *exzisus_sharedram_ac;
/***************************************************************************
Memory Handler(s)
@ -57,15 +48,15 @@ static UINT8 *exzisus_sharedram_ac;
static WRITE8_HANDLER( exzisus_cpua_bankswitch_w )
{
exzisus_state *state = space->machine->driver_data<exzisus_state>();
UINT8 *RAM = space->machine->region("cpua")->base();
static int exzisus_cpua_bank = 0;
if ( (data & 0x0f) != exzisus_cpua_bank )
if ( (data & 0x0f) != state->cpua_bank )
{
exzisus_cpua_bank = data & 0x0f;
if (exzisus_cpua_bank >= 2)
state->cpua_bank = data & 0x0f;
if (state->cpua_bank >= 2)
{
memory_set_bankptr(space->machine, "bank2", &RAM[ 0x10000 + ( (exzisus_cpua_bank - 2) * 0x4000 ) ] );
memory_set_bankptr(space->machine, "bank2", &RAM[ 0x10000 + ( (state->cpua_bank - 2) * 0x4000 ) ] );
}
}
@ -74,15 +65,15 @@ static WRITE8_HANDLER( exzisus_cpua_bankswitch_w )
static WRITE8_HANDLER( exzisus_cpub_bankswitch_w )
{
exzisus_state *state = space->machine->driver_data<exzisus_state>();
UINT8 *RAM = space->machine->region("cpub")->base();
static int exzisus_cpub_bank = 0;
if ( (data & 0x0f) != exzisus_cpub_bank )
if ( (data & 0x0f) != state->cpub_bank )
{
exzisus_cpub_bank = data & 0x0f;
if (exzisus_cpub_bank >= 2)
state->cpub_bank = data & 0x0f;
if (state->cpub_bank >= 2)
{
memory_set_bankptr(space->machine, "bank1", &RAM[ 0x10000 + ( (exzisus_cpub_bank - 2) * 0x4000 ) ] );
memory_set_bankptr(space->machine, "bank1", &RAM[ 0x10000 + ( (state->cpub_bank - 2) * 0x4000 ) ] );
}
}
@ -99,22 +90,26 @@ static WRITE8_HANDLER( exzisus_coincounter_w )
static READ8_HANDLER( exzisus_sharedram_ab_r )
{
return exzisus_sharedram_ab[offset];
exzisus_state *state = space->machine->driver_data<exzisus_state>();
return state->sharedram_ab[offset];
}
static READ8_HANDLER( exzisus_sharedram_ac_r )
{
return exzisus_sharedram_ac[offset];
exzisus_state *state = space->machine->driver_data<exzisus_state>();
return state->sharedram_ac[offset];
}
static WRITE8_HANDLER( exzisus_sharedram_ab_w )
{
exzisus_sharedram_ab[offset] = data;
exzisus_state *state = space->machine->driver_data<exzisus_state>();
state->sharedram_ab[offset] = data;
}
static WRITE8_HANDLER( exzisus_sharedram_ac_w )
{
exzisus_sharedram_ac[offset] = data;
exzisus_state *state = space->machine->driver_data<exzisus_state>();
state->sharedram_ac[offset] = data;
}
// is it ok that cpub_reset refers to cpuc?
@ -148,19 +143,19 @@ static DRIVER_INIT( exzisus )
static ADDRESS_MAP_START( cpua_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank2")
AM_RANGE(0xc000, 0xc5ff) AM_READWRITE(exzisus_objectram_1_r, exzisus_objectram_1_w) AM_BASE(&exzisus_objectram1) AM_SIZE(&exzisus_objectram_size1)
AM_RANGE(0xc600, 0xdfff) AM_READWRITE(exzisus_videoram_1_r, exzisus_videoram_1_w) AM_BASE(&exzisus_videoram1)
AM_RANGE(0xe000, 0xefff) AM_READWRITE(exzisus_sharedram_ac_r, exzisus_sharedram_ac_w) AM_BASE(&exzisus_sharedram_ac)
AM_RANGE(0xc000, 0xc5ff) AM_READWRITE(exzisus_objectram_1_r, exzisus_objectram_1_w) AM_BASE_MEMBER(exzisus_state, objectram1) AM_SIZE_MEMBER(exzisus_state, objectram_size1)
AM_RANGE(0xc600, 0xdfff) AM_READWRITE(exzisus_videoram_1_r, exzisus_videoram_1_w) AM_BASE_MEMBER(exzisus_state, videoram1)
AM_RANGE(0xe000, 0xefff) AM_READWRITE(exzisus_sharedram_ac_r, exzisus_sharedram_ac_w) AM_BASE_MEMBER(exzisus_state, sharedram_ac)
AM_RANGE(0xf400, 0xf400) AM_WRITE(exzisus_cpua_bankswitch_w)
AM_RANGE(0xf404, 0xf404) AM_WRITE(exzisus_cpub_reset_w) // ??
AM_RANGE(0xf800, 0xffff) AM_READWRITE(exzisus_sharedram_ab_r, exzisus_sharedram_ab_w) AM_BASE(&exzisus_sharedram_ab)
AM_RANGE(0xf800, 0xffff) AM_READWRITE(exzisus_sharedram_ab_r, exzisus_sharedram_ab_w) AM_BASE_MEMBER(exzisus_state, sharedram_ab)
ADDRESS_MAP_END
static ADDRESS_MAP_START( cpub_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xc5ff) AM_READWRITE(exzisus_objectram_0_r, exzisus_objectram_0_w) AM_BASE(&exzisus_objectram0) AM_SIZE(&exzisus_objectram_size0)
AM_RANGE(0xc600, 0xdfff) AM_READWRITE(exzisus_videoram_0_r, exzisus_videoram_0_w) AM_BASE(&exzisus_videoram0)
AM_RANGE(0xc000, 0xc5ff) AM_READWRITE(exzisus_objectram_0_r, exzisus_objectram_0_w) AM_BASE_MEMBER(exzisus_state, objectram0) AM_SIZE_MEMBER(exzisus_state, objectram_size0)
AM_RANGE(0xc600, 0xdfff) AM_READWRITE(exzisus_videoram_0_r, exzisus_videoram_0_w) AM_BASE_MEMBER(exzisus_state, videoram0)
AM_RANGE(0xe000, 0xefff) AM_RAM
AM_RANGE(0xf000, 0xf000) AM_READNOP AM_DEVWRITE("tc0140syt", tc0140syt_port_w)
AM_RANGE(0xf001, 0xf001) AM_DEVREADWRITE("tc0140syt", tc0140syt_comm_r, tc0140syt_comm_w)
@ -280,7 +275,7 @@ static const tc0140syt_interface exzisus_tc0140syt_intf =
};
/* All clocks are unconfirmed */
static MACHINE_CONFIG_START( exzisus, driver_device )
static MACHINE_CONFIG_START( exzisus, exzisus_state )
/* basic machine hardware */
MCFG_CPU_ADD("cpua", Z80, 6000000)

View File

@ -158,29 +158,27 @@ static ADDRESS_MAP_START( victnine_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE_MEMBER(flstory_state, workram) /* work RAM */
ADDRESS_MAP_END
static UINT8 mcu_cmd,mcu_counter,mcu_b4_cmd;
static UINT8 mcu_param;
static UINT8 mcu_b2_res,mcu_b1_res,mcu_bb_res,mcu_b5_res,mcu_b6_res;
static READ8_HANDLER( rumba_mcu_r )
{
//printf("PC=%04x R %02x\n",cpu_get_pc(space->cpu),mcu_cmd);
flstory_state *state = space->machine->driver_data<flstory_state>();
//printf("PC=%04x R %02x\n",cpu_get_pc(space->cpu),state->mcu_cmd);
if((mcu_cmd & 0xf0) == 0x00) // end packet cmd, value returned is meaningless (probably used for main <-> mcu comms syncronization)
if((state->mcu_cmd & 0xf0) == 0x00) // end packet cmd, value returned is meaningless (probably used for main <-> mcu comms syncronization)
return 0;
switch(mcu_cmd)
switch(state->mcu_cmd)
{
case 0x73: return 0xa4; //initial MCU check
case 0x33: return mcu_b2_res; //0xb2 result
case 0x31: return mcu_b1_res; //0xb1 result
case 0x33: return state->mcu_b2_res; //0xb2 result
case 0x31: return state->mcu_b1_res; //0xb1 result
case 0x35: mcu_b5_res = 1; mcu_b6_res = 1; return 0;
case 0x36: return mcu_b4_cmd; //0xb4 command, extra protection for lives (first play only), otherwise game gives one extra life at start-up (!)
case 0x37: return mcu_b5_res; //0xb4 / 0xb5 / 0xb6 result y value
case 0x38: return mcu_b6_res; //x value
case 0x35: state->mcu_b5_res = 1; state->mcu_b6_res = 1; return 0;
case 0x36: return state->mcu_b4_cmd; //0xb4 command, extra protection for lives (first play only), otherwise game gives one extra life at start-up (!)
case 0x37: return state->mcu_b5_res; //0xb4 / 0xb5 / 0xb6 result y value
case 0x38: return state->mcu_b6_res; //x value
case 0x3b: return mcu_bb_res; //0xbb result
case 0x3b: return state->mcu_bb_res; //0xbb result
case 0x40: return 0;
case 0x41: return 0;
case 0x42:
@ -207,7 +205,7 @@ static READ8_HANDLER( rumba_mcu_r )
return 0;
}
//case 0x42: return 0x06;
//default: printf("PC=%04x R %02x\n",cpu_get_pc(space->cpu),mcu_cmd); break;
//default: printf("PC=%04x R %02x\n",cpu_get_pc(space->cpu),state->mcu_cmd); break;
}
return 0;
@ -215,19 +213,20 @@ static READ8_HANDLER( rumba_mcu_r )
static WRITE8_HANDLER( rumba_mcu_w )
{
//if((mcu_cmd & 0xf0) == 0xc0)
flstory_state *state = space->machine->driver_data<flstory_state>();
//if((state->mcu_cmd & 0xf0) == 0xc0)
// printf("%02x ",data);
//if(mcu_cmd == 0x42)
//if(state->mcu_cmd == 0x42)
// printf("\n");
if(mcu_param)
if(state->mcu_param)
{
mcu_param = 0; // clear param
state->mcu_param = 0; // clear param
//printf("%02x %02x\n",mcu_cmd,data);
//printf("%02x %02x\n",state->mcu_cmd,data);
switch(mcu_cmd)
switch(state->mcu_cmd)
{
case 0xb0: // counter, used by command 0xb1 (and something else?
{
@ -235,21 +234,21 @@ static WRITE8_HANDLER( rumba_mcu_w )
sends 0xb0 -> param then 0xb1 -> param -> 0x01 (end of cmd packet?) finally 0x31 for reply
*/
mcu_counter = data;
state->mcu_counter = data;
break;
}
case 0xb1: // player death sequence, controls X position
{
mcu_b1_res = data;
state->mcu_b1_res = data;
/* TODO: this is pretty hard to simulate ... */
if(mcu_counter >= 0x10)
mcu_b1_res++; // left
else if(mcu_counter >= 0x08)
mcu_b1_res--; // right
if(state->mcu_counter >= 0x10)
state->mcu_b1_res++; // left
else if(state->mcu_counter >= 0x08)
state->mcu_b1_res--; // right
else
mcu_b1_res++; // left again
state->mcu_b1_res++; // left again
break;
}
@ -261,10 +260,10 @@ static WRITE8_HANDLER( rumba_mcu_w )
switch(data)
{
case 1: mcu_b2_res = 0xaa; break; //left
case 2: mcu_b2_res = 0xaa; break; //right
case 4: mcu_b2_res = 0xab; break; //down
case 8: mcu_b2_res = 0xa9; break; //up
case 1: state->mcu_b2_res = 0xaa; break; //left
case 2: state->mcu_b2_res = 0xaa; break; //right
case 4: state->mcu_b2_res = 0xab; break; //down
case 8: state->mcu_b2_res = 0xa9; break; //up
}
break;
}
@ -274,15 +273,15 @@ static WRITE8_HANDLER( rumba_mcu_w )
sends 0xbb -> param -> 0x04 (end of cmd packet?) then 0x3b for reply
*/
mcu_bb_res = data;
//printf("PC=%04x W %02x -> %02x\n",cpu_get_pc(space->cpu),mcu_cmd,data);
state->mcu_bb_res = data;
//printf("PC=%04x W %02x -> %02x\n",cpu_get_pc(space->cpu),state->mcu_cmd,data);
break;
}
case 0xb4: // when the bird touches the top / bottom / left / right of the screen, for correct repositioning
{
mcu_b4_cmd = data;
state->mcu_b4_cmd = data;
//popmessage("%02x",mcu_b4_cmd);
//popmessage("%02x",state->mcu_b4_cmd);
/*
sends 0xb4 -> param -> 0xb5 -> param (bird X coord) -> 0xb6 -> param (bird Y coord) ->
@ -302,43 +301,43 @@ static WRITE8_HANDLER( rumba_mcu_w )
case 0xb5: // bird X coord
{
/* TODO: values might be off by one */
mcu_b5_res = data;
state->mcu_b5_res = data;
if(mcu_b4_cmd == 3) // from right to left
mcu_b5_res = 0x0d;
if(state->mcu_b4_cmd == 3) // from right to left
state->mcu_b5_res = 0x0d;
if(mcu_b4_cmd == 2) // from left to right
mcu_b5_res = 0xe4;
if(state->mcu_b4_cmd == 2) // from left to right
state->mcu_b5_res = 0xe4;
break;
}
case 0xb6: // bird Y coord
{
mcu_b6_res = data;
state->mcu_b6_res = data;
if(mcu_b4_cmd == 1) // from up to down
mcu_b6_res = 0x04;
if(state->mcu_b4_cmd == 1) // from up to down
state->mcu_b6_res = 0x04;
if(mcu_b4_cmd == 4) // from down to up
mcu_b6_res = 0xdc;
if(state->mcu_b4_cmd == 4) // from down to up
state->mcu_b6_res = 0xdc;
break;
}
}
//if((mcu_cmd & 0xf0) == 0xc0)
//if((state->mcu_cmd & 0xf0) == 0xc0)
// printf("%02x ",data);
//if(mcu_cmd == 0xc7)
//if(state->mcu_cmd == 0xc7)
// printf("\n");
return;
}
mcu_cmd = data;
state->mcu_cmd = data;
if(((data & 0xf0) == 0xb0 || (data & 0xf0) == 0xc0) && mcu_param == 0)
mcu_param = 1;
if(((data & 0xf0) == 0xb0 || (data & 0xf0) == 0xc0) && state->mcu_param == 0)
state->mcu_param = 1;
}
static ADDRESS_MAP_START( rumba_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -1267,8 +1266,9 @@ MACHINE_CONFIG_END
static MACHINE_RESET( rumba )
{
flstory_state *state = machine->driver_data<flstory_state>();
MACHINE_RESET_CALL(flstory);
mcu_cmd = 0;
state->mcu_cmd = 0;
}
static MACHINE_CONFIG_START( rumba, flstory_state )

View File

@ -46,14 +46,13 @@ $305.b invincibility
#include "audio/taito_en.h"
#include "includes/galastrm.h"
static UINT16 coin_word, frame_counter=0;
static UINT32 *galastrm_ram;
/*********************************************************************/
static INTERRUPT_GEN( galastrm_interrupt )
{
frame_counter ^= 1;
galastrm_state *state = device->machine->driver_data<galastrm_state>();
state->frame_counter ^= 1;
cpu_set_input_line(device, 5, HOLD_LINE);
}
@ -63,55 +62,57 @@ static TIMER_CALLBACK( galastrm_interrupt6 )
}
static int tc0110pcr_addr;
static int tc0610_0_addr;
static int tc0610_1_addr;
static WRITE32_HANDLER( galastrm_palette_w )
{
galastrm_state *state = space->machine->driver_data<galastrm_state>();
if (ACCESSING_BITS_16_31)
tc0110pcr_addr = data >> 16;
if ((ACCESSING_BITS_0_15) && (tc0110pcr_addr < 4096))
palette_set_color_rgb(space->machine, tc0110pcr_addr, pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
state->tc0110pcr_addr = data >> 16;
if ((ACCESSING_BITS_0_15) && (state->tc0110pcr_addr < 4096))
palette_set_color_rgb(space->machine, state->tc0110pcr_addr, pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
}
static WRITE32_HANDLER( galastrm_tc0610_0_w )
{
galastrm_state *state = space->machine->driver_data<galastrm_state>();
if (ACCESSING_BITS_16_31)
tc0610_0_addr = data >> 16;
if ((ACCESSING_BITS_0_15) && (tc0610_0_addr < 8))
galastrm_tc0610_ctrl_reg[0][tc0610_0_addr] = data;
state->tc0610_0_addr = data >> 16;
if ((ACCESSING_BITS_0_15) && (state->tc0610_0_addr < 8))
state->tc0610_ctrl_reg[0][state->tc0610_0_addr] = data;
}
static WRITE32_HANDLER( galastrm_tc0610_1_w )
{
galastrm_state *state = space->machine->driver_data<galastrm_state>();
if (ACCESSING_BITS_16_31)
tc0610_1_addr = data >> 16;
if ((ACCESSING_BITS_0_15) && (tc0610_1_addr < 8))
galastrm_tc0610_ctrl_reg[1][tc0610_1_addr] = data;
state->tc0610_1_addr = data >> 16;
if ((ACCESSING_BITS_0_15) && (state->tc0610_1_addr < 8))
state->tc0610_ctrl_reg[1][state->tc0610_1_addr] = data;
}
static CUSTOM_INPUT( frame_counter_r )
{
return frame_counter;
galastrm_state *state = field->port->machine->driver_data<galastrm_state>();
return state->frame_counter;
}
static CUSTOM_INPUT( coin_word_r )
{
return coin_word;
galastrm_state *state = field->port->machine->driver_data<galastrm_state>();
return state->coin_word;
}
static WRITE32_HANDLER( galastrm_input_w )
{
galastrm_state *state = space->machine->driver_data<galastrm_state>();
#if 0
{
char t[64];
static UINT32 mem[2];
COMBINE_DATA(&mem[offset]);
COMBINE_DATA(&state->mem[offset]);
sprintf(t,"%08x %08x",mem[0],mem[1]);
sprintf(t,"%08x %08x",state->mem[0],state->mem[1]);
popmessage(t);
}
#endif
@ -144,7 +145,7 @@ popmessage(t);
coin_lockout_w(space->machine, 1, ~data & 0x02000000);
coin_counter_w(space->machine, 0, data & 0x04000000);
coin_counter_w(space->machine, 1, data & 0x04000000);
coin_word = (data >> 16) &0xffff;
state->coin_word = (data >> 16) &0xffff;
}
//logerror("CPU #0 PC %06x: write input %06x\n",cpu_get_pc(space->cpu),offset);
}
@ -174,7 +175,7 @@ static WRITE32_HANDLER( galastrm_adstick_ctrl_w )
static ADDRESS_MAP_START( galastrm_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE(&galastrm_ram) /* main CPUA ram */
AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE_MEMBER(galastrm_state, ram) /* main CPUA ram */
AM_RANGE(0x300000, 0x303fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0x400000, 0x400003) AM_READ_PORT("IN0")
AM_RANGE(0x400004, 0x400007) AM_READ_PORT("IN1")
@ -312,7 +313,7 @@ static const tc0480scp_interface galastrm_tc0480scp_intf =
0 /* col_base */
};
static MACHINE_CONFIG_START( galastrm, driver_device )
static MACHINE_CONFIG_START( galastrm, galastrm_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68EC020, 16000000) /* 16 MHz */
MCFG_CPU_PROGRAM_MAP(galastrm_map)

View File

@ -320,23 +320,24 @@ static WRITE8_HANDLER( gladiatr_irq_patch_w )
static int data1,data2,flag1,flag2;
static WRITE8_HANDLER(qx0_w)
{
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
if(!offset)
{
data2=data;
flag2=1;
state->data2=data;
state->flag2=1;
}
}
static WRITE8_HANDLER(qx1_w)
{
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
if(!offset)
{
data1=data;
flag1=1;
state->data1=data;
state->flag1=1;
}
}
@ -350,24 +351,27 @@ static READ8_HANDLER(qx3_r){ return space->machine->rand()&0xf; }
static READ8_HANDLER(qx0_r)
{
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
if(!offset)
return data1;
return state->data1;
else
return flag2;
return state->flag2;
}
static READ8_HANDLER(qx1_r)
{
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
if(!offset)
return data2;
return state->data2;
else
return flag1;
return state->flag1;
}
static MACHINE_RESET( ppking )
{
data1 = data2 = 0;
flag1 = flag2 = 1;
gladiatr_state *state = machine->driver_data<gladiatr_state>();
state->data1 = state->data2 = 0;
state->flag1 = state->flag2 = 1;
}
static ADDRESS_MAP_START( ppking_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -375,9 +379,9 @@ static ADDRESS_MAP_START( ppking_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc000, 0xcbff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xcc00, 0xcfff) AM_WRITE(ppking_video_registers_w)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(gladiatr_paletteram_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(gladiatr_videoram_w) AM_BASE(&gladiatr_videoram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(gladiatr_colorram_w) AM_BASE(&gladiatr_colorram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(gladiatr_textram_w) AM_BASE(&gladiatr_textram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(gladiatr_videoram_w) AM_BASE_MEMBER(gladiatr_state, videoram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(gladiatr_colorram_w) AM_BASE_MEMBER(gladiatr_state, colorram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(gladiatr_textram_w) AM_BASE_MEMBER(gladiatr_state, textram)
AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_SHARE("nvram") /* battery backed RAM */
ADDRESS_MAP_END
@ -413,9 +417,9 @@ static ADDRESS_MAP_START( gladiatr_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc000, 0xcbff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xcc00, 0xcfff) AM_WRITE(gladiatr_video_registers_w)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(gladiatr_paletteram_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(gladiatr_videoram_w) AM_BASE(&gladiatr_videoram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(gladiatr_colorram_w) AM_BASE(&gladiatr_colorram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(gladiatr_textram_w) AM_BASE(&gladiatr_textram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(gladiatr_videoram_w) AM_BASE_MEMBER(gladiatr_state, videoram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(gladiatr_colorram_w) AM_BASE_MEMBER(gladiatr_state, colorram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(gladiatr_textram_w) AM_BASE_MEMBER(gladiatr_state, textram)
AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_SHARE("nvram") /* battery backed RAM */
ADDRESS_MAP_END

View File

@ -71,9 +71,6 @@
#include "audio/taito_en.h"
#include "includes/groundfx.h"
static UINT16 coin_word, frame_counter=0;
static UINT16 port_sel = 0;
static UINT32 *groundfx_ram;
/***********************************************************
COLOR RAM
@ -130,16 +127,19 @@ static const eeprom_interface groundfx_eeprom_interface =
static CUSTOM_INPUT( frame_counter_r )
{
return frame_counter;
groundfx_state *state = field->port->machine->driver_data<groundfx_state>();
return state->frame_counter;
}
static CUSTOM_INPUT( coin_word_r )
{
return coin_word;
groundfx_state *state = field->port->machine->driver_data<groundfx_state>();
return state->coin_word;
}
static WRITE32_HANDLER( groundfx_input_w )
{
groundfx_state *state = space->machine->driver_data<groundfx_state>();
switch (offset)
{
case 0x00:
@ -162,7 +162,7 @@ static WRITE32_HANDLER( groundfx_input_w )
coin_lockout_w(space->machine, 1,~data & 0x02000000);
coin_counter_w(space->machine, 0, data & 0x04000000);
coin_counter_w(space->machine, 1, data & 0x08000000);
coin_word = (data >> 16) &0xffff;
state->coin_word = (data >> 16) &0xffff;
}
break;
}
@ -182,15 +182,16 @@ static WRITE32_HANDLER( groundfx_adc_w )
static WRITE32_HANDLER( rotate_control_w ) /* only a guess that it's rotation */
{
groundfx_state *state = space->machine->driver_data<groundfx_state>();
if (ACCESSING_BITS_0_15)
{
groundfx_rotate_ctrl[port_sel] = data;
state->rotate_ctrl[state->port_sel] = data;
return;
}
if (ACCESSING_BITS_16_31)
{
port_sel = (data &0x70000) >> 16;
state->port_sel = (data &0x70000) >> 16;
}
}
@ -217,7 +218,7 @@ static WRITE32_HANDLER( motor_control_w )
static ADDRESS_MAP_START( groundfx_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x000000, 0x1fffff) AM_ROM
AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE(&groundfx_ram) /* main CPUA ram */
AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE_MEMBER(groundfx_state, ram) /* main CPUA ram */
AM_RANGE(0x300000, 0x303fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprite ram */
AM_RANGE(0x400000, 0x400003) AM_WRITE(motor_control_w) /* gun vibration */
AM_RANGE(0x500000, 0x500003) AM_READ_PORT("BUTTONS")
@ -360,11 +361,12 @@ static const tc0480scp_interface groundfx_tc0480scp_intf =
static INTERRUPT_GEN( groundfx_interrupt )
{
frame_counter^=1;
groundfx_state *state = device->machine->driver_data<groundfx_state>();
state->frame_counter^=1;
cpu_set_input_line(device, 4, HOLD_LINE);
}
static MACHINE_CONFIG_START( groundfx, driver_device )
static MACHINE_CONFIG_START( groundfx, groundfx_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68EC020, 16000000) /* 16 MHz */
@ -440,17 +442,18 @@ ROM_END
static READ32_HANDLER( irq_speedup_r_groundfx )
{
groundfx_state *state = space->machine->driver_data<groundfx_state>();
cpu_device *cpu = downcast<cpu_device *>(space->cpu);
int ptr;
offs_t sp = cpu->sp();
if ((sp&2)==0) ptr=groundfx_ram[(sp&0x1ffff)/4];
else ptr=(((groundfx_ram[(sp&0x1ffff)/4])&0x1ffff)<<16) |
(groundfx_ram[((sp&0x1ffff)/4)+1]>>16);
if ((sp&2)==0) ptr=state->ram[(sp&0x1ffff)/4];
else ptr=(((state->ram[(sp&0x1ffff)/4])&0x1ffff)<<16) |
(state->ram[((sp&0x1ffff)/4)+1]>>16);
if (cpu->pc()==0x1ece && ptr==0x1b9a)
cpu->spin_until_interrupt();
return groundfx_ram[0xb574/4];
return state->ram[0xb574/4];
}

View File

@ -149,13 +149,6 @@ reg: 0->1 (main->2nd) / : (1->0) 2nd->main :
#include "sound/msm5205.h"
#include "includes/gsword.h"
static int coins;
static int fake8910_0,fake8910_1;
static int gsword_nmi_enable;
static UINT8 *gsword_cpu2_ram;
static int gsword_protect_hack;
#if 0
static int gsword_coins_in(void)
@ -178,12 +171,13 @@ static int gsword_coins_in(void)
/* (4004,4005) clear down counter , if (4004,4005)==0 then (402E)=0 */
static READ8_HANDLER( gsword_hack_r )
{
UINT8 data = gsword_cpu2_ram[offset + 4];
gsword_state *state = space->machine->driver_data<gsword_state>();
UINT8 data = state->cpu2_ram[offset + 4];
/*if(offset==1)mame_printf_debug("CNT %02X%02X\n",gsword_cpu2_ram[5],gsword_cpu2_ram[4]); */
/*if(offset==1)mame_printf_debug("CNT %02X%02X\n",state->cpu2_ram[5],state->cpu2_ram[4]); */
/* speedup timeout cound down */
if(gsword_protect_hack)
if(state->protect_hack)
{
switch(offset)
{
@ -238,14 +232,15 @@ static const struct TAITO8741interface gsword_8741interface=
static MACHINE_RESET( gsword )
{
gsword_state *state = machine->driver_data<gsword_state>();
int i;
for(i=0;i<4;i++) TAITO8741_reset(i);
coins = 0;
state->coins = 0;
/* snd CPU mask NMI during reset phase */
gsword_nmi_enable = 0;
gsword_protect_hack = 0;
state->nmi_enable = 0;
state->protect_hack = 0;
TAITO8741_start(&gsword_8741interface);
}
@ -268,7 +263,8 @@ static INTERRUPT_GEN( josvolly_snd_interrupt )
static INTERRUPT_GEN( gsword_snd_interrupt )
{
if(gsword_nmi_enable)
gsword_state *state = device->machine->driver_data<gsword_state>();
if(state->nmi_enable)
{
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}
@ -276,32 +272,33 @@ static INTERRUPT_GEN( gsword_snd_interrupt )
static WRITE8_DEVICE_HANDLER( gsword_nmi_set_w )
{
gsword_state *state = device->machine->driver_data<gsword_state>();
/* mame_printf_debug("AY write %02X\n",data);*/
gsword_protect_hack = (data&0x80) ? 0 : 1;
state->protect_hack = (data&0x80) ? 0 : 1;
#if 0
/* An actual circuit isn't known. */
/* write ff,02,ff,fe, 17 x 0d,0f */
gsword_nmi_enable = ((data>>7) & (data&1) &1) == 0;
state->nmi_enable = ((data>>7) & (data&1) &1) == 0;
#else
switch(data)
{
case 0xff:
gsword_nmi_enable = 0; /* NMI must be disable */
state->nmi_enable = 0; /* NMI must be disable */
break;
case 0x02:
gsword_nmi_enable = 0; /* ANY */
state->nmi_enable = 0; /* ANY */
break;
case 0x0d:
gsword_nmi_enable = 1;
state->nmi_enable = 1;
break;
case 0x0f:
gsword_nmi_enable = 1; /* NMI must be enable */
state->nmi_enable = 1; /* NMI must be enable */
break;
case 0xfe:
gsword_nmi_enable = 1; /* NMI must be enable */
state->nmi_enable = 1; /* NMI must be enable */
break;
}
/* bit1= nmi disable , for ram check */
@ -316,22 +313,26 @@ static WRITE8_HANDLER( josvolly_nmi_enable_w )
static WRITE8_DEVICE_HANDLER( gsword_AY8910_control_port_0_w )
{
gsword_state *state = device->machine->driver_data<gsword_state>();
ay8910_address_w(device,offset,data);
fake8910_0 = data;
state->fake8910_0 = data;
}
static WRITE8_DEVICE_HANDLER( gsword_AY8910_control_port_1_w )
{
gsword_state *state = device->machine->driver_data<gsword_state>();
ay8910_address_w(device,offset,data);
fake8910_1 = data;
state->fake8910_1 = data;
}
static READ8_DEVICE_HANDLER( gsword_fake_0_r )
{
return fake8910_0+1;
gsword_state *state = device->machine->driver_data<gsword_state>();
return state->fake8910_0+1;
}
static READ8_DEVICE_HANDLER( gsword_fake_1_r )
{
return fake8910_1+1;
gsword_state *state = device->machine->driver_data<gsword_state>();
return state->fake8910_1+1;
}
static WRITE8_DEVICE_HANDLER( gsword_adpcm_data_w )
@ -351,13 +352,13 @@ static ADDRESS_MAP_START( cpu1_map, ADDRESS_SPACE_PROGRAM , 8 )
AM_RANGE(0x0000, 0x8fff) AM_ROM
AM_RANGE(0x9000, 0x9fff) AM_RAM
AM_RANGE(0xa000, 0xa37f) AM_RAM
AM_RANGE(0xa380, 0xa3ff) AM_RAM AM_BASE(&gsword_spritetile_ram)
AM_RANGE(0xa380, 0xa3ff) AM_RAM AM_BASE_MEMBER(gsword_state, spritetile_ram)
AM_RANGE(0xa400, 0xa77f) AM_RAM
AM_RANGE(0xa780, 0xa7ff) AM_RAM AM_BASE(&gsword_spritexy_ram) AM_SIZE(&gsword_spritexy_size)
AM_RANGE(0xa780, 0xa7ff) AM_RAM AM_BASE_MEMBER(gsword_state, spritexy_ram) AM_SIZE_MEMBER(gsword_state, spritexy_size)
AM_RANGE(0xa980, 0xa980) AM_WRITE(gsword_charbank_w)
AM_RANGE(0xaa80, 0xaa80) AM_WRITE(gsword_videoctrl_w) /* flip screen, char palette bank */
AM_RANGE(0xab00, 0xab00) AM_WRITE(gsword_scroll_w)
AM_RANGE(0xab80, 0xabff) AM_WRITEONLY AM_BASE(&gsword_spriteattrib_ram)
AM_RANGE(0xab80, 0xabff) AM_WRITEONLY AM_BASE_MEMBER(gsword_state, spriteattrib_ram)
AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(gsword_videoram_w) AM_BASE_MEMBER(gsword_state, videoram)
ADDRESS_MAP_END
@ -374,7 +375,7 @@ ADDRESS_MAP_END
//
static ADDRESS_MAP_START( cpu2_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x3fff) AM_ROM
AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE(&gsword_cpu2_ram)
AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE_MEMBER(gsword_state, cpu2_ram)
AM_RANGE(0x6000, 0x6000) AM_WRITE(adpcm_soundcommand_w)
ADDRESS_MAP_END
@ -404,7 +405,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( josvolly_cpu2_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x3fff) AM_ROM
AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE(&gsword_cpu2_ram)
AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE_MEMBER(gsword_state, cpu2_ram)
/* 8000 to 8003 looks MCU */
AM_RANGE(0x8000, 0x8000) AM_READ_PORT("IN1") // 1PL

View File

@ -53,8 +53,6 @@
#include "audio/taito_en.h"
#include "includes/gunbustr.h"
static UINT16 coin_word;
static UINT32 *gunbustr_ram;
/*********************************************************************/
@ -83,19 +81,20 @@ static WRITE32_HANDLER( gunbustr_palette_w )
static CUSTOM_INPUT( coin_word_r )
{
return coin_word;
gunbustr_state *state = field->port->machine->driver_data<gunbustr_state>();
return state->coin_word;
}
static WRITE32_HANDLER( gunbustr_input_w )
{
gunbustr_state *state = space->machine->driver_data<gunbustr_state>();
#if 0
{
char t[64];
static UINT32 mem[2];
COMBINE_DATA(&mem[offset]);
COMBINE_DATA(&state->mem[offset]);
sprintf(t,"%08x %08x",mem[0],mem[1]);
sprintf(t,"%08x %08x",state->mem[0],state->mem[1]);
popmessage(t);
}
#endif
@ -131,7 +130,7 @@ popmessage(t);
coin_lockout_w(space->machine, 1, data & 0x02000000);
coin_counter_w(space->machine, 0, data & 0x04000000);
coin_counter_w(space->machine, 1, data & 0x04000000);
coin_word = (data >> 16) &0xffff;
state->coin_word = (data >> 16) &0xffff;
}
//logerror("CPU #0 PC %06x: write input %06x\n",cpu_get_pc(space->cpu),offset);
}
@ -195,7 +194,7 @@ static WRITE32_HANDLER( gunbustr_gun_w )
static ADDRESS_MAP_START( gunbustr_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE(&gunbustr_ram) /* main CPUA ram */
AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE_MEMBER(gunbustr_state, ram) /* main CPUA ram */
AM_RANGE(0x300000, 0x301fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Sprite ram */
AM_RANGE(0x380000, 0x380003) AM_WRITE(motor_control_w) /* motor, lamps etc. */
AM_RANGE(0x390000, 0x3907ff) AM_RAM AM_BASE(&f3_shared_ram) /* Sound shared ram */
@ -342,7 +341,7 @@ static const tc0480scp_interface gunbustr_tc0480scp_intf =
0 /* col_base */
};
static MACHINE_CONFIG_START( gunbustr, driver_device )
static MACHINE_CONFIG_START( gunbustr, gunbustr_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68EC020, 16000000) /* 16 MHz */
@ -409,10 +408,11 @@ ROM_END
static READ32_HANDLER( main_cycle_r )
{
if (cpu_get_pc(space->cpu)==0x55a && (gunbustr_ram[0x3acc/4]&0xff000000)==0)
gunbustr_state *state = space->machine->driver_data<gunbustr_state>();
if (cpu_get_pc(space->cpu)==0x55a && (state->ram[0x3acc/4]&0xff000000)==0)
cpu_spinuntil_int(space->cpu);
return gunbustr_ram[0x3acc/4];
return state->ram[0x3acc/4];
}
static DRIVER_INIT( gunbustr )

View File

@ -32,15 +32,13 @@ confirmed for m107 games as well.
#include "sound/iremga20.h"
#define M107_IRQ_0 ((m107_irq_vectorbase+0)/4) /* VBL interrupt*/
#define M107_IRQ_1 ((m107_irq_vectorbase+4)/4) /* ??? */
#define M107_IRQ_2 ((m107_irq_vectorbase+8)/4) /* Raster interrupt */
#define M107_IRQ_3 ((m107_irq_vectorbase+12)/4) /* ??? */
#define M107_IRQ_0 ((state->irq_vectorbase+0)/4) /* VBL interrupt*/
#define M107_IRQ_1 ((state->irq_vectorbase+4)/4) /* ??? */
#define M107_IRQ_2 ((state->irq_vectorbase+8)/4) /* Raster interrupt */
#define M107_IRQ_3 ((state->irq_vectorbase+12)/4) /* ??? */
static emu_timer *scanline_timer;
static UINT8 m107_irq_vectorbase;
static TIMER_CALLBACK( m107_scanline_interrupt );
@ -57,22 +55,25 @@ static WRITE16_HANDLER( bankswitch_w )
static MACHINE_START( m107 )
{
scanline_timer = timer_alloc(machine, m107_scanline_interrupt, NULL);
m107_state *state = machine->driver_data<m107_state>();
state->scanline_timer = timer_alloc(machine, m107_scanline_interrupt, NULL);
}
static MACHINE_RESET( m107 )
{
timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0);
m107_state *state = machine->driver_data<m107_state>();
timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0), 0);
}
/*****************************************************************************/
static TIMER_CALLBACK( m107_scanline_interrupt )
{
m107_state *state = machine->driver_data<m107_state>();
int scanline = param;
/* raster interrupt */
if (scanline == m107_raster_irq_position)
if (scanline == state->raster_irq_position)
{
machine->primary_screen->update_partial(scanline);
cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, M107_IRQ_2);
@ -88,7 +89,7 @@ static TIMER_CALLBACK( m107_scanline_interrupt )
/* adjust for next scanline */
if (++scanline >= machine->primary_screen->height())
scanline = 0;
timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
}
@ -107,23 +108,23 @@ enum { VECTOR_INIT, YM2151_ASSERT, YM2151_CLEAR, V30_ASSERT, V30_CLEAR };
static TIMER_CALLBACK( setvector_callback )
{
static int irqvector;
m107_state *state = machine->driver_data<m107_state>();
switch(param)
{
case VECTOR_INIT: irqvector = 0; break;
case YM2151_ASSERT: irqvector |= 0x2; break;
case YM2151_CLEAR: irqvector &= ~0x2; break;
case V30_ASSERT: irqvector |= 0x1; break;
case V30_CLEAR: irqvector &= ~0x1; break;
case VECTOR_INIT: state->irqvector = 0; break;
case YM2151_ASSERT: state->irqvector |= 0x2; break;
case YM2151_CLEAR: state->irqvector &= ~0x2; break;
case V30_ASSERT: state->irqvector |= 0x1; break;
case V30_CLEAR: state->irqvector &= ~0x1; break;
}
if (irqvector & 0x2) /* YM2151 has precedence */
if (state->irqvector & 0x2) /* YM2151 has precedence */
cpu_set_input_line_vector(machine->device("soundcpu"), 0, 0x18);
else if (irqvector & 0x1) /* V30 */
else if (state->irqvector & 0x1) /* V30 */
cpu_set_input_line_vector(machine->device("soundcpu"), 0, 0x19);
if (irqvector == 0) /* no IRQs pending */
if (state->irqvector == 0) /* no IRQs pending */
cputag_set_input_line(machine, "soundcpu", 0, CLEAR_LINE);
else /* IRQ pending */
cputag_set_input_line(machine, "soundcpu", 0, ASSERT_LINE);
@ -136,11 +137,11 @@ static WRITE16_HANDLER( m107_soundlatch_w )
// logerror("soundlatch_w %02x\n",data);
}
static int sound_status;
static READ16_HANDLER( m107_sound_status_r )
{
return sound_status;
m107_state *state = space->machine->driver_data<m107_state>();
return state->sound_status;
}
static READ16_HANDLER( m107_soundlatch_r )
@ -155,7 +156,8 @@ static WRITE16_HANDLER( m107_sound_irq_ack_w )
static WRITE16_HANDLER( m107_sound_status_w )
{
COMBINE_DATA(&sound_status);
m107_state *state = space->machine->driver_data<m107_state>();
COMBINE_DATA(&state->sound_status);
cputag_set_input_line_and_vector(space->machine, "maincpu", 0, HOLD_LINE, M107_IRQ_3);
}
@ -169,7 +171,7 @@ static WRITE16_HANDLER( m107_sound_reset_w )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x00000, 0x9ffff) AM_ROM
AM_RANGE(0xa0000, 0xbffff) AM_ROMBANK("bank1")
AM_RANGE(0xd0000, 0xdffff) AM_RAM_WRITE(m107_vram_w) AM_BASE(&m107_vram_data)
AM_RANGE(0xd0000, 0xdffff) AM_RAM_WRITE(m107_vram_w) AM_BASE_MEMBER(m107_state, vram_data)
AM_RANGE(0xe0000, 0xeffff) AM_RAM /* System ram */
AM_RANGE(0xf8000, 0xf8fff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xf9000, 0xf9fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
@ -817,7 +819,7 @@ static const ym2151_interface ym2151_config =
static const nec_config firebarr_config ={ rtypeleo_decryption_table, };
static MACHINE_CONFIG_START( firebarr, driver_device )
static MACHINE_CONFIG_START( firebarr, m107_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", V33, 28000000/2) /* NEC V33, 28MHz clock */
@ -1012,6 +1014,7 @@ ROM_END
static DRIVER_INIT( firebarr )
{
m107_state *state = machine->driver_data<m107_state>();
UINT8 *RAM = machine->region("maincpu")->base();
memcpy(RAM + 0xffff0, RAM + 0x7fff0, 0x10); /* Start vector */
@ -1020,12 +1023,13 @@ static DRIVER_INIT( firebarr )
RAM = machine->region("soundcpu")->base();
memcpy(RAM + 0xffff0,RAM + 0x1fff0, 0x10); /* Sound cpu Start vector */
m107_irq_vectorbase = 0x20;
m107_spritesystem = 1;
state->irq_vectorbase = 0x20;
state->spritesystem = 1;
}
static DRIVER_INIT( dsoccr94 )
{
m107_state *state = machine->driver_data<m107_state>();
UINT8 *RAM = machine->region("maincpu")->base();
memcpy(RAM + 0xffff0, RAM + 0x7fff0, 0x10); /* Start vector */
@ -1034,12 +1038,13 @@ static DRIVER_INIT( dsoccr94 )
RAM = machine->region("soundcpu")->base();
memcpy(RAM + 0xffff0, RAM + 0x1fff0, 0x10); /* Sound cpu Start vector */
m107_irq_vectorbase = 0x80;
m107_spritesystem = 0;
state->irq_vectorbase = 0x80;
state->spritesystem = 0;
}
static DRIVER_INIT( wpksoc )
{
m107_state *state = machine->driver_data<m107_state>();
UINT8 *RAM = machine->region("maincpu")->base();
memcpy(RAM + 0xffff0, RAM + 0x7fff0, 0x10); /* Start vector */
@ -1049,8 +1054,8 @@ static DRIVER_INIT( wpksoc )
memcpy(RAM + 0xffff0, RAM + 0x1fff0, 0x10); /* Sound cpu Start vector */
m107_irq_vectorbase = 0x80;
m107_spritesystem = 0;
state->irq_vectorbase = 0x80;
state->spritesystem = 0;
}
/***************************************************************************/

View File

@ -97,12 +97,6 @@ other supported games as well.
#define SOUND_CLOCK XTAL_3_579545MHz
static UINT16 *protection_ram;
static emu_timer *scanline_timer;
static UINT8 m72_irq_base;
static UINT8 mcu_snd_cmd_latch;
static UINT8 mcu_sample_latch;
static UINT32 mcu_sample_addr;
static TIMER_CALLBACK( m72_scanline_interrupt );
static TIMER_CALLBACK( kengo_scanline_interrupt );
@ -111,18 +105,20 @@ static TIMER_CALLBACK( kengo_scanline_interrupt );
static MACHINE_START( m72 )
{
scanline_timer = timer_alloc(machine, m72_scanline_interrupt, NULL);
m72_state *state = machine->driver_data<m72_state>();
state->scanline_timer = timer_alloc(machine, m72_scanline_interrupt, NULL);
state_save_register_global(machine, mcu_sample_addr);
state_save_register_global(machine, mcu_snd_cmd_latch);
state_save_register_global(machine, state->mcu_sample_addr);
state_save_register_global(machine, state->mcu_snd_cmd_latch);
}
static MACHINE_START( kengo )
{
scanline_timer = timer_alloc(machine, kengo_scanline_interrupt, NULL);
m72_state *state = machine->driver_data<m72_state>();
state->scanline_timer = timer_alloc(machine, kengo_scanline_interrupt, NULL);
state_save_register_global(machine, mcu_sample_addr);
state_save_register_global(machine, mcu_snd_cmd_latch);
state_save_register_global(machine, state->mcu_sample_addr);
state_save_register_global(machine, state->mcu_snd_cmd_latch);
}
static TIMER_CALLBACK( synch_callback )
@ -133,55 +129,60 @@ static TIMER_CALLBACK( synch_callback )
static MACHINE_RESET( m72 )
{
m72_irq_base = 0x20;
mcu_sample_addr = 0;
mcu_snd_cmd_latch = 0;
m72_state *state = machine->driver_data<m72_state>();
state->irq_base = 0x20;
state->mcu_sample_addr = 0;
state->mcu_snd_cmd_latch = 0;
timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0);
timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0), 0);
timer_call_after_resynch(machine, NULL, 0, synch_callback);
}
static MACHINE_RESET( xmultipl )
{
m72_irq_base = 0x08;
timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0);
m72_state *state = machine->driver_data<m72_state>();
state->irq_base = 0x08;
timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0), 0);
}
static MACHINE_RESET( kengo )
{
timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0);
m72_state *state = machine->driver_data<m72_state>();
timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0), 0);
}
static TIMER_CALLBACK( m72_scanline_interrupt )
{
m72_state *state = machine->driver_data<m72_state>();
int scanline = param;
/* raster interrupt - visible area only? */
if (scanline < 256 && scanline == m72_raster_irq_position - 128)
if (scanline < 256 && scanline == state->raster_irq_position - 128)
{
machine->primary_screen->update_partial(scanline);
cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, m72_irq_base + 2);
cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, state->irq_base + 2);
}
/* VBLANK interrupt */
else if (scanline == 256)
{
machine->primary_screen->update_partial(scanline);
cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, m72_irq_base + 0);
cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, state->irq_base + 0);
}
/* adjust for next scanline */
if (++scanline >= machine->primary_screen->height())
scanline = 0;
timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
}
static TIMER_CALLBACK( kengo_scanline_interrupt )
{
m72_state *state = machine->driver_data<m72_state>();
int scanline = param;
/* raster interrupt - visible area only? */
if (scanline < 256 && scanline == m72_raster_irq_position - 128)
if (scanline < 256 && scanline == state->raster_irq_position - 128)
{
machine->primary_screen->update_partial(scanline);
cputag_set_input_line(machine, "maincpu", NEC_INPUT_LINE_INTP2, ASSERT_LINE);
@ -201,7 +202,7 @@ static TIMER_CALLBACK( kengo_scanline_interrupt )
/* adjust for next scanline */
if (++scanline >= machine->primary_screen->height())
scanline = 0;
timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
}
/***************************************************************************
@ -231,19 +232,21 @@ static TIMER_CALLBACK( delayed_ram16_w )
static WRITE16_HANDLER( m72_main_mcu_sound_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
if (data & 0xfff0)
logerror("sound_w: %04x %04x\n", mem_mask, data);
if (ACCESSING_BITS_0_7)
{
mcu_snd_cmd_latch = data;
state->mcu_snd_cmd_latch = data;
cputag_set_input_line(space->machine, "mcu", 1, ASSERT_LINE);
}
}
static WRITE16_HANDLER( m72_main_mcu_w)
{
UINT16 val = protection_ram[offset];
m72_state *state = space->machine->driver_data<m72_state>();
UINT16 val = state->protection_ram[offset];
COMBINE_DATA(&val);
@ -253,27 +256,29 @@ static WRITE16_HANDLER( m72_main_mcu_w)
if (offset == 0x0fff/2 && ACCESSING_BITS_8_15)
{
protection_ram[offset] = val;
state->protection_ram[offset] = val;
cputag_set_input_line(space->machine, "mcu", 0, ASSERT_LINE);
/* Line driven, most likely by write line */
//timer_set(space->machine, space->machine->device<cpu_device>("mcu")->cycles_to_attotime(2), NULL, 0, mcu_irq0_clear);
//timer_set(space->machine, space->machine->device<cpu_device>("mcu")->cycles_to_attotime(0), NULL, 0, mcu_irq0_raise);
}
else
timer_call_after_resynch( space->machine, protection_ram, (offset<<16) | val, delayed_ram16_w);
timer_call_after_resynch( space->machine, state->protection_ram, (offset<<16) | val, delayed_ram16_w);
}
static WRITE8_HANDLER( m72_mcu_data_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
UINT16 val;
if (offset&1) val = (protection_ram[offset/2] & 0x00ff) | (data << 8);
else val = (protection_ram[offset/2] & 0xff00) | (data&0xff);
if (offset&1) val = (state->protection_ram[offset/2] & 0x00ff) | (data << 8);
else val = (state->protection_ram[offset/2] & 0xff00) | (data&0xff);
timer_call_after_resynch( space->machine, protection_ram, ((offset >>1 ) << 16) | val, delayed_ram16_w);
timer_call_after_resynch( space->machine, state->protection_ram, ((offset >>1 ) << 16) | val, delayed_ram16_w);
}
static READ8_HANDLER(m72_mcu_data_r )
{
m72_state *state = space->machine->driver_data<m72_state>();
UINT8 ret;
if (offset == 0x0fff || offset == 0x0ffe)
@ -281,35 +286,39 @@ static READ8_HANDLER(m72_mcu_data_r )
cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
}
if (offset&1) ret = (protection_ram[offset/2] & 0xff00)>>8;
else ret = (protection_ram[offset/2] & 0x00ff);
if (offset&1) ret = (state->protection_ram[offset/2] & 0xff00)>>8;
else ret = (state->protection_ram[offset/2] & 0x00ff);
return ret;
}
static INTERRUPT_GEN( m72_mcu_int )
{
//mcu_snd_cmd_latch |= 0x11; /* 0x10 is special as well - FIXME */
mcu_snd_cmd_latch = 0x11;// | (machine->rand() & 1); /* 0x10 is special as well - FIXME */
m72_state *state = device->machine->driver_data<m72_state>();
//state->mcu_snd_cmd_latch |= 0x11; /* 0x10 is special as well - FIXME */
state->mcu_snd_cmd_latch = 0x11;// | (machine->rand() & 1); /* 0x10 is special as well - FIXME */
cpu_set_input_line(device, 1, ASSERT_LINE);
}
static READ8_HANDLER(m72_mcu_sample_r )
{
m72_state *state = space->machine->driver_data<m72_state>();
UINT8 sample;
sample = space->machine->region("samples")->base()[mcu_sample_addr++];
sample = space->machine->region("samples")->base()[state->mcu_sample_addr++];
return sample;
}
static WRITE8_HANDLER(m72_mcu_ack_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
cputag_set_input_line(space->machine, "mcu", 1, CLEAR_LINE);
mcu_snd_cmd_latch = 0;
state->mcu_snd_cmd_latch = 0;
}
static READ8_HANDLER(m72_mcu_snd_r )
{
return mcu_snd_cmd_latch;
m72_state *state = space->machine->driver_data<m72_state>();
return state->mcu_snd_cmd_latch;
}
static READ8_HANDLER(m72_mcu_port_r )
@ -320,9 +329,10 @@ static READ8_HANDLER(m72_mcu_port_r )
static WRITE8_HANDLER(m72_mcu_port_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
if (offset == 1)
{
mcu_sample_latch = data;
state->mcu_sample_latch = data;
cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
}
else
@ -332,14 +342,16 @@ static WRITE8_HANDLER(m72_mcu_port_w )
static WRITE8_HANDLER( m72_mcu_low_w )
{
mcu_sample_addr = (mcu_sample_addr & 0xffe000) | (data<<5);
logerror("low: %02x %02x %08x\n", offset, data, mcu_sample_addr);
m72_state *state = space->machine->driver_data<m72_state>();
state->mcu_sample_addr = (state->mcu_sample_addr & 0xffe000) | (data<<5);
logerror("low: %02x %02x %08x\n", offset, data, state->mcu_sample_addr);
}
static WRITE8_HANDLER( m72_mcu_high_w )
{
mcu_sample_addr = (mcu_sample_addr & 0x1fff) | (data<<(8+5));
logerror("high: %02x %02x %08x\n", offset, data, mcu_sample_addr);
m72_state *state = space->machine->driver_data<m72_state>();
state->mcu_sample_addr = (state->mcu_sample_addr & 0x1fff) | (data<<(8+5));
logerror("high: %02x %02x %08x\n", offset, data, state->mcu_sample_addr);
}
static WRITE8_DEVICE_HANDLER( m72_snd_cpu_sample_w )
@ -350,20 +362,22 @@ static WRITE8_DEVICE_HANDLER( m72_snd_cpu_sample_w )
static READ8_HANDLER( m72_snd_cpu_sample_r )
{
return mcu_sample_latch;
m72_state *state = space->machine->driver_data<m72_state>();
return state->mcu_sample_latch;
}
INLINE DRIVER_INIT( m72_8751 )
{
m72_state *state = machine->driver_data<m72_state>();
address_space *program = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
address_space *io = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO);
address_space *sndio = cputag_get_address_space(machine, "soundcpu", ADDRESS_SPACE_IO);
device_t *dac = machine->device("dac");
protection_ram = auto_alloc_array(machine, UINT16, 0x10000/2);
state->protection_ram = auto_alloc_array(machine, UINT16, 0x10000/2);
memory_install_read_bank(program, 0xb0000, 0xbffff, 0, 0, "bank1");
memory_install_write16_handler(program, 0xb0000, 0xb0fff, 0, 0, m72_main_mcu_w);
memory_set_bankptr(machine, "bank1", protection_ram);
memory_set_bankptr(machine, "bank1", state->protection_ram);
//memory_install_write16_handler(io, 0xc0, 0xc1, 0, 0, loht_sample_trigger_w);
memory_install_write16_handler(io, 0xc0, 0xc1, 0, 0, m72_main_mcu_sound_w);
@ -702,7 +716,6 @@ static const UINT8 dkgenm72_crc[CRC_LEN] = { 0xc8,0xb4,0xdc,0xf8, 0xd3,0xba,0x4
0x79,0x08,0x1c,0xb3, 0x00,0x00 };
static const UINT8 *protection_code, *protection_crc;
static void copy_le(UINT16 *dest, const UINT8 *src, UINT8 bytes)
{
@ -714,30 +727,33 @@ static void copy_le(UINT16 *dest, const UINT8 *src, UINT8 bytes)
static READ16_HANDLER( protection_r )
{
m72_state *state = space->machine->driver_data<m72_state>();
if (ACCESSING_BITS_8_15)
copy_le(protection_ram,protection_code,CODE_LEN);
return protection_ram[0xffa/2+offset];
copy_le(state->protection_ram,state->protection_code,CODE_LEN);
return state->protection_ram[0xffa/2+offset];
}
static WRITE16_HANDLER( protection_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
data ^= 0xffff;
COMBINE_DATA(&protection_ram[offset]);
COMBINE_DATA(&state->protection_ram[offset]);
data ^= 0xffff;
if (offset == 0x0fff/2 && ACCESSING_BITS_8_15 && (data >> 8) == 0)
copy_le(&protection_ram[0x0fe0],protection_crc,CRC_LEN);
copy_le(&state->protection_ram[0x0fe0],state->protection_crc,CRC_LEN);
}
static void install_protection_handler(running_machine *machine, const UINT8 *code,const UINT8 *crc)
{
protection_ram = auto_alloc_array(machine, UINT16, 0x1000/2);
protection_code = code;
protection_crc = crc;
m72_state *state = machine->driver_data<m72_state>();
state->protection_ram = auto_alloc_array(machine, UINT16, 0x1000/2);
state->protection_code = code;
state->protection_crc = crc;
memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xb0000, 0xb0fff, 0, 0, "bank1");
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xb0ffa, 0xb0ffb, 0, 0, protection_r);
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xb0000, 0xb0fff, 0, 0, protection_w);
memory_set_bankptr(machine, "bank1", protection_ram);
memory_set_bankptr(machine, "bank1", state->protection_ram);
}
static DRIVER_INIT( bchopper )
@ -770,12 +786,13 @@ static DRIVER_INIT( imgfight )
static DRIVER_INIT( loht )
{
m72_state *state = machine->driver_data<m72_state>();
install_protection_handler(machine, loht_code,loht_crc);
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0xc0, 0xc1, 0, 0, loht_sample_trigger_w);
/* since we skip the startup tests, clear video RAM to prevent garbage on title screen */
memset(m72_videoram2,0,0x4000);
memset(state->videoram2,0,0x4000);
}
static DRIVER_INIT( xmultiplm72 )
@ -814,26 +831,27 @@ static DRIVER_INIT( gallop )
static UINT8 *soundram;
static READ16_HANDLER( soundram_r )
{
return soundram[offset * 2 + 0] | (soundram[offset * 2 + 1] << 8);
m72_state *state = space->machine->driver_data<m72_state>();
return state->soundram[offset * 2 + 0] | (state->soundram[offset * 2 + 1] << 8);
}
static WRITE16_HANDLER( soundram_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
if (ACCESSING_BITS_0_7)
soundram[offset * 2 + 0] = data;
state->soundram[offset * 2 + 0] = data;
if (ACCESSING_BITS_8_15)
soundram[offset * 2 + 1] = data >> 8;
state->soundram[offset * 2 + 1] = data >> 8;
}
static READ16_HANDLER( poundfor_trackball_r )
{
static int prev[4],diff[4];
m72_state *state = space->machine->driver_data<m72_state>();
static const char *const axisnames[] = { "TRACK0_X", "TRACK0_Y", "TRACK1_X", "TRACK1_Y" };
if (offset == 0)
@ -843,8 +861,8 @@ static READ16_HANDLER( poundfor_trackball_r )
for (i = 0;i < 4;i++)
{
curr = input_port_read(space->machine, axisnames[i]);
diff[i] = (curr - prev[i]);
prev[i] = curr;
state->diff[i] = (curr - state->prev[i]);
state->prev[i] = curr;
}
}
@ -852,13 +870,13 @@ static READ16_HANDLER( poundfor_trackball_r )
{
default:
case 0:
return (diff[0] & 0xff) | ((diff[2] & 0xff) << 8);
return (state->diff[0] & 0xff) | ((state->diff[2] & 0xff) << 8);
case 1:
return ((diff[0] >> 8) & 0x1f) | (diff[2] & 0x1f00) | (input_port_read(space->machine, "IN0") & 0xe0e0);
return ((state->diff[0] >> 8) & 0x1f) | (state->diff[2] & 0x1f00) | (input_port_read(space->machine, "IN0") & 0xe0e0);
case 2:
return (diff[1] & 0xff) | ((diff[3] & 0xff) << 8);
return (state->diff[1] & 0xff) | ((state->diff[3] & 0xff) << 8);
case 3:
return ((diff[1] >> 8) & 0x1f) | (diff[3] & 0x1f00);
return ((state->diff[1] >> 8) & 0x1f) | (state->diff[3] & 0x1f00);
}
}
@ -870,8 +888,8 @@ static ADDRESS_MAP_START( NAME##_map, ADDRESS_SPACE_PROGRAM, 16 ) \
AM_RANGE(0xc0000, 0xc03ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) \
AM_RANGE(0xc8000, 0xc8bff) AM_READWRITE(m72_palette1_r, m72_palette1_w) AM_BASE_GENERIC(paletteram) \
AM_RANGE(0xcc000, 0xccbff) AM_READWRITE(m72_palette2_r, m72_palette2_w) AM_BASE_GENERIC(paletteram2) \
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE(&m72_videoram1) \
AM_RANGE(0xd8000, 0xdbfff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE(&m72_videoram2) \
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE_MEMBER(m72_state, videoram1) \
AM_RANGE(0xd8000, 0xdbfff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE_MEMBER(m72_state, videoram2) \
AM_RANGE(0xe0000, 0xeffff) AM_READWRITE(soundram_r, soundram_w) \
AM_RANGE(0xffff0, 0xfffff) AM_ROM \
ADDRESS_MAP_END
@ -890,8 +908,8 @@ static ADDRESS_MAP_START( xmultipl_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xc0000, 0xc03ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xc8000, 0xc8bff) AM_READWRITE(m72_palette1_r, m72_palette1_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xcc000, 0xccbff) AM_READWRITE(m72_palette2_r, m72_palette2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE(&m72_videoram1)
AM_RANGE(0xd8000, 0xdbfff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE(&m72_videoram2)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE_MEMBER(m72_state, videoram1)
AM_RANGE(0xd8000, 0xdbfff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE_MEMBER(m72_state, videoram2)
AM_RANGE(0xffff0, 0xfffff) AM_ROM
ADDRESS_MAP_END
@ -902,8 +920,8 @@ static ADDRESS_MAP_START( dbreed_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xc0000, 0xc03ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xc8000, 0xc8bff) AM_READWRITE(m72_palette1_r, m72_palette1_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xcc000, 0xccbff) AM_READWRITE(m72_palette2_r, m72_palette2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE(&m72_videoram1)
AM_RANGE(0xd8000, 0xdbfff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE(&m72_videoram2)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE_MEMBER(m72_state, videoram1)
AM_RANGE(0xd8000, 0xdbfff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE_MEMBER(m72_state, videoram2)
AM_RANGE(0xffff0, 0xfffff) AM_ROM
ADDRESS_MAP_END
@ -913,8 +931,8 @@ static ADDRESS_MAP_START( rtype2_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xbc000, 0xbc001) AM_WRITE(m72_dmaon_w)
AM_RANGE(0xc0000, 0xc03ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xc8000, 0xc8bff) AM_READWRITE(m72_palette1_r, m72_palette1_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE(&m72_videoram1)
AM_RANGE(0xd4000, 0xd7fff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE(&m72_videoram2)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE_MEMBER(m72_state, videoram1)
AM_RANGE(0xd4000, 0xd7fff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE_MEMBER(m72_state, videoram2)
AM_RANGE(0xd8000, 0xd8bff) AM_READWRITE(m72_palette2_r, m72_palette2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xe0000, 0xe3fff) AM_RAM /* work RAM */
AM_RANGE(0xffff0, 0xfffff) AM_ROM
@ -922,10 +940,10 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( majtitle_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x00000, 0x7ffff) AM_ROM
AM_RANGE(0xa0000, 0xa03ff) AM_RAM AM_BASE(&majtitle_rowscrollram)
AM_RANGE(0xa0000, 0xa03ff) AM_RAM AM_BASE_MEMBER(m72_state, majtitle_rowscrollram)
AM_RANGE(0xa4000, 0xa4bff) AM_READWRITE(m72_palette2_r, m72_palette2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xac000, 0xaffff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE(&m72_videoram1)
AM_RANGE(0xb0000, 0xbffff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE(&m72_videoram2) /* larger than the other games */
AM_RANGE(0xac000, 0xaffff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE_MEMBER(m72_state, videoram1)
AM_RANGE(0xb0000, 0xbffff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE_MEMBER(m72_state, videoram2) /* larger than the other games */
AM_RANGE(0xc0000, 0xc03ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xc8000, 0xc83ff) AM_RAM AM_BASE_GENERIC(spriteram2)
AM_RANGE(0xcc000, 0xccbff) AM_READWRITE(m72_palette1_r, m72_palette1_w) AM_BASE_GENERIC(paletteram)
@ -943,8 +961,8 @@ static ADDRESS_MAP_START( hharry_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xc0000, 0xc03ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xc8000, 0xc8bff) AM_READWRITE(m72_palette1_r, m72_palette1_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xcc000, 0xccbff) AM_READWRITE(m72_palette2_r, m72_palette2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE(&m72_videoram1)
AM_RANGE(0xd8000, 0xdbfff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE(&m72_videoram2)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE_MEMBER(m72_state, videoram1)
AM_RANGE(0xd8000, 0xdbfff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE_MEMBER(m72_state, videoram2)
AM_RANGE(0xffff0, 0xfffff) AM_ROM
ADDRESS_MAP_END
@ -956,8 +974,8 @@ static ADDRESS_MAP_START( hharryu_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xbc000, 0xbc001) AM_WRITE(m72_dmaon_w)
AM_RANGE(0xb0ffe, 0xb0fff) AM_WRITEONLY /* leftover from protection?? */
AM_RANGE(0xc0000, 0xc03ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE(&m72_videoram1)
AM_RANGE(0xd4000, 0xd7fff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE(&m72_videoram2)
AM_RANGE(0xd0000, 0xd3fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE_MEMBER(m72_state, videoram1)
AM_RANGE(0xd4000, 0xd7fff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE_MEMBER(m72_state, videoram2)
AM_RANGE(0xe0000, 0xe3fff) AM_RAM /* work RAM */
AM_RANGE(0xffff0, 0xfffff) AM_ROM
ADDRESS_MAP_END
@ -970,8 +988,8 @@ static ADDRESS_MAP_START( kengo_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xb4000, 0xb4001) AM_WRITENOP /* ??? */
AM_RANGE(0xbc000, 0xbc001) AM_WRITE(m72_dmaon_w)
AM_RANGE(0xc0000, 0xc03ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0x80000, 0x83fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE(&m72_videoram1)
AM_RANGE(0x84000, 0x87fff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE(&m72_videoram2)
AM_RANGE(0x80000, 0x83fff) AM_RAM_WRITE(m72_videoram1_w) AM_BASE_MEMBER(m72_state, videoram1)
AM_RANGE(0x84000, 0x87fff) AM_RAM_WRITE(m72_videoram2_w) AM_BASE_MEMBER(m72_state, videoram2)
AM_RANGE(0xe0000, 0xe3fff) AM_RAM /* work RAM */
AM_RANGE(0xffff0, 0xfffff) AM_ROM
ADDRESS_MAP_END
@ -1062,7 +1080,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( sound_ram_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xffff) AM_RAM AM_BASE(&soundram)
AM_RANGE(0x0000, 0xffff) AM_RAM AM_BASE_MEMBER(m72_state, soundram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( sound_rom_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -1827,7 +1845,7 @@ static const ym2151_interface ym2151_config =
static MACHINE_CONFIG_START( m72_base, driver_device )
static MACHINE_CONFIG_START( m72_base, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -1883,7 +1901,7 @@ static MACHINE_CONFIG_DERIVED( m72_8751, m72_base )
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( rtype, driver_device )
static MACHINE_CONFIG_START( rtype, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -1921,7 +1939,7 @@ static MACHINE_CONFIG_START( rtype, driver_device )
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( xmultipl, driver_device )
static MACHINE_CONFIG_START( xmultipl, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -1964,7 +1982,7 @@ static MACHINE_CONFIG_START( xmultipl, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( xmultiplm72, driver_device )
static MACHINE_CONFIG_START( xmultiplm72, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -2007,7 +2025,7 @@ static MACHINE_CONFIG_START( xmultiplm72, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( dbreed, driver_device )
static MACHINE_CONFIG_START( dbreed, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -2050,7 +2068,7 @@ static MACHINE_CONFIG_START( dbreed, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( dbreedm72, driver_device )
static MACHINE_CONFIG_START( dbreedm72, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -2093,7 +2111,7 @@ static MACHINE_CONFIG_START( dbreedm72, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( rtype2, driver_device )
static MACHINE_CONFIG_START( rtype2, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -2136,7 +2154,7 @@ static MACHINE_CONFIG_START( rtype2, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( majtitle, driver_device )
static MACHINE_CONFIG_START( majtitle, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -2179,7 +2197,7 @@ static MACHINE_CONFIG_START( majtitle, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( hharry, driver_device )
static MACHINE_CONFIG_START( hharry, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -2222,7 +2240,7 @@ static MACHINE_CONFIG_START( hharry, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( hharryu, driver_device )
static MACHINE_CONFIG_START( hharryu, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -2265,7 +2283,7 @@ static MACHINE_CONFIG_START( hharryu, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( dkgenm72, driver_device )
static MACHINE_CONFIG_START( dkgenm72, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -2308,7 +2326,7 @@ static MACHINE_CONFIG_START( dkgenm72, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( poundfor, driver_device )
static MACHINE_CONFIG_START( poundfor, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", V30,MASTER_CLOCK/2/2) /* 16 MHz external freq (8MHz internal) */
@ -2351,7 +2369,7 @@ static MACHINE_CONFIG_START( poundfor, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( cosmccop, driver_device )
static MACHINE_CONFIG_START( cosmccop, m72_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", V35,MASTER_CLOCK/2)

View File

@ -203,17 +203,12 @@ psoldier dip locations still need veritication.
#include "sound/iremga20.h"
#include "sound/okim6295.h"
static UINT8 irqvector;
static UINT16 sound_status;
static UINT32 bankaddress;
static emu_timer *scanline_timer;
static UINT8 m92_irq_vectorbase;
#define M92_IRQ_0 ((m92_irq_vectorbase+0)/4) /* VBL interrupt*/
#define M92_IRQ_1 ((m92_irq_vectorbase+4)/4) /* Sprite buffer complete interrupt */
#define M92_IRQ_2 ((m92_irq_vectorbase+8)/4) /* Raster interrupt */
#define M92_IRQ_3 ((m92_irq_vectorbase+12)/4) /* Sound cpu interrupt */
#define M92_IRQ_0 ((state->irq_vectorbase+0)/4) /* VBL interrupt*/
#define M92_IRQ_1 ((state->irq_vectorbase+4)/4) /* Sprite buffer complete interrupt */
#define M92_IRQ_2 ((state->irq_vectorbase+8)/4) /* Raster interrupt */
#define M92_IRQ_3 ((state->irq_vectorbase+12)/4) /* Sound cpu interrupt */
static TIMER_CALLBACK( m92_scanline_interrupt );
@ -222,8 +217,9 @@ static TIMER_CALLBACK( m92_scanline_interrupt );
static void set_m92_bank(running_machine *machine)
{
m92_state *state = machine->driver_data<m92_state>();
UINT8 *RAM = machine->region("maincpu")->base();
memory_set_bankptr(machine, "bank1",&RAM[bankaddress]);
memory_set_bankptr(machine, "bank1",&RAM[state->bankaddress]);
}
static STATE_POSTLOAD( m92_postload )
@ -233,27 +229,30 @@ static STATE_POSTLOAD( m92_postload )
static MACHINE_START( m92 )
{
state_save_register_global(machine, irqvector);
state_save_register_global(machine, sound_status);
state_save_register_global(machine, bankaddress);
m92_state *state = machine->driver_data<m92_state>();
state_save_register_global(machine, state->irqvector);
state_save_register_global(machine, state->sound_status);
state_save_register_global(machine, state->bankaddress);
state_save_register_postload(machine, m92_postload, NULL);
scanline_timer = timer_alloc(machine, m92_scanline_interrupt, NULL);
state->scanline_timer = timer_alloc(machine, m92_scanline_interrupt, NULL);
}
static MACHINE_RESET( m92 )
{
timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0);
m92_state *state = machine->driver_data<m92_state>();
timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0), 0);
}
/*****************************************************************************/
static TIMER_CALLBACK( m92_scanline_interrupt )
{
m92_state *state = machine->driver_data<m92_state>();
int scanline = param;
/* raster interrupt */
if (scanline == m92_raster_irq_position)
if (scanline == state->raster_irq_position)
{
machine->primary_screen->update_partial(scanline);
cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, M92_IRQ_2);
@ -269,7 +268,7 @@ static TIMER_CALLBACK( m92_scanline_interrupt )
/* adjust for next scanline */
if (++scanline >= machine->primary_screen->height())
scanline = 0;
timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline);
}
/*****************************************************************************/
@ -303,16 +302,18 @@ static WRITE16_HANDLER( m92_coincounter_w )
static WRITE16_HANDLER( m92_bankswitch_w )
{
m92_state *state = space->machine->driver_data<m92_state>();
if (ACCESSING_BITS_0_7)
{
bankaddress = 0x100000 + ((data & 0x7) * 0x10000);
state->bankaddress = 0x100000 + ((data & 0x7) * 0x10000);
set_m92_bank(space->machine);
}
}
static CUSTOM_INPUT( m92_sprite_busy_r )
{
return m92_sprite_buffer_busy;
m92_state *state = field->port->machine->driver_data<m92_state>();
return state->sprite_buffer_busy;
}
/*****************************************************************************/
@ -321,24 +322,25 @@ enum { VECTOR_INIT, YM2151_ASSERT, YM2151_CLEAR, V30_ASSERT, V30_CLEAR };
static TIMER_CALLBACK( setvector_callback )
{
m92_state *state = machine->driver_data<m92_state>();
if (!machine->device("soundcpu"))
return;
switch(param)
{
case VECTOR_INIT: irqvector = 0; break;
case YM2151_ASSERT: irqvector |= 0x2; break;
case YM2151_CLEAR: irqvector &= ~0x2; break;
case V30_ASSERT: irqvector |= 0x1; break;
case V30_CLEAR: irqvector &= ~0x1; break;
case VECTOR_INIT: state->irqvector = 0; break;
case YM2151_ASSERT: state->irqvector |= 0x2; break;
case YM2151_CLEAR: state->irqvector &= ~0x2; break;
case V30_ASSERT: state->irqvector |= 0x1; break;
case V30_CLEAR: state->irqvector &= ~0x1; break;
}
if (irqvector & 0x2) /* YM2151 has precedence */
if (state->irqvector & 0x2) /* YM2151 has precedence */
cpu_set_input_line_vector(machine->device("soundcpu"), 0, 0x18);
else if (irqvector & 0x1) /* V30 */
else if (state->irqvector & 0x1) /* V30 */
cpu_set_input_line_vector(machine->device("soundcpu"), 0, 0x19);
if (irqvector == 0) /* no IRQs pending */
if (state->irqvector == 0) /* no IRQs pending */
cputag_set_input_line(machine, "soundcpu", 0, CLEAR_LINE);
else /* IRQ pending */
cputag_set_input_line(machine, "soundcpu", 0, ASSERT_LINE);
@ -352,8 +354,9 @@ static WRITE16_HANDLER( m92_soundlatch_w )
static READ16_HANDLER( m92_sound_status_r )
{
m92_state *state = space->machine->driver_data<m92_state>();
//logerror("%06x: read sound status\n",cpu_get_pc(space->cpu));
return sound_status;
return state->sound_status;
}
static READ16_HANDLER( m92_soundlatch_r )
@ -368,7 +371,8 @@ static WRITE16_HANDLER( m92_sound_irq_ack_w )
static WRITE16_HANDLER( m92_sound_status_w )
{
COMBINE_DATA(&sound_status);
m92_state *state = space->machine->driver_data<m92_state>();
COMBINE_DATA(&state->sound_status);
cputag_set_input_line_and_vector(space->machine, "maincpu", 0, HOLD_LINE, M92_IRQ_3);
}
@ -383,11 +387,11 @@ static WRITE16_HANDLER( m92_sound_reset_w )
/* appears to be an earlier board */
static ADDRESS_MAP_START( lethalth_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x00000, 0x7ffff) AM_ROM
AM_RANGE(0x80000, 0x8ffff) AM_RAM_WRITE(m92_vram_w) AM_BASE(&m92_vram_data)
AM_RANGE(0x80000, 0x8ffff) AM_RAM_WRITE(m92_vram_w) AM_BASE_MEMBER(m92_state, vram_data)
AM_RANGE(0xe0000, 0xeffff) AM_RAM /* System ram */
AM_RANGE(0xf8000, 0xf87ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xf8800, 0xf8fff) AM_READWRITE(m92_paletteram_r, m92_paletteram_w)
AM_RANGE(0xf9000, 0xf900f) AM_WRITE(m92_spritecontrol_w) AM_BASE(&m92_spritecontrol)
AM_RANGE(0xf9000, 0xf900f) AM_WRITE(m92_spritecontrol_w) AM_BASE_MEMBER(m92_state, spritecontrol)
AM_RANGE(0xf9800, 0xf9801) AM_WRITE(m92_videocontrol_w)
AM_RANGE(0xffff0, 0xfffff) AM_ROM AM_REGION("maincpu", 0x7fff0)
ADDRESS_MAP_END
@ -396,11 +400,11 @@ static ADDRESS_MAP_START( m92_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x00000, 0x9ffff) AM_ROM
AM_RANGE(0xa0000, 0xbffff) AM_ROMBANK("bank1")
AM_RANGE(0xc0000, 0xcffff) AM_ROMBANK("bank2") /* Mirror of rom: Used by In The Hunt as protection */
AM_RANGE(0xd0000, 0xdffff) AM_RAM_WRITE(m92_vram_w) AM_BASE(&m92_vram_data)
AM_RANGE(0xd0000, 0xdffff) AM_RAM_WRITE(m92_vram_w) AM_BASE_MEMBER(m92_state, vram_data)
AM_RANGE(0xe0000, 0xeffff) AM_RAM /* System ram */
AM_RANGE(0xf8000, 0xf87ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xf8800, 0xf8fff) AM_READWRITE(m92_paletteram_r, m92_paletteram_w)
AM_RANGE(0xf9000, 0xf900f) AM_WRITE(m92_spritecontrol_w) AM_BASE(&m92_spritecontrol)
AM_RANGE(0xf9000, 0xf900f) AM_WRITE(m92_spritecontrol_w) AM_BASE_MEMBER(m92_state, spritecontrol)
AM_RANGE(0xf9800, 0xf9801) AM_WRITE(m92_videocontrol_w)
AM_RANGE(0xffff0, 0xfffff) AM_ROM
ADDRESS_MAP_END
@ -921,10 +925,12 @@ static const ym2151_interface ym2151_config =
void m92_sprite_interrupt(running_machine *machine)
{
m92_state *state = machine->driver_data<m92_state>();
cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, M92_IRQ_1);
}
static MACHINE_CONFIG_START( m92, driver_device )
static MACHINE_CONFIG_START( m92, m92_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",V33,18000000/2) /* NEC V33, 18 MHz clock */
@ -1010,7 +1016,7 @@ static MACHINE_CONFIG_DERIVED( hook, m92 )
MCFG_CPU_CONFIG(hook_config)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( ppan, driver_device )
static MACHINE_CONFIG_START( ppan, m92_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",V33,18000000/2)
@ -2078,12 +2084,13 @@ ROM_END
static void init_m92(running_machine *machine, int hasbanks)
{
m92_state *state = machine->driver_data<m92_state>();
UINT8 *RAM = machine->region("maincpu")->base();
if (hasbanks)
{
memcpy(RAM + 0xffff0, RAM + 0x7fff0, 0x10); /* Start vector */
bankaddress = 0xa0000; /* Initial bank */
state->bankaddress = 0xa0000; /* Initial bank */
set_m92_bank(machine);
/* Mirror used by In The Hunt for protection */
@ -2096,9 +2103,9 @@ static void init_m92(running_machine *machine, int hasbanks)
if (RAM)
memcpy(RAM + 0xffff0, RAM + 0x1fff0, 0x10); /* Sound cpu Start vector */
m92_game_kludge = 0;
m92_irq_vectorbase = 0x80;
m92_sprite_buffer_busy = 1;
state->game_kludge = 0;
state->irq_vectorbase = 0x80;
state->sprite_buffer_busy = 1;
setvector_callback(machine, NULL, VECTOR_INIT);
}
@ -2130,24 +2137,27 @@ static DRIVER_INIT( uccops )
static DRIVER_INIT( rtypeleo )
{
m92_state *state = machine->driver_data<m92_state>();
init_m92(machine, 1);
m92_irq_vectorbase = 0x20;
state->irq_vectorbase = 0x20;
}
static DRIVER_INIT( rtypelej )
{
m92_state *state = machine->driver_data<m92_state>();
init_m92(machine, 1);
m92_irq_vectorbase = 0x20;
state->irq_vectorbase = 0x20;
}
static DRIVER_INIT( majtitl2 )
{
m92_state *state = machine->driver_data<m92_state>();
init_m92(machine, 1);
/* This game has an eprom on the game board */
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xf0000, 0xf3fff, 0, 0, m92_eeprom_r, m92_eeprom_w);
m92_game_kludge = 2;
state->game_kludge = 2;
}
static DRIVER_INIT( kaiteids )
@ -2163,8 +2173,9 @@ static DRIVER_INIT( inthunt )
static DRIVER_INIT( lethalth )
{
m92_state *state = machine->driver_data<m92_state>();
init_m92(machine, 0);
m92_irq_vectorbase = 0x20;
state->irq_vectorbase = 0x20;
/* NOP out the bankswitcher */
memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x20, 0x21, 0, 0);
@ -2181,18 +2192,20 @@ static DRIVER_INIT( nbbatman )
static DRIVER_INIT( ssoldier )
{
m92_state *state = machine->driver_data<m92_state>();
init_m92(machine, 1);
m92_irq_vectorbase = 0x20;
state->irq_vectorbase = 0x20;
/* main CPU expects an answer even before writing the first command */
sound_status = 0x80;
state->sound_status = 0x80;
}
static DRIVER_INIT( psoldier )
{
m92_state *state = machine->driver_data<m92_state>();
init_m92(machine, 1);
m92_irq_vectorbase = 0x20;
state->irq_vectorbase = 0x20;
/* main CPU expects an answer even before writing the first command */
sound_status = 0x80;
state->sound_status = 0x80;
}
static DRIVER_INIT( dsoccr94j )

View File

@ -69,16 +69,17 @@ K1000233A
#include "sound/ay8910.h"
#include "includes/pitnrun.h"
static int pitnrun_nmi;
static INTERRUPT_GEN( pitnrun_nmi_source )
{
if(pitnrun_nmi) cpu_set_input_line(device,INPUT_LINE_NMI, PULSE_LINE);
pitnrun_state *state = device->machine->driver_data<pitnrun_state>();
if(state->nmi) cpu_set_input_line(device,INPUT_LINE_NMI, PULSE_LINE);
}
static WRITE8_HANDLER( nmi_enable_w )
{
pitnrun_nmi = data & 1;
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
state->nmi = data & 1;
}
static WRITE8_HANDLER(pitnrun_hflip_w)
@ -95,7 +96,7 @@ static ADDRESS_MAP_START( pitnrun_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(pitnrun_videoram_w) AM_BASE_MEMBER(pitnrun_state, videoram)
AM_RANGE(0x9000, 0x9fff) AM_RAM_WRITE(pitnrun_videoram2_w) AM_BASE(&pitnrun_videoram2)
AM_RANGE(0x9000, 0x9fff) AM_RAM_WRITE(pitnrun_videoram2_w) AM_BASE_MEMBER(pitnrun_state, videoram2)
AM_RANGE(0xa000, 0xa0ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xa800, 0xa800) AM_READ_PORT("SYSTEM")
AM_RANGE(0xa800, 0xa807) AM_WRITENOP /* Analog Sound */

View File

@ -152,15 +152,15 @@ static READ8_HANDLER( panther_unk_r )
static ADDRESS_MAP_START( redalert_main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_RAM
AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(redalert_bitmap_videoram_w) AM_BASE(&redalert_bitmap_videoram)
AM_RANGE(0x4000, 0x4fff) AM_RAM AM_BASE(&redalert_charmap_videoram)
AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(redalert_bitmap_videoram_w) AM_BASE_MEMBER(redalert_state, bitmap_videoram)
AM_RANGE(0x4000, 0x4fff) AM_RAM AM_BASE_MEMBER(redalert_state, charmap_videoram)
AM_RANGE(0x5000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xc000) AM_MIRROR(0x0f8f) AM_READ_PORT("C000") AM_WRITENOP
AM_RANGE(0xc010, 0xc010) AM_MIRROR(0x0f8f) AM_READ_PORT("C010") AM_WRITENOP
AM_RANGE(0xc020, 0xc020) AM_MIRROR(0x0f8f) AM_READ_PORT("C020") AM_WRITENOP
AM_RANGE(0xc030, 0xc030) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITE(redalert_audio_command_w)
AM_RANGE(0xc040, 0xc040) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE(&redalert_video_control)
AM_RANGE(0xc050, 0xc050) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE(&redalert_bitmap_color)
AM_RANGE(0xc040, 0xc040) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE_MEMBER(redalert_state, video_control)
AM_RANGE(0xc050, 0xc050) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE_MEMBER(redalert_state, bitmap_color)
AM_RANGE(0xc060, 0xc060) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITE(redalert_voice_command_w)
AM_RANGE(0xc070, 0xc070) AM_MIRROR(0x0f8f) AM_READWRITE(redalert_interrupt_clear_r, redalert_interrupt_clear_w)
AM_RANGE(0xf000, 0xffff) AM_ROM AM_REGION("maincpu", 0x8000)
@ -168,45 +168,45 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( ww3_main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_RAM
AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(redalert_bitmap_videoram_w) AM_BASE(&redalert_bitmap_videoram)
AM_RANGE(0x4000, 0x4fff) AM_RAM AM_BASE(&redalert_charmap_videoram)
AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(redalert_bitmap_videoram_w) AM_BASE_MEMBER(redalert_state, bitmap_videoram)
AM_RANGE(0x4000, 0x4fff) AM_RAM AM_BASE_MEMBER(redalert_state, charmap_videoram)
AM_RANGE(0x5000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xc000) AM_MIRROR(0x0f8f) AM_READ_PORT("C000") AM_WRITENOP
AM_RANGE(0xc010, 0xc010) AM_MIRROR(0x0f8f) AM_READ_PORT("C010") AM_WRITENOP
AM_RANGE(0xc020, 0xc020) AM_MIRROR(0x0f8f) AM_READ_PORT("C020") AM_WRITENOP
AM_RANGE(0xc030, 0xc030) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITE(redalert_audio_command_w)
AM_RANGE(0xc040, 0xc040) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE(&redalert_video_control)
AM_RANGE(0xc050, 0xc050) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE(&redalert_bitmap_color)
AM_RANGE(0xc040, 0xc040) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE_MEMBER(redalert_state, video_control)
AM_RANGE(0xc050, 0xc050) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE_MEMBER(redalert_state, bitmap_color)
AM_RANGE(0xc070, 0xc070) AM_MIRROR(0x0f8f) AM_READWRITE(redalert_interrupt_clear_r, redalert_interrupt_clear_w)
AM_RANGE(0xf000, 0xffff) AM_ROM AM_REGION("maincpu", 0x8000)
ADDRESS_MAP_END
static ADDRESS_MAP_START( panther_main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_RAM
AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(redalert_bitmap_videoram_w) AM_BASE(&redalert_bitmap_videoram)
AM_RANGE(0x4000, 0x4fff) AM_RAM AM_BASE(&redalert_charmap_videoram)
AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(redalert_bitmap_videoram_w) AM_BASE_MEMBER(redalert_state, bitmap_videoram)
AM_RANGE(0x4000, 0x4fff) AM_RAM AM_BASE_MEMBER(redalert_state, charmap_videoram)
AM_RANGE(0x5000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xc000) AM_MIRROR(0x0f8f) AM_READ_PORT("C000") AM_WRITENOP
AM_RANGE(0xc010, 0xc010) AM_MIRROR(0x0f8f) AM_READ_PORT("C010") AM_WRITENOP
AM_RANGE(0xc020, 0xc020) AM_MIRROR(0x0f8f) AM_READ(panther_unk_r) /* vblank? */
AM_RANGE(0xc030, 0xc030) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITE(redalert_audio_command_w)
AM_RANGE(0xc040, 0xc040) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE(&redalert_video_control)
AM_RANGE(0xc050, 0xc050) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE(&redalert_bitmap_color)
AM_RANGE(0xc040, 0xc040) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE_MEMBER(redalert_state, video_control)
AM_RANGE(0xc050, 0xc050) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE_MEMBER(redalert_state, bitmap_color)
AM_RANGE(0xc070, 0xc070) AM_MIRROR(0x0f8f) AM_READWRITE(panther_interrupt_clear_r, redalert_interrupt_clear_w)
AM_RANGE(0xf000, 0xffff) AM_ROM AM_REGION("maincpu", 0x8000)
ADDRESS_MAP_END
static ADDRESS_MAP_START( demoneye_main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_RAM
AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(redalert_bitmap_videoram_w) AM_BASE(&redalert_bitmap_videoram)
AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&redalert_charmap_videoram)
AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(redalert_bitmap_videoram_w) AM_BASE_MEMBER(redalert_state, bitmap_videoram)
AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(redalert_state, charmap_videoram)
AM_RANGE(0x6000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xc000) AM_MIRROR(0x0f8f) AM_READ_PORT("C000") AM_WRITENOP
AM_RANGE(0xc010, 0xc010) AM_MIRROR(0x0f8f) AM_READ_PORT("C010") AM_WRITENOP
AM_RANGE(0xc020, 0xc020) AM_MIRROR(0x0f8f) AM_READ_PORT("C020") AM_WRITENOP
AM_RANGE(0xc030, 0xc030) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITE(demoneye_audio_command_w)
AM_RANGE(0xc040, 0xc040) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE(&redalert_video_control)
AM_RANGE(0xc050, 0xc050) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE(&redalert_bitmap_color)
AM_RANGE(0xc040, 0xc040) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE_MEMBER(redalert_state, video_control)
AM_RANGE(0xc050, 0xc050) AM_MIRROR(0x0f8f) AM_READNOP AM_WRITEONLY AM_BASE_MEMBER(redalert_state, bitmap_color)
AM_RANGE(0xc060, 0xc060) AM_MIRROR(0x0f80) AM_NOP /* unknown */
AM_RANGE(0xc061, 0xc061) AM_MIRROR(0x0f80) AM_NOP /* unknown */
AM_RANGE(0xc062, 0xc062) AM_MIRROR(0x0f80) AM_NOP /* unknown */
@ -385,7 +385,7 @@ INPUT_PORTS_END
*
*************************************/
static MACHINE_CONFIG_START( redalert, driver_device )
static MACHINE_CONFIG_START( redalert, redalert_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, MAIN_CPU_CLOCK)
@ -399,7 +399,7 @@ static MACHINE_CONFIG_START( redalert, driver_device )
MCFG_FRAGMENT_ADD(redalert_audio)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( ww3, driver_device )
static MACHINE_CONFIG_START( ww3, redalert_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, MAIN_CPU_CLOCK)
@ -413,7 +413,7 @@ static MACHINE_CONFIG_START( ww3, driver_device )
MCFG_FRAGMENT_ADD(ww3_audio)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( panther, driver_device )
static MACHINE_CONFIG_START( panther, redalert_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, MAIN_CPU_CLOCK)
@ -427,7 +427,7 @@ static MACHINE_CONFIG_START( panther, driver_device )
MCFG_FRAGMENT_ADD(ww3_audio)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( demoneye, driver_device )
static MACHINE_CONFIG_START( demoneye, redalert_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M6502, MAIN_CPU_CLOCK)

View File

@ -35,7 +35,6 @@ Notes:
#include "sound/sn76496.h"
#include "includes/retofinv.h"
static UINT8 cpu2_m6000=0;
static WRITE8_HANDLER( cpu1_reset_w )
@ -57,12 +56,14 @@ static WRITE8_HANDLER( mcu_reset_w )
static WRITE8_HANDLER( cpu2_m6000_w )
{
cpu2_m6000 = data;
retofinv_state *state = space->machine->driver_data<retofinv_state>();
state->cpu2_m6000 = data;
}
static READ8_HANDLER( cpu0_mf800_r )
{
return cpu2_m6000;
retofinv_state *state = space->machine->driver_data<retofinv_state>();
return state->cpu2_m6000;
}
static WRITE8_HANDLER( soundcommand_w )
@ -105,9 +106,9 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x7fff, 0x7fff) AM_WRITE(coincounter_w)
AM_RANGE(0x7b00, 0x7bff) AM_ROM /* space for diagnostic ROM? The code looks */
/* for a string here, and jumps if it's present */
AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(retofinv_fg_videoram_w) AM_SHARE("share2") AM_BASE(&retofinv_fg_videoram)
AM_RANGE(0x8800, 0x9fff) AM_RAM AM_SHARE("share1") AM_BASE(&retofinv_sharedram)
AM_RANGE(0xa000, 0xa7ff) AM_RAM_WRITE(retofinv_bg_videoram_w) AM_SHARE("share3") AM_BASE(&retofinv_bg_videoram)
AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(retofinv_fg_videoram_w) AM_SHARE("share2") AM_BASE_MEMBER(retofinv_state, fg_videoram)
AM_RANGE(0x8800, 0x9fff) AM_RAM AM_SHARE("share1") AM_BASE_MEMBER(retofinv_state, sharedram)
AM_RANGE(0xa000, 0xa7ff) AM_RAM_WRITE(retofinv_bg_videoram_w) AM_SHARE("share3") AM_BASE_MEMBER(retofinv_state, bg_videoram)
AM_RANGE(0xb800, 0xb802) AM_WRITE(retofinv_gfx_ctrl_w)
AM_RANGE(0xc000, 0xc000) AM_READ_PORT("P1")
AM_RANGE(0xc001, 0xc001) AM_READ_PORT("P2")
@ -336,7 +337,7 @@ GFXDECODE_END
static MACHINE_CONFIG_START( retofinv, driver_device )
static MACHINE_CONFIG_START( retofinv, retofinv_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 18432000/6) /* 3.072 MHz? */

View File

@ -30,8 +30,8 @@ static ADDRESS_MAP_START( rollrace_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xc000, 0xcfff) AM_RAM
AM_RANGE(0xd806, 0xd806) AM_READNOP /* looks like a watchdog, bit4 checked*/
AM_RANGE(0xd900, 0xd900) AM_READWRITE(ra_fake_d800_r,ra_fake_d800_w) /* protection ??*/
AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE(&rollrace_videoram)
AM_RANGE(0xe400, 0xe47f) AM_RAM AM_BASE(&rollrace_colorram)
AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE_MEMBER(rollrace_state, videoram)
AM_RANGE(0xe400, 0xe47f) AM_RAM AM_BASE_MEMBER(rollrace_state, colorram)
AM_RANGE(0xe800, 0xe800) AM_WRITE(soundlatch_w)
AM_RANGE(0xec00, 0xec0f) AM_NOP /* Analog sound effects ?? ec00 sound enable ?*/
AM_RANGE(0xf000, 0xf0ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
@ -197,7 +197,7 @@ static GFXDECODE_START( rollrace )
GFXDECODE_ENTRY( "gfx5", 0x0000, spritelayout, 0, 32 )
GFXDECODE_END
static MACHINE_CONFIG_START( rollrace, driver_device )
static MACHINE_CONFIG_START( rollrace, rollrace_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80,XTAL_24MHz/8) /* verified on pcb */

View File

@ -74,7 +74,7 @@ static INTERRUPT_GEN( sprint2 )
sprint2_state *state = device->machine->driver_data<sprint2_state>();
device_t *discrete = device->machine->device("discrete");
/* handle state->steering wheels */
/* handle steering wheels */
if (GAME_IS_SPRINT1 || GAME_IS_SPRINT2)
{

View File

@ -44,32 +44,30 @@
#include "superchs.lh"
#include "includes/superchs.h"
static UINT16 coin_word;
static UINT32 *superchs_ram;
static UINT32 *shared_ram;
static int steer=0;
/*********************************************************************/
static READ16_HANDLER( shared_ram_r )
{
if ((offset&1)==0) return (shared_ram[offset/2]&0xffff0000)>>16;
return (shared_ram[offset/2]&0x0000ffff);
superchs_state *state = space->machine->driver_data<superchs_state>();
if ((offset&1)==0) return (state->shared_ram[offset/2]&0xffff0000)>>16;
return (state->shared_ram[offset/2]&0x0000ffff);
}
static WRITE16_HANDLER( shared_ram_w )
{
superchs_state *state = space->machine->driver_data<superchs_state>();
if ((offset&1)==0) {
if (ACCESSING_BITS_8_15)
shared_ram[offset/2]=(shared_ram[offset/2]&0x00ffffff)|((data&0xff00)<<16);
state->shared_ram[offset/2]=(state->shared_ram[offset/2]&0x00ffffff)|((data&0xff00)<<16);
if (ACCESSING_BITS_0_7)
shared_ram[offset/2]=(shared_ram[offset/2]&0xff00ffff)|((data&0x00ff)<<16);
state->shared_ram[offset/2]=(state->shared_ram[offset/2]&0xff00ffff)|((data&0x00ff)<<16);
} else {
if (ACCESSING_BITS_8_15)
shared_ram[offset/2]=(shared_ram[offset/2]&0xffff00ff)|((data&0xff00)<< 0);
state->shared_ram[offset/2]=(state->shared_ram[offset/2]&0xffff00ff)|((data&0xff00)<< 0);
if (ACCESSING_BITS_0_7)
shared_ram[offset/2]=(shared_ram[offset/2]&0xffffff00)|((data&0x00ff)<< 0);
state->shared_ram[offset/2]=(state->shared_ram[offset/2]&0xffffff00)|((data&0x00ff)<< 0);
}
}
@ -111,13 +109,14 @@ static WRITE32_HANDLER( superchs_palette_w )
static READ32_HANDLER( superchs_input_r )
{
superchs_state *state = space->machine->driver_data<superchs_state>();
switch (offset)
{
case 0x00:
return input_port_read(space->machine, "INPUTS");
case 0x01:
return coin_word<<16;
return state->coin_word<<16;
}
return 0xffffffff;
@ -125,13 +124,13 @@ static READ32_HANDLER( superchs_input_r )
static WRITE32_HANDLER( superchs_input_w )
{
superchs_state *state = space->machine->driver_data<superchs_state>();
#if 0
{
char t[64];
static UINT32 mem[2];
COMBINE_DATA(&mem[offset]);
sprintf(t,"%08x %08x",mem[0],mem[1]);
COMBINE_DATA(&state->mem[offset]);
sprintf(t,"%08x %08x",state->mem[0],state->mem[1]);
//popmessage(t);
}
#endif
@ -167,7 +166,7 @@ static WRITE32_HANDLER( superchs_input_w )
coin_lockout_w(space->machine, 1,~data & 0x02000000);
coin_counter_w(space->machine, 0, data & 0x04000000);
coin_counter_w(space->machine, 1, data & 0x08000000);
coin_word=(data >> 16) &0xffff;
state->coin_word=(data >> 16) &0xffff;
}
}
}
@ -175,12 +174,13 @@ static WRITE32_HANDLER( superchs_input_w )
static READ32_HANDLER( superchs_stick_r )
{
superchs_state *state = space->machine->driver_data<superchs_state>();
int fake = input_port_read(space->machine, "FAKE");
int accel;
if (!(fake &0x10)) /* Analogue steer (the real control method) */
{
steer = input_port_read(space->machine, "WHEEL");
state->steer = input_port_read(space->machine, "WHEEL");
}
else /* Digital steer, with smoothing - speed depends on how often stick_r is called */
{
@ -189,10 +189,10 @@ static READ32_HANDLER( superchs_stick_r )
if (fake &0x04) goal = 0xff; /* pressing left */
if (fake &0x08) goal = 0x0; /* pressing right */
if (steer!=goal)
if (state->steer!=goal)
{
delta = goal - steer;
if (steer < goal)
delta = goal - state->steer;
if (state->steer < goal)
{
if (delta >2) delta = 2;
}
@ -200,7 +200,7 @@ static READ32_HANDLER( superchs_stick_r )
{
if (delta < (-2)) delta = -2;
}
steer += delta;
state->steer += delta;
}
}
@ -211,7 +211,7 @@ static READ32_HANDLER( superchs_stick_r )
accel = 0xff;
/* Todo: Verify brake - and figure out other input */
return (steer << 24) | (accel << 16) | (input_port_read(space->machine, "SOUND") << 8) | input_port_read(space->machine, "UNKNOWN");
return (state->steer << 24) | (accel << 16) | (input_port_read(space->machine, "SOUND") << 8) | input_port_read(space->machine, "UNKNOWN");
}
static WRITE32_HANDLER( superchs_stick_w )
@ -229,11 +229,11 @@ static WRITE32_HANDLER( superchs_stick_w )
static ADDRESS_MAP_START( superchs_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE(&superchs_ram)
AM_RANGE(0x100000, 0x11ffff) AM_RAM AM_BASE_MEMBER(superchs_state, ram)
AM_RANGE(0x140000, 0x141fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0x180000, 0x18ffff) AM_DEVREADWRITE("tc0480scp", tc0480scp_long_r, tc0480scp_long_w)
AM_RANGE(0x1b0000, 0x1b002f) AM_DEVREADWRITE("tc0480scp", tc0480scp_ctrl_long_r, tc0480scp_ctrl_long_w)
AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE(&shared_ram)
AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE_MEMBER(superchs_state, shared_ram)
AM_RANGE(0x240000, 0x240003) AM_WRITE(cpua_ctrl_w)
AM_RANGE(0x280000, 0x287fff) AM_RAM_WRITE(superchs_palette_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x2c0000, 0x2c07ff) AM_RAM AM_BASE(&f3_shared_ram)
@ -368,7 +368,7 @@ static const tc0480scp_interface superchs_tc0480scp_intf =
0 /* col_base */
};
static MACHINE_CONFIG_START( superchs, driver_device )
static MACHINE_CONFIG_START( superchs, superchs_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68EC020, 16000000) /* 16 MHz */
@ -445,18 +445,20 @@ ROM_END
static READ32_HANDLER( main_cycle_r )
{
superchs_state *state = space->machine->driver_data<superchs_state>();
if (cpu_get_pc(space->cpu)==0x702)
cpu_spinuntil_int(space->cpu);
return superchs_ram[0];
return state->ram[0];
}
static READ16_HANDLER( sub_cycle_r )
{
superchs_state *state = space->machine->driver_data<superchs_state>();
if (cpu_get_pc(space->cpu)==0x454)
cpu_spinuntil_int(space->cpu);
return superchs_ram[2]&0xffff;
return state->ram[2]&0xffff;
}
static DRIVER_INIT( superchs )

View File

@ -113,33 +113,33 @@ DSW2 stored @ $f237
#include "sound/samples.h"
#include "includes/superqix.h"
/* pbillian sample playback */
static INT16 *samplebuf;
static SAMPLES_START( pbillian_sh_start )
{
superqix_state *state = device->machine->driver_data<superqix_state>();
running_machine *machine = device->machine;
UINT8 *src = machine->region("samples")->base();
int i, len = machine->region("samples")->bytes();
/* convert 8-bit unsigned samples to 8-bit signed */
samplebuf = auto_alloc_array(machine, INT16, len);
state->samplebuf = auto_alloc_array(machine, INT16, len);
for (i = 0;i < len;i++)
samplebuf[i] = (INT8)(src[i] ^ 0x80) * 256;
state->samplebuf[i] = (INT8)(src[i] ^ 0x80) * 256;
}
static WRITE8_HANDLER( pbillian_sample_trigger_w )
{
superqix_state *state = space->machine->driver_data<superqix_state>();
device_t *samples = space->machine->device("samples");
int start,end;
start = data << 7;
/* look for end of sample marker */
end = start;
while (end < 0x8000 && samplebuf[end] != (0xff^0x80))
while (end < 0x8000 && state->samplebuf[end] != (0xff^0x80))
end++;
sample_start_raw(samples, 0, samplebuf + start, end - start, 5000, 0); // 5khz ?
sample_start_raw(samples, 0, state->samplebuf + start, end - start, 5000, 0); // 5khz ?
}
@ -174,26 +174,27 @@ The MCU acts this way:
**************************************************************************/
static UINT8 port1, port2, port3, port3_latch, from_mcu, from_z80, portb;
static int from_mcu_pending, from_z80_pending, invert_coin_lockout;
static READ8_DEVICE_HANDLER( in4_mcu_r )
{
superqix_state *state = device->machine->driver_data<superqix_state>();
// logerror("%04x: in4_mcu_r\n",cpu_get_pc(space->cpu));
return input_port_read(device->machine, "P2") | (from_mcu_pending << 6) | (from_z80_pending << 7);
return input_port_read(device->machine, "P2") | (state->from_mcu_pending << 6) | (state->from_z80_pending << 7);
}
static READ8_DEVICE_HANDLER( sqix_from_mcu_r )
{
// logerror("%04x: read mcu answer (%02x)\n",cpu_get_pc(space->cpu),from_mcu);
return from_mcu;
superqix_state *state = device->machine->driver_data<superqix_state>();
// logerror("%04x: read mcu answer (%02x)\n",cpu_get_pc(space->cpu),state->from_mcu);
return state->from_mcu;
}
static TIMER_CALLBACK( mcu_acknowledge_callback )
{
from_z80_pending = 1;
from_z80 = portb;
// logerror("Z80->MCU %02x\n",from_z80);
superqix_state *state = machine->driver_data<superqix_state>();
state->from_z80_pending = 1;
state->from_z80 = state->portb;
// logerror("Z80->MCU %02x\n",state->from_z80);
}
static READ8_HANDLER( mcu_acknowledge_r )
@ -204,12 +205,14 @@ static READ8_HANDLER( mcu_acknowledge_r )
static WRITE8_DEVICE_HANDLER( sqix_z80_mcu_w )
{
superqix_state *state = device->machine->driver_data<superqix_state>();
// logerror("%04x: sqix_z80_mcu_w %02x\n",cpu_get_pc(space->cpu),data);
portb = data;
state->portb = data;
}
static WRITE8_HANDLER( bootleg_mcu_p1_w )
{
superqix_state *state = space->machine->driver_data<superqix_state>();
switch ((data & 0x0e) >> 1)
{
case 0:
@ -222,28 +225,28 @@ static WRITE8_HANDLER( bootleg_mcu_p1_w )
coin_counter_w(space->machine, 1,data & 1);
break;
case 3:
coin_lockout_global_w(space->machine, (data & 1) ^ invert_coin_lockout);
coin_lockout_global_w(space->machine, (data & 1) ^ state->invert_coin_lockout);
break;
case 4:
flip_screen_set(space->machine, data & 1);
break;
case 5:
port1 = data;
if ((port1 & 0x80) == 0)
state->port1 = data;
if ((state->port1 & 0x80) == 0)
{
port3_latch = port3;
state->port3_latch = state->port3;
}
break;
case 6:
from_mcu_pending = 0; // ????
state->from_mcu_pending = 0; // ????
break;
case 7:
if ((data & 1) == 0)
{
// logerror("%04x: MCU -> Z80 %02x\n",cpu_get_pc(space->cpu),port3);
from_mcu = port3_latch;
from_mcu_pending = 1;
from_z80_pending = 0; // ????
// logerror("%04x: MCU -> Z80 %02x\n",cpu_get_pc(space->cpu),state->port3);
state->from_mcu = state->port3_latch;
state->from_mcu_pending = 1;
state->from_z80_pending = 0; // ????
}
break;
}
@ -251,35 +254,39 @@ static WRITE8_HANDLER( bootleg_mcu_p1_w )
static WRITE8_HANDLER( mcu_p3_w )
{
port3 = data;
superqix_state *state = space->machine->driver_data<superqix_state>();
state->port3 = data;
}
static READ8_HANDLER( bootleg_mcu_p3_r )
{
if ((port1 & 0x10) == 0)
superqix_state *state = space->machine->driver_data<superqix_state>();
if ((state->port1 & 0x10) == 0)
{
return input_port_read(space->machine, "DSW1");
}
else if ((port1 & 0x20) == 0)
else if ((state->port1 & 0x20) == 0)
{
return input_port_read(space->machine, "SYSTEM") | (from_mcu_pending << 6) | (from_z80_pending << 7);
return input_port_read(space->machine, "SYSTEM") | (state->from_mcu_pending << 6) | (state->from_z80_pending << 7);
}
else if ((port1 & 0x40) == 0)
else if ((state->port1 & 0x40) == 0)
{
// logerror("%04x: read Z80 command %02x\n",cpu_get_pc(space->cpu),from_z80);
from_z80_pending = 0;
return from_z80;
// logerror("%04x: read Z80 command %02x\n",cpu_get_pc(space->cpu),state->from_z80);
state->from_z80_pending = 0;
return state->from_z80;
}
return 0;
}
static READ8_HANDLER( sqixu_mcu_p0_r )
{
return input_port_read(space->machine, "SYSTEM") | (from_mcu_pending << 6) | (from_z80_pending << 7);
superqix_state *state = space->machine->driver_data<superqix_state>();
return input_port_read(space->machine, "SYSTEM") | (state->from_mcu_pending << 6) | (state->from_z80_pending << 7);
}
static WRITE8_HANDLER( sqixu_mcu_p2_w )
{
superqix_state *state = space->machine->driver_data<superqix_state>();
// bit 0 = unknown (clocked often)
// bit 1 = coin cointer 1
@ -298,25 +305,26 @@ static WRITE8_HANDLER( sqixu_mcu_p2_w )
// bit 6 = unknown
if ((data & 0x40) == 0)
from_mcu_pending = 0; // ????
state->from_mcu_pending = 0; // ????
// bit 7 = clock latch from port 3 to Z80
if ((port2 & 0x80) != 0 && (data & 0x80) == 0)
if ((state->port2 & 0x80) != 0 && (data & 0x80) == 0)
{
// logerror("%04x: MCU -> Z80 %02x\n",cpu_get_pc(space->cpu),port3);
from_mcu = port3;
from_mcu_pending = 1;
from_z80_pending = 0; // ????
// logerror("%04x: MCU -> Z80 %02x\n",cpu_get_pc(space->cpu),state->port3);
state->from_mcu = state->port3;
state->from_mcu_pending = 1;
state->from_z80_pending = 0; // ????
}
port2 = data;
state->port2 = data;
}
static READ8_HANDLER( sqixu_mcu_p3_r )
{
// logerror("%04x: read Z80 command %02x\n",cpu_get_pc(space->cpu),from_z80);
from_z80_pending = 0;
return from_z80;
superqix_state *state = space->machine->driver_data<superqix_state>();
// logerror("%04x: read Z80 command %02x\n",cpu_get_pc(space->cpu),state->from_z80);
state->from_z80_pending = 0;
return state->from_z80;
}
@ -351,40 +359,41 @@ static WRITE8_HANDLER( bootleg_flipscreen_w )
static int read_dial(running_machine *machine, int player)
{
superqix_state *state = machine->driver_data<superqix_state>();
int newpos;
static int oldpos[2];
static int sign[2];
/* get the new position and adjust the result */
newpos = input_port_read(machine, player ? "DIAL2" : "DIAL1");
if (newpos != oldpos[player])
if (newpos != state->oldpos[player])
{
sign[player] = ((newpos - oldpos[player]) & 0x80) >> 7;
oldpos[player] = newpos;
state->sign[player] = ((newpos - state->oldpos[player]) & 0x80) >> 7;
state->oldpos[player] = newpos;
}
if (player == 0)
return ((oldpos[player] & 1) << 2) | (sign[player] << 3);
return ((state->oldpos[player] & 1) << 2) | (state->sign[player] << 3);
else // player == 1
return ((oldpos[player] & 1) << 3) | (sign[player] << 2);
return ((state->oldpos[player] & 1) << 3) | (state->sign[player] << 2);
}
static TIMER_CALLBACK( delayed_z80_mcu_w )
{
superqix_state *state = machine->driver_data<superqix_state>();
logerror("Z80 sends command %02x\n",param);
from_z80 = param;
from_mcu_pending = 0;
state->from_z80 = param;
state->from_mcu_pending = 0;
cputag_set_input_line(machine, "mcu", 0, HOLD_LINE);
cpuexec_boost_interleave(machine, attotime::zero, attotime::from_usec(200));
}
static TIMER_CALLBACK( delayed_mcu_z80_w )
{
superqix_state *state = machine->driver_data<superqix_state>();
logerror("68705 sends answer %02x\n",param);
from_mcu = param;
from_mcu_pending = 1;
state->from_mcu = param;
state->from_mcu_pending = 1;
}
@ -405,61 +414,64 @@ logerror("68705 sends answer %02x\n",param);
* 4-7 W not used
*/
static UINT8 portA_in, portB_out, portC;
static READ8_HANDLER( hotsmash_68705_portA_r )
{
//logerror("%04x: 68705 reads port A = %02x\n",cpu_get_pc(space->cpu),portA_in);
return portA_in;
superqix_state *state = space->machine->driver_data<superqix_state>();
//logerror("%04x: 68705 reads port A = %02x\n",cpu_get_pc(space->cpu),state->portA_in);
return state->portA_in;
}
static WRITE8_HANDLER( hotsmash_68705_portB_w )
{
portB_out = data;
superqix_state *state = space->machine->driver_data<superqix_state>();
state->portB_out = data;
}
static READ8_HANDLER( hotsmash_68705_portC_r )
{
return portC;
superqix_state *state = space->machine->driver_data<superqix_state>();
return state->portC;
}
static WRITE8_HANDLER( hotsmash_68705_portC_w )
{
portC = data;
superqix_state *state = space->machine->driver_data<superqix_state>();
state->portC = data;
if ((data & 0x08) == 0)
{
switch (data & 0x07)
{
case 0x0: // dsw A
portA_in = input_port_read(space->machine, "DSW1");
state->portA_in = input_port_read(space->machine, "DSW1");
break;
case 0x1: // dsw B
portA_in = input_port_read(space->machine, "DSW2");
state->portA_in = input_port_read(space->machine, "DSW2");
break;
case 0x2:
break;
case 0x3: // command from Z80
portA_in = from_z80;
logerror("%04x: z80 reads command %02x\n",cpu_get_pc(space->cpu),from_z80);
state->portA_in = state->from_z80;
logerror("%04x: z80 reads command %02x\n",cpu_get_pc(space->cpu),state->from_z80);
break;
case 0x4:
break;
case 0x5: // answer to Z80
timer_call_after_resynch(space->machine, NULL, portB_out, delayed_mcu_z80_w);
timer_call_after_resynch(space->machine, NULL, state->portB_out, delayed_mcu_z80_w);
break;
case 0x6:
portA_in = read_dial(space->machine, 0);
state->portA_in = read_dial(space->machine, 0);
break;
case 0x7:
portA_in = read_dial(space->machine, 1);
state->portA_in = read_dial(space->machine, 1);
break;
}
}
@ -472,15 +484,17 @@ static WRITE8_HANDLER( hotsmash_z80_mcu_w )
static READ8_HANDLER(hotsmash_from_mcu_r)
{
logerror("%04x: z80 reads answer %02x\n",cpu_get_pc(space->cpu),from_mcu);
from_mcu_pending = 0;
return from_mcu;
superqix_state *state = space->machine->driver_data<superqix_state>();
logerror("%04x: z80 reads answer %02x\n",cpu_get_pc(space->cpu),state->from_mcu);
state->from_mcu_pending = 0;
return state->from_mcu;
}
static READ8_DEVICE_HANDLER(hotsmash_ay_port_a_r)
{
//logerror("%04x: ay_port_a_r and mcu_pending is %d\n",cpu_get_pc(space->cpu),from_mcu_pending);
return input_port_read(device->machine, "SYSTEM") | ((from_mcu_pending^1) << 7);
superqix_state *state = device->machine->driver_data<superqix_state>();
//logerror("%04x: ay_port_a_r and mcu_pending is %d\n",cpu_get_pc(space->cpu),state->from_mcu_pending);
return input_port_read(device->machine, "SYSTEM") | ((state->from_mcu_pending^1) << 7);
}
/**************************************************************************
@ -491,24 +505,25 @@ pbillian MCU simulation
static WRITE8_HANDLER( pbillian_z80_mcu_w )
{
from_z80 = data;
superqix_state *state = space->machine->driver_data<superqix_state>();
state->from_z80 = data;
}
static READ8_HANDLER(pbillian_from_mcu_r)
{
static int curr_player;
superqix_state *state = space->machine->driver_data<superqix_state>();
switch (from_z80)
switch (state->from_z80)
{
case 0x01: return input_port_read(space->machine, curr_player ? "PADDLE2" : "PADDLE1");
case 0x02: return input_port_read(space->machine, curr_player ? "DIAL2" : "DIAL1");
case 0x01: return input_port_read(space->machine, state->curr_player ? "PADDLE2" : "PADDLE1");
case 0x02: return input_port_read(space->machine, state->curr_player ? "DIAL2" : "DIAL1");
case 0x04: return input_port_read(space->machine, "DSW1");
case 0x08: return input_port_read(space->machine, "DSW2");
case 0x80: curr_player = 0; return 0;
case 0x81: curr_player = 1; return 0;
case 0x80: state->curr_player = 0; return 0;
case 0x81: state->curr_player = 1; return 0;
}
logerror("408[%x] r at %x\n",from_z80,cpu_get_pc(space->cpu));
logerror("408[%x] r at %x\n",state->from_z80,cpu_get_pc(space->cpu));
return 0;
}
@ -522,21 +537,22 @@ static READ8_DEVICE_HANDLER(pbillian_ay_port_a_r)
static void machine_init_common(running_machine *machine)
{
state_save_register_global(machine, invert_coin_lockout);
state_save_register_global(machine, from_mcu_pending);
state_save_register_global(machine, from_z80_pending);
state_save_register_global(machine, port1);
state_save_register_global(machine, port2);
state_save_register_global(machine, port3);
state_save_register_global(machine, port3_latch);
state_save_register_global(machine, from_mcu);
state_save_register_global(machine, from_z80);
state_save_register_global(machine, portb);
superqix_state *state = machine->driver_data<superqix_state>();
state_save_register_global(machine, state->invert_coin_lockout);
state_save_register_global(machine, state->from_mcu_pending);
state_save_register_global(machine, state->from_z80_pending);
state_save_register_global(machine, state->port1);
state_save_register_global(machine, state->port2);
state_save_register_global(machine, state->port3);
state_save_register_global(machine, state->port3_latch);
state_save_register_global(machine, state->from_mcu);
state_save_register_global(machine, state->from_z80);
state_save_register_global(machine, state->portb);
// hotsmash ???
state_save_register_global(machine, portA_in);
state_save_register_global(machine, portB_out);
state_save_register_global(machine, portC);
state_save_register_global(machine, state->portA_in);
state_save_register_global(machine, state->portB_out);
state_save_register_global(machine, state->portC);
}
static MACHINE_START( superqix )
@ -561,7 +577,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xe000, 0xe0ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0xe100, 0xe7ff) AM_RAM
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(superqix_videoram_w) AM_BASE(&superqix_videoram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(superqix_videoram_w) AM_BASE_MEMBER(superqix_state, videoram)
AM_RANGE(0xf000, 0xffff) AM_RAM
ADDRESS_MAP_END
@ -600,8 +616,8 @@ static ADDRESS_MAP_START( sqix_port_map, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x0408, 0x0408) AM_READ(mcu_acknowledge_r)
AM_RANGE(0x0410, 0x0410) AM_WRITE(superqix_0410_w) /* ROM bank, NMI enable, tile bank */
AM_RANGE(0x0418, 0x0418) AM_READ(nmi_ack_r)
AM_RANGE(0x0800, 0x77ff) AM_RAM_WRITE(superqix_bitmapram_w) AM_BASE(&superqix_bitmapram)
AM_RANGE(0x8800, 0xf7ff) AM_RAM_WRITE(superqix_bitmapram2_w) AM_BASE(&superqix_bitmapram2)
AM_RANGE(0x0800, 0x77ff) AM_RAM_WRITE(superqix_bitmapram_w) AM_BASE_MEMBER(superqix_state, bitmapram)
AM_RANGE(0x8800, 0xf7ff) AM_RAM_WRITE(superqix_bitmapram2_w) AM_BASE_MEMBER(superqix_state, bitmapram2)
ADDRESS_MAP_END
static ADDRESS_MAP_START( bootleg_port_map, ADDRESS_SPACE_IO, 8 )
@ -613,8 +629,8 @@ static ADDRESS_MAP_START( bootleg_port_map, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x0408, 0x0408) AM_WRITE(bootleg_flipscreen_w)
AM_RANGE(0x0410, 0x0410) AM_WRITE(superqix_0410_w) /* ROM bank, NMI enable, tile bank */
AM_RANGE(0x0418, 0x0418) AM_READ_PORT("SYSTEM")
AM_RANGE(0x0800, 0x77ff) AM_RAM_WRITE(superqix_bitmapram_w) AM_BASE(&superqix_bitmapram)
AM_RANGE(0x8800, 0xf7ff) AM_RAM_WRITE(superqix_bitmapram2_w) AM_BASE(&superqix_bitmapram2)
AM_RANGE(0x0800, 0x77ff) AM_RAM_WRITE(superqix_bitmapram_w) AM_BASE_MEMBER(superqix_state, bitmapram)
AM_RANGE(0x8800, 0xf7ff) AM_RAM_WRITE(superqix_bitmapram2_w) AM_BASE_MEMBER(superqix_state, bitmapram2)
ADDRESS_MAP_END
@ -1011,7 +1027,7 @@ static INTERRUPT_GEN( bootleg_interrupt )
static MACHINE_CONFIG_START( pbillian, driver_device )
static MACHINE_CONFIG_START( pbillian, superqix_state )
MCFG_CPU_ADD("maincpu", Z80,12000000/2) /* 6 MHz */
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_CPU_IO_MAP(pbillian_port_map)
@ -1044,7 +1060,7 @@ static MACHINE_CONFIG_START( pbillian, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( hotsmash, driver_device )
static MACHINE_CONFIG_START( hotsmash, superqix_state )
MCFG_CPU_ADD("maincpu", Z80,12000000/2) /* 6 MHz */
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_CPU_IO_MAP(hotsmash_port_map)
@ -1080,7 +1096,7 @@ static MACHINE_CONFIG_START( hotsmash, driver_device )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( sqix, driver_device )
static MACHINE_CONFIG_START( sqix, superqix_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 12000000/2) /* 6 MHz */
@ -1129,7 +1145,7 @@ static MACHINE_CONFIG_DERIVED( sqixu, sqix )
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( sqixbl, driver_device )
static MACHINE_CONFIG_START( sqixbl, superqix_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 12000000/2) /* 6 MHz */
@ -1333,22 +1349,26 @@ ROM_END
static DRIVER_INIT( pbillian )
{
pbillian_show_power = 1;
superqix_state *state = machine->driver_data<superqix_state>();
state->pbillian_show_power = 1;
}
static DRIVER_INIT( hotsmash )
{
pbillian_show_power = 0;
superqix_state *state = machine->driver_data<superqix_state>();
state->pbillian_show_power = 0;
}
static DRIVER_INIT( sqix )
{
invert_coin_lockout = 1;
superqix_state *state = machine->driver_data<superqix_state>();
state->invert_coin_lockout = 1;
}
static DRIVER_INIT( sqixa )
{
invert_coin_lockout = 0;
superqix_state *state = machine->driver_data<superqix_state>();
state->invert_coin_lockout = 0;
}
static DRIVER_INIT( perestro )

View File

@ -592,10 +592,10 @@ static READ32_HANDLER(dsp_shared_r)
#define DEBUG_BLOCK_MOVES 0
#if DEBUG_DSP
static UINT16 debug_dsp_ram[0x8000];
static void debug_dsp_command(void)
{
taitojc_state *state = machine->driver_data<taitojc_state>();
UINT16 *cmd = &dsp_shared_ram[0x7f0];
switch (cmd[0])
@ -638,7 +638,7 @@ static void debug_dsp_command(void)
UINT16 d = dsp_shared_ram[saddr++];
if (daddr >= 0x8000 && daddr < 0x10000)
{
debug_dsp_ram[daddr-0x8000] = d;
state->debug_dsp_ram[daddr-0x8000] = d;
}
daddr++;
@ -678,7 +678,7 @@ static void debug_dsp_command(void)
while (!end)
{
int i;
UINT16 cmd = debug_dsp_ram[addr++];
UINT16 cmd = state->debug_dsp_ram[addr++];
int length = cmd & 0xff;
if ((cmd >> 11) == 6)
@ -687,7 +687,7 @@ static void debug_dsp_command(void)
printf(" %04X (%02X): ", cmd, cmd >> 11);
for (i=0; i < length; i++)
{
printf("%04X ", debug_dsp_ram[addr+i]);
printf("%04X ", state->debug_dsp_ram[addr+i]);
}
printf("\n");

View File

@ -171,29 +171,30 @@ TODO:
#include "includes/taitosj.h"
static UINT8 sndnmi_disable;
static WRITE8_DEVICE_HANDLER( taitosj_sndnmi_msk_w )
{
sndnmi_disable = data & 0x01;
taitosj_state *state = device->machine->driver_data<taitosj_state>();
state->sndnmi_disable = data & 0x01;
}
static WRITE8_HANDLER( taitosj_soundcommand_w )
{
taitosj_state *state = space->machine->driver_data<taitosj_state>();
soundlatch_w(space,offset,data);
if (!sndnmi_disable) cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
if (!state->sndnmi_disable) cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
}
static UINT8 input_port_4_f0;
static WRITE8_DEVICE_HANDLER( input_port_4_f0_w )
{
input_port_4_f0 = data >> 4;
taitosj_state *state = device->machine->driver_data<taitosj_state>();
state->input_port_4_f0 = data >> 4;
}
static CUSTOM_INPUT( input_port_4_f0_r )
{
return input_port_4_f0;
taitosj_state *state = field->port->machine->driver_data<taitosj_state>();
return state->input_port_4_f0;
}
@ -203,16 +204,16 @@ static ADDRESS_MAP_START( taitosj_main_nomcu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8800, 0x8800) AM_MIRROR(0x07fe) AM_READWRITE(taitosj_fake_data_r, taitosj_fake_data_w)
AM_RANGE(0x8801, 0x8801) AM_MIRROR(0x07fe) AM_READ(taitosj_fake_status_r)
AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE(&taitosj_characterram)
AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE_MEMBER(taitosj_state, characterram)
AM_RANGE(0xc000, 0xc3ff) AM_RAM
AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE(&taitosj_videoram_1)
AM_RANGE(0xc800, 0xcbff) AM_RAM AM_BASE(&taitosj_videoram_2)
AM_RANGE(0xcc00, 0xcfff) AM_RAM AM_BASE(&taitosj_videoram_3)
AM_RANGE(0xd000, 0xd05f) AM_RAM AM_BASE(&taitosj_colscrolly)
AM_RANGE(0xd100, 0xd1ff) AM_RAM AM_BASE(&taitosj_spriteram)
AM_RANGE(0xd200, 0xd27f) AM_MIRROR(0x0080) AM_RAM AM_BASE(&taitosj_paletteram)
AM_RANGE(0xd300, 0xd300) AM_MIRROR(0x00ff) AM_WRITEONLY AM_BASE(&taitosj_video_priority)
AM_RANGE(0xd400, 0xd403) AM_MIRROR(0x00f0) AM_READONLY AM_BASE(&taitosj_collision_reg)
AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE_MEMBER(taitosj_state, videoram_1)
AM_RANGE(0xc800, 0xcbff) AM_RAM AM_BASE_MEMBER(taitosj_state, videoram_2)
AM_RANGE(0xcc00, 0xcfff) AM_RAM AM_BASE_MEMBER(taitosj_state, videoram_3)
AM_RANGE(0xd000, 0xd05f) AM_RAM AM_BASE_MEMBER(taitosj_state, colscrolly)
AM_RANGE(0xd100, 0xd1ff) AM_RAM AM_BASE_MEMBER(taitosj_state, spriteram)
AM_RANGE(0xd200, 0xd27f) AM_MIRROR(0x0080) AM_RAM AM_BASE_MEMBER(taitosj_state, paletteram)
AM_RANGE(0xd300, 0xd300) AM_MIRROR(0x00ff) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, video_priority)
AM_RANGE(0xd400, 0xd403) AM_MIRROR(0x00f0) AM_READONLY AM_BASE_MEMBER(taitosj_state, collision_reg)
AM_RANGE(0xd404, 0xd404) AM_MIRROR(0x00f3) AM_READ(taitosj_gfxrom_r)
AM_RANGE(0xd408, 0xd408) AM_MIRROR(0x00f0) AM_READ_PORT("IN0")
AM_RANGE(0xd409, 0xd409) AM_MIRROR(0x00f0) AM_READ_PORT("IN1")
@ -222,15 +223,15 @@ static ADDRESS_MAP_START( taitosj_main_nomcu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xd40d, 0xd40d) AM_MIRROR(0x00f0) AM_READ_PORT("IN4")
AM_RANGE(0xd40e, 0xd40f) AM_MIRROR(0x00f0) AM_DEVWRITE("ay1", ay8910_address_data_w)
AM_RANGE(0xd40f, 0xd40f) AM_MIRROR(0x00f0) AM_DEVREAD("ay1", ay8910_r) /* DSW2 and DSW3 */
AM_RANGE(0xd500, 0xd505) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE(&taitosj_scroll)
AM_RANGE(0xd506, 0xd507) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE(&taitosj_colorbank)
AM_RANGE(0xd500, 0xd505) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, scroll)
AM_RANGE(0xd506, 0xd507) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, colorbank)
AM_RANGE(0xd508, 0xd508) AM_MIRROR(0x00f0) AM_WRITE(taitosj_collision_reg_clear_w)
AM_RANGE(0xd509, 0xd50a) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE(&taitosj_gfxpointer)
AM_RANGE(0xd509, 0xd50a) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, gfxpointer)
AM_RANGE(0xd50b, 0xd50b) AM_MIRROR(0x00f0) AM_WRITE(taitosj_soundcommand_w)
AM_RANGE(0xd50d, 0xd50d) AM_MIRROR(0x00f0) AM_WRITEONLY /*watchdog_reset_w*/ /* Bio Attack sometimes resets after you die */
AM_RANGE(0xd50e, 0xd50e) AM_MIRROR(0x00f0) AM_WRITE(taitosj_bankswitch_w)
AM_RANGE(0xd50f, 0xd50f) AM_MIRROR(0x00f0) AM_WRITENOP
AM_RANGE(0xd600, 0xd600) AM_MIRROR(0x00ff) AM_WRITEONLY AM_BASE(&taitosj_video_mode)
AM_RANGE(0xd600, 0xd600) AM_MIRROR(0x00ff) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, video_mode)
AM_RANGE(0xd700, 0xdfff) AM_NOP
AM_RANGE(0xe000, 0xffff) AM_ROM
ADDRESS_MAP_END
@ -243,16 +244,16 @@ static ADDRESS_MAP_START( taitosj_main_mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8000, 0x87ff) AM_RAM
AM_RANGE(0x8800, 0x8800) AM_MIRROR(0x07fe) AM_READWRITE(taitosj_mcu_data_r, taitosj_mcu_data_w)
AM_RANGE(0x8801, 0x8801) AM_MIRROR(0x07fe) AM_READ(taitosj_mcu_status_r)
AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE(&taitosj_characterram)
AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE_MEMBER(taitosj_state, characterram)
AM_RANGE(0xc000, 0xc3ff) AM_RAM
AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE(&taitosj_videoram_1)
AM_RANGE(0xc800, 0xcbff) AM_RAM AM_BASE(&taitosj_videoram_2)
AM_RANGE(0xcc00, 0xcfff) AM_RAM AM_BASE(&taitosj_videoram_3)
AM_RANGE(0xd000, 0xd05f) AM_RAM AM_BASE(&taitosj_colscrolly)
AM_RANGE(0xd100, 0xd1ff) AM_RAM AM_BASE(&taitosj_spriteram)
AM_RANGE(0xd200, 0xd27f) AM_MIRROR(0x0080) AM_RAM AM_BASE(&taitosj_paletteram)
AM_RANGE(0xd300, 0xd300) AM_MIRROR(0x00ff) AM_WRITEONLY AM_BASE(&taitosj_video_priority)
AM_RANGE(0xd400, 0xd403) AM_MIRROR(0x00f0) AM_READONLY AM_BASE(&taitosj_collision_reg)
AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE_MEMBER(taitosj_state, videoram_1)
AM_RANGE(0xc800, 0xcbff) AM_RAM AM_BASE_MEMBER(taitosj_state, videoram_2)
AM_RANGE(0xcc00, 0xcfff) AM_RAM AM_BASE_MEMBER(taitosj_state, videoram_3)
AM_RANGE(0xd000, 0xd05f) AM_RAM AM_BASE_MEMBER(taitosj_state, colscrolly)
AM_RANGE(0xd100, 0xd1ff) AM_RAM AM_BASE_MEMBER(taitosj_state, spriteram)
AM_RANGE(0xd200, 0xd27f) AM_MIRROR(0x0080) AM_RAM AM_BASE_MEMBER(taitosj_state, paletteram)
AM_RANGE(0xd300, 0xd300) AM_MIRROR(0x00ff) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, video_priority)
AM_RANGE(0xd400, 0xd403) AM_MIRROR(0x00f0) AM_READONLY AM_BASE_MEMBER(taitosj_state, collision_reg)
AM_RANGE(0xd404, 0xd404) AM_MIRROR(0x00f3) AM_READ(taitosj_gfxrom_r)
AM_RANGE(0xd408, 0xd408) AM_MIRROR(0x00f0) AM_READ_PORT("IN0")
AM_RANGE(0xd409, 0xd409) AM_MIRROR(0x00f0) AM_READ_PORT("IN1")
@ -262,15 +263,15 @@ static ADDRESS_MAP_START( taitosj_main_mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xd40d, 0xd40d) AM_MIRROR(0x00f0) AM_READ_PORT("IN4")
AM_RANGE(0xd40e, 0xd40f) AM_MIRROR(0x00f0) AM_DEVWRITE("ay1", ay8910_address_data_w)
AM_RANGE(0xd40f, 0xd40f) AM_MIRROR(0x00f0) AM_DEVREAD("ay1", ay8910_r) /* DSW2 and DSW3 */
AM_RANGE(0xd500, 0xd505) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE(&taitosj_scroll)
AM_RANGE(0xd506, 0xd507) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE(&taitosj_colorbank)
AM_RANGE(0xd500, 0xd505) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, scroll)
AM_RANGE(0xd506, 0xd507) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, colorbank)
AM_RANGE(0xd508, 0xd508) AM_MIRROR(0x00f0) AM_WRITE(taitosj_collision_reg_clear_w)
AM_RANGE(0xd509, 0xd50a) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE(&taitosj_gfxpointer)
AM_RANGE(0xd509, 0xd50a) AM_MIRROR(0x00f0) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, gfxpointer)
AM_RANGE(0xd50b, 0xd50b) AM_MIRROR(0x00f0) AM_WRITE(taitosj_soundcommand_w)
AM_RANGE(0xd50d, 0xd50d) AM_MIRROR(0x00f0) AM_WRITEONLY /*watchdog_reset_w*/ /* Bio Attack sometimes resets after you die */
AM_RANGE(0xd50e, 0xd50e) AM_MIRROR(0x00f0) AM_WRITE(taitosj_bankswitch_w)
AM_RANGE(0xd50f, 0xd50f) AM_MIRROR(0x00f0) AM_WRITENOP
AM_RANGE(0xd600, 0xd600) AM_MIRROR(0x00ff) AM_WRITEONLY AM_BASE(&taitosj_video_mode)
AM_RANGE(0xd600, 0xd600) AM_MIRROR(0x00ff) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, video_mode)
AM_RANGE(0xd700, 0xdfff) AM_NOP
AM_RANGE(0xe000, 0xffff) AM_ROM
ADDRESS_MAP_END
@ -278,10 +279,10 @@ ADDRESS_MAP_END
/* seems the most logical way to do the gears */
static UINT8 kikstart_gears[2];
static CUSTOM_INPUT( kikstart_gear_r )
{
taitosj_state *state = field->port->machine->driver_data<taitosj_state>();
const char *port_tag;
int player = (int)(FPTR)param;
@ -292,11 +293,11 @@ static CUSTOM_INPUT( kikstart_gear_r )
port_tag = "GEARP2";
/* gear MUST be 1, 2 or 3 */
if (input_port_read(field->port->machine, port_tag) & 0x01) kikstart_gears[player] = 0x02;
if (input_port_read(field->port->machine, port_tag) & 0x02) kikstart_gears[player] = 0x03;
if (input_port_read(field->port->machine, port_tag) & 0x04) kikstart_gears[player] = 0x01;
if (input_port_read(field->port->machine, port_tag) & 0x01) state->kikstart_gears[player] = 0x02;
if (input_port_read(field->port->machine, port_tag) & 0x02) state->kikstart_gears[player] = 0x03;
if (input_port_read(field->port->machine, port_tag) & 0x04) state->kikstart_gears[player] = 0x01;
return kikstart_gears[player];
return state->kikstart_gears[player];
}
@ -307,18 +308,18 @@ static ADDRESS_MAP_START( kikstart_main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8800, 0x8800) AM_READWRITE(taitosj_mcu_data_r, taitosj_mcu_data_w)
AM_RANGE(0x8801, 0x8801) AM_READ(taitosj_mcu_status_r)
AM_RANGE(0x8802, 0x8802) AM_NOP
AM_RANGE(0x8a00, 0x8a5f) AM_WRITEONLY AM_BASE(&taitosj_colscrolly)
AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE(&taitosj_characterram)
AM_RANGE(0x8a00, 0x8a5f) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, colscrolly)
AM_RANGE(0x9000, 0xbfff) AM_WRITE(taitosj_characterram_w) AM_BASE_MEMBER(taitosj_state, characterram)
AM_RANGE(0xc000, 0xc3ff) AM_RAM
AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE(&taitosj_videoram_1)
AM_RANGE(0xc800, 0xcbff) AM_RAM AM_BASE(&taitosj_videoram_2)
AM_RANGE(0xcc00, 0xcfff) AM_RAM AM_BASE(&taitosj_videoram_3)
AM_RANGE(0xd000, 0xd001) AM_WRITEONLY AM_BASE(&taitosj_colorbank)
AM_RANGE(0xd002, 0xd007) AM_WRITEONLY AM_BASE(&taitosj_scroll)
AM_RANGE(0xd100, 0xd1ff) AM_RAM AM_BASE(&taitosj_spriteram)
AM_RANGE(0xd200, 0xd27f) AM_RAM AM_BASE(&taitosj_paletteram)
AM_RANGE(0xd300, 0xd300) AM_WRITEONLY AM_BASE(&taitosj_video_priority)
AM_RANGE(0xd400, 0xd403) AM_READONLY AM_BASE(&taitosj_collision_reg)
AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE_MEMBER(taitosj_state, videoram_1)
AM_RANGE(0xc800, 0xcbff) AM_RAM AM_BASE_MEMBER(taitosj_state, videoram_2)
AM_RANGE(0xcc00, 0xcfff) AM_RAM AM_BASE_MEMBER(taitosj_state, videoram_3)
AM_RANGE(0xd000, 0xd001) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, colorbank)
AM_RANGE(0xd002, 0xd007) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, scroll)
AM_RANGE(0xd100, 0xd1ff) AM_RAM AM_BASE_MEMBER(taitosj_state, spriteram)
AM_RANGE(0xd200, 0xd27f) AM_RAM AM_BASE_MEMBER(taitosj_state, paletteram)
AM_RANGE(0xd300, 0xd300) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, video_priority)
AM_RANGE(0xd400, 0xd403) AM_READONLY AM_BASE_MEMBER(taitosj_state, collision_reg)
AM_RANGE(0xd404, 0xd404) AM_READ(taitosj_gfxrom_r)
AM_RANGE(0xd408, 0xd408) AM_MIRROR(0x00f0) AM_READ_PORT("IN0")
AM_RANGE(0xd409, 0xd409) AM_MIRROR(0x00f0) AM_READ_PORT("IN1")
@ -329,12 +330,12 @@ static ADDRESS_MAP_START( kikstart_main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xd40e, 0xd40f) AM_DEVWRITE("ay1", ay8910_address_data_w)
AM_RANGE(0xd40f, 0xd40f) AM_DEVREAD("ay1", ay8910_r) /* DSW2 and DSW3 */
AM_RANGE(0xd508, 0xd508) AM_WRITE(taitosj_collision_reg_clear_w)
AM_RANGE(0xd509, 0xd50a) AM_WRITEONLY AM_BASE(&taitosj_gfxpointer)
AM_RANGE(0xd509, 0xd50a) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, gfxpointer)
AM_RANGE(0xd50b, 0xd50b) AM_WRITE(taitosj_soundcommand_w)
AM_RANGE(0xd50d, 0xd50d) AM_WRITE(watchdog_reset_w)
AM_RANGE(0xd50e, 0xd50e) AM_WRITE(taitosj_bankswitch_w)
AM_RANGE(0xd600, 0xd600) AM_WRITEONLY AM_BASE(&taitosj_video_mode)
AM_RANGE(0xd800, 0xdfff) AM_RAM AM_BASE(&kikstart_scrollram)// scroll ram + ???
AM_RANGE(0xd600, 0xd600) AM_WRITEONLY AM_BASE_MEMBER(taitosj_state, video_mode)
AM_RANGE(0xd800, 0xdfff) AM_RAM AM_BASE_MEMBER(taitosj_state, kikstart_scrollram)// scroll ram + ???
AM_RANGE(0xe000, 0xefff) AM_ROM
ADDRESS_MAP_END
@ -1732,19 +1733,19 @@ static const UINT8 voltable[256] =
0x65,0x65,0x65,0x65,0x64,0x64,0x64,0x64,0x64,0x63,0x63,0x63,0x63,0x62,0x62,0x62,
};
static INT8 dac_out;
static UINT8 dac_vol;
static WRITE8_DEVICE_HANDLER( dac_out_w )
{
dac_out = data - 0x80;
dac_signed_data_16_w(device,dac_out * dac_vol + 0x8000);
taitosj_state *state = device->machine->driver_data<taitosj_state>();
state->dac_out = data - 0x80;
dac_signed_data_16_w(device,state->dac_out * state->dac_vol + 0x8000);
}
static WRITE8_DEVICE_HANDLER( dac_vol_w )
{
dac_vol = voltable[data];
dac_signed_data_16_w(device,dac_out * dac_vol + 0x8000);
taitosj_state *state = device->machine->driver_data<taitosj_state>();
state->dac_vol = voltable[data];
dac_signed_data_16_w(device,state->dac_out * state->dac_vol + 0x8000);
}
@ -1790,7 +1791,7 @@ static const ay8910_interface ay8910_interface_4 =
static MACHINE_CONFIG_START( nomcu, driver_device )
static MACHINE_CONFIG_START( nomcu, taitosj_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu",Z80,8000000/2) /* 4 MHz */
@ -2708,22 +2709,24 @@ ROM_END
static void reset_common(running_machine &machine)
{
sndnmi_disable = 1;
input_port_4_f0 = 0;
taitosj_state *state = machine.driver_data<taitosj_state>();
state->sndnmi_disable = 1;
state->input_port_4_f0 = 0;
/* start in 1st gear */
kikstart_gears[0] = 0x02;
kikstart_gears[1] = 0x02;
dac_out = 0;
dac_vol = 0;
state->kikstart_gears[0] = 0x02;
state->kikstart_gears[1] = 0x02;
state->dac_out = 0;
state->dac_vol = 0;
}
static void init_common(running_machine *machine)
{
state_save_register_global(machine, sndnmi_disable);
state_save_register_global(machine, input_port_4_f0);
state_save_register_global_array(machine, kikstart_gears);
state_save_register_global(machine, dac_out);
state_save_register_global(machine, dac_vol);
taitosj_state *state = machine->driver_data<taitosj_state>();
state_save_register_global(machine, state->sndnmi_disable);
state_save_register_global(machine, state->input_port_4_f0);
state_save_register_global_array(machine, state->kikstart_gears);
state_save_register_global(machine, state->dac_out);
state_save_register_global(machine, state->dac_vol);
machine->add_notifier(MACHINE_NOTIFY_RESET, reset_common);
}

View File

@ -17,10 +17,25 @@
#include "machine/pckeybrd.h"
#include "machine/idectrl.h"
class taitowlf_state : public driver_device
{
public:
taitowlf_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT32 *cga_ram;
UINT32 *bios_ram;
UINT8 mxtc_config_reg[256];
UINT8 piix4_config_reg[4][256];
int dma_channel;
UINT8 dma_offset[2][4];
UINT8 at_pages[0x10];
};
static void ide_interrupt(device_t *device, int state);
static UINT32 *cga_ram;
static UINT32 *bios_ram;
static struct {
device_t *pit8254;
@ -71,9 +86,10 @@ static void draw_char(bitmap_t *bitmap, const rectangle *cliprect, const gfx_ele
static VIDEO_UPDATE(taitowlf)
{
taitowlf_state *state = screen->machine->driver_data<taitowlf_state>();
int i, j;
const gfx_element *gfx = screen->machine->gfx[0];
UINT32 *cga = cga_ram;
UINT32 *cga = state->cga_ram;
int index = 0;
bitmap_fill(bitmap, cliprect, 0);
@ -118,17 +134,18 @@ static WRITE32_DEVICE_HANDLER(at32_dma8237_2_w)
// Intel 82439TX System Controller (MXTC)
static UINT8 mxtc_config_reg[256];
static UINT8 mxtc_config_r(device_t *busdevice, device_t *device, int function, int reg)
{
taitowlf_state *state = busdevice->machine->driver_data<taitowlf_state>();
// mame_printf_debug("MXTC: read %d, %02X\n", function, reg);
return mxtc_config_reg[reg];
return state->mxtc_config_reg[reg];
}
static void mxtc_config_w(device_t *busdevice, device_t *device, int function, int reg, UINT8 data)
{
taitowlf_state *state = busdevice->machine->driver_data<taitowlf_state>();
// mame_printf_debug("%s:MXTC: write %d, %02X, %02X\n", cpuexec_describe_context(machine), function, reg, data);
switch(reg)
@ -137,7 +154,7 @@ static void mxtc_config_w(device_t *busdevice, device_t *device, int function, i
{
if (data & 0x10) // enable RAM access to region 0xf0000 - 0xfffff
{
memory_set_bankptr(busdevice->machine, "bank1", bios_ram);
memory_set_bankptr(busdevice->machine, "bank1", state->bios_ram);
}
else // disable RAM access (reads go to BIOS ROM)
{
@ -147,17 +164,18 @@ static void mxtc_config_w(device_t *busdevice, device_t *device, int function, i
}
}
mxtc_config_reg[reg] = data;
state->mxtc_config_reg[reg] = data;
}
static void intel82439tx_init(void)
static void intel82439tx_init(running_machine *machine)
{
mxtc_config_reg[0x60] = 0x02;
mxtc_config_reg[0x61] = 0x02;
mxtc_config_reg[0x62] = 0x02;
mxtc_config_reg[0x63] = 0x02;
mxtc_config_reg[0x64] = 0x02;
mxtc_config_reg[0x65] = 0x02;
taitowlf_state *state = machine->driver_data<taitowlf_state>();
state->mxtc_config_reg[0x60] = 0x02;
state->mxtc_config_reg[0x61] = 0x02;
state->mxtc_config_reg[0x62] = 0x02;
state->mxtc_config_reg[0x63] = 0x02;
state->mxtc_config_reg[0x64] = 0x02;
state->mxtc_config_reg[0x65] = 0x02;
}
static UINT32 intel82439tx_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask)
@ -203,18 +221,19 @@ static void intel82439tx_pci_w(device_t *busdevice, device_t *device, int functi
}
// Intel 82371AB PCI-to-ISA / IDE bridge (PIIX4)
static UINT8 piix4_config_reg[4][256];
static UINT8 piix4_config_r(device_t *busdevice, device_t *device, int function, int reg)
{
taitowlf_state *state = device->machine->driver_data<taitowlf_state>();
// mame_printf_debug("PIIX4: read %d, %02X\n", function, reg);
return piix4_config_reg[function][reg];
return state->piix4_config_reg[function][reg];
}
static void piix4_config_w(device_t *busdevice, device_t *device, int function, int reg, UINT8 data)
{
taitowlf_state *state = busdevice->machine->driver_data<taitowlf_state>();
// mame_printf_debug("%s:PIIX4: write %d, %02X, %02X\n", cpuexec_describe_context(machine), function, reg, data);
piix4_config_reg[function][reg] = data;
state->piix4_config_reg[function][reg] = data;
}
static UINT32 intel82371ab_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask)
@ -303,9 +322,10 @@ static WRITE32_DEVICE_HANDLER( fdc_w )
static WRITE32_HANDLER(bios_ram_w)
{
if (mxtc_config_reg[0x59] & 0x20) // write to RAM if this region is write-enabled
taitowlf_state *state = space->machine->driver_data<taitowlf_state>();
if (state->mxtc_config_reg[0x59] & 0x20) // write to RAM if this region is write-enabled
{
COMBINE_DATA(bios_ram + offset);
COMBINE_DATA(state->bios_ram + offset);
}
}
@ -316,28 +336,26 @@ static WRITE32_HANDLER(bios_ram_w)
*
*************************************************************************/
static int dma_channel;
static UINT8 dma_offset[2][4];
static UINT8 at_pages[0x10];
static READ8_HANDLER(at_page8_r)
{
UINT8 data = at_pages[offset % 0x10];
taitowlf_state *state = space->machine->driver_data<taitowlf_state>();
UINT8 data = state->at_pages[offset % 0x10];
switch(offset % 8)
{
case 1:
data = dma_offset[(offset / 8) & 1][2];
data = state->dma_offset[(offset / 8) & 1][2];
break;
case 2:
data = dma_offset[(offset / 8) & 1][3];
data = state->dma_offset[(offset / 8) & 1][3];
break;
case 3:
data = dma_offset[(offset / 8) & 1][1];
data = state->dma_offset[(offset / 8) & 1][1];
break;
case 7:
data = dma_offset[(offset / 8) & 1][0];
data = state->dma_offset[(offset / 8) & 1][0];
break;
}
return data;
@ -346,21 +364,22 @@ static READ8_HANDLER(at_page8_r)
static WRITE8_HANDLER(at_page8_w)
{
at_pages[offset % 0x10] = data;
taitowlf_state *state = space->machine->driver_data<taitowlf_state>();
state->at_pages[offset % 0x10] = data;
switch(offset % 8)
{
case 1:
dma_offset[(offset / 8) & 1][2] = data;
state->dma_offset[(offset / 8) & 1][2] = data;
break;
case 2:
dma_offset[(offset / 8) & 1][3] = data;
state->dma_offset[(offset / 8) & 1][3] = data;
break;
case 3:
dma_offset[(offset / 8) & 1][1] = data;
state->dma_offset[(offset / 8) & 1][1] = data;
break;
case 7:
dma_offset[(offset / 8) & 1][0] = data;
state->dma_offset[(offset / 8) & 1][0] = data;
break;
}
}
@ -377,7 +396,8 @@ static WRITE_LINE_DEVICE_HANDLER( pc_dma_hrq_changed )
static READ8_HANDLER( pc_dma_read_byte )
{
offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
taitowlf_state *state = space->machine->driver_data<taitowlf_state>();
offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
& 0xFF0000;
return space->read_byte(page_offset + offset);
@ -386,17 +406,37 @@ static READ8_HANDLER( pc_dma_read_byte )
static WRITE8_HANDLER( pc_dma_write_byte )
{
offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
taitowlf_state *state = space->machine->driver_data<taitowlf_state>();
offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
& 0xFF0000;
space->write_byte(page_offset + offset, data);
}
static WRITE_LINE_DEVICE_HANDLER( pc_dack0_w ) { if (state) dma_channel = 0; }
static WRITE_LINE_DEVICE_HANDLER( pc_dack1_w ) { if (state) dma_channel = 1; }
static WRITE_LINE_DEVICE_HANDLER( pc_dack2_w ) { if (state) dma_channel = 2; }
static WRITE_LINE_DEVICE_HANDLER( pc_dack3_w ) { if (state) dma_channel = 3; }
static WRITE_LINE_DEVICE_HANDLER( pc_dack0_w )
{
taitowlf_state *drvstate = device->machine->driver_data<taitowlf_state>();
if (state) drvstate->dma_channel = 0;
}
static WRITE_LINE_DEVICE_HANDLER( pc_dack1_w )
{
taitowlf_state *drvstate = device->machine->driver_data<taitowlf_state>();
if (state) drvstate->dma_channel = 1;
}
static WRITE_LINE_DEVICE_HANDLER( pc_dack2_w )
{
taitowlf_state *drvstate = device->machine->driver_data<taitowlf_state>();
if (state) drvstate->dma_channel = 2;
}
static WRITE_LINE_DEVICE_HANDLER( pc_dack3_w )
{
taitowlf_state *drvstate = device->machine->driver_data<taitowlf_state>();
if (state) drvstate->dma_channel = 3;
}
static I8237_INTERFACE( dma8237_1_config )
{
@ -437,7 +477,7 @@ static WRITE32_HANDLER(at_page32_w)
static ADDRESS_MAP_START( taitowlf_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x00000000, 0x0009ffff) AM_RAM
AM_RANGE(0x000a0000, 0x000affff) AM_RAM
AM_RANGE(0x000b0000, 0x000b7fff) AM_RAM AM_BASE(&cga_ram)
AM_RANGE(0x000b0000, 0x000b7fff) AM_RAM AM_BASE_MEMBER(taitowlf_state, cga_ram)
AM_RANGE(0x000e0000, 0x000effff) AM_RAM
AM_RANGE(0x000f0000, 0x000fffff) AM_ROMBANK("bank1")
AM_RANGE(0x000f0000, 0x000fffff) AM_WRITE(bios_ram_w)
@ -597,7 +637,7 @@ static const struct pit8253_config taitowlf_pit8254_config =
}
};
static MACHINE_CONFIG_START( taitowlf, driver_device )
static MACHINE_CONFIG_START( taitowlf, taitowlf_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", PENTIUM, 200000000)
@ -673,11 +713,12 @@ static void taitowlf_set_keyb_int(running_machine *machine, int state)
static DRIVER_INIT( taitowlf )
{
bios_ram = auto_alloc_array(machine, UINT32, 0x10000/4);
taitowlf_state *state = machine->driver_data<taitowlf_state>();
state->bios_ram = auto_alloc_array(machine, UINT32, 0x10000/4);
init_pc_common(machine, PCCOMMON_KEYBOARD_AT, taitowlf_set_keyb_int);
intel82439tx_init();
intel82439tx_init(machine);
kbdc8042_init(machine, &at8042);
}

View File

@ -48,17 +48,17 @@ TODO:
#include "sound/dac.h"
#include "includes/tsamurai.h"
static int nmi_enabled;
static int sound_command1, sound_command2, sound_command3;
static WRITE8_HANDLER( nmi_enable_w )
{
nmi_enabled = data;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
state->nmi_enabled = data;
}
static INTERRUPT_GEN( samurai_interrupt )
{
if (nmi_enabled) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
tsamurai_state *state = device->machine->driver_data<tsamurai_state>();
if (state->nmi_enabled) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}
static READ8_HANDLER( unknown_d803_r )
@ -88,19 +88,22 @@ static READ8_HANDLER( unknown_d938_r )
static WRITE8_HANDLER( sound_command1_w )
{
sound_command1 = data;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
state->sound_command1 = data;
cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE );
}
static WRITE8_HANDLER( sound_command2_w )
{
sound_command2 = data;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
state->sound_command2 = data;
cputag_set_input_line(space->machine, "audio2", 0, HOLD_LINE );
}
static WRITE8_HANDLER( sound_command3_w )
{
sound_command3 = data;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
state->sound_command3 = data;
cputag_set_input_line(space->machine, "audio3", 0, HOLD_LINE );
}
@ -125,10 +128,10 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xd900, 0xd900) AM_READ(unknown_d900_r)
AM_RANGE(0xd938, 0xd938) AM_READ(unknown_d938_r)
AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE(&tsamurai_videoram)
AM_RANGE(0xe400, 0xe43f) AM_RAM_WRITE(tsamurai_fg_colorram_w) AM_BASE(&tsamurai_colorram)
AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE_MEMBER(tsamurai_state, videoram)
AM_RANGE(0xe400, 0xe43f) AM_RAM_WRITE(tsamurai_fg_colorram_w) AM_BASE_MEMBER(tsamurai_state, colorram)
AM_RANGE(0xe440, 0xe7ff) AM_RAM
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(tsamurai_bg_videoram_w) AM_BASE(&tsamurai_bg_videoram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(tsamurai_bg_videoram_w) AM_BASE_MEMBER(tsamurai_state, bg_videoram)
AM_RANGE(0xf000, 0xf3ff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xf400, 0xf400) AM_WRITENOP
@ -158,10 +161,10 @@ static ADDRESS_MAP_START( m660_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xd900, 0xd900) AM_READ(unknown_d900_r)
AM_RANGE(0xd938, 0xd938) AM_READ(unknown_d938_r)
AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE(&tsamurai_videoram)
AM_RANGE(0xe400, 0xe43f) AM_RAM_WRITE(tsamurai_fg_colorram_w) AM_BASE(&tsamurai_colorram)
AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE_MEMBER(tsamurai_state, videoram)
AM_RANGE(0xe400, 0xe43f) AM_RAM_WRITE(tsamurai_fg_colorram_w) AM_BASE_MEMBER(tsamurai_state, colorram)
AM_RANGE(0xe440, 0xe7ff) AM_RAM
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(tsamurai_bg_videoram_w) AM_BASE(&tsamurai_bg_videoram)
AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(tsamurai_bg_videoram_w) AM_BASE_MEMBER(tsamurai_state, bg_videoram)
AM_RANGE(0xf000, 0xf3ff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xf400, 0xf400) AM_WRITENOP/* This is always written with F401, F402 & F403 data */
@ -202,17 +205,20 @@ ADDRESS_MAP_END
static READ8_HANDLER( sound_command1_r )
{
return sound_command1;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
return state->sound_command1;
}
static READ8_HANDLER( sound_command2_r )
{
return sound_command2;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
return state->sound_command2;
}
static READ8_HANDLER( sound_command3_r )
{
return sound_command3;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
return state->sound_command3;
}
/*******************************************************************************/
@ -271,15 +277,16 @@ ADDRESS_MAP_END
/*******************************************************************************/
static int vsgongf_sound_nmi_enabled;
static WRITE8_HANDLER( vsgongf_sound_nmi_enable_w )
{
vsgongf_sound_nmi_enabled = data;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
state->vsgongf_sound_nmi_enabled = data;
}
static INTERRUPT_GEN( vsgongf_sound_interrupt )
{
if (vsgongf_sound_nmi_enabled) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
tsamurai_state *state = device->machine->driver_data<tsamurai_state>();
if (state->vsgongf_sound_nmi_enabled) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}
/* what are these, protection of some kind? */
@ -318,7 +325,7 @@ static ADDRESS_MAP_START( vsgongf_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xa006, 0xa006) AM_READ(vsgongf_a006_r) /* protection */
AM_RANGE(0xa100, 0xa100) AM_READ(vsgongf_a100_r) /* protection */
AM_RANGE(0xc000, 0xc7ff) AM_RAM /* work ram */
AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE(&tsamurai_videoram)
AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE_MEMBER(tsamurai_state, videoram)
AM_RANGE(0xe400, 0xe43f) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xe440, 0xe47b) AM_RAM
AM_RANGE(0xe800, 0xe800) AM_WRITE(vsgongf_sound_command_w)
@ -641,7 +648,7 @@ GFXDECODE_END
/*******************************************************************************/
static MACHINE_CONFIG_START( tsamurai, driver_device )
static MACHINE_CONFIG_START( tsamurai, tsamurai_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 4000000)
@ -684,7 +691,7 @@ static MACHINE_CONFIG_START( tsamurai, driver_device )
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( m660, driver_device )
static MACHINE_CONFIG_START( m660, tsamurai_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 4000000)
@ -732,7 +739,7 @@ static MACHINE_CONFIG_START( m660, driver_device )
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( vsgongf, driver_device )
static MACHINE_CONFIG_START( vsgongf, tsamurai_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 4000000)

View File

@ -197,12 +197,7 @@ Board contains only 29 ROMs and not much else.
#include "cbombers.lh"
static UINT16 coin_word;
static UINT16 port_sel = 0;
static int frame_counter=0;
static UINT32 *undrfire_ram; /* will be read in video for gun target calcs */
static UINT32 *shared_ram;
/***********************************************************
COLOR RAM
@ -259,11 +254,13 @@ static const eeprom_interface undrfire_eeprom_interface =
static CUSTOM_INPUT(frame_counter_r)
{
return frame_counter;
undrfire_state *state = field->port->machine->driver_data<undrfire_state>();
return state->frame_counter;
}
static READ32_HANDLER( undrfire_input_r )
{
undrfire_state *state = space->machine->driver_data<undrfire_state>();
switch (offset)
{
case 0x00:
@ -273,7 +270,7 @@ static READ32_HANDLER( undrfire_input_r )
case 0x01:
{
return input_port_read(space->machine, "SYSTEM") | (coin_word << 16);
return input_port_read(space->machine, "SYSTEM") | (state->coin_word << 16);
}
}
@ -282,6 +279,7 @@ static READ32_HANDLER( undrfire_input_r )
static WRITE32_HANDLER( undrfire_input_w )
{
undrfire_state *state = space->machine->driver_data<undrfire_state>();
switch (offset)
{
case 0x00:
@ -311,7 +309,7 @@ static WRITE32_HANDLER( undrfire_input_w )
coin_lockout_w(space->machine, 1,~data & 0x02000000);
coin_counter_w(space->machine, 0, data & 0x04000000);
coin_counter_w(space->machine, 1, data & 0x08000000);
coin_word = (data >> 16) &0xffff;
state->coin_word = (data >> 16) &0xffff;
}
}
}
@ -320,22 +318,24 @@ static WRITE32_HANDLER( undrfire_input_w )
static READ16_HANDLER( shared_ram_r )
{
if ((offset&1)==0) return (shared_ram[offset/2]&0xffff0000)>>16;
return (shared_ram[offset/2]&0x0000ffff);
undrfire_state *state = space->machine->driver_data<undrfire_state>();
if ((offset&1)==0) return (state->shared_ram[offset/2]&0xffff0000)>>16;
return (state->shared_ram[offset/2]&0x0000ffff);
}
static WRITE16_HANDLER( shared_ram_w )
{
undrfire_state *state = space->machine->driver_data<undrfire_state>();
if ((offset&1)==0) {
if (ACCESSING_BITS_8_15)
shared_ram[offset/2]=(shared_ram[offset/2]&0x00ffffff)|((data&0xff00)<<16);
state->shared_ram[offset/2]=(state->shared_ram[offset/2]&0x00ffffff)|((data&0xff00)<<16);
if (ACCESSING_BITS_0_7)
shared_ram[offset/2]=(shared_ram[offset/2]&0xff00ffff)|((data&0x00ff)<<16);
state->shared_ram[offset/2]=(state->shared_ram[offset/2]&0xff00ffff)|((data&0x00ff)<<16);
} else {
if (ACCESSING_BITS_8_15)
shared_ram[offset/2]=(shared_ram[offset/2]&0xffff00ff)|((data&0xff00)<< 0);
state->shared_ram[offset/2]=(state->shared_ram[offset/2]&0xffff00ff)|((data&0xff00)<< 0);
if (ACCESSING_BITS_0_7)
shared_ram[offset/2]=(shared_ram[offset/2]&0xffffff00)|((data&0x00ff)<< 0);
state->shared_ram[offset/2]=(state->shared_ram[offset/2]&0xffffff00)|((data&0x00ff)<< 0);
}
}
@ -407,15 +407,16 @@ logerror("CPU #0 PC %06x: warning - read unmapped lightgun offset %06x\n",cpu_ge
static WRITE32_HANDLER( rotate_control_w ) /* only a guess that it's rotation */
{
undrfire_state *state = space->machine->driver_data<undrfire_state>();
if (ACCESSING_BITS_0_15)
{
undrfire_rotate_ctrl[port_sel] = data;
state->rotate_ctrl[state->port_sel] = data;
return;
}
if (ACCESSING_BITS_16_31)
{
port_sel = (data &0x70000) >> 16;
state->port_sel = (data &0x70000) >> 16;
}
}
@ -464,7 +465,7 @@ static WRITE32_HANDLER( cbombers_adc_w )
static ADDRESS_MAP_START( undrfire_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x000000, 0x1fffff) AM_ROM
AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE(&undrfire_ram)
AM_RANGE(0x200000, 0x21ffff) AM_RAM AM_BASE_MEMBER(undrfire_state, ram)
AM_RANGE(0x300000, 0x303fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
// AM_RANGE(0x304000, 0x304003) AM_RAM // debugging - doesn't change ???
// AM_RANGE(0x304400, 0x304403) AM_RAM // debugging - doesn't change ???
@ -499,7 +500,7 @@ static ADDRESS_MAP_START( cbombers_cpua_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0xb00000, 0xb0000f) AM_RAM /* ? */
AM_RANGE(0xc00000, 0xc00007) AM_RAM /* LAN controller? */
AM_RANGE(0xd00000, 0xd00003) AM_WRITE(rotate_control_w) /* perhaps port based rotate control? */
AM_RANGE(0xe00000, 0xe0ffff) AM_RAM AM_BASE(&shared_ram)
AM_RANGE(0xe00000, 0xe0ffff) AM_RAM AM_BASE_MEMBER(undrfire_state, shared_ram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( cbombers_cpub_map, ADDRESS_SPACE_PROGRAM, 16 )
@ -690,7 +691,8 @@ GFXDECODE_END
static INTERRUPT_GEN( undrfire_interrupt )
{
frame_counter ^= 1;
undrfire_state *state = device->machine->driver_data<undrfire_state>();
state->frame_counter ^= 1;
cpu_set_input_line(device, 4, HOLD_LINE);
}
@ -714,7 +716,7 @@ static const tc0480scp_interface undrfire_tc0480scp_intf =
0 /* col_base */
};
static MACHINE_CONFIG_START( undrfire, driver_device )
static MACHINE_CONFIG_START( undrfire, undrfire_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68EC020, 16000000) /* 16 MHz */
@ -745,7 +747,7 @@ static MACHINE_CONFIG_START( undrfire, driver_device )
MACHINE_CONFIG_END
static MACHINE_CONFIG_START( cbombers, driver_device )
static MACHINE_CONFIG_START( cbombers, undrfire_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68EC020, 16000000) /* 16 MHz */

View File

@ -26,6 +26,16 @@ public:
/* devices */
device_t *audiocpu;
#if 0
/* 68705 */
UINT8 port_a_in;
UINT8 port_a_out;
UINT8 ddr_a;
UINT8 port_b_in;
UINT8 port_b_out;
UINT8 ddr_b;
#endif
};

View File

@ -8,6 +8,22 @@ Crazy Ballooon
#define CRBALOON_MASTER_XTAL (XTAL_9_987MHz)
class crbaloon_state : public driver_device
{
public:
crbaloon_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *pc3092_data;
UINT8 *videoram;
UINT8 *colorram;
UINT8 *spriteram;
UINT16 collision_address;
UINT8 collision_address_clear;
tilemap_t *bg_tilemap;
};
/*----------- defined in audio/crbaloon.c -----------*/
WRITE8_DEVICE_HANDLER( crbaloon_audio_set_music_freq );
@ -22,10 +38,6 @@ MACHINE_CONFIG_EXTERN( crbaloon_audio );
/*----------- defined in video/crbaloon.c -----------*/
extern UINT8 *crbaloon_videoram;
extern UINT8 *crbaloon_colorram;
extern UINT8 *crbaloon_spriteram;
PALETTE_INIT( crbaloon );
VIDEO_START( crbaloon );
VIDEO_UPDATE( crbaloon );
@ -33,6 +45,5 @@ VIDEO_UPDATE( crbaloon );
WRITE8_HANDLER( crbaloon_videoram_w );
WRITE8_HANDLER( crbaloon_colorram_w );
UINT16 crbaloon_get_collision_address(void);
void crbaloon_set_clear_collision_address(int _crbaloon_collision_address_clear);
UINT16 crbaloon_get_collision_address(running_machine *machine);
void crbaloon_set_clear_collision_address(running_machine *machine, int _crbaloon_collision_address_clear);

View File

@ -5,19 +5,19 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
UINT8 *workram;
int hw;
UINT8 *scroll;
UINT8 *spritebank;
tilemap_t *bgtilemap;
tilemap_t *fgtilemap;
tilemap_t *txtilemap;
};
/*----------- defined in drivers/darkmist.c -----------*/
extern int darkmist_hw;
/*----------- defined in video/darkmist.c -----------*/
VIDEO_START( darkmist );
VIDEO_UPDATE( darkmist );
PALETTE_INIT( darkmist );
extern UINT8 *darkmist_scroll;
extern UINT8 *darkmist_spritebank;

View File

@ -1,11 +1,23 @@
/*----------- defined in video/exzisus.c -----------*/
class exzisus_state : public driver_device
{
public:
exzisus_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *exzisus_videoram0;
extern UINT8 *exzisus_videoram1;
extern UINT8 *exzisus_objectram0;
extern UINT8 *exzisus_objectram1;
extern size_t exzisus_objectram_size0;
extern size_t exzisus_objectram_size1;
UINT8 *sharedram_ab;
UINT8 *sharedram_ac;
int cpua_bank;
int cpub_bank;
UINT8 *videoram0;
UINT8 *videoram1;
UINT8 *objectram0;
UINT8 *objectram1;
size_t objectram_size0;
size_t objectram_size1;
};
/*----------- defined in video/exzisus.c -----------*/
READ8_HANDLER( exzisus_videoram_0_r );
READ8_HANDLER( exzisus_videoram_1_r );

View File

@ -41,6 +41,17 @@ public:
device_t *maincpu;
device_t *audiocpu;
device_t *mcu;
/* mcu */
UINT8 mcu_cmd;
UINT8 mcu_counter;
UINT8 mcu_b4_cmd;
UINT8 mcu_param;
UINT8 mcu_b2_res;
UINT8 mcu_b1_res;
UINT8 mcu_bb_res;
UINT8 mcu_b5_res;
UINT8 mcu_b6_res;
};

View File

@ -1,6 +1,42 @@
/*----------- defined in video/galastrm.c -----------*/
#include "video/poly.h"
extern INT16 galastrm_tc0610_ctrl_reg[2][8];
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int primask;
};
class galastrm_state : public driver_device
{
public:
galastrm_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT16 coin_word;
UINT16 frame_counter;
UINT32 *ram;
int tc0110pcr_addr;
int tc0610_0_addr;
int tc0610_1_addr;
UINT32 mem[2];
INT16 tc0610_ctrl_reg[2][8];
struct tempsprite *spritelist;
struct tempsprite *sprite_ptr_pre;
bitmap_t *tmpbitmaps;
bitmap_t *polybitmap;
poly_manager *poly;
int rsxb;
int rsyb;
int rsxoffs;
int rsyoffs;
};
/*----------- defined in video/galastrm.c -----------*/
VIDEO_START( galastrm );
VIDEO_UPDATE( galastrm );

View File

@ -6,12 +6,28 @@ public:
m_nvram(*this, "nvram") { }
required_shared_ptr<UINT8> m_nvram;
int data1;
int data2;
int flag1;
int flag2;
UINT8 *videoram;
UINT8 *colorram;
UINT8 *textram;
int video_attributes;
int fg_scrollx;
int fg_scrolly;
int bg_scrollx;
int bg_scrolly;
int sprite_bank;
int sprite_buffer;
tilemap_t *fg_tilemap;
tilemap_t *bg_tilemap;
int fg_tile_bank;
int bg_tile_bank;
};
/*----------- defined in video/gladiatr.c -----------*/
extern UINT8 *gladiatr_videoram, *gladiatr_colorram,*gladiatr_textram;
WRITE8_HANDLER( gladiatr_videoram_w );
WRITE8_HANDLER( gladiatr_colorram_w );
WRITE8_HANDLER( gladiatr_textram_w );

View File

@ -1,6 +1,30 @@
/*----------- defined in video/groundfx.c -----------*/
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int pri;
};
extern UINT16 groundfx_rotate_ctrl[8];
class groundfx_state : public driver_device
{
public:
groundfx_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT16 coin_word;
UINT16 frame_counter;
UINT16 port_sel;
UINT32 *ram;
struct tempsprite *spritelist;
UINT16 rotate_ctrl[8];
rectangle hack_cliprect;
};
/*----------- defined in video/groundfx.c -----------*/
VIDEO_START( groundfx );
VIDEO_UPDATE( groundfx );

View File

@ -5,17 +5,25 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
int coins;
int fake8910_0;
int fake8910_1;
int nmi_enable;
UINT8 *cpu2_ram;
int protect_hack;
size_t spritexy_size;
UINT8 *spritexy_ram;
UINT8 *spritetile_ram;
UINT8 *spriteattrib_ram;
int charbank;
int charpalbank;
int flipscreen;
tilemap_t *bg_tilemap;
};
/*----------- defined in video/gsword.c -----------*/
extern size_t gsword_spritexy_size;
extern UINT8 *gsword_spritexy_ram;
extern UINT8 *gsword_spritetile_ram;
extern UINT8 *gsword_spriteattrib_ram;
WRITE8_HANDLER( gsword_charbank_w );
WRITE8_HANDLER( gsword_videoctrl_w );
WRITE8_HANDLER( gsword_videoram_w );

View File

@ -1,3 +1,26 @@
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int primask;
};
class gunbustr_state : public driver_device
{
public:
gunbustr_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT16 coin_word;
UINT32 *ram;
struct tempsprite *spritelist;
UINT32 mem[2];
};
/*----------- defined in video/gunbustr.c -----------*/
VIDEO_START( gunbustr );

View File

@ -5,11 +5,35 @@
*************************************************************************/
/*----------- defined in video/m107.c -----------*/
typedef struct _pf_layer_info pf_layer_info;
struct _pf_layer_info
{
tilemap_t * tmap;
UINT16 vram_base;
UINT16 control[4];
};
extern UINT16 *m107_vram_data;
extern UINT8 m107_spritesystem;
extern UINT16 m107_raster_irq_position;
class m107_state : public driver_device
{
public:
m107_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
emu_timer *scanline_timer;
UINT8 irq_vectorbase;
int irqvector;
int sound_status;
UINT16 *vram_data;
UINT8 spritesystem;
UINT8 sprite_display;
UINT16 raster_irq_position;
pf_layer_info pf_layer[4];
UINT16 control[0x10];
UINT16 *spriteram;
};
/*----------- defined in video/m107.c -----------*/
WRITE16_HANDLER( m107_spritebuffer_w );
VIDEO_UPDATE( m107 );

View File

@ -4,10 +4,42 @@
*************************************************************************/
/*----------- defined in video/m72.c -----------*/
class m72_state : public driver_device
{
public:
m72_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT16 *m72_videoram1,*m72_videoram2,*majtitle_rowscrollram;
extern UINT32 m72_raster_irq_position;
UINT8 irqvector;
UINT32 sample_addr;
UINT16 *protection_ram;
emu_timer *scanline_timer;
UINT8 irq_base;
UINT8 mcu_snd_cmd_latch;
UINT8 mcu_sample_latch;
UINT32 mcu_sample_addr;
const UINT8 *protection_code;
const UINT8 *protection_crc;
UINT8 *soundram;
int prev[4];
int diff[4];
UINT16 *videoram1;
UINT16 *videoram2;
UINT16 *majtitle_rowscrollram;
UINT32 raster_irq_position;
UINT16 *spriteram;
tilemap_t *fg_tilemap;
tilemap_t *bg_tilemap;
INT32 scrollx1;
INT32 scrolly1;
INT32 scrollx2;
INT32 scrolly2;
INT32 video_off;
int majtitle_rowscroll;
};
/*----------- defined in video/m72.c -----------*/
VIDEO_START( m72 );
VIDEO_START( rtype2 );

View File

@ -4,6 +4,38 @@
*************************************************************************/
typedef struct _pf_layer_info pf_layer_info;
struct _pf_layer_info
{
tilemap_t * tmap;
tilemap_t * wide_tmap;
UINT16 vram_base;
UINT16 control[4];
};
class m92_state : public driver_device
{
public:
m92_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 irqvector;
UINT16 sound_status;
UINT32 bankaddress;
emu_timer *scanline_timer;
UINT8 irq_vectorbase;
UINT32 raster_irq_position;
UINT16 *vram_data;
UINT16 *spritecontrol;
UINT8 sprite_buffer_busy;
UINT8 game_kludge;
pf_layer_info pf_layer[3];
UINT16 pf_master_control[4];
INT32 sprite_list;
int palette_bank;
};
/*----------- defined in drivers/m92.c -----------*/
extern void m92_sprite_interrupt(running_machine *machine);
@ -11,11 +43,6 @@ extern void m92_sprite_interrupt(running_machine *machine);
/*----------- defined in video/m92.c -----------*/
extern UINT32 m92_raster_irq_position;
extern UINT16 *m92_vram_data, *m92_spritecontrol;
extern UINT8 m92_sprite_buffer_busy, m92_game_kludge;
WRITE16_HANDLER( m92_spritecontrol_w );
WRITE16_HANDLER( m92_videocontrol_w );
READ16_HANDLER( m92_paletteram_r );

View File

@ -28,6 +28,11 @@ public:
device_t *audiocpu;
device_t *subcpu;
device_t *mcu;
/* queue */
UINT8 queue[64];
int qfront;
int qstate;
};

View File

@ -29,6 +29,7 @@ public:
UINT8 snd_data;
int vol_ctrl[16];
int gametype;
int mask;
/* devices */
device_t *maincpu;

View File

@ -5,6 +5,24 @@ public:
: driver_device(machine, config) { }
UINT8 *videoram;
int nmi;
UINT8* videoram2;
UINT8 fromz80;
UINT8 toz80;
int zaccept;
int zready;
UINT8 portA_in;
UINT8 portA_out;
int address;
int h_heed;
int v_heed;
int ha;
int scroll;
int char_bank;
int color_select;
bitmap_t *tmp_bitmap[4];
tilemap_t *bg;
tilemap_t *fg;
};
@ -26,8 +44,6 @@ WRITE8_HANDLER( pitnrun_mcu_data_w );
/*----------- defined in video/pitnrun.c -----------*/
extern UINT8* pitnrun_videoram2;
WRITE8_HANDLER( pitnrun_videoram_w );
WRITE8_HANDLER( pitnrun_videoram2_w );
WRITE8_HANDLER(pitnrun_ha_w);

View File

@ -17,6 +17,8 @@
#define QIX_CHARACTER_CLOCK (20000000/2/16)
#define NUM_PENS (0x100)
class qix_state : public driver_device
{
public:
@ -38,6 +40,7 @@ public:
UINT8 palette_bank;
UINT8 leds;
UINT8 *scanline_latch;
pen_t pens[NUM_PENS];
};

View File

@ -7,6 +7,23 @@
****************************************************************************/
class redalert_state : public driver_device
{
public:
redalert_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 ay8910_latch_1;
UINT8 ay8910_latch_2;
UINT8 *bitmap_videoram;
UINT8 *bitmap_color;
UINT8 *charmap_videoram;
UINT8 *video_control;
UINT8 *bitmap_colorram;
UINT8 control_xor;
};
/*----------- defined in audio/redalert.c -----------*/
WRITE8_HANDLER( redalert_audio_command_w );
@ -21,10 +38,6 @@ MACHINE_CONFIG_EXTERN( demoneye_audio );
/*----------- defined in video/redalert.c -----------*/
extern UINT8 *redalert_bitmap_videoram;
extern UINT8 *redalert_bitmap_color;
extern UINT8 *redalert_charmap_videoram;
extern UINT8 *redalert_video_control;
WRITE8_HANDLER( redalert_bitmap_videoram_w );
MACHINE_CONFIG_EXTERN( ww3_video );

View File

@ -1,3 +1,33 @@
class retofinv_state : public driver_device
{
public:
retofinv_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 cpu2_m6000;
UINT8 *fg_videoram;
UINT8 *bg_videoram;
UINT8 *sharedram;
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 fg_bank;
int bg_bank;
tilemap_t *bg_tilemap;
tilemap_t *fg_tilemap;
};
/*----------- defined in machine/retofinv.c -----------*/
READ8_HANDLER( retofinv_68705_portA_r );
@ -16,10 +46,6 @@ READ8_HANDLER( retofinv_mcu_status_r );
/*----------- defined in video/retofinv.c -----------*/
extern UINT8 *retofinv_fg_videoram;
extern UINT8 *retofinv_bg_videoram;
extern UINT8 *retofinv_sharedram;
VIDEO_START( retofinv );
PALETTE_INIT( retofinv );
VIDEO_UPDATE( retofinv );

View File

@ -1,7 +1,24 @@
/*----------- defined in video/rollrace.c -----------*/
class rollrace_state : public driver_device
{
public:
rollrace_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *rollrace_videoram;
extern UINT8 *rollrace_colorram;
UINT8 *videoram;
UINT8 *colorram;
int ra_charbank[2];
int ra_bkgpage;
int ra_bkgflip;
int ra_chrbank;
int ra_bkgpen;
int ra_bkgcol;
int ra_flipy;
int ra_flipx;
int ra_spritebank;
};
/*----------- defined in video/rollrace.c -----------*/
VIDEO_UPDATE( rollrace );

View File

@ -34,6 +34,7 @@ public:
INT32 sprites_disabled, sprites_active_area, sprites_master_scrollx, sprites_master_scrolly;
int sprites_flipscreen;
int prepare_sprites;
int dislayer[5];
UINT16 spritebank[8];

View File

@ -1,3 +1,28 @@
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int primask;
};
class superchs_state : public driver_device
{
public:
superchs_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT16 coin_word;
UINT32 *ram;
UINT32 *shared_ram;
int steer;
struct tempsprite *spritelist;
UINT32 mem[2];
};
/*----------- defined in video/superchs.c -----------*/
VIDEO_START( superchs );

View File

@ -1,8 +1,39 @@
/*----------- defined in video/superqix.c -----------*/
class superqix_state : public driver_device
{
public:
superqix_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *superqix_videoram;
extern UINT8 *superqix_bitmapram,*superqix_bitmapram2;
extern int pbillian_show_power;
INT16 *samplebuf;
UINT8 port1;
UINT8 port2;
UINT8 port3;
UINT8 port3_latch;
UINT8 from_mcu;
UINT8 from_z80;
UINT8 portb;
int from_mcu_pending;
int from_z80_pending;
int invert_coin_lockout;
int oldpos[2];
int sign[2];
UINT8 portA_in;
UINT8 portB_out;
UINT8 portC;
int curr_player;
UINT8 *videoram;
UINT8 *bitmapram;
UINT8 *bitmapram2;
int pbillian_show_power;
int gfxbank;
bitmap_t *fg_bitmap[2];
int show_bitmap;
tilemap_t *bg_tilemap;
int last_power[2];
};
/*----------- defined in video/superqix.c -----------*/
WRITE8_HANDLER( superqix_videoram_w );
WRITE8_HANDLER( superqix_bitmapram_w );

View File

@ -51,6 +51,8 @@ public:
UINT8 mcu_comm_hc11;
UINT8 mcu_data_main;
UINT8 mcu_data_hc11;
UINT16 debug_dsp_ram[0x8000];
};

View File

@ -1,3 +1,47 @@
class taitosj_state : public driver_device
{
public:
taitosj_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 sndnmi_disable;
UINT8 input_port_4_f0;
UINT8 kikstart_gears[2];
INT8 dac_out;
UINT8 dac_vol;
UINT8 *videoram_1;
UINT8 *videoram_2;
UINT8 *videoram_3;
UINT8 *spriteram;
UINT8 *paletteram;
UINT8 *characterram;
UINT8 *scroll;
UINT8 *colscrolly;
UINT8 *gfxpointer;
UINT8 *colorbank;
UINT8 *video_mode;
UINT8 *video_priority;
UINT8 *collision_reg;
UINT8 *kikstart_scrollram;
UINT8 fromz80;
UINT8 toz80;
UINT8 zaccept;
UINT8 zready;
UINT8 busreq;
UINT8 portA_in;
UINT8 portA_out;
UINT8 spacecr_prot_value;
UINT8 protection_value;
UINT32 address;
bitmap_t *layer_bitmap[3];
bitmap_t *sprite_sprite_collbitmap1;
bitmap_t *sprite_sprite_collbitmap2;
bitmap_t *sprite_layer_collbitmap1;
bitmap_t *sprite_layer_collbitmap2[3];
int draw_order[32][4];
};
/*----------- defined in machine/taitosj.c -----------*/
MACHINE_START( taitosj );
@ -23,21 +67,6 @@ READ8_HANDLER( alpine_port_2_r );
/*----------- defined in video/taitosj.c -----------*/
extern UINT8 *taitosj_videoram_1;
extern UINT8 *taitosj_videoram_2;
extern UINT8 *taitosj_videoram_3;
extern UINT8 *taitosj_spriteram;
extern UINT8 *taitosj_paletteram;
extern UINT8 *taitosj_characterram;
extern UINT8 *taitosj_scroll;
extern UINT8 *taitosj_colscrolly;
extern UINT8 *taitosj_gfxpointer;
extern UINT8 *taitosj_colorbank;
extern UINT8 *taitosj_video_mode;
extern UINT8 *taitosj_video_priority;
extern UINT8 *taitosj_collision_reg;
extern UINT8 *kikstart_scrollram;
READ8_HANDLER( taitosj_gfxrom_r );
WRITE8_HANDLER( taitosj_characterram_w );
WRITE8_HANDLER( junglhbr_characterram_w );

View File

@ -33,6 +33,8 @@ public:
device_t *pc080sn_1;
device_t *pc080sn_2;
device_t *tc0220ioc;
UINT8 dislayer[5];
};

View File

@ -1,8 +1,29 @@
/*----------- defined in video/tsamurai.c -----------*/
class tsamurai_state : public driver_device
{
public:
tsamurai_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *tsamurai_videoram;
extern UINT8 *tsamurai_colorram;
extern UINT8 *tsamurai_bg_videoram;
int nmi_enabled;
int sound_command1;
int sound_command2;
int sound_command3;
int vsgongf_sound_nmi_enabled;
UINT8 *videoram;
UINT8 *colorram;
UINT8 *bg_videoram;
int bgcolor;
int textbank1;
int textbank2;
tilemap_t *background;
tilemap_t *foreground;
int flicker;
int vsgongf_color;
int key_count;
};
/*----------- defined in video/tsamurai.c -----------*/
WRITE8_HANDLER( vsgongf_color_w );

View File

@ -1,6 +1,31 @@
/*----------- defined in video/undrfire.c -----------*/
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int primask;
};
extern UINT16 undrfire_rotate_ctrl[8];
class undrfire_state : public driver_device
{
public:
undrfire_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT16 coin_word;
UINT16 port_sel;
int frame_counter;
UINT32 *ram;
UINT32 *shared_ram;
struct tempsprite *spritelist;
UINT16 rotate_ctrl[8];
UINT8 dislayer[6];
};
/*----------- defined in video/undrfire.c -----------*/
VIDEO_START( undrfire );
VIDEO_UPDATE( undrfire );

View File

@ -27,6 +27,7 @@ public:
UINT16 piv_zoom[3], piv_scrollx[3], piv_scrolly[3];
UINT16 rotate_ctrl[8];
int piv_xoffs, piv_yoffs;
UINT8 dislayer[4];
/* misc */
UINT16 cpua_ctrl;

View File

@ -181,30 +181,28 @@ static void kiki_clogic(running_machine *machine, int address, int latch)
{
mexico86_state *state = machine->driver_data<mexico86_state>();
static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00};
static UINT8 queue[64];
static int qfront = 0, state = 0;
int sy, sx, hw, i, qptr, diff1, diff2;
if (address != KIKI_CL_TRIGGER) // queue latched data
if (address != KIKI_CL_TRIGGER) // state->queue latched data
{
queue[qfront++] = latch;
qfront &= 0x3f;
state->queue[state->qfront++] = latch;
state->qfront &= 0x3f;
}
else if (state ^= 1) // scan queue
else if (state->qstate ^= 1) // scan state->queue
{
sy = queue[(qfront-0x3a)&0x3f] + ((0x18-DCHEIGHT)>>1);
sx = queue[(qfront-0x39)&0x3f] + ((0x18-DCWIDTH)>>1);
sy = state->queue[(state->qfront-0x3a)&0x3f] + ((0x18-DCHEIGHT)>>1);
sx = state->queue[(state->qfront-0x39)&0x3f] + ((0x18-DCWIDTH)>>1);
for (i=0x38; i; i-=8)
{
qptr = qfront - i;
if (!(hw = db[queue[qptr&0x3f]&0xf])) continue;
qptr = state->qfront - i;
if (!(hw = db[state->queue[qptr&0x3f]&0xf])) continue;
diff1 = sx - (short)(queue[(qptr+6)&0x3f]<<8|queue[(qptr+7)&0x3f]) + DCWIDTH;
diff1 = sx - (short)(state->queue[(qptr+6)&0x3f]<<8|state->queue[(qptr+7)&0x3f]) + DCWIDTH;
diff2 = diff1 - (hw + DCWIDTH);
if ((diff1^diff2)<0)
{
diff1 = sy - (short)(queue[(qptr+4)&0x3f]<<8|queue[(qptr+5)&0x3f]) + DCHEIGHT;
diff1 = sy - (short)(state->queue[(qptr+4)&0x3f]<<8|state->queue[(qptr+5)&0x3f]) + DCHEIGHT;
diff2 = diff1 - (hw + DCHEIGHT);
if ((diff1^diff2)<0)
state->protection_ram[KIKI_CL_OUT] = 1; // we have a collision

View File

@ -12,32 +12,33 @@
#include "includes/pitnrun.h"
static UINT8 fromz80,toz80;
static int zaccept,zready;
MACHINE_RESET( pitnrun )
{
zaccept = 1;
zready = 0;
pitnrun_state *state = machine->driver_data<pitnrun_state>();
state->zaccept = 1;
state->zready = 0;
cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
}
static TIMER_CALLBACK( pitnrun_mcu_real_data_r )
{
zaccept = 1;
pitnrun_state *state = machine->driver_data<pitnrun_state>();
state->zaccept = 1;
}
READ8_HANDLER( pitnrun_mcu_data_r )
{
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
timer_call_after_resynch(space->machine, NULL, 0,pitnrun_mcu_real_data_r);
return toz80;
return state->toz80;
}
static TIMER_CALLBACK( pitnrun_mcu_real_data_w )
{
zready = 1;
pitnrun_state *state = machine->driver_data<pitnrun_state>();
state->zready = 1;
cputag_set_input_line(machine, "mcu", 0, ASSERT_LINE);
fromz80 = param;
state->fromz80 = param;
}
WRITE8_HANDLER( pitnrun_mcu_data_w )
@ -48,22 +49,24 @@ WRITE8_HANDLER( pitnrun_mcu_data_w )
READ8_HANDLER( pitnrun_mcu_status_r )
{
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
/* mcu synchronization */
/* bit 0 = the 68705 has read data from the Z80 */
/* bit 1 = the 68705 has written data for the Z80 */
return ~((zready << 1) | (zaccept << 0));
return ~((state->zready << 1) | (state->zaccept << 0));
}
static UINT8 portA_in,portA_out;
READ8_HANDLER( pitnrun_68705_portA_r )
{
return portA_in;
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
return state->portA_in;
}
WRITE8_HANDLER( pitnrun_68705_portA_w )
{
portA_out = data;
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
state->portA_out = data;
}
@ -91,49 +94,51 @@ READ8_HANDLER( pitnrun_68705_portB_r )
return 0xff;
}
static int address;
static TIMER_CALLBACK( pitnrun_mcu_data_real_r )
{
zready = 0;
pitnrun_state *state = machine->driver_data<pitnrun_state>();
state->zready = 0;
}
static TIMER_CALLBACK( pitnrun_mcu_status_real_w )
{
toz80 = param;
zaccept = 0;
pitnrun_state *state = machine->driver_data<pitnrun_state>();
state->toz80 = param;
state->zaccept = 0;
}
WRITE8_HANDLER( pitnrun_68705_portB_w )
{
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
address_space *cpu0space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
if (~data & 0x02)
{
/* 68705 is going to read data from the Z80 */
timer_call_after_resynch(space->machine, NULL, 0,pitnrun_mcu_data_real_r);
cputag_set_input_line(space->machine, "mcu",0,CLEAR_LINE);
portA_in = fromz80;
state->portA_in = state->fromz80;
}
if (~data & 0x04)
{
/* 68705 is writing data for the Z80 */
timer_call_after_resynch(space->machine, NULL, portA_out,pitnrun_mcu_status_real_w);
timer_call_after_resynch(space->machine, NULL, state->portA_out,pitnrun_mcu_status_real_w);
}
if (~data & 0x10)
{
cpu0space->write_byte(address, portA_out);
cpu0space->write_byte(state->address, state->portA_out);
}
if (~data & 0x20)
{
portA_in = cpu0space->read_byte(address);
state->portA_in = cpu0space->read_byte(state->address);
}
if (~data & 0x40)
{
address = (address & 0xff00) | portA_out;
state->address = (state->address & 0xff00) | state->portA_out;
}
if (~data & 0x80)
{
address = (address & 0x00ff) | (portA_out << 8);
state->address = (state->address & 0x00ff) | (state->portA_out << 8);
}
}
@ -149,5 +154,6 @@ WRITE8_HANDLER( pitnrun_68705_portB_w )
READ8_HANDLER( pitnrun_68705_portC_r )
{
return (zready << 0) | (zaccept << 1);
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
return (state->zready << 0) | (state->zaccept << 1);
}

View File

@ -3,33 +3,31 @@
#include "includes/retofinv.h"
static UINT8 from_main,from_mcu;
static int mcu_sent = 0,main_sent = 0;
/***************************************************************************
Return of Invaders 68705 protection interface
***************************************************************************/
static UINT8 portA_in,portA_out,ddrA;
READ8_HANDLER( retofinv_68705_portA_r )
{
//logerror("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in);
return (portA_out & ddrA) | (portA_in & ~ddrA);
retofinv_state *state = space->machine->driver_data<retofinv_state>();
//logerror("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),state->portA_in);
return (state->portA_out & state->ddrA) | (state->portA_in & ~state->ddrA);
}
WRITE8_HANDLER( retofinv_68705_portA_w )
{
retofinv_state *state = space->machine->driver_data<retofinv_state>();
//logerror("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data);
portA_out = data;
state->portA_out = data;
}
WRITE8_HANDLER( retofinv_68705_ddrA_w )
{
ddrA = data;
retofinv_state *state = space->machine->driver_data<retofinv_state>();
state->ddrA = data;
}
@ -43,37 +41,39 @@ WRITE8_HANDLER( retofinv_68705_ddrA_w )
* 2 W loads latch to Z80
*/
static UINT8 portB_in,portB_out,ddrB;
READ8_HANDLER( retofinv_68705_portB_r )
{
return (portB_out & ddrB) | (portB_in & ~ddrB);
retofinv_state *state = space->machine->driver_data<retofinv_state>();
return (state->portB_out & state->ddrB) | (state->portB_in & ~state->ddrB);
}
WRITE8_HANDLER( retofinv_68705_portB_w )
{
retofinv_state *state = space->machine->driver_data<retofinv_state>();
//logerror("%04x: 68705 port B write %02x\n",cpu_get_pc(space->cpu),data);
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, "68705", 0, CLEAR_LINE);
main_sent = 0;
//logerror("read command %02x from main cpu\n",portA_in);
state->portA_in = state->from_main;
if (state->main_sent) cputag_set_input_line(space->machine, "68705", 0, CLEAR_LINE);
state->main_sent = 0;
//logerror("read command %02x from main cpu\n",state->portA_in);
}
if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04))
if ((state->ddrB & 0x04) && (data & 0x04) && (~state->portB_out & 0x04))
{
//logerror("send command %02x to main cpu\n",portA_out);
from_mcu = portA_out;
mcu_sent = 1;
//logerror("send command %02x to main cpu\n",state->portA_out);
state->from_mcu = state->portA_out;
state->mcu_sent = 1;
}
portB_out = data;
state->portB_out = data;
}
WRITE8_HANDLER( retofinv_68705_ddrB_w )
{
ddrB = data;
retofinv_state *state = space->machine->driver_data<retofinv_state>();
state->ddrB = data;
}
@ -86,53 +86,58 @@ WRITE8_HANDLER( retofinv_68705_ddrB_w )
* 1 R 0 when pending command 68705->Z80
*/
static UINT8 portC_in,portC_out,ddrC;
READ8_HANDLER( retofinv_68705_portC_r )
{
portC_in = 0;
if (main_sent) portC_in |= 0x01;
if (!mcu_sent) portC_in |= 0x02;
//logerror("%04x: 68705 port C read %02x\n",cpu_get_pc(space->cpu),portC_in);
return (portC_out & ddrC) | (portC_in & ~ddrC);
retofinv_state *state = space->machine->driver_data<retofinv_state>();
state->portC_in = 0;
if (state->main_sent) state->portC_in |= 0x01;
if (!state->mcu_sent) state->portC_in |= 0x02;
//logerror("%04x: 68705 port C read %02x\n",cpu_get_pc(space->cpu),state->portC_in);
return (state->portC_out & state->ddrC) | (state->portC_in & ~state->ddrC);
}
WRITE8_HANDLER( retofinv_68705_portC_w )
{
retofinv_state *state = space->machine->driver_data<retofinv_state>();
logerror("%04x: 68705 port C write %02x\n",cpu_get_pc(space->cpu),data);
portC_out = data;
state->portC_out = data;
}
WRITE8_HANDLER( retofinv_68705_ddrC_w )
{
ddrC = data;
retofinv_state *state = space->machine->driver_data<retofinv_state>();
state->ddrC = data;
}
WRITE8_HANDLER( retofinv_mcu_w )
{
retofinv_state *state = space->machine->driver_data<retofinv_state>();
logerror("%04x: mcu_w %02x\n",cpu_get_pc(space->cpu),data);
from_main = data;
main_sent = 1;
state->from_main = data;
state->main_sent = 1;
cputag_set_input_line(space->machine, "68705", 0, ASSERT_LINE);
}
READ8_HANDLER( retofinv_mcu_r )
{
logerror("%04x: mcu_r %02x\n",cpu_get_pc(space->cpu),from_mcu);
mcu_sent = 0;
return from_mcu;
retofinv_state *state = space->machine->driver_data<retofinv_state>();
logerror("%04x: mcu_r %02x\n",cpu_get_pc(space->cpu),state->from_mcu);
state->mcu_sent = 0;
return state->from_mcu;
}
READ8_HANDLER( retofinv_mcu_status_r )
{
retofinv_state *state = space->machine->driver_data<retofinv_state>();
int res = 0;
/* bit 4 = when 1, mcu is ready to receive data from main cpu */
/* bit 5 = when 1, mcu has sent data to the main cpu */
//logerror("%04x: mcu_status_r\n",cpu_get_pc(space->cpu));
if (!main_sent) res |= 0x10;
if (mcu_sent) res |= 0x20;
if (!state->main_sent) res |= 0x10;
if (state->mcu_sent) res |= 0x20;
return res;
}

View File

@ -328,7 +328,7 @@ static void run_mproc(running_machine *machine)
state->ACC += (((INT32)(state->A - state->B) << 1) * state->C) << 1;
/* state->A and state->B are sign extended (requred by the ls384). After
/* A and B are sign extended (requred by the ls384). After
* multiplication they just contain the sign.
*/
state->A = (state->A & 0x8000)? 0xffff: 0;
@ -355,7 +355,7 @@ static void run_mproc(running_machine *machine)
* leaking from one to another. It may not matter, but I've put it in anyway
*/
tmp = state->MPA + 1;
state->MPA = (state->MPA & 0x0300) | (tmp & 0x00ff); /* New state->MPA value */
state->MPA = (state->MPA & 0x0300) | (tmp & 0x00ff); /* New MPA value */
M_STOP--; /* Decrease count */
}

View File

@ -16,47 +16,41 @@
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
static UINT8 fromz80,toz80;
static UINT8 zaccept,zready,busreq;
static UINT8 portA_in,portA_out;
static UINT8 spacecr_prot_value;
static UINT8 protection_value;
static UINT32 address;
MACHINE_START( taitosj )
{
taitosj_state *state = machine->driver_data<taitosj_state>();
memory_configure_bank(machine, "bank1", 0, 1, machine->region("maincpu")->base() + 0x6000, 0);
memory_configure_bank(machine, "bank1", 1, 1, machine->region("maincpu")->base() + 0x10000, 0);
state_save_register_global(machine, fromz80);
state_save_register_global(machine, toz80);
state_save_register_global(machine, zaccept);
state_save_register_global(machine, zready);
state_save_register_global(machine, busreq);
state_save_register_global(machine, state->fromz80);
state_save_register_global(machine, state->toz80);
state_save_register_global(machine, state->zaccept);
state_save_register_global(machine, state->zready);
state_save_register_global(machine, state->busreq);
state_save_register_global(machine, portA_in);
state_save_register_global(machine, portA_out);
state_save_register_global(machine, address);
state_save_register_global(machine, spacecr_prot_value);
state_save_register_global(machine, protection_value);
state_save_register_global(machine, state->portA_in);
state_save_register_global(machine, state->portA_out);
state_save_register_global(machine, state->address);
state_save_register_global(machine, state->spacecr_prot_value);
state_save_register_global(machine, state->protection_value);
}
MACHINE_RESET( taitosj )
{
taitosj_state *state = machine->driver_data<taitosj_state>();
address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
/* set the default ROM bank (many games only have one bank and */
/* never write to the bank selector register) */
taitosj_bankswitch_w(space, 0, 0);
zaccept = 1;
zready = 0;
busreq = 0;
state->zaccept = 1;
state->zready = 0;
state->busreq = 0;
if (machine->device("mcu") != NULL)
cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
spacecr_prot_value = 0;
state->spacecr_prot_value = 0;
}
@ -104,17 +98,19 @@ READ8_HANDLER( taitosj_fake_status_r )
/* timer callback : */
READ8_HANDLER( taitosj_mcu_data_r )
{
LOG(("%04x: protection read %02x\n",cpu_get_pc(space->cpu),toz80));
zaccept = 1;
return toz80;
taitosj_state *state = space->machine->driver_data<taitosj_state>();
LOG(("%04x: protection read %02x\n",cpu_get_pc(space->cpu),state->toz80));
state->zaccept = 1;
return state->toz80;
}
/* timer callback : */
static TIMER_CALLBACK( taitosj_mcu_real_data_w )
{
zready = 1;
taitosj_state *state = machine->driver_data<taitosj_state>();
state->zready = 1;
cputag_set_input_line(machine, "mcu", 0, ASSERT_LINE);
fromz80 = param;
state->fromz80 = param;
}
WRITE8_HANDLER( taitosj_mcu_data_w )
@ -127,24 +123,27 @@ WRITE8_HANDLER( taitosj_mcu_data_w )
READ8_HANDLER( taitosj_mcu_status_r )
{
taitosj_state *state = space->machine->driver_data<taitosj_state>();
/* temporarily boost the interleave to sync things up */
cpuexec_boost_interleave(space->machine, attotime::zero, attotime::from_usec(10));
/* bit 0 = the 68705 has read data from the Z80 */
/* bit 1 = the 68705 has written data for the Z80 */
return ~((zready << 0) | (zaccept << 1));
return ~((state->zready << 0) | (state->zaccept << 1));
}
READ8_HANDLER( taitosj_68705_portA_r )
{
LOG(("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in));
return portA_in;
taitosj_state *state = space->machine->driver_data<taitosj_state>();
LOG(("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),state->portA_in));
return state->portA_in;
}
WRITE8_HANDLER( taitosj_68705_portA_w )
{
taitosj_state *state = space->machine->driver_data<taitosj_state>();
LOG(("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data));
portA_out = data;
state->portA_out = data;
}
@ -177,18 +176,21 @@ READ8_HANDLER( taitosj_68705_portB_r )
/* timer callback : 68705 is going to read data from the Z80 */
static TIMER_CALLBACK( taitosj_mcu_data_real_r )
{
zready = 0;
taitosj_state *state = machine->driver_data<taitosj_state>();
state->zready = 0;
}
/* timer callback : 68705 is writing data for the Z80 */
static TIMER_CALLBACK( taitosj_mcu_status_real_w )
{
toz80 = param;
zaccept = 0;
taitosj_state *state = machine->driver_data<taitosj_state>();
state->toz80 = param;
state->zaccept = 0;
}
WRITE8_HANDLER( taitosj_68705_portB_w )
{
taitosj_state *state = space->machine->driver_data<taitosj_state>();
LOG(("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data));
if (~data & 0x01)
@ -200,45 +202,45 @@ WRITE8_HANDLER( taitosj_68705_portB_w )
/* 68705 is going to read data from the Z80 */
timer_call_after_resynch(space->machine, NULL, 0, taitosj_mcu_data_real_r);
cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
portA_in = fromz80;
LOG(("%04x: 68705 <- Z80 %02x\n", cpu_get_pc(space->cpu), portA_in));
state->portA_in = state->fromz80;
LOG(("%04x: 68705 <- Z80 %02x\n", cpu_get_pc(space->cpu), state->portA_in));
}
if (~data & 0x08)
busreq = 1;
state->busreq = 1;
else
busreq = 0;
state->busreq = 0;
if (~data & 0x04)
{
LOG(("%04x: 68705 -> Z80 %02x\n", cpu_get_pc(space->cpu), portA_out));
LOG(("%04x: 68705 -> Z80 %02x\n", cpu_get_pc(space->cpu), state->portA_out));
/* 68705 is writing data for the Z80 */
timer_call_after_resynch(space->machine, NULL, portA_out, taitosj_mcu_status_real_w);
timer_call_after_resynch(space->machine, NULL, state->portA_out, taitosj_mcu_status_real_w);
}
if (~data & 0x10)
{
address_space *cpu0space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
LOG(("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(space->cpu), portA_out, address));
LOG(("%04x: 68705 write %02x to state->address %04x\n",cpu_get_pc(space->cpu), state->portA_out, state->address));
cpu0space->write_byte(address, portA_out);
cpu0space->write_byte(state->address, state->portA_out);
/* increase low 8 bits of latched address for burst writes */
address = (address & 0xff00) | ((address + 1) & 0xff);
state->address = (state->address & 0xff00) | ((state->address + 1) & 0xff);
}
if (~data & 0x20)
{
address_space *cpu0space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
portA_in = cpu0space->read_byte(address);
LOG(("%04x: 68705 read %02x from address %04x\n", cpu_get_pc(space->cpu), portA_in, address));
state->portA_in = cpu0space->read_byte(state->address);
LOG(("%04x: 68705 read %02x from state->address %04x\n", cpu_get_pc(space->cpu), state->portA_in, state->address));
}
if (~data & 0x40)
{
LOG(("%04x: 68705 address low %02x\n", cpu_get_pc(space->cpu), portA_out));
address = (address & 0xff00) | portA_out;
LOG(("%04x: 68705 state->address low %02x\n", cpu_get_pc(space->cpu), state->portA_out));
state->address = (state->address & 0xff00) | state->portA_out;
}
if (~data & 0x80)
{
LOG(("%04x: 68705 address high %02x\n", cpu_get_pc(space->cpu), portA_out));
address = (address & 0x00ff) | (portA_out << 8);
LOG(("%04x: 68705 state->address high %02x\n", cpu_get_pc(space->cpu), state->portA_out));
state->address = (state->address & 0x00ff) | (state->portA_out << 8);
}
}
@ -254,9 +256,10 @@ WRITE8_HANDLER( taitosj_68705_portB_w )
READ8_HANDLER( taitosj_68705_portC_r )
{
taitosj_state *state = space->machine->driver_data<taitosj_state>();
int res;
res = (zready << 0) | (zaccept << 1) | ((busreq^1) << 2);
res = (state->zready << 0) | (state->zaccept << 1) | ((state->busreq^1) << 2);
LOG(("%04x: 68705 port C read %02x\n",cpu_get_pc(space->cpu),res));
return res;
}
@ -266,14 +269,15 @@ READ8_HANDLER( taitosj_68705_portC_r )
READ8_HANDLER( spacecr_prot_r )
{
taitosj_state *state = space->machine->driver_data<taitosj_state>();
int pc = cpu_get_pc(space->cpu);
if( pc != 0x368A && pc != 0x36A6 )
logerror("Read protection from an unknown location: %04X\n",pc);
spacecr_prot_value ^= 0xff;
state->spacecr_prot_value ^= 0xff;
return spacecr_prot_value;
return state->spacecr_prot_value;
}
@ -281,35 +285,38 @@ READ8_HANDLER( spacecr_prot_r )
WRITE8_HANDLER( alpine_protection_w )
{
taitosj_state *state = space->machine->driver_data<taitosj_state>();
switch (data)
{
case 0x05:
protection_value = 0x18;
state->protection_value = 0x18;
break;
case 0x07:
case 0x0c:
case 0x0f:
protection_value = 0x00; /* not used as far as I can tell */
state->protection_value = 0x00; /* not used as far as I can tell */
break;
case 0x16:
protection_value = 0x08;
state->protection_value = 0x08;
break;
case 0x1d:
protection_value = 0x18;
state->protection_value = 0x18;
break;
default:
protection_value = data; /* not used as far as I can tell */
state->protection_value = data; /* not used as far as I can tell */
break;
}
}
WRITE8_HANDLER( alpinea_bankswitch_w )
{
taitosj_state *state = space->machine->driver_data<taitosj_state>();
taitosj_bankswitch_w(space, offset, data);
protection_value = data >> 2;
state->protection_value = data >> 2;
}
READ8_HANDLER( alpine_port_2_r )
{
return input_port_read(space->machine, "IN2") | protection_value;
taitosj_state *state = space->machine->driver_data<taitosj_state>();
return input_port_read(space->machine, "IN2") | state->protection_value;
}

View File

@ -10,15 +10,6 @@
#include "includes/crbaloon.h"
UINT8 *crbaloon_videoram;
UINT8 *crbaloon_colorram;
UINT8 *crbaloon_spriteram;
static UINT16 crbaloon_collision_address;
static UINT8 crbaloon_collision_address_clear;
static tilemap_t *bg_tilemap;
/***************************************************************************
Convert the color PROMs into a more useable format.
@ -58,52 +49,59 @@ PALETTE_INIT( crbaloon )
WRITE8_HANDLER( crbaloon_videoram_w )
{
crbaloon_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
crbaloon_state *state = space->machine->driver_data<crbaloon_state>();
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( crbaloon_colorram_w )
{
crbaloon_colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
crbaloon_state *state = space->machine->driver_data<crbaloon_state>();
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
static TILE_GET_INFO( get_bg_tile_info )
{
int code = crbaloon_videoram[tile_index];
int color = crbaloon_colorram[tile_index] & 0x0f;
crbaloon_state *state = machine->driver_data<crbaloon_state>();
int code = state->videoram[tile_index];
int color = state->colorram[tile_index] & 0x0f;
SET_TILE_INFO(0, code, color, 0);
}
VIDEO_START( crbaloon )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows_flip_xy, 8, 8, 32, 32);
crbaloon_state *state = machine->driver_data<crbaloon_state>();
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows_flip_xy, 8, 8, 32, 32);
state_save_register_global(machine, crbaloon_collision_address);
state_save_register_global(machine, crbaloon_collision_address_clear);
state_save_register_global(machine, state->collision_address);
state_save_register_global(machine, state->collision_address_clear);
}
UINT16 crbaloon_get_collision_address(void)
UINT16 crbaloon_get_collision_address(running_machine *machine)
{
return crbaloon_collision_address_clear ? 0xffff : crbaloon_collision_address;
crbaloon_state *state = machine->driver_data<crbaloon_state>();
return state->collision_address_clear ? 0xffff : state->collision_address;
}
void crbaloon_set_clear_collision_address(int _crbaloon_collision_address_clear)
void crbaloon_set_clear_collision_address(running_machine *machine, int _crbaloon_collision_address_clear)
{
crbaloon_collision_address_clear = !_crbaloon_collision_address_clear; /* active LO */
crbaloon_state *state = machine->driver_data<crbaloon_state>();
state->collision_address_clear = !_crbaloon_collision_address_clear; /* active LO */
}
static void draw_sprite_and_check_collision(running_machine *machine, bitmap_t *bitmap)
{
crbaloon_state *state = machine->driver_data<crbaloon_state>();
int y;
UINT8 code = crbaloon_spriteram[0] & 0x0f;
UINT8 color = crbaloon_spriteram[0] >> 4;
UINT8 sy = crbaloon_spriteram[2] - 32;
UINT8 code = state->spriteram[0] & 0x0f;
UINT8 color = state->spriteram[0] >> 4;
UINT8 sy = state->spriteram[2] - 32;
UINT8 *gfx = machine->region("gfx2")->base() + (code << 7);
@ -112,13 +110,13 @@ static void draw_sprite_and_check_collision(running_machine *machine, bitmap_t *
sy += 32;
/* assume no collision */
crbaloon_collision_address = 0xffff;
state->collision_address = 0xffff;
for (y = 0x1f; y >= 0; y--)
{
int x;
UINT8 data = 0;
UINT8 sx = crbaloon_spriteram[1];
UINT8 sx = state->spriteram[1];
for (x = 0x1f; x >= 0; x--)
{
@ -136,7 +134,7 @@ static void draw_sprite_and_check_collision(running_machine *machine, bitmap_t *
if (*BITMAP_ADDR16(bitmap, sy, sx) & 0x01)
/* compute the collision address -- the +1 is via observation
of the game code, probably wrong for cocktail mode */
crbaloon_collision_address = ((((sy ^ 0xff) >> 3) << 5) | ((sx ^ 0xff) >> 3)) + 1;
state->collision_address = ((((sy ^ 0xff) >> 3) << 5) | ((sx ^ 0xff) >> 3)) + 1;
*BITMAP_ADDR16(bitmap, sy, sx) = (color << 1) | 1;
}
@ -152,7 +150,8 @@ static void draw_sprite_and_check_collision(running_machine *machine, bitmap_t *
VIDEO_UPDATE( crbaloon )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
crbaloon_state *state = screen->machine->driver_data<crbaloon_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprite_and_check_collision(screen->machine, bitmap);

View File

@ -2,8 +2,6 @@
#include "includes/darkmist.h"
UINT8 *darkmist_scroll;
UINT8 *darkmist_spritebank;
/* vis. flags */
@ -12,7 +10,6 @@ UINT8 *darkmist_spritebank;
#define DISPLAY_BG 4
#define DISPLAY_TXT 16
static tilemap_t *bgtilemap, *fgtilemap, *txtilemap;
static TILE_GET_INFO( get_bgtile_info )
{
@ -122,35 +119,37 @@ static void set_pens(running_machine *machine)
VIDEO_START(darkmist)
{
bgtilemap = tilemap_create( machine, get_bgtile_info,tilemap_scan_rows,16,16,512,64 );
fgtilemap = tilemap_create( machine, get_fgtile_info,tilemap_scan_rows,16,16,64,256 );
txtilemap = tilemap_create( machine, get_txttile_info,tilemap_scan_rows,8,8,32,32 );
tilemap_set_transparent_pen(fgtilemap, 0);
tilemap_set_transparent_pen(txtilemap, 0);
darkmist_state *state = machine->driver_data<darkmist_state>();
state->bgtilemap = tilemap_create( machine, get_bgtile_info,tilemap_scan_rows,16,16,512,64 );
state->fgtilemap = tilemap_create( machine, get_fgtile_info,tilemap_scan_rows,16,16,64,256 );
state->txtilemap = tilemap_create( machine, get_txttile_info,tilemap_scan_rows,8,8,32,32 );
tilemap_set_transparent_pen(state->fgtilemap, 0);
tilemap_set_transparent_pen(state->txtilemap, 0);
}
VIDEO_UPDATE( darkmist)
{
darkmist_state *state = screen->machine->driver_data<darkmist_state>();
UINT8 *spriteram = screen->machine->generic.spriteram.u8;
#define DM_GETSCROLL(n) (((darkmist_scroll[(n)]<<1)&0xff) + ((darkmist_scroll[(n)]&0x80)?1:0) +( ((darkmist_scroll[(n)-1]<<4) | (darkmist_scroll[(n)-1]<<12) )&0xff00))
#define DM_GETSCROLL(n) (((state->scroll[(n)]<<1)&0xff) + ((state->scroll[(n)]&0x80)?1:0) +( ((state->scroll[(n)-1]<<4) | (state->scroll[(n)-1]<<12) )&0xff00))
set_pens(screen->machine);
tilemap_set_scrollx(bgtilemap, 0, DM_GETSCROLL(0x2));
tilemap_set_scrolly(bgtilemap, 0, DM_GETSCROLL(0x6));
tilemap_set_scrollx(fgtilemap, 0, DM_GETSCROLL(0xa));
tilemap_set_scrolly(fgtilemap, 0, DM_GETSCROLL(0xe));
tilemap_set_scrollx(state->bgtilemap, 0, DM_GETSCROLL(0x2));
tilemap_set_scrolly(state->bgtilemap, 0, DM_GETSCROLL(0x6));
tilemap_set_scrollx(state->fgtilemap, 0, DM_GETSCROLL(0xa));
tilemap_set_scrolly(state->fgtilemap, 0, DM_GETSCROLL(0xe));
bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
if(darkmist_hw & DISPLAY_BG)
tilemap_draw(bitmap,cliprect,bgtilemap, 0,0);
if(state->hw & DISPLAY_BG)
tilemap_draw(bitmap,cliprect,state->bgtilemap, 0,0);
if(darkmist_hw & DISPLAY_FG)
tilemap_draw(bitmap,cliprect,fgtilemap, 0,0);
if(state->hw & DISPLAY_FG)
tilemap_draw(bitmap,cliprect,state->fgtilemap, 0,0);
if(darkmist_hw & DISPLAY_SPR)
if(state->hw & DISPLAY_SPR)
{
/*
Sprites
@ -172,7 +171,7 @@ VIDEO_UPDATE( darkmist)
tile=spriteram[i+0];
if(spriteram[i+1]&0x20)
tile += (*darkmist_spritebank << 8);
tile += (*state->spritebank << 8);
palette=((spriteram[i+1])>>1)&0xf;
@ -191,10 +190,10 @@ VIDEO_UPDATE( darkmist)
}
}
if(darkmist_hw & DISPLAY_TXT)
if(state->hw & DISPLAY_TXT)
{
tilemap_mark_all_tiles_dirty(txtilemap);
tilemap_draw(bitmap,cliprect,txtilemap, 0,0);
tilemap_mark_all_tiles_dirty(state->txtilemap);
tilemap_draw(bitmap,cliprect,state->txtilemap, 0,0);
}

View File

@ -12,64 +12,63 @@ Functions to emulate the video hardware of the machine.
#include "includes/exzisus.h"
UINT8 *exzisus_videoram0;
UINT8 *exzisus_videoram1;
UINT8 *exzisus_objectram0;
UINT8 *exzisus_objectram1;
size_t exzisus_objectram_size0;
size_t exzisus_objectram_size1;
/***************************************************************************
Memory handlers
***************************************************************************/
READ8_HANDLER ( exzisus_videoram_0_r )
{
return exzisus_videoram0[offset];
exzisus_state *state = space->machine->driver_data<exzisus_state>();
return state->videoram0[offset];
}
READ8_HANDLER ( exzisus_videoram_1_r )
{
return exzisus_videoram1[offset];
exzisus_state *state = space->machine->driver_data<exzisus_state>();
return state->videoram1[offset];
}
READ8_HANDLER ( exzisus_objectram_0_r )
{
return exzisus_objectram0[offset];
exzisus_state *state = space->machine->driver_data<exzisus_state>();
return state->objectram0[offset];
}
READ8_HANDLER ( exzisus_objectram_1_r )
{
return exzisus_objectram1[offset];
exzisus_state *state = space->machine->driver_data<exzisus_state>();
return state->objectram1[offset];
}
WRITE8_HANDLER( exzisus_videoram_0_w )
{
exzisus_videoram0[offset] = data;
exzisus_state *state = space->machine->driver_data<exzisus_state>();
state->videoram0[offset] = data;
}
WRITE8_HANDLER( exzisus_videoram_1_w )
{
exzisus_videoram1[offset] = data;
exzisus_state *state = space->machine->driver_data<exzisus_state>();
state->videoram1[offset] = data;
}
WRITE8_HANDLER( exzisus_objectram_0_w )
{
exzisus_objectram0[offset] = data;
exzisus_state *state = space->machine->driver_data<exzisus_state>();
state->objectram0[offset] = data;
}
WRITE8_HANDLER( exzisus_objectram_1_w )
{
exzisus_objectram1[offset] = data;
exzisus_state *state = space->machine->driver_data<exzisus_state>();
state->objectram1[offset] = data;
}
@ -79,6 +78,7 @@ WRITE8_HANDLER( exzisus_objectram_1_w )
VIDEO_UPDATE( exzisus )
{
exzisus_state *state = screen->machine->driver_data<exzisus_state>();
int offs;
int sx, sy, xc, yc;
int gfx_num, gfx_attr, gfx_offs;
@ -88,25 +88,25 @@ VIDEO_UPDATE( exzisus )
/* ---------- 1st TC0010VCU ---------- */
sx = 0;
for (offs = 0 ; offs < exzisus_objectram_size0 ; offs += 4)
for (offs = 0 ; offs < state->objectram_size0 ; offs += 4)
{
int height;
/* Skip empty sprites. */
if ( !(*(UINT32 *)(&exzisus_objectram0[offs])) )
if ( !(*(UINT32 *)(&state->objectram0[offs])) )
{
continue;
}
gfx_num = exzisus_objectram0[offs + 1];
gfx_attr = exzisus_objectram0[offs + 3];
gfx_num = state->objectram0[offs + 1];
gfx_attr = state->objectram0[offs + 3];
if ((gfx_num & 0x80) == 0) /* 16x16 sprites */
{
gfx_offs = ((gfx_num & 0x7f) << 3);
height = 2;
sx = exzisus_objectram0[offs + 2];
sx = state->objectram0[offs + 2];
sx |= (gfx_attr & 0x40) << 2;
}
else /* tilemaps (each sprite is a 16x256 column) */
@ -120,12 +120,12 @@ VIDEO_UPDATE( exzisus )
}
else
{
sx = exzisus_objectram0[offs + 2];
sx = state->objectram0[offs + 2];
sx |= (gfx_attr & 0x40) << 2;
}
}
sy = 256 - (height << 3) - (exzisus_objectram0[offs]);
sy = 256 - (height << 3) - (state->objectram0[offs]);
for (xc = 0 ; xc < 2 ; xc++)
{
@ -134,8 +134,8 @@ VIDEO_UPDATE( exzisus )
{
int code, color, x, y;
code = (exzisus_videoram0[goffs + 1] << 8) | exzisus_videoram0[goffs];
color = (exzisus_videoram0[goffs + 1] >> 6) | (gfx_attr & 0x0f);
code = (state->videoram0[goffs + 1] << 8) | state->videoram0[goffs];
color = (state->videoram0[goffs + 1] >> 6) | (gfx_attr & 0x0f);
x = (sx + (xc << 3)) & 0xff;
y = (sy + (yc << 3)) & 0xff;
@ -158,25 +158,25 @@ VIDEO_UPDATE( exzisus )
/* ---------- 2nd TC0010VCU ---------- */
sx = 0;
for (offs = 0 ; offs < exzisus_objectram_size1 ; offs += 4)
for (offs = 0 ; offs < state->objectram_size1 ; offs += 4)
{
int height;
/* Skip empty sprites. */
if ( !(*(UINT32 *)(&exzisus_objectram1[offs])) )
if ( !(*(UINT32 *)(&state->objectram1[offs])) )
{
continue;
}
gfx_num = exzisus_objectram1[offs + 1];
gfx_attr = exzisus_objectram1[offs + 3];
gfx_num = state->objectram1[offs + 1];
gfx_attr = state->objectram1[offs + 3];
if ((gfx_num & 0x80) == 0) /* 16x16 sprites */
{
gfx_offs = ((gfx_num & 0x7f) << 3);
height = 2;
sx = exzisus_objectram1[offs + 2];
sx = state->objectram1[offs + 2];
sx |= (gfx_attr & 0x40) << 2;
}
else /* tilemaps (each sprite is a 16x256 column) */
@ -190,11 +190,11 @@ VIDEO_UPDATE( exzisus )
}
else
{
sx = exzisus_objectram1[offs + 2];
sx = state->objectram1[offs + 2];
sx |= (gfx_attr & 0x40) << 2;
}
}
sy = 256 - (height << 3) - (exzisus_objectram1[offs]);
sy = 256 - (height << 3) - (state->objectram1[offs]);
for (xc = 0 ; xc < 2 ; xc++)
{
@ -203,8 +203,8 @@ VIDEO_UPDATE( exzisus )
{
int code, color, x, y;
code = (exzisus_videoram1[goffs + 1] << 8) | exzisus_videoram1[goffs];
color = (exzisus_videoram1[goffs + 1] >> 6) | (gfx_attr & 0x0f);
code = (state->videoram1[goffs + 1] << 8) | state->videoram1[goffs];
color = (state->videoram1[goffs + 1] >> 6) | (gfx_attr & 0x0f);
x = (sx + (xc << 3)) & 0xff;
y = (sy + (yc << 3)) & 0xff;

View File

@ -6,21 +6,6 @@
#define X_OFFSET 96
#define Y_OFFSET 60
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int primask;
};
static struct tempsprite *spritelist;
static bitmap_t *tmpbitmaps;
static bitmap_t *polybitmap;
static poly_manager *poly;
INT16 galastrm_tc0610_ctrl_reg[2][8];
typedef struct _poly_extra_data poly_extra_data;
struct _poly_extra_data
{
@ -39,17 +24,19 @@ struct _polygon
static void galastrm_exit(running_machine &machine)
{
poly_free(poly);
galastrm_state *state = machine.driver_data<galastrm_state>();
poly_free(state->poly);
}
VIDEO_START( galastrm )
{
spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
galastrm_state *state = machine->driver_data<galastrm_state>();
state->spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
tmpbitmaps = machine->primary_screen->alloc_compatible_bitmap();
polybitmap = machine->primary_screen->alloc_compatible_bitmap();
state->tmpbitmaps = machine->primary_screen->alloc_compatible_bitmap();
state->polybitmap = machine->primary_screen->alloc_compatible_bitmap();
poly = poly_alloc(machine, 16, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS);
state->poly = poly_alloc(machine, 16, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS);
machine->add_notifier(MACHINE_NOTIFY_EXIT, galastrm_exit);
}
@ -99,10 +86,9 @@ Heavy use is made of sprite zooming.
********************************************************/
static struct tempsprite *sprite_ptr_pre;
static void draw_sprites_pre(running_machine *machine, int x_offs, int y_offs)
{
galastrm_state *state = machine->driver_data<galastrm_state>();
UINT32 *spriteram32 = machine->generic.spriteram.u32;
UINT16 *spritemap = (UINT16 *)machine->region("user1")->base();
int offs, data, tilenum, color, flipx, flipy;
@ -114,7 +100,7 @@ static void draw_sprites_pre(running_machine *machine, int x_offs, int y_offs)
/* pdrawgfx() needs us to draw sprites front to back, so we have to build a list
while processing sprite ram and then draw them all at the end */
sprite_ptr_pre = spritelist;
state->sprite_ptr_pre = state->spritelist;
for (offs = (machine->generic.spriteram_size/4-4);offs >= 0;offs -= 4)
{
@ -189,18 +175,18 @@ static void draw_sprites_pre(running_machine *machine, int x_offs, int y_offs)
flipy = !flipy;
}
sprite_ptr_pre->gfx = 0;
sprite_ptr_pre->code = code;
sprite_ptr_pre->color = color;
sprite_ptr_pre->flipx = !flipx;
sprite_ptr_pre->flipy = flipy;
sprite_ptr_pre->x = curx;
sprite_ptr_pre->y = cury;
sprite_ptr_pre->zoomx = zx << 12;
sprite_ptr_pre->zoomy = zy << 12;
sprite_ptr_pre->primask = priority;
state->sprite_ptr_pre->gfx = 0;
state->sprite_ptr_pre->code = code;
state->sprite_ptr_pre->color = color;
state->sprite_ptr_pre->flipx = !flipx;
state->sprite_ptr_pre->flipy = flipy;
state->sprite_ptr_pre->x = curx;
state->sprite_ptr_pre->y = cury;
state->sprite_ptr_pre->zoomx = zx << 12;
state->sprite_ptr_pre->zoomy = zy << 12;
state->sprite_ptr_pre->primask = priority;
sprite_ptr_pre++;
state->sprite_ptr_pre++;
}
if (bad_chunks)
logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
@ -209,9 +195,10 @@ logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const int *primasks, int priority)
{
struct tempsprite *sprite_ptr = sprite_ptr_pre;
galastrm_state *state = machine->driver_data<galastrm_state>();
struct tempsprite *sprite_ptr = state->sprite_ptr_pre;
while (sprite_ptr != spritelist)
while (sprite_ptr != state->spritelist)
{
sprite_ptr--;
@ -257,19 +244,19 @@ static void tc0610_draw_scanline(void *dest, INT32 scanline, const poly_extent *
static void tc0610_rotate_draw(running_machine *machine, bitmap_t *bitmap, bitmap_t *srcbitmap, const rectangle *clip)
{
poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(poly);
galastrm_state *state = machine->driver_data<galastrm_state>();
poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(state->poly);
poly_draw_scanline_func callback;
poly_vertex vert[4];
int rsx = galastrm_tc0610_ctrl_reg[1][0];
int rsy = galastrm_tc0610_ctrl_reg[1][1];
const int rzx = galastrm_tc0610_ctrl_reg[1][2];
const int rzy = galastrm_tc0610_ctrl_reg[1][3];
const int ryx = galastrm_tc0610_ctrl_reg[1][5];
const int ryy = galastrm_tc0610_ctrl_reg[1][4];
int rsx = state->tc0610_ctrl_reg[1][0];
int rsy = state->tc0610_ctrl_reg[1][1];
const int rzx = state->tc0610_ctrl_reg[1][2];
const int rzy = state->tc0610_ctrl_reg[1][3];
const int ryx = state->tc0610_ctrl_reg[1][5];
const int ryy = state->tc0610_ctrl_reg[1][4];
const int lx = srcbitmap->width;
const int ly = srcbitmap->height;
static int rsxb=0, rsyb=0, rsxoffs=0, rsyoffs=0;
int yx, /*yy,*/ zx, zy, pxx, pxy, pyx, pyy;
float /*ssn, scs, ysn, ycs,*/ zsn, zcs;
@ -300,48 +287,48 @@ static void tc0610_rotate_draw(running_machine *machine, bitmap_t *bitmap, bitma
zcs = ((float)pxx/4096.0) / (float)(lx / 2);
if ((rsx == -240 && rsy == 1072) || !galastrm_tc0610_ctrl_reg[1][7])
if ((rsx == -240 && rsy == 1072) || !state->tc0610_ctrl_reg[1][7])
{
rsxoffs = 0;
rsyoffs = 0;
state->rsxoffs = 0;
state->rsyoffs = 0;
}
else
{
if (rsx > rsxb && rsxb < 0 && rsx-rsxb > 0x8000)
if (rsx > state->rsxb && state->rsxb < 0 && rsx-state->rsxb > 0x8000)
{
if (rsxoffs == 0)
rsxoffs = -0x10000;
if (state->rsxoffs == 0)
state->rsxoffs = -0x10000;
else
rsxoffs = 0;
state->rsxoffs = 0;
}
if (rsx < rsxb && rsxb > 0 && rsxb-rsx > 0x8000)
if (rsx < state->rsxb && state->rsxb > 0 && state->rsxb-rsx > 0x8000)
{
if (rsxoffs == 0)
rsxoffs = 0x10000-1;
if (state->rsxoffs == 0)
state->rsxoffs = 0x10000-1;
else
rsxoffs = 0;
state->rsxoffs = 0;
}
if (rsy > rsyb && rsyb < 0 && rsy-rsyb > 0x8000)
if (rsy > state->rsyb && state->rsyb < 0 && rsy-state->rsyb > 0x8000)
{
if (rsyoffs == 0)
rsyoffs = -0x10000;
if (state->rsyoffs == 0)
state->rsyoffs = -0x10000;
else
rsyoffs = 0;
state->rsyoffs = 0;
}
if (rsy < rsyb && rsyb > 0 && rsyb-rsy > 0x8000)
if (rsy < state->rsyb && state->rsyb > 0 && state->rsyb-rsy > 0x8000)
{
if (rsyoffs == 0)
rsyoffs = 0x10000-1;
if (state->rsyoffs == 0)
state->rsyoffs = 0x10000-1;
else
rsyoffs = 0;
state->rsyoffs = 0;
}
}
rsxb = rsx;
rsyb = rsy;
if (rsxoffs) rsx += rsxoffs;
if (rsyoffs) rsy += rsyoffs;
if (rsx < -0x14000 || rsx >= 0x14000) rsxoffs = 0;
if (rsy < -0x14000 || rsy >= 0x14000) rsyoffs = 0;
state->rsxb = rsx;
state->rsyb = rsy;
if (state->rsxoffs) rsx += state->rsxoffs;
if (state->rsyoffs) rsy += state->rsyoffs;
if (rsx < -0x14000 || rsx >= 0x14000) state->rsxoffs = 0;
if (rsy < -0x14000 || rsy >= 0x14000) state->rsyoffs = 0;
pxx = 0;
@ -355,7 +342,7 @@ static void tc0610_rotate_draw(running_machine *machine, bitmap_t *bitmap, bitma
//ysn = 0.0;
//ycs = 0.0;
if (galastrm_tc0610_ctrl_reg[1][7])
if (state->tc0610_ctrl_reg[1][7])
{
if (ryx != 0 || ryy != 0)
@ -441,7 +428,7 @@ static void tc0610_rotate_draw(running_machine *machine, bitmap_t *bitmap, bitma
extra->texbase = srcbitmap;
callback = tc0610_draw_scanline;
poly_render_quad(poly, bitmap, clip, callback, 2, &vert[0], &vert[1], &vert[2], &vert[3]);
poly_render_quad(state->poly, bitmap, clip, callback, 2, &vert[0], &vert[1], &vert[2], &vert[3]);
}
/**************************************************************
@ -450,6 +437,7 @@ static void tc0610_rotate_draw(running_machine *machine, bitmap_t *bitmap, bitma
VIDEO_UPDATE( galastrm )
{
galastrm_state *state = screen->machine->driver_data<galastrm_state>();
device_t *tc0100scn = screen->machine->device("tc0100scn");
device_t *tc0480scp = screen->machine->device("tc0480scp");
UINT8 layer[5];
@ -480,7 +468,7 @@ VIDEO_UPDATE( galastrm )
bitmap_fill(bitmap, cliprect, 0);
bitmap_fill(priority_bitmap, &clip, 0);
bitmap_fill(tmpbitmaps, &clip, 0);
bitmap_fill(state->tmpbitmaps, &clip, 0);
tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, pivlayer[0], 0, 0);
tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, pivlayer[1], 0, 0);
@ -488,17 +476,17 @@ VIDEO_UPDATE( galastrm )
#if 0
if (layer[0]==0 && layer[1]==3 && layer[2]==2 && layer[3]==1)
{
if (!input_code_pressed(screen->machine, KEYCODE_Z)) tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[0], 0, 1);
if (!input_code_pressed(screen->machine, KEYCODE_X)) tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[1], 0, 4);
if (!input_code_pressed(screen->machine, KEYCODE_C)) tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[2], 0, 4);
if (!input_code_pressed(screen->machine, KEYCODE_V)) tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[3], 0, 4);
if (!input_code_pressed(screen->machine, KEYCODE_Z)) tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[0], 0, 1);
if (!input_code_pressed(screen->machine, KEYCODE_X)) tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[1], 0, 4);
if (!input_code_pressed(screen->machine, KEYCODE_C)) tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[2], 0, 4);
if (!input_code_pressed(screen->machine, KEYCODE_V)) tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[3], 0, 4);
}
else
{
if (!input_code_pressed(screen->machine, KEYCODE_Z)) tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[0], 0, 1);
if (!input_code_pressed(screen->machine, KEYCODE_X)) tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[1], 0, 2);
if (!input_code_pressed(screen->machine, KEYCODE_C)) tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[2], 0, 4);
if (!input_code_pressed(screen->machine, KEYCODE_V)) tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[3], 0, 8);
if (!input_code_pressed(screen->machine, KEYCODE_Z)) tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[0], 0, 1);
if (!input_code_pressed(screen->machine, KEYCODE_X)) tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[1], 0, 2);
if (!input_code_pressed(screen->machine, KEYCODE_C)) tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[2], 0, 4);
if (!input_code_pressed(screen->machine, KEYCODE_V)) tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[3], 0, 8);
}
if (layer[0]==3 && layer[1]==0 && layer[2]==1 && layer[3]==2)
@ -511,18 +499,18 @@ VIDEO_UPDATE( galastrm )
for (x=0; x < priority_bitmap->width; x++)
{
pri = BITMAP_ADDR8(priority_bitmap, y, x);
if (!(*pri & 0x02) && *BITMAP_ADDR16(tmpbitmaps, y, x))
if (!(*pri & 0x02) && *BITMAP_ADDR16(state->tmpbitmaps, y, x))
*pri |= 0x04;
}
}
}
draw_sprites_pre(screen->machine, 42-X_OFFSET, -571+Y_OFFSET);
draw_sprites(screen->machine,tmpbitmaps,&clip,primasks,1);
draw_sprites(screen->machine,state->tmpbitmaps,&clip,primasks,1);
copybitmap_trans(bitmap,polybitmap,0,0, 0,0,cliprect,0);
bitmap_fill(polybitmap, &clip, 0);
tc0610_rotate_draw(screen->machine,polybitmap,tmpbitmaps,cliprect);
copybitmap_trans(bitmap,state->polybitmap,0,0, 0,0,cliprect,0);
bitmap_fill(state->polybitmap, &clip, 0);
tc0610_rotate_draw(screen->machine,state->polybitmap,state->tmpbitmaps,cliprect);
bitmap_fill(priority_bitmap, cliprect, 0);
draw_sprites(screen->machine,bitmap,cliprect,primasks,0);
@ -535,17 +523,17 @@ VIDEO_UPDATE( galastrm )
#else
if (layer[0]==0 && layer[1]==3 && layer[2]==2 && layer[3]==1)
{
tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[0], 0, 1);
tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[1], 0, 4);
tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[2], 0, 4);
tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[3], 0, 4);
tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[0], 0, 1);
tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[1], 0, 4);
tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[2], 0, 4);
tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[3], 0, 4);
}
else
{
tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[0], 0, 1);
tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[1], 0, 2);
tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[2], 0, 4);
tc0480scp_tilemap_draw(tc0480scp, tmpbitmaps, &clip, layer[3], 0, 8);
tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[0], 0, 1);
tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[1], 0, 2);
tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[2], 0, 4);
tc0480scp_tilemap_draw(tc0480scp, state->tmpbitmaps, &clip, layer[3], 0, 8);
}
if (layer[0]==3 && layer[1]==0 && layer[2]==1 && layer[3]==2)
@ -558,18 +546,18 @@ VIDEO_UPDATE( galastrm )
for (x=0; x < priority_bitmap->width; x++)
{
pri = BITMAP_ADDR8(priority_bitmap, y, x);
if (!(*pri & 0x02) && *BITMAP_ADDR16(tmpbitmaps, y, x))
if (!(*pri & 0x02) && *BITMAP_ADDR16(state->tmpbitmaps, y, x))
*pri |= 0x04;
}
}
}
draw_sprites_pre(screen->machine, 42-X_OFFSET, -571+Y_OFFSET);
draw_sprites(screen->machine,tmpbitmaps,&clip,primasks,1);
draw_sprites(screen->machine,state->tmpbitmaps,&clip,primasks,1);
copybitmap_trans(bitmap,polybitmap,0,0, 0,0,cliprect,0);
bitmap_fill(polybitmap, &clip, 0);
tc0610_rotate_draw(screen->machine,polybitmap,tmpbitmaps,cliprect);
copybitmap_trans(bitmap,state->polybitmap,0,0, 0,0,cliprect,0);
bitmap_fill(state->polybitmap, &clip, 0);
tc0610_rotate_draw(screen->machine,state->polybitmap,state->tmpbitmaps,cliprect);
bitmap_fill(priority_bitmap, cliprect, 0);
draw_sprites(screen->machine,bitmap,cliprect,primasks,0);

View File

@ -7,16 +7,6 @@
#include "emu.h"
#include "includes/gladiatr.h"
UINT8 *gladiatr_videoram, *gladiatr_colorram, *gladiatr_textram;
static int video_attributes;
static int fg_scrollx, fg_scrolly, bg_scrollx, bg_scrolly;
static int sprite_bank, sprite_buffer;
static tilemap_t *fg_tilemap, *bg_tilemap;
static int fg_tile_bank, bg_tile_bank;
/***************************************************************************
@ -26,20 +16,22 @@ static int fg_tile_bank, bg_tile_bank;
static TILE_GET_INFO( bg_get_tile_info )
{
UINT8 attr = gladiatr_colorram[tile_index];
gladiatr_state *state = machine->driver_data<gladiatr_state>();
UINT8 attr = state->colorram[tile_index];
SET_TILE_INFO(
1,
gladiatr_videoram[tile_index] + ((attr & 0x07) << 8) + (bg_tile_bank << 11),
state->videoram[tile_index] + ((attr & 0x07) << 8) + (state->bg_tile_bank << 11),
(attr >> 3) ^ 0x1f,
0);
}
static TILE_GET_INFO( fg_get_tile_info )
{
gladiatr_state *state = machine->driver_data<gladiatr_state>();
SET_TILE_INFO(
0,
gladiatr_textram[tile_index] + (fg_tile_bank << 8),
state->textram[tile_index] + (state->fg_tile_bank << 8),
0,
0);
}
@ -54,27 +46,29 @@ static TILE_GET_INFO( fg_get_tile_info )
VIDEO_START( ppking )
{
bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan_rows,8,8,32,64);
fg_tilemap = tilemap_create(machine, fg_get_tile_info,tilemap_scan_rows,8,8,32,64);
gladiatr_state *state = machine->driver_data<gladiatr_state>();
state->bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan_rows,8,8,32,64);
state->fg_tilemap = tilemap_create(machine, fg_get_tile_info,tilemap_scan_rows,8,8,32,64);
tilemap_set_transparent_pen(fg_tilemap,0);
tilemap_set_transparent_pen(state->fg_tilemap,0);
tilemap_set_scroll_cols(bg_tilemap, 0x10);
tilemap_set_scroll_cols(state->bg_tilemap, 0x10);
sprite_bank = 1;
state->sprite_bank = 1;
}
VIDEO_START( gladiatr )
{
bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan_rows,8,8,64,32);
fg_tilemap = tilemap_create(machine, fg_get_tile_info,tilemap_scan_rows,8,8,64,32);
gladiatr_state *state = machine->driver_data<gladiatr_state>();
state->bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan_rows,8,8,64,32);
state->fg_tilemap = tilemap_create(machine, fg_get_tile_info,tilemap_scan_rows,8,8,64,32);
tilemap_set_transparent_pen(fg_tilemap,0);
tilemap_set_transparent_pen(state->fg_tilemap,0);
tilemap_set_scrolldx(bg_tilemap, -0x30, 0x12f);
tilemap_set_scrolldx(fg_tilemap, -0x30, 0x12f);
tilemap_set_scrolldx(state->bg_tilemap, -0x30, 0x12f);
tilemap_set_scrolldx(state->fg_tilemap, -0x30, 0x12f);
sprite_bank = 2;
state->sprite_bank = 2;
}
@ -87,20 +81,23 @@ VIDEO_START( gladiatr )
WRITE8_HANDLER( gladiatr_videoram_w )
{
gladiatr_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset);
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap,offset);
}
WRITE8_HANDLER( gladiatr_colorram_w )
{
gladiatr_colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset);
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap,offset);
}
WRITE8_HANDLER( gladiatr_textram_w )
{
gladiatr_textram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap,offset);
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
state->textram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap,offset);
}
WRITE8_HANDLER( gladiatr_paletteram_w )
@ -124,69 +121,73 @@ WRITE8_HANDLER( gladiatr_paletteram_w )
WRITE8_HANDLER( gladiatr_spritebuffer_w )
{
sprite_buffer = data & 1;
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
state->sprite_buffer = data & 1;
}
WRITE8_HANDLER( gladiatr_spritebank_w )
{
sprite_bank = (data & 1) ? 4 : 2;
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
state->sprite_bank = (data & 1) ? 4 : 2;
}
WRITE8_HANDLER( ppking_video_registers_w )
{
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
switch (offset & 0x300)
{
case 0x000:
tilemap_set_scrolly(bg_tilemap, offset & 0x0f, 0x100-data);
tilemap_set_scrolly(state->bg_tilemap, offset & 0x0f, 0x100-data);
break;
case 0x200:
if (data & 0x80)
fg_scrolly = data + 0x100;
state->fg_scrolly = data + 0x100;
else
fg_scrolly = data;
state->fg_scrolly = data;
break;
case 0x300:
if (fg_tile_bank != (data & 0x03))
if (state->fg_tile_bank != (data & 0x03))
{
fg_tile_bank = data & 0x03;
tilemap_mark_all_tiles_dirty(fg_tilemap);
state->fg_tile_bank = data & 0x03;
tilemap_mark_all_tiles_dirty(state->fg_tilemap);
}
video_attributes = data;
state->video_attributes = data;
break;
}
//popmessage("%02x %02x",fg_scrolly, video_attributes);
//popmessage("%02x %02x",state->fg_scrolly, state->video_attributes);
}
WRITE8_HANDLER( gladiatr_video_registers_w )
{
gladiatr_state *state = space->machine->driver_data<gladiatr_state>();
switch (offset)
{
case 0x000:
fg_scrolly = data;
state->fg_scrolly = data;
break;
case 0x080:
if (fg_tile_bank != (data & 0x03))
if (state->fg_tile_bank != (data & 0x03))
{
fg_tile_bank = data & 0x03;
tilemap_mark_all_tiles_dirty(fg_tilemap);
state->fg_tile_bank = data & 0x03;
tilemap_mark_all_tiles_dirty(state->fg_tilemap);
}
if (bg_tile_bank != ((data & 0x10) >> 4))
if (state->bg_tile_bank != ((data & 0x10) >> 4))
{
bg_tile_bank = (data & 0x10) >> 4;
tilemap_mark_all_tiles_dirty(bg_tilemap);
state->bg_tile_bank = (data & 0x10) >> 4;
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
video_attributes = data;
state->video_attributes = data;
break;
case 0x100:
fg_scrollx = data;
state->fg_scrollx = data;
break;
case 0x200:
bg_scrolly = data;
state->bg_scrolly = data;
break;
case 0x300:
bg_scrollx = data;
state->bg_scrollx = data;
break;
}
}
@ -201,6 +202,7 @@ WRITE8_HANDLER( gladiatr_video_registers_w )
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
gladiatr_state *state = machine->driver_data<gladiatr_state>();
int offs;
for (offs = 0;offs < 0x80;offs += 2)
@ -210,10 +212,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
{0x0,0x1},
{0x2,0x3},
};
UINT8 *src = &machine->generic.spriteram.u8[offs + (sprite_buffer << 7)];
UINT8 *src = &machine->generic.spriteram.u8[offs + (state->sprite_buffer << 7)];
int attributes = src[0x800];
int size = (attributes & 0x10) >> 4;
int bank = (attributes & 0x01) + ((attributes & 0x02) ? sprite_bank : 0);
int bank = (attributes & 0x01) + ((attributes & 0x02) ? state->sprite_bank : 0);
int tile_number = (src[0]+256*bank);
int sx = src[0x400+1] + 256*(src[0x801]&1) - 0x38;
int sy = 240 - src[0x400] - (size ? 16 : 0);
@ -251,7 +253,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( ppking )
{
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
gladiatr_state *state = screen->machine->driver_data<gladiatr_state>();
tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
draw_sprites(screen->machine, bitmap,cliprect);
/* the fg layer just selects the upper palette bank on underlying pixels */
@ -260,13 +263,13 @@ VIDEO_UPDATE( ppking )
int sx = cliprect->min_x;
int sy = cliprect->min_y;
tilemap_get_pixmap( fg_tilemap );
flagsbitmap = tilemap_get_flagsmap( fg_tilemap );
tilemap_get_pixmap( state->fg_tilemap );
flagsbitmap = tilemap_get_flagsmap( state->fg_tilemap );
while( sy <= cliprect->max_y )
{
int x = sx;
int y = (sy + fg_scrolly) & 0x1ff;
int y = (sy + state->fg_scrolly) & 0x1ff;
UINT16 *dest = BITMAP_ADDR16(bitmap, sy, sx);
while( x <= cliprect->max_x )
@ -286,22 +289,23 @@ VIDEO_UPDATE( ppking )
VIDEO_UPDATE( gladiatr )
{
if (video_attributes & 0x20)
gladiatr_state *state = screen->machine->driver_data<gladiatr_state>();
if (state->video_attributes & 0x20)
{
int scroll;
scroll = bg_scrollx + ((video_attributes & 0x04) << 6);
tilemap_set_scrollx(bg_tilemap, 0, scroll ^ (flip_screen_get(screen->machine) ? 0x0f : 0));
scroll = fg_scrollx + ((video_attributes & 0x08) << 5);
tilemap_set_scrollx(fg_tilemap, 0, scroll ^ (flip_screen_get(screen->machine) ? 0x0f : 0));
scroll = state->bg_scrollx + ((state->video_attributes & 0x04) << 6);
tilemap_set_scrollx(state->bg_tilemap, 0, scroll ^ (flip_screen_get(screen->machine) ? 0x0f : 0));
scroll = state->fg_scrollx + ((state->video_attributes & 0x08) << 5);
tilemap_set_scrollx(state->fg_tilemap, 0, scroll ^ (flip_screen_get(screen->machine) ? 0x0f : 0));
// always 0 anyway
tilemap_set_scrolly(bg_tilemap, 0, bg_scrolly);
tilemap_set_scrolly(fg_tilemap, 0, fg_scrolly);
tilemap_set_scrolly(state->bg_tilemap, 0, state->bg_scrolly);
tilemap_set_scrolly(state->fg_tilemap, 0, state->fg_scrolly);
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,fg_tilemap,0,0);
tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0);
}
else
bitmap_fill( bitmap, cliprect , get_black_pen(screen->machine));

View File

@ -2,31 +2,18 @@
#include "video/taitoic.h"
#include "includes/groundfx.h"
UINT16 groundfx_rotate_ctrl[8];
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int pri;
};
static struct tempsprite *spritelist;
static rectangle hack_cliprect;
/******************************************************************/
VIDEO_START( groundfx )
{
spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
groundfx_state *state = machine->driver_data<groundfx_state>();
state->spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
/* Hack */
hack_cliprect.min_x = 69;
hack_cliprect.max_x = 250;
hack_cliprect.min_y = 24 + 5;
hack_cliprect.max_y = 24 + 44;
state->hack_cliprect.min_x = 69;
state->hack_cliprect.max_x = 250;
state->hack_cliprect.min_y = 24 + 5;
state->hack_cliprect.max_y = 24 + 44;
}
/***************************************************************
@ -78,6 +65,7 @@ Heavy use is made of sprite zooming.
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int do_hack,int x_offs,int y_offs)
{
groundfx_state *state = machine->driver_data<groundfx_state>();
UINT32 *spriteram32 = machine->generic.spriteram.u32;
UINT16 *spritemap = (UINT16 *)machine->region("user1")->base();
int offs, data, tilenum, color, flipx, flipy;
@ -90,7 +78,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
/* pdrawgfx() needs us to draw sprites front to back, so we have to build a list
while processing sprite ram and then draw them all at the end */
struct tempsprite *sprite_ptr = spritelist;
struct tempsprite *sprite_ptr = state->spritelist;
for (offs = (machine->generic.spriteram_size/4-4);offs >= 0;offs -= 4)
{
@ -186,14 +174,14 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
}
/* this happens only if primsks != NULL */
while (sprite_ptr != spritelist)
while (sprite_ptr != state->spritelist)
{
const rectangle *clipper;
sprite_ptr--;
if (do_hack && sprite_ptr->pri==1 && sprite_ptr->y<100)
clipper=&hack_cliprect;
clipper=&state->hack_cliprect;
else
clipper=cliprect;
@ -213,6 +201,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
VIDEO_UPDATE( groundfx )
{
groundfx_state *state = screen->machine->driver_data<groundfx_state>();
device_t *tc0100scn = screen->machine->device("tc0100scn");
device_t *tc0480scp = screen->machine->device("tc0480scp");
UINT8 layer[5];
@ -266,7 +255,7 @@ VIDEO_UPDATE( groundfx )
//tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, 0, pivlayer[2], 0, 0);
if (tc0480scp_long_r(tc0480scp, 0x20 / 4, 0xffffffff) != 0x240866) /* Stupid hack for start of race */
tc0480scp_tilemap_draw(tc0480scp, bitmap, &hack_cliprect, layer[0], 0, 0);
tc0480scp_tilemap_draw(tc0480scp, bitmap, &state->hack_cliprect, layer[0], 0, 0);
draw_sprites(screen->machine, bitmap, cliprect, 1, 44, -574);
}
else

View File

@ -8,17 +8,6 @@
#include "emu.h"
#include "includes/gsword.h"
size_t gsword_spritexy_size;
//UINT8 *gsword_scrolly_ram;
UINT8 *gsword_spritexy_ram;
UINT8 *gsword_spritetile_ram;
UINT8 *gsword_spriteattrib_ram;
static int charbank, charpalbank, flipscreen;
static tilemap_t *bg_tilemap;
static PALETTE_INIT( common )
{
@ -106,20 +95,22 @@ WRITE8_HANDLER( gsword_videoram_w )
gsword_state *state = space->machine->driver_data<gsword_state>();
UINT8 *videoram = state->videoram;
videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( gsword_charbank_w )
{
if (charbank != data)
gsword_state *state = space->machine->driver_data<gsword_state>();
if (state->charbank != data)
{
charbank = data;
state->charbank = data;
tilemap_mark_all_tiles_dirty_all(space->machine);
}
}
WRITE8_HANDLER( gsword_videoctrl_w )
{
gsword_state *state = space->machine->driver_data<gsword_state>();
if (data & 0x8f)
{
popmessage("videoctrl %02x",data);
@ -127,17 +118,17 @@ WRITE8_HANDLER( gsword_videoctrl_w )
/* bits 5-6 are char palette bank */
if (charpalbank != ((data & 0x60) >> 5))
if (state->charpalbank != ((data & 0x60) >> 5))
{
charpalbank = (data & 0x60) >> 5;
state->charpalbank = (data & 0x60) >> 5;
tilemap_mark_all_tiles_dirty_all(space->machine);
}
/* bit 4 is flip screen */
if (flipscreen != (data & 0x10))
if (state->flipscreen != (data & 0x10))
{
flipscreen = data & 0x10;
state->flipscreen = data & 0x10;
tilemap_mark_all_tiles_dirty_all(space->machine);
}
@ -148,43 +139,46 @@ WRITE8_HANDLER( gsword_videoctrl_w )
WRITE8_HANDLER( gsword_scroll_w )
{
tilemap_set_scrolly(bg_tilemap, 0, data);
gsword_state *state = space->machine->driver_data<gsword_state>();
tilemap_set_scrolly(state->bg_tilemap, 0, data);
}
static TILE_GET_INFO( get_bg_tile_info )
{
gsword_state *state = machine->driver_data<gsword_state>();
UINT8 *videoram = state->videoram;
int code = videoram[tile_index] + ((charbank & 0x03) << 8);
int color = ((code & 0x3c0) >> 6) + 16 * charpalbank;
int flags = flipscreen ? (TILE_FLIPX | TILE_FLIPY) : 0;
int code = videoram[tile_index] + ((state->charbank & 0x03) << 8);
int color = ((code & 0x3c0) >> 6) + 16 * state->charpalbank;
int flags = state->flipscreen ? (TILE_FLIPX | TILE_FLIPY) : 0;
SET_TILE_INFO(0, code, color, flags);
}
VIDEO_START( gsword )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
gsword_state *state = machine->driver_data<gsword_state>();
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
8, 8, 32, 64);
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
gsword_state *state = machine->driver_data<gsword_state>();
int offs;
for (offs = 0; offs < gsword_spritexy_size - 1; offs+=2)
for (offs = 0; offs < state->spritexy_size - 1; offs+=2)
{
int sx,sy,flipx,flipy,spritebank,tile,color;
if (gsword_spritexy_ram[offs]!=0xf1)
if (state->spritexy_ram[offs]!=0xf1)
{
spritebank = 0;
tile = gsword_spritetile_ram[offs];
color = gsword_spritetile_ram[offs+1] & 0x3f;
sy = 241-gsword_spritexy_ram[offs];
sx = gsword_spritexy_ram[offs+1]-56;
flipx = gsword_spriteattrib_ram[offs] & 0x02;
flipy = gsword_spriteattrib_ram[offs] & 0x01;
tile = state->spritetile_ram[offs];
color = state->spritetile_ram[offs+1] & 0x3f;
sy = 241-state->spritexy_ram[offs];
sx = state->spritexy_ram[offs+1]-56;
flipx = state->spriteattrib_ram[offs] & 0x02;
flipy = state->spriteattrib_ram[offs] & 0x01;
// Adjust sprites that should be far far right!
if (sx<0) sx+=256;
@ -196,7 +190,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
tile -= 128;
sy-=16;
}
if (flipscreen)
if (state->flipscreen)
{
flipx = !flipx;
flipy = !flipy;
@ -213,7 +207,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( gsword )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
gsword_state *state = screen->machine->driver_data<gsword_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;
}

View File

@ -2,22 +2,12 @@
#include "video/taitoic.h"
#include "includes/gunbustr.h"
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int primask;
};
static struct tempsprite *spritelist;
/************************************************************/
VIDEO_START( gunbustr )
{
spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
gunbustr_state *state = machine->driver_data<gunbustr_state>();
state->spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
}
/************************************************************
@ -68,6 +58,7 @@ Heavy use is made of sprite zooming.
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,const int *primasks,int x_offs,int y_offs)
{
gunbustr_state *state = machine->driver_data<gunbustr_state>();
UINT32 *spriteram32 = machine->generic.spriteram.u32;
UINT16 *spritemap = (UINT16 *)machine->region("user1")->base();
int offs, data, tilenum, color, flipx, flipy;
@ -79,7 +70,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
/* pdrawgfx() needs us to draw sprites front to back, so we have to build a list
while processing sprite ram and then draw them all at the end */
struct tempsprite *sprite_ptr = spritelist;
struct tempsprite *sprite_ptr = state->spritelist;
for (offs = (machine->generic.spriteram_size/4-4);offs >= 0;offs -= 4)
{
@ -191,7 +182,7 @@ logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
}
/* this happens only if primsks != NULL */
while (sprite_ptr != spritelist)
while (sprite_ptr != state->spritelist)
{
sprite_ptr--;

View File

@ -13,7 +13,10 @@
#include "emu.h"
#include "includes/m10.h"
static UINT32 extyoffs[32 * 8]; // FIXME: this should be moved to m10_state, but backlayout would have problems
static const UINT32 extyoffs[] =
{
STEP256(0, 8)
};
static const gfx_layout backlayout =
@ -103,10 +106,6 @@ INLINE void plot_pixel_m10( running_machine *machine, bitmap_t *bm, int x, int y
VIDEO_START( m10 )
{
m10_state *state = machine->driver_data<m10_state>();
int i;
for (i = 0; i < 32 * 8; i++)
extyoffs[i] = i * 8;
state->tx_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan, 8, 8, 32, 32);
tilemap_set_transparent_pen(state->tx_tilemap, 0);

View File

@ -38,35 +38,19 @@
#include "emu.h"
#include "includes/m107.h"
typedef struct _pf_layer_info pf_layer_info;
struct _pf_layer_info
{
tilemap_t * tmap;
UINT16 vram_base;
UINT16 control[4];
};
static pf_layer_info pf_layer[4];
static UINT16 m107_control[0x10];
static UINT16 *m107_spriteram;
UINT16 *m107_vram_data;
UINT16 m107_raster_irq_position;
UINT8 m107_spritesystem;
UINT8 m107_sprite_display;
/*****************************************************************************/
static TILE_GET_INFO( get_pf_tile_info )
{
m107_state *state = machine->driver_data<m107_state>();
pf_layer_info *layer = (pf_layer_info *)param;
int tile, attrib;
tile_index = 2 * tile_index + layer->vram_base;
attrib = m107_vram_data[tile_index + 1];
tile = m107_vram_data[tile_index] + ((attrib & 0x1000) << 4);
attrib = state->vram_data[tile_index + 1];
tile = state->vram_data[tile_index] + ((attrib & 0x1000) << 4);
SET_TILE_INFO(
0,
@ -82,22 +66,24 @@ static TILE_GET_INFO( get_pf_tile_info )
WRITE16_HANDLER( m107_vram_w )
{
m107_state *state = space->machine->driver_data<m107_state>();
int laynum;
COMBINE_DATA(&m107_vram_data[offset]);
COMBINE_DATA(&state->vram_data[offset]);
for (laynum = 0; laynum < 4; laynum++)
if ((offset & 0x6000) == pf_layer[laynum].vram_base)
tilemap_mark_tile_dirty(pf_layer[laynum].tmap, (offset & 0x1fff) / 2);
if ((offset & 0x6000) == state->pf_layer[laynum].vram_base)
tilemap_mark_tile_dirty(state->pf_layer[laynum].tmap, (offset & 0x1fff) / 2);
}
/*****************************************************************************/
WRITE16_HANDLER( m107_control_w )
{
UINT16 old = m107_control[offset];
m107_state *state = space->machine->driver_data<m107_state>();
UINT16 old = state->control[offset];
pf_layer_info *layer;
COMBINE_DATA(&m107_control[offset]);
COMBINE_DATA(&state->control[offset]);
switch (offset*2)
{
@ -105,20 +91,20 @@ WRITE16_HANDLER( m107_control_w )
case 0x12: /* Playfield 2 */
case 0x14: /* Playfield 3 */
case 0x16: /* Playfield 4 (bottom layer) */
layer = &pf_layer[offset - 0x08];
layer = &state->pf_layer[offset - 0x08];
/* update VRAM base (bits 8-11) */
layer->vram_base = ((m107_control[offset] >> 8) & 15) * 0x800;
layer->vram_base = ((state->control[offset] >> 8) & 15) * 0x800;
/* update enable (bit 7) */
tilemap_set_enable(layer->tmap, (~m107_control[offset] >> 7) & 1);
tilemap_set_enable(layer->tmap, (~state->control[offset] >> 7) & 1);
/* mark everything dirty of the VRAM base changes */
if ((old ^ m107_control[offset]) & 0x0f00)
if ((old ^ state->control[offset]) & 0x0f00)
tilemap_mark_all_tiles_dirty(layer->tmap);
if(m107_control[offset] & 0xf07c)
printf("%04x %02x\n",m107_control[offset],offset*2);
if(state->control[offset] & 0xf07c)
printf("%04x %02x\n",state->control[offset],offset*2);
break;
@ -128,7 +114,7 @@ WRITE16_HANDLER( m107_control_w )
break;
case 0x1e:
m107_raster_irq_position = m107_control[offset] - 128;
state->raster_irq_position = state->control[offset] - 128;
break;
}
}
@ -137,17 +123,18 @@ WRITE16_HANDLER( m107_control_w )
VIDEO_START( m107 )
{
m107_state *state = machine->driver_data<m107_state>();
int laynum;
for (laynum = 0; laynum < 4; laynum++)
{
pf_layer_info *layer = &pf_layer[laynum];
pf_layer_info *layer = &state->pf_layer[laynum];
/* allocate a tilemaps per layer */
layer->tmap = tilemap_create(machine, get_pf_tile_info, tilemap_scan_rows, 8,8, 64,64);
/* set the user data to point to the layer */
tilemap_set_user_data(layer->tmap, &pf_layer[laynum]);
tilemap_set_user_data(layer->tmap, &state->pf_layer[laynum]);
/* set scroll offsets */
tilemap_set_scrolldx(layer->tmap, -3 + 2 * laynum, -3 + 2 * laynum);
@ -158,13 +145,14 @@ VIDEO_START( m107 )
tilemap_set_transparent_pen(layer->tmap, 0);
}
m107_spriteram = auto_alloc_array_clear(machine, UINT16, 0x1000/2);
state->spriteram = auto_alloc_array_clear(machine, UINT16, 0x1000/2);
}
/*****************************************************************************/
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
m107_state *state = machine->driver_data<m107_state>();
int offs;
UINT8 *rom = machine->region("user1")->base();
@ -172,26 +160,26 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
{
int x,y,sprite,colour,fx,fy,y_multi,i,s_ptr,pri_mask;
pri_mask = (!(m107_spriteram[offs+2]&0x80)) ? 2 : 0;
pri_mask = (!(state->spriteram[offs+2]&0x80)) ? 2 : 0;
y=m107_spriteram[offs+0];
x=m107_spriteram[offs+3];
y=state->spriteram[offs+0];
x=state->spriteram[offs+3];
x&=0x1ff;
y&=0x1ff;
if (x==0 || y==0) continue; /* offscreen */
sprite=m107_spriteram[offs+1]&0x7fff;
sprite=state->spriteram[offs+1]&0x7fff;
x = x - 16;
y = 384 - 16 - y;
colour=m107_spriteram[offs+2]&0x7f;
fx=(m107_spriteram[offs+2]>>8)&0x1;
fy=(m107_spriteram[offs+2]>>8)&0x2;
y_multi=(m107_spriteram[offs+0]>>11)&0x3;
colour=state->spriteram[offs+2]&0x7f;
fx=(state->spriteram[offs+2]>>8)&0x1;
fy=(state->spriteram[offs+2]>>8)&0x2;
y_multi=(state->spriteram[offs+0]>>11)&0x3;
if (m107_spritesystem == 0)
if (state->spritesystem == 0)
{
y_multi=1 << y_multi; /* 1, 2, 4 or 8 */
@ -284,8 +272,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
/*****************************************************************************/
static void m107_update_scroll_positions(void)
static void m107_update_scroll_positions(running_machine *machine)
{
m107_state *state = machine->driver_data<m107_state>();
int laynum;
int i;
@ -295,16 +284,16 @@ static void m107_update_scroll_positions(void)
Perhaps 0xdf000 - 0xdffff and bit 2-3 are respectively colscroll and colselect?
*/
for (laynum = 0; laynum < 4; laynum++)
{
pf_layer_info *layer = &pf_layer[laynum];
for (laynum = 0; laynum < 4; laynum++)
{
pf_layer_info *layer = &state->pf_layer[laynum];
int scrolly = m107_control[0 + 2 * laynum];
int scrollx = m107_control[1 + 2 * laynum];
int scrolly = state->control[0 + 2 * laynum];
int scrollx = state->control[1 + 2 * laynum];
if (m107_control[0x08 + laynum] & 0x01) //used by World PK Soccer goal scrolling and Fire Barrel sea wave effect (stage 2) / canyon parallax effect (stage 6)
if (state->control[0x08 + laynum] & 0x01) //used by World PK Soccer goal scrolling and Fire Barrel sea wave effect (stage 2) / canyon parallax effect (stage 6)
{
const UINT16 *scrolldata = m107_vram_data + (0xe000 + 0x200 * laynum) / 2;
const UINT16 *scrolldata = state->vram_data + (0xe000 + 0x200 * laynum) / 2;
tilemap_set_scroll_rows(layer->tmap, 512);
for (i = 0; i < 512; i++)
@ -325,6 +314,7 @@ static void m107_update_scroll_positions(void)
static void m107_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int laynum, int category,int opaque)
{
m107_state *state = machine->driver_data<m107_state>();
int line;
rectangle clip;
const rectangle &visarea = machine->primary_screen->visible_area();
@ -333,29 +323,30 @@ static void m107_tilemap_draw(running_machine *machine, bitmap_t *bitmap, const
clip.min_y = visarea.min_y;
clip.max_y = visarea.max_y;
if (m107_control[0x08 + laynum] & 0x02)
if (state->control[0x08 + laynum] & 0x02)
{
for (line = cliprect->min_y; line <= cliprect->max_y;line++)
{
const UINT16 *scrolldata = m107_vram_data + (0xe800 + 0x200 * laynum) / 2;
const UINT16 *scrolldata = state->vram_data + (0xe800 + 0x200 * laynum) / 2;
clip.min_y = clip.max_y = line;
tilemap_set_scrollx(pf_layer[laynum].tmap,0, m107_control[1 + 2 * laynum]);
tilemap_set_scrolly(pf_layer[laynum].tmap,0, (m107_control[0 + 2 * laynum] + scrolldata[line]));
tilemap_set_scrollx(state->pf_layer[laynum].tmap,0, state->control[1 + 2 * laynum]);
tilemap_set_scrolly(state->pf_layer[laynum].tmap,0, (state->control[0 + 2 * laynum] + scrolldata[line]));
tilemap_draw(bitmap, &clip, pf_layer[laynum].tmap, category | opaque, category);
tilemap_draw(bitmap, &clip, state->pf_layer[laynum].tmap, category | opaque, category);
}
}
else
tilemap_draw(bitmap, cliprect, pf_layer[laynum].tmap, category | opaque, category);
tilemap_draw(bitmap, cliprect, state->pf_layer[laynum].tmap, category | opaque, category);
}
static void m107_screenrefresh(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
m107_state *state = machine->driver_data<m107_state>();
bitmap_fill(machine->priority_bitmap, cliprect, 0);
if ((~m107_control[0x0b] >> 7) & 1)
if ((~state->control[0x0b] >> 7) & 1)
{
m107_tilemap_draw(machine, bitmap, cliprect, 3, 0,0);
m107_tilemap_draw(machine, bitmap, cliprect, 3, 1,0);
@ -364,14 +355,14 @@ static void m107_screenrefresh(running_machine *machine, bitmap_t *bitmap, const
bitmap_fill(bitmap, cliprect, 0);
/* note: the opaque flag is used if layer 3 is disabled, noticeable in World PK Soccer title and gameplay screens */
m107_tilemap_draw(machine, bitmap, cliprect, 2, 0,(((m107_control[0x0b] >> 7) & 1) ? TILEMAP_DRAW_OPAQUE : 0));
m107_tilemap_draw(machine, bitmap, cliprect, 2, 0,(((state->control[0x0b] >> 7) & 1) ? TILEMAP_DRAW_OPAQUE : 0));
m107_tilemap_draw(machine, bitmap, cliprect, 1, 0,0);
m107_tilemap_draw(machine, bitmap, cliprect, 0, 0,0);
m107_tilemap_draw(machine, bitmap, cliprect, 2, 1,0);
m107_tilemap_draw(machine, bitmap, cliprect, 1, 1,0);
m107_tilemap_draw(machine, bitmap, cliprect, 0, 1,0);
if(m107_sprite_display)
if(state->sprite_display)
draw_sprites(machine, bitmap, cliprect);
/* This hardware probably has more priority values - but I haven't found
@ -382,14 +373,15 @@ static void m107_screenrefresh(running_machine *machine, bitmap_t *bitmap, const
WRITE16_HANDLER( m107_spritebuffer_w )
{
m107_state *state = space->machine->driver_data<m107_state>();
if (ACCESSING_BITS_0_7) {
/*
TODO: this register looks a lot more complex than how the game uses it. All of them seems to test various bit combinations during POST.
*/
// logerror("%04x: buffered spriteram\n",cpu_get_pc(space->cpu));
m107_sprite_display = (!(data & 0x1000));
state->sprite_display = (!(data & 0x1000));
memcpy(m107_spriteram,space->machine->generic.spriteram.u16,0x1000);
memcpy(state->spriteram,space->machine->generic.spriteram.u16,0x1000);
}
}
@ -397,7 +389,7 @@ WRITE16_HANDLER( m107_spritebuffer_w )
VIDEO_UPDATE( m107 )
{
m107_update_scroll_positions();
m107_update_scroll_positions(screen->machine);
m107_screenrefresh(screen->machine, bitmap, cliprect);
return 0;
}

View File

@ -4,12 +4,6 @@
UINT16 *m72_videoram1,*m72_videoram2,*majtitle_rowscrollram;
UINT32 m72_raster_irq_position;
static UINT16 *m72_spriteram;
static tilemap_t *fg_tilemap,*bg_tilemap;
static INT32 scrollx1,scrolly1,scrollx2,scrolly2;
static INT32 video_off;
@ -70,27 +64,32 @@ INLINE void rtype2_get_tile_info(running_machine *machine,tile_data *tileinfo,in
static TILE_GET_INFO( m72_get_bg_tile_info )
{
m72_get_tile_info(machine,tileinfo,tile_index,m72_videoram2,2);
m72_state *state = machine->driver_data<m72_state>();
m72_get_tile_info(machine,tileinfo,tile_index,state->videoram2,2);
}
static TILE_GET_INFO( m72_get_fg_tile_info )
{
m72_get_tile_info(machine,tileinfo,tile_index,m72_videoram1,1);
m72_state *state = machine->driver_data<m72_state>();
m72_get_tile_info(machine,tileinfo,tile_index,state->videoram1,1);
}
static TILE_GET_INFO( hharry_get_bg_tile_info )
{
m72_get_tile_info(machine,tileinfo,tile_index,m72_videoram2,1);
m72_state *state = machine->driver_data<m72_state>();
m72_get_tile_info(machine,tileinfo,tile_index,state->videoram2,1);
}
static TILE_GET_INFO( rtype2_get_bg_tile_info )
{
rtype2_get_tile_info(machine,tileinfo,tile_index,m72_videoram2,1);
m72_state *state = machine->driver_data<m72_state>();
rtype2_get_tile_info(machine,tileinfo,tile_index,state->videoram2,1);
}
static TILE_GET_INFO( rtype2_get_fg_tile_info )
{
rtype2_get_tile_info(machine,tileinfo,tile_index,m72_videoram1,1);
m72_state *state = machine->driver_data<m72_state>();
rtype2_get_tile_info(machine,tileinfo,tile_index,state->videoram1,1);
}
@ -109,130 +108,136 @@ static TILEMAP_MAPPER( majtitle_scan_rows )
static void register_savestate(running_machine *machine)
{
state_save_register_global(machine, m72_raster_irq_position);
state_save_register_global(machine, video_off);
state_save_register_global(machine, scrollx1);
state_save_register_global(machine, scrolly1);
state_save_register_global(machine, scrollx2);
state_save_register_global(machine, scrolly2);
state_save_register_global_pointer(machine, m72_spriteram, machine->generic.spriteram_size/2);
m72_state *state = machine->driver_data<m72_state>();
state_save_register_global(machine, state->raster_irq_position);
state_save_register_global(machine, state->video_off);
state_save_register_global(machine, state->scrollx1);
state_save_register_global(machine, state->scrolly1);
state_save_register_global(machine, state->scrollx2);
state_save_register_global(machine, state->scrolly2);
state_save_register_global_pointer(machine, state->spriteram, machine->generic.spriteram_size/2);
}
VIDEO_START( m72 )
{
bg_tilemap = tilemap_create(machine, m72_get_bg_tile_info,tilemap_scan_rows,8,8,64,64);
fg_tilemap = tilemap_create(machine, m72_get_fg_tile_info,tilemap_scan_rows,8,8,64,64);
m72_state *state = machine->driver_data<m72_state>();
state->bg_tilemap = tilemap_create(machine, m72_get_bg_tile_info,tilemap_scan_rows,8,8,64,64);
state->fg_tilemap = tilemap_create(machine, m72_get_fg_tile_info,tilemap_scan_rows,8,8,64,64);
m72_spriteram = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2);
state->spriteram = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2);
tilemap_set_transmask(fg_tilemap,0,0xffff,0x0001);
tilemap_set_transmask(fg_tilemap,1,0x00ff,0xff01);
tilemap_set_transmask(fg_tilemap,2,0x0001,0xffff);
tilemap_set_transmask(state->fg_tilemap,0,0xffff,0x0001);
tilemap_set_transmask(state->fg_tilemap,1,0x00ff,0xff01);
tilemap_set_transmask(state->fg_tilemap,2,0x0001,0xffff);
tilemap_set_transmask(bg_tilemap,0,0xffff,0x0000);
tilemap_set_transmask(bg_tilemap,1,0x00ff,0xff00);
//tilemap_set_transmask(bg_tilemap,2,0x0001,0xfffe);
tilemap_set_transmask(bg_tilemap,2,0x0007,0xfff8);
tilemap_set_transmask(state->bg_tilemap,0,0xffff,0x0000);
tilemap_set_transmask(state->bg_tilemap,1,0x00ff,0xff00);
//tilemap_set_transmask(state->bg_tilemap,2,0x0001,0xfffe);
tilemap_set_transmask(state->bg_tilemap,2,0x0007,0xfff8);
memset(m72_spriteram,0,machine->generic.spriteram_size);
memset(state->spriteram,0,machine->generic.spriteram_size);
tilemap_set_scrolldx(fg_tilemap,0,0);
tilemap_set_scrolldy(fg_tilemap,-128,16);
tilemap_set_scrolldx(state->fg_tilemap,0,0);
tilemap_set_scrolldy(state->fg_tilemap,-128,16);
tilemap_set_scrolldx(bg_tilemap,0,0);
tilemap_set_scrolldy(bg_tilemap,-128,16);
tilemap_set_scrolldx(state->bg_tilemap,0,0);
tilemap_set_scrolldy(state->bg_tilemap,-128,16);
register_savestate(machine);
}
VIDEO_START( rtype2 )
{
bg_tilemap = tilemap_create(machine, rtype2_get_bg_tile_info,tilemap_scan_rows,8,8,64,64);
fg_tilemap = tilemap_create(machine, rtype2_get_fg_tile_info,tilemap_scan_rows,8,8,64,64);
m72_state *state = machine->driver_data<m72_state>();
state->bg_tilemap = tilemap_create(machine, rtype2_get_bg_tile_info,tilemap_scan_rows,8,8,64,64);
state->fg_tilemap = tilemap_create(machine, rtype2_get_fg_tile_info,tilemap_scan_rows,8,8,64,64);
m72_spriteram = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2);
state->spriteram = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2);
tilemap_set_transmask(fg_tilemap,0,0xffff,0x0001);
tilemap_set_transmask(fg_tilemap,1,0x00ff,0xff01);
tilemap_set_transmask(fg_tilemap,2,0x0001,0xffff);
tilemap_set_transmask(state->fg_tilemap,0,0xffff,0x0001);
tilemap_set_transmask(state->fg_tilemap,1,0x00ff,0xff01);
tilemap_set_transmask(state->fg_tilemap,2,0x0001,0xffff);
tilemap_set_transmask(bg_tilemap,0,0xffff,0x0000);
tilemap_set_transmask(bg_tilemap,1,0x00ff,0xff00);
tilemap_set_transmask(bg_tilemap,2,0x0001,0xfffe);
tilemap_set_transmask(state->bg_tilemap,0,0xffff,0x0000);
tilemap_set_transmask(state->bg_tilemap,1,0x00ff,0xff00);
tilemap_set_transmask(state->bg_tilemap,2,0x0001,0xfffe);
memset(m72_spriteram,0,machine->generic.spriteram_size);
memset(state->spriteram,0,machine->generic.spriteram_size);
tilemap_set_scrolldx(fg_tilemap,4,0);
tilemap_set_scrolldy(fg_tilemap,-128,16);
tilemap_set_scrolldx(state->fg_tilemap,4,0);
tilemap_set_scrolldy(state->fg_tilemap,-128,16);
tilemap_set_scrolldx(bg_tilemap,4,0);
tilemap_set_scrolldy(bg_tilemap,-128,16);
tilemap_set_scrolldx(state->bg_tilemap,4,0);
tilemap_set_scrolldy(state->bg_tilemap,-128,16);
register_savestate(machine);
}
VIDEO_START( poundfor )
{
m72_state *state = machine->driver_data<m72_state>();
VIDEO_START_CALL(rtype2);
tilemap_set_scrolldx(fg_tilemap,6,0);
tilemap_set_scrolldx(bg_tilemap,6,0);
tilemap_set_scrolldx(state->fg_tilemap,6,0);
tilemap_set_scrolldx(state->bg_tilemap,6,0);
}
/* Major Title has a larger background RAM, and rowscroll */
VIDEO_START( majtitle )
{
m72_state *state = machine->driver_data<m72_state>();
// The tilemap can be 256x64, but seems to be used at 128x64 (scroll wraparound).
// The layout ramains 256x64, the right half is just not displayed.
// bg_tilemap = tilemap_create(machine, rtype2_get_bg_tile_info,tilemap_scan_rows,8,8,256,64);
bg_tilemap = tilemap_create(machine, rtype2_get_bg_tile_info,majtitle_scan_rows,8,8,128,64);
fg_tilemap = tilemap_create(machine, rtype2_get_fg_tile_info,tilemap_scan_rows,8,8,64,64);
// state->bg_tilemap = tilemap_create(machine, rtype2_get_bg_tile_info,tilemap_scan_rows,8,8,256,64);
state->bg_tilemap = tilemap_create(machine, rtype2_get_bg_tile_info,majtitle_scan_rows,8,8,128,64);
state->fg_tilemap = tilemap_create(machine, rtype2_get_fg_tile_info,tilemap_scan_rows,8,8,64,64);
m72_spriteram = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2);
state->spriteram = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2);
tilemap_set_transmask(fg_tilemap,0,0xffff,0x0001);
tilemap_set_transmask(fg_tilemap,1,0x00ff,0xff01);
tilemap_set_transmask(fg_tilemap,2,0x0001,0xffff);
tilemap_set_transmask(state->fg_tilemap,0,0xffff,0x0001);
tilemap_set_transmask(state->fg_tilemap,1,0x00ff,0xff01);
tilemap_set_transmask(state->fg_tilemap,2,0x0001,0xffff);
tilemap_set_transmask(bg_tilemap,0,0xffff,0x0000);
tilemap_set_transmask(bg_tilemap,1,0x00ff,0xff00);
tilemap_set_transmask(bg_tilemap,2,0x0001,0xfffe);
tilemap_set_transmask(state->bg_tilemap,0,0xffff,0x0000);
tilemap_set_transmask(state->bg_tilemap,1,0x00ff,0xff00);
tilemap_set_transmask(state->bg_tilemap,2,0x0001,0xfffe);
memset(m72_spriteram,0,machine->generic.spriteram_size);
memset(state->spriteram,0,machine->generic.spriteram_size);
tilemap_set_scrolldx(fg_tilemap,4,0);
tilemap_set_scrolldy(fg_tilemap,-128,16);
tilemap_set_scrolldx(state->fg_tilemap,4,0);
tilemap_set_scrolldy(state->fg_tilemap,-128,16);
tilemap_set_scrolldx(bg_tilemap,4,0);
tilemap_set_scrolldy(bg_tilemap,-128,16);
tilemap_set_scrolldx(state->bg_tilemap,4,0);
tilemap_set_scrolldy(state->bg_tilemap,-128,16);
register_savestate(machine);
}
VIDEO_START( hharry )
{
bg_tilemap = tilemap_create(machine, hharry_get_bg_tile_info,tilemap_scan_rows,8,8,64,64);
fg_tilemap = tilemap_create(machine, m72_get_fg_tile_info, tilemap_scan_rows,8,8,64,64);
m72_state *state = machine->driver_data<m72_state>();
state->bg_tilemap = tilemap_create(machine, hharry_get_bg_tile_info,tilemap_scan_rows,8,8,64,64);
state->fg_tilemap = tilemap_create(machine, m72_get_fg_tile_info, tilemap_scan_rows,8,8,64,64);
m72_spriteram = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2);
state->spriteram = auto_alloc_array(machine, UINT16, machine->generic.spriteram_size/2);
tilemap_set_transmask(fg_tilemap,0,0xffff,0x0001);
tilemap_set_transmask(fg_tilemap,1,0x00ff,0xff01);
tilemap_set_transmask(fg_tilemap,2,0x0001,0xffff);
tilemap_set_transmask(state->fg_tilemap,0,0xffff,0x0001);
tilemap_set_transmask(state->fg_tilemap,1,0x00ff,0xff01);
tilemap_set_transmask(state->fg_tilemap,2,0x0001,0xffff);
tilemap_set_transmask(bg_tilemap,0,0xffff,0x0000);
tilemap_set_transmask(bg_tilemap,1,0x00ff,0xff00);
tilemap_set_transmask(bg_tilemap,2,0x0001,0xfffe);
tilemap_set_transmask(state->bg_tilemap,0,0xffff,0x0000);
tilemap_set_transmask(state->bg_tilemap,1,0x00ff,0xff00);
tilemap_set_transmask(state->bg_tilemap,2,0x0001,0xfffe);
memset(m72_spriteram,0,machine->generic.spriteram_size);
memset(state->spriteram,0,machine->generic.spriteram_size);
tilemap_set_scrolldx(fg_tilemap,4,0);
tilemap_set_scrolldy(fg_tilemap,-128,16);
tilemap_set_scrolldx(state->fg_tilemap,4,0);
tilemap_set_scrolldy(state->fg_tilemap,-128,16);
tilemap_set_scrolldx(bg_tilemap,6,0);
tilemap_set_scrolldy(bg_tilemap,-128,16);
tilemap_set_scrolldx(state->bg_tilemap,6,0);
tilemap_set_scrolldy(state->bg_tilemap,-128,16);
register_savestate(machine);
}
@ -295,50 +300,59 @@ WRITE16_HANDLER( m72_palette2_w )
WRITE16_HANDLER( m72_videoram1_w )
{
COMBINE_DATA(&m72_videoram1[offset]);
tilemap_mark_tile_dirty(fg_tilemap,offset/2);
m72_state *state = space->machine->driver_data<m72_state>();
COMBINE_DATA(&state->videoram1[offset]);
tilemap_mark_tile_dirty(state->fg_tilemap,offset/2);
}
WRITE16_HANDLER( m72_videoram2_w )
{
COMBINE_DATA(&m72_videoram2[offset]);
tilemap_mark_tile_dirty(bg_tilemap,offset/2);
m72_state *state = space->machine->driver_data<m72_state>();
COMBINE_DATA(&state->videoram2[offset]);
tilemap_mark_tile_dirty(state->bg_tilemap,offset/2);
}
WRITE16_HANDLER( m72_irq_line_w )
{
COMBINE_DATA(&m72_raster_irq_position);
m72_state *state = space->machine->driver_data<m72_state>();
COMBINE_DATA(&state->raster_irq_position);
}
WRITE16_HANDLER( m72_scrollx1_w )
{
COMBINE_DATA(&scrollx1);
m72_state *state = space->machine->driver_data<m72_state>();
COMBINE_DATA(&state->scrollx1);
}
WRITE16_HANDLER( m72_scrollx2_w )
{
COMBINE_DATA(&scrollx2);
m72_state *state = space->machine->driver_data<m72_state>();
COMBINE_DATA(&state->scrollx2);
}
WRITE16_HANDLER( m72_scrolly1_w )
{
COMBINE_DATA(&scrolly1);
m72_state *state = space->machine->driver_data<m72_state>();
COMBINE_DATA(&state->scrolly1);
}
WRITE16_HANDLER( m72_scrolly2_w )
{
COMBINE_DATA(&scrolly2);
m72_state *state = space->machine->driver_data<m72_state>();
COMBINE_DATA(&state->scrolly2);
}
WRITE16_HANDLER( m72_dmaon_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
if (ACCESSING_BITS_0_7)
memcpy(m72_spriteram,space->machine->generic.spriteram.u16,space->machine->generic.spriteram_size);
memcpy(state->spriteram,space->machine->generic.spriteram.u16,space->machine->generic.spriteram_size);
}
WRITE16_HANDLER( m72_port02_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
if (ACCESSING_BITS_0_7)
{
if (data & 0xe0) logerror("write %02x to port 02\n",data);
@ -351,7 +365,7 @@ WRITE16_HANDLER( m72_port02_w )
flip_screen_set(space->machine, ((data & 0x04) >> 2) ^ ((~input_port_read(space->machine, "DSW") >> 8) & 1));
/* bit 3 is display disable */
video_off = data & 0x08;
state->video_off = data & 0x08;
/* bit 4 resets sound CPU (active low) */
if (data & 0x10)
@ -365,6 +379,7 @@ WRITE16_HANDLER( m72_port02_w )
WRITE16_HANDLER( rtype2_port02_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
if (ACCESSING_BITS_0_7)
{
if (data & 0xe0) logerror("write %02x to port 02\n",data);
@ -377,22 +392,22 @@ WRITE16_HANDLER( rtype2_port02_w )
flip_screen_set(space->machine, ((data & 0x04) >> 2) ^ ((~input_port_read(space->machine, "DSW") >> 8) & 1));
/* bit 3 is display disable */
video_off = data & 0x08;
state->video_off = data & 0x08;
/* other bits unknown */
}
}
static int majtitle_rowscroll;
/* the following is mostly a kludge. This register seems to be used for something else */
WRITE16_HANDLER( majtitle_gfx_ctrl_w )
{
m72_state *state = space->machine->driver_data<m72_state>();
if (ACCESSING_BITS_8_15)
{
if (data & 0xff00) majtitle_rowscroll = 1;
else majtitle_rowscroll = 0;
if (data & 0xff00) state->majtitle_rowscroll = 1;
else state->majtitle_rowscroll = 0;
}
}
@ -405,6 +420,7 @@ WRITE16_HANDLER( majtitle_gfx_ctrl_w )
static void m72_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
{
m72_state *state = machine->driver_data<m72_state>();
int offs;
offs = 0;
@ -413,15 +429,15 @@ static void m72_draw_sprites(running_machine *machine, bitmap_t *bitmap,const re
int code,color,sx,sy,flipx,flipy,w,h,x,y;
code = m72_spriteram[offs+1];
color = m72_spriteram[offs+2] & 0x0f;
sx = -256+(m72_spriteram[offs+3] & 0x3ff);
sy = 384-(m72_spriteram[offs+0] & 0x1ff);
flipx = m72_spriteram[offs+2] & 0x0800;
flipy = m72_spriteram[offs+2] & 0x0400;
code = state->spriteram[offs+1];
color = state->spriteram[offs+2] & 0x0f;
sx = -256+(state->spriteram[offs+3] & 0x3ff);
sy = 384-(state->spriteram[offs+0] & 0x1ff);
flipx = state->spriteram[offs+2] & 0x0800;
flipy = state->spriteram[offs+2] & 0x0400;
w = 1 << ((m72_spriteram[offs+2] & 0xc000) >> 14);
h = 1 << ((m72_spriteram[offs+2] & 0x3000) >> 12);
w = 1 << ((state->spriteram[offs+2] & 0xc000) >> 14);
h = 1 << ((state->spriteram[offs+2] & 0x3000) >> 12);
sy -= 16 * h;
if (flip_screen_get(machine))
@ -507,59 +523,61 @@ static void majtitle_draw_sprites(running_machine *machine, bitmap_t *bitmap,con
VIDEO_UPDATE( m72 )
{
if (video_off)
m72_state *state = screen->machine->driver_data<m72_state>();
if (state->video_off)
{
bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
return 0;
}
tilemap_set_scrollx(fg_tilemap,0,scrollx1);
tilemap_set_scrolly(fg_tilemap,0,scrolly1);
tilemap_set_scrollx(state->fg_tilemap,0,state->scrollx1);
tilemap_set_scrolly(state->fg_tilemap,0,state->scrolly1);
tilemap_set_scrollx(bg_tilemap,0,scrollx2);
tilemap_set_scrolly(bg_tilemap,0,scrolly2);
tilemap_set_scrollx(state->bg_tilemap,0,state->scrollx2);
tilemap_set_scrolly(state->bg_tilemap,0,state->scrolly2);
tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1,0);
tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER1,0);
tilemap_draw(bitmap,cliprect,state->bg_tilemap,TILEMAP_DRAW_LAYER1,0);
tilemap_draw(bitmap,cliprect,state->fg_tilemap,TILEMAP_DRAW_LAYER1,0);
m72_draw_sprites(screen->machine, bitmap,cliprect);
tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0,0);
tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER0,0);
tilemap_draw(bitmap,cliprect,state->bg_tilemap,TILEMAP_DRAW_LAYER0,0);
tilemap_draw(bitmap,cliprect,state->fg_tilemap,TILEMAP_DRAW_LAYER0,0);
return 0;
}
VIDEO_UPDATE( majtitle )
{
m72_state *state = screen->machine->driver_data<m72_state>();
int i;
if (video_off)
if (state->video_off)
{
bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
return 0;
}
tilemap_set_scrollx(fg_tilemap,0,scrollx1);
tilemap_set_scrolly(fg_tilemap,0,scrolly1);
tilemap_set_scrollx(state->fg_tilemap,0,state->scrollx1);
tilemap_set_scrolly(state->fg_tilemap,0,state->scrolly1);
if (majtitle_rowscroll)
if (state->majtitle_rowscroll)
{
tilemap_set_scroll_rows(bg_tilemap,512);
tilemap_set_scroll_rows(state->bg_tilemap,512);
for (i = 0;i < 512;i++)
tilemap_set_scrollx(bg_tilemap,(i+scrolly2)&0x1ff,
256 + majtitle_rowscrollram[i]);
tilemap_set_scrollx(state->bg_tilemap,(i+state->scrolly2)&0x1ff,
256 + state->majtitle_rowscrollram[i]);
}
else
{
tilemap_set_scroll_rows(bg_tilemap,1);
tilemap_set_scrollx(bg_tilemap,0,256 + scrollx2);
tilemap_set_scroll_rows(state->bg_tilemap,1);
tilemap_set_scrollx(state->bg_tilemap,0,256 + state->scrollx2);
}
tilemap_set_scrolly(bg_tilemap,0,scrolly2);
tilemap_set_scrolly(state->bg_tilemap,0,state->scrolly2);
tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1,0);
tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER1,0);
tilemap_draw(bitmap,cliprect,state->bg_tilemap,TILEMAP_DRAW_LAYER1,0);
tilemap_draw(bitmap,cliprect,state->fg_tilemap,TILEMAP_DRAW_LAYER1,0);
majtitle_draw_sprites(screen->machine, bitmap,cliprect);
m72_draw_sprites(screen->machine, bitmap,cliprect);
tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0,0);
tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_LAYER0,0);
tilemap_draw(bitmap,cliprect,state->bg_tilemap,TILEMAP_DRAW_LAYER0,0);
tilemap_draw(bitmap,cliprect,state->fg_tilemap,TILEMAP_DRAW_LAYER0,0);
return 0;
}

View File

@ -42,39 +42,20 @@
#include "emu.h"
#include "includes/m92.h"
typedef struct _pf_layer_info pf_layer_info;
struct _pf_layer_info
{
tilemap_t * tmap;
tilemap_t * wide_tmap;
UINT16 vram_base;
UINT16 control[4];
};
static pf_layer_info pf_layer[3];
static UINT16 pf_master_control[4];
static INT32 m92_sprite_list;
UINT32 m92_raster_irq_position;
UINT16 *m92_vram_data,*m92_spritecontrol;
UINT8 m92_game_kludge;
UINT8 m92_sprite_buffer_busy;
static int m92_palette_bank;
/*****************************************************************************/
static TIMER_CALLBACK( spritebuffer_callback )
{
m92_sprite_buffer_busy = 1;
if (m92_game_kludge!=2) /* Major Title 2 doesn't like this interrupt!? */
m92_state *state = machine->driver_data<m92_state>();
state->sprite_buffer_busy = 1;
if (state->game_kludge!=2) /* Major Title 2 doesn't like this interrupt!? */
m92_sprite_interrupt(machine);
}
WRITE16_HANDLER( m92_spritecontrol_w )
{
COMBINE_DATA(&m92_spritecontrol[offset]);
m92_state *state = space->machine->driver_data<m92_state>();
COMBINE_DATA(&state->spritecontrol[offset]);
/* Sprite list size register - used in spriteroutine */
@ -82,9 +63,9 @@ WRITE16_HANDLER( m92_spritecontrol_w )
if (offset==2 && ACCESSING_BITS_0_7)
{
if ((data & 0xff) == 8)
m92_sprite_list = (((0x100 - m92_spritecontrol[0]) & 0xff) * 4);
state->sprite_list = (((0x100 - state->spritecontrol[0]) & 0xff) * 4);
else
m92_sprite_list = 0x400;
state->sprite_list = 0x400;
/* Bit 0 is also significant */
}
@ -93,7 +74,7 @@ WRITE16_HANDLER( m92_spritecontrol_w )
if (offset==4)
{
buffer_spriteram16_w(space,0,0,0xffff);
m92_sprite_buffer_busy = 0;
state->sprite_buffer_busy = 0;
/* Pixel clock is 26.6666 MHz, we have 0x800 bytes, or 0x400 words
to copy from spriteram to the buffer. It seems safe to assume 1
@ -105,6 +86,7 @@ WRITE16_HANDLER( m92_spritecontrol_w )
WRITE16_HANDLER( m92_videocontrol_w )
{
m92_state *state = space->machine->driver_data<m92_state>();
/*
Many games write:
0x2000
@ -121,31 +103,34 @@ WRITE16_HANDLER( m92_videocontrol_w )
if (ACCESSING_BITS_0_7)
{
/* Access to upper palette bank */
m92_palette_bank = (data >> 1) & 1;
state->palette_bank = (data >> 1) & 1;
}
// logerror("%04x: m92_videocontrol_w %d = %02x\n",cpu_get_pc(space->cpu),offset,data);
}
READ16_HANDLER( m92_paletteram_r )
{
return space->machine->generic.paletteram.u16[offset + 0x400 * m92_palette_bank];
m92_state *state = space->machine->driver_data<m92_state>();
return space->machine->generic.paletteram.u16[offset + 0x400 * state->palette_bank];
}
WRITE16_HANDLER( m92_paletteram_w )
{
paletteram16_xBBBBBGGGGGRRRRR_word_w(space, offset + 0x400 * m92_palette_bank, data, mem_mask);
m92_state *state = space->machine->driver_data<m92_state>();
paletteram16_xBBBBBGGGGGRRRRR_word_w(space, offset + 0x400 * state->palette_bank, data, mem_mask);
}
/*****************************************************************************/
static TILE_GET_INFO( get_pf_tile_info )
{
m92_state *state = machine->driver_data<m92_state>();
pf_layer_info *layer = (pf_layer_info *)param;
int tile, attrib;
tile_index = 2 * tile_index + layer->vram_base;
attrib = m92_vram_data[tile_index + 1];
tile = m92_vram_data[tile_index] + ((attrib & 0x8000) << 1);
attrib = state->vram_data[tile_index + 1];
tile = state->vram_data[tile_index] + ((attrib & 0x8000) << 1);
SET_TILE_INFO(
0,
@ -161,19 +146,20 @@ static TILE_GET_INFO( get_pf_tile_info )
WRITE16_HANDLER( m92_vram_w )
{
m92_state *state = space->machine->driver_data<m92_state>();
int laynum;
COMBINE_DATA(&m92_vram_data[offset]);
COMBINE_DATA(&state->vram_data[offset]);
for (laynum = 0; laynum < 3; laynum++)
{
if ((offset & 0x6000) == pf_layer[laynum].vram_base)
if ((offset & 0x6000) == state->pf_layer[laynum].vram_base)
{
tilemap_mark_tile_dirty(pf_layer[laynum].tmap, (offset & 0x1fff) / 2);
tilemap_mark_tile_dirty(pf_layer[laynum].wide_tmap, (offset & 0x3fff) / 2);
tilemap_mark_tile_dirty(state->pf_layer[laynum].tmap, (offset & 0x1fff) / 2);
tilemap_mark_tile_dirty(state->pf_layer[laynum].wide_tmap, (offset & 0x3fff) / 2);
}
if ((offset & 0x6000) == pf_layer[laynum].vram_base + 0x2000)
tilemap_mark_tile_dirty(pf_layer[laynum].wide_tmap, (offset & 0x3fff) / 2);
if ((offset & 0x6000) == state->pf_layer[laynum].vram_base + 0x2000)
tilemap_mark_tile_dirty(state->pf_layer[laynum].wide_tmap, (offset & 0x3fff) / 2);
}
}
@ -181,50 +167,54 @@ WRITE16_HANDLER( m92_vram_w )
WRITE16_HANDLER( m92_pf1_control_w )
{
COMBINE_DATA(&pf_layer[0].control[offset]);
m92_state *state = space->machine->driver_data<m92_state>();
COMBINE_DATA(&state->pf_layer[0].control[offset]);
}
WRITE16_HANDLER( m92_pf2_control_w )
{
COMBINE_DATA(&pf_layer[1].control[offset]);
m92_state *state = space->machine->driver_data<m92_state>();
COMBINE_DATA(&state->pf_layer[1].control[offset]);
}
WRITE16_HANDLER( m92_pf3_control_w )
{
COMBINE_DATA(&pf_layer[2].control[offset]);
m92_state *state = space->machine->driver_data<m92_state>();
COMBINE_DATA(&state->pf_layer[2].control[offset]);
}
WRITE16_HANDLER( m92_master_control_w )
{
UINT16 old = pf_master_control[offset];
m92_state *state = space->machine->driver_data<m92_state>();
UINT16 old = state->pf_master_control[offset];
pf_layer_info *layer;
COMBINE_DATA(&pf_master_control[offset]);
COMBINE_DATA(&state->pf_master_control[offset]);
switch (offset)
{
case 0: /* Playfield 1 (top layer) */
case 1: /* Playfield 2 (middle layer) */
case 2: /* Playfield 3 (bottom layer) */
layer = &pf_layer[offset];
layer = &state->pf_layer[offset];
/* update VRAM base (bits 0-1) */
layer->vram_base = (pf_master_control[offset] & 3) * 0x2000;
layer->vram_base = (state->pf_master_control[offset] & 3) * 0x2000;
/* update size (bit 2) */
if (pf_master_control[offset] & 0x04)
if (state->pf_master_control[offset] & 0x04)
{
tilemap_set_enable(layer->tmap, FALSE);
tilemap_set_enable(layer->wide_tmap, (~pf_master_control[offset] >> 4) & 1);
tilemap_set_enable(layer->wide_tmap, (~state->pf_master_control[offset] >> 4) & 1);
}
else
{
tilemap_set_enable(layer->tmap, (~pf_master_control[offset] >> 4) & 1);
tilemap_set_enable(layer->tmap, (~state->pf_master_control[offset] >> 4) & 1);
tilemap_set_enable(layer->wide_tmap, FALSE);
}
/* mark everything dirty of the VRAM base or size changes */
if ((old ^ pf_master_control[offset]) & 0x07)
if ((old ^ state->pf_master_control[offset]) & 0x07)
{
tilemap_mark_all_tiles_dirty(layer->tmap);
tilemap_mark_all_tiles_dirty(layer->wide_tmap);
@ -232,7 +222,7 @@ WRITE16_HANDLER( m92_master_control_w )
break;
case 3:
m92_raster_irq_position = pf_master_control[3] - 128;
state->raster_irq_position = state->pf_master_control[3] - 128;
break;
}
}
@ -241,20 +231,21 @@ WRITE16_HANDLER( m92_master_control_w )
VIDEO_START( m92 )
{
m92_state *state = machine->driver_data<m92_state>();
int laynum;
memset(&pf_layer, 0, sizeof(pf_layer));
memset(&state->pf_layer, 0, sizeof(state->pf_layer));
for (laynum = 0; laynum < 3; laynum++)
{
pf_layer_info *layer = &pf_layer[laynum];
pf_layer_info *layer = &state->pf_layer[laynum];
/* allocate two tilemaps per layer, one normal, one wide */
layer->tmap = tilemap_create(machine, get_pf_tile_info, tilemap_scan_rows, 8,8, 64,64);
layer->wide_tmap = tilemap_create(machine, get_pf_tile_info, tilemap_scan_rows, 8,8, 128,64);
/* set the user data for each one to point to the layer */
tilemap_set_user_data(layer->tmap, &pf_layer[laynum]);
tilemap_set_user_data(layer->wide_tmap, &pf_layer[laynum]);
tilemap_set_user_data(layer->tmap, &state->pf_layer[laynum]);
tilemap_set_user_data(layer->wide_tmap, &state->pf_layer[laynum]);
/* set scroll offsets */
tilemap_set_scrolldx(layer->tmap, 2 * laynum, -2 * laynum + 8);
@ -283,12 +274,12 @@ VIDEO_START( m92 )
memset(machine->generic.spriteram.u16,0,0x800);
memset(machine->generic.buffered_spriteram.u16,0,0x800);
state_save_register_global_array(machine, pf_master_control);
state_save_register_global_array(machine, state->pf_master_control);
state_save_register_global(machine, m92_sprite_list);
state_save_register_global(machine, m92_raster_irq_position);
state_save_register_global(machine, m92_sprite_buffer_busy);
state_save_register_global(machine, m92_palette_bank);
state_save_register_global(machine, state->sprite_list);
state_save_register_global(machine, state->raster_irq_position);
state_save_register_global(machine, state->sprite_buffer_busy);
state_save_register_global(machine, state->palette_bank);
state_save_register_global_pointer(machine, machine->generic.paletteram.u16, 0x1000);
}
@ -297,12 +288,13 @@ VIDEO_START( m92 )
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
m92_state *state = machine->driver_data<m92_state>();
UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
int offs,k;
for (k=0; k<8; k++)
{
for (offs = 0; offs < m92_sprite_list; )
for (offs = 0; offs < state->sprite_list; )
{
int x,y,sprite,colour,fx,fy,x_multi,y_multi,i,j,s_ptr,pri_back,pri_sprite;
@ -381,8 +373,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
/*****************************************************************************/
static void m92_update_scroll_positions(void)
static void m92_update_scroll_positions(running_machine *machine)
{
m92_state *state = machine->driver_data<m92_state>();
int laynum;
int i;
@ -399,11 +392,11 @@ static void m92_update_scroll_positions(void)
for (laynum = 0; laynum < 3; laynum++)
{
pf_layer_info *layer = &pf_layer[laynum];
pf_layer_info *layer = &state->pf_layer[laynum];
if (pf_master_control[laynum] & 0x40)
if (state->pf_master_control[laynum] & 0x40)
{
const UINT16 *scrolldata = m92_vram_data + (0xf400 + 0x400 * laynum) / 2;
const UINT16 *scrolldata = state->vram_data + (0xf400 + 0x400 * laynum) / 2;
tilemap_set_scroll_rows(layer->tmap, 512);
tilemap_set_scroll_rows(layer->wide_tmap, 512);
@ -430,27 +423,28 @@ static void m92_update_scroll_positions(void)
static void m92_screenrefresh(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
{
m92_state *state = machine->driver_data<m92_state>();
bitmap_fill(machine->priority_bitmap, cliprect, 0);
if ((~pf_master_control[2] >> 4) & 1)
if ((~state->pf_master_control[2] >> 4) & 1)
{
tilemap_draw(bitmap, cliprect, pf_layer[2].wide_tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, pf_layer[2].tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, pf_layer[2].wide_tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, pf_layer[2].tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, state->pf_layer[2].wide_tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, state->pf_layer[2].tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, state->pf_layer[2].wide_tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, state->pf_layer[2].tmap, TILEMAP_DRAW_LAYER0, 1);
}
else
bitmap_fill(bitmap, cliprect, 0);
tilemap_draw(bitmap, cliprect, pf_layer[1].wide_tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, pf_layer[1].tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, pf_layer[1].wide_tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, pf_layer[1].tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, state->pf_layer[1].wide_tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, state->pf_layer[1].tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, state->pf_layer[1].wide_tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, state->pf_layer[1].tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, pf_layer[0].wide_tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, pf_layer[0].tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, pf_layer[0].wide_tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, pf_layer[0].tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, state->pf_layer[0].wide_tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, state->pf_layer[0].tmap, TILEMAP_DRAW_LAYER1, 0);
tilemap_draw(bitmap, cliprect, state->pf_layer[0].wide_tmap, TILEMAP_DRAW_LAYER0, 1);
tilemap_draw(bitmap, cliprect, state->pf_layer[0].tmap, TILEMAP_DRAW_LAYER0, 1);
draw_sprites(machine, bitmap, cliprect);
}
@ -458,7 +452,7 @@ static void m92_screenrefresh(running_machine *machine, bitmap_t *bitmap,const r
VIDEO_UPDATE( m92 )
{
m92_update_scroll_positions();
m92_update_scroll_positions(screen->machine);
m92_screenrefresh(screen->machine, bitmap, cliprect);
/* Flipscreen appears hardwired to the dipswitch - strange */

View File

@ -10,11 +10,6 @@
#define NYCAPTOR_DEBUG 0
#if NYCAPTOR_DEBUG
static int nycaptor_mask = 0;
#endif
/*
298 (e298) - spot (0-3) , 299 (e299) - lives
spot number isn't set to 0 in main menu ; lives - yes
@ -60,7 +55,7 @@ static TILE_GET_INFO( get_tile_info )
tileinfo->group = 3;
#if NYCAPTOR_DEBUG
if (nycaptor_mask & (1 << tileinfo->category))
if (state->mask & (1 << tileinfo->category))
{
if (nycaptor_spot(machine))
pal = 0xe;
@ -192,7 +187,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect
if (priori == pri)
{
#if NYCAPTOR_DEBUG
if (nycaptor_mask & (1 << (pri + 4))) pal = 0xd;
if (state->mask & (1 << (pri + 4))) pal = 0xd;
#endif
flipx = BIT(state->spriteram[offs + 1], 6);
flipy = BIT(state->spriteram[offs + 1], 7);
@ -229,7 +224,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect
x - no bg/sprite pri.
*/
#define mKEY_MASK(x,y) if (input_code_pressed_once(machine, x)) { nycaptor_mask |= y; tilemap_mark_all_tiles_dirty(state->bg_tilemap);}
#define mKEY_MASK(x,y) if (input_code_pressed_once(machine, x)) { state->mask |= y; tilemap_mark_all_tiles_dirty(state->bg_tilemap); }
static void nycaptor_setmask( running_machine *machine )
{
@ -249,8 +244,8 @@ static void nycaptor_setmask( running_machine *machine )
mKEY_MASK(KEYCODE_J, 0x400);
mKEY_MASK(KEYCODE_K, 0x800);
if (input_code_pressed_once(machine, KEYCODE_Z)){nycaptor_mask = 0; tilemap_mark_all_tiles_dirty(state->bg_tilemap);} /* disable */
if (input_code_pressed_once(machine, KEYCODE_X)){nycaptor_mask |= 0x1000; tilemap_mark_all_tiles_dirty(state->bg_tilemap);} /* no layers */
if (input_code_pressed_once(machine, KEYCODE_Z)){state->mask = 0; tilemap_mark_all_tiles_dirty(state->bg_tilemap);} /* disable */
if (input_code_pressed_once(machine, KEYCODE_X)){state->mask |= 0x1000; tilemap_mark_all_tiles_dirty(state->bg_tilemap);} /* no layers */
}
#endif
@ -260,7 +255,7 @@ VIDEO_UPDATE( nycaptor )
#if NYCAPTOR_DEBUG
nycaptor_setmask(screen->machine);
if (nycaptor_mask & 0x1000)
if (state->mask & 0x1000)
{
tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 3, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 3, 0);

View File

@ -19,15 +19,6 @@ In debug build press 'w' for spotlight and 'e' for lightning
#include "emu.h"
#include "includes/pitnrun.h"
static int pitnrun_h_heed;
static int pitnrun_v_heed;
static int pitnrun_ha;
static int pitnrun_scroll;
static int pitnrun_char_bank;
static int pitnrun_color_select;
static bitmap_t *tmp_bitmap[4];
static tilemap_t *bg, *fg;
UINT8* pitnrun_videoram2;
static TILE_GET_INFO( get_tile_info1 )
@ -45,12 +36,13 @@ static TILE_GET_INFO( get_tile_info1 )
static TILE_GET_INFO( get_tile_info2 )
{
pitnrun_state *state = machine->driver_data<pitnrun_state>();
int code;
code = pitnrun_videoram2[tile_index];
code = state->videoram2[tile_index];
SET_TILE_INFO(
1,
code + (pitnrun_char_bank<<8),
pitnrun_color_select&1,
code + (state->char_bank<<8),
state->color_select&1,
0);
}
@ -59,54 +51,62 @@ WRITE8_HANDLER( pitnrun_videoram_w )
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
UINT8 *videoram = state->videoram;
videoram[offset] = data;
tilemap_mark_all_tiles_dirty( fg );
tilemap_mark_all_tiles_dirty( state->fg );
}
WRITE8_HANDLER( pitnrun_videoram2_w )
{
pitnrun_videoram2[offset] = data;
tilemap_mark_all_tiles_dirty( bg );
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
state->videoram2[offset] = data;
tilemap_mark_all_tiles_dirty( state->bg );
}
WRITE8_HANDLER( pitnrun_char_bank_select )
{
if(pitnrun_char_bank!=data)
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
if(state->char_bank!=data)
{
tilemap_mark_all_tiles_dirty( bg );
pitnrun_char_bank=data;
tilemap_mark_all_tiles_dirty( state->bg );
state->char_bank=data;
}
}
WRITE8_HANDLER( pitnrun_scroll_w )
{
pitnrun_scroll = (pitnrun_scroll & (0xff<<((offset)?0:8))) |( data<<((offset)?8:0));
tilemap_set_scrollx( bg, 0, pitnrun_scroll);
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
state->scroll = (state->scroll & (0xff<<((offset)?0:8))) |( data<<((offset)?8:0));
tilemap_set_scrollx( state->bg, 0, state->scroll);
}
WRITE8_HANDLER(pitnrun_ha_w)
{
pitnrun_ha=data;
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
state->ha=data;
}
WRITE8_HANDLER(pitnrun_h_heed_w)
{
pitnrun_h_heed=data;
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
state->h_heed=data;
}
WRITE8_HANDLER(pitnrun_v_heed_w)
{
pitnrun_v_heed=data;
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
state->v_heed=data;
}
WRITE8_HANDLER(pitnrun_color_select_w)
{
pitnrun_color_select=data;
pitnrun_state *state = space->machine->driver_data<pitnrun_state>();
state->color_select=data;
tilemap_mark_all_tiles_dirty_all(space->machine);
}
static void pitnrun_spotlights(running_machine *machine)
{
pitnrun_state *state = machine->driver_data<pitnrun_state>();
int x,y,i,b,datapix;
UINT8 *ROM = machine->region("user1")->base();
for(i=0;i<4;i++)
@ -116,7 +116,7 @@ static void pitnrun_spotlights(running_machine *machine)
datapix=ROM[128*16*i+x+y*16];
for(b=0;b<8;b++)
{
*BITMAP_ADDR16(tmp_bitmap[i], y, x*8+(7-b)) = (datapix&1);
*BITMAP_ADDR16(state->tmp_bitmap[i], y, x*8+(7-b)) = (datapix&1);
datapix>>=1;
}
}
@ -171,13 +171,14 @@ PALETTE_INIT (pitnrun)
VIDEO_START(pitnrun)
{
fg = tilemap_create( machine, get_tile_info1,tilemap_scan_rows,8,8,32,32 );
bg = tilemap_create( machine, get_tile_info2,tilemap_scan_rows,8,8,32*4,32 );
tilemap_set_transparent_pen( fg, 0 );
tmp_bitmap[0] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format());
tmp_bitmap[1] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format());
tmp_bitmap[2] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format());
tmp_bitmap[3] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format());
pitnrun_state *state = machine->driver_data<pitnrun_state>();
state->fg = tilemap_create( machine, get_tile_info1,tilemap_scan_rows,8,8,32,32 );
state->bg = tilemap_create( machine, get_tile_info2,tilemap_scan_rows,8,8,32*4,32 );
tilemap_set_transparent_pen( state->fg, 0 );
state->tmp_bitmap[0] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format());
state->tmp_bitmap[1] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format());
state->tmp_bitmap[2] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format());
state->tmp_bitmap[3] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format());
pitnrun_spotlights(machine);
}
@ -217,6 +218,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( pitnrun )
{
pitnrun_state *state = screen->machine->driver_data<pitnrun_state>();
int dx=0,dy=0;
rectangle myclip=*cliprect;
@ -243,12 +245,12 @@ VIDEO_UPDATE( pitnrun )
bitmap_fill(bitmap,cliprect,0);
if(!(pitnrun_ha&4))
tilemap_draw(bitmap,cliprect,bg, 0,0);
if(!(state->ha&4))
tilemap_draw(bitmap,cliprect,state->bg, 0,0);
else
{
dx=128-pitnrun_h_heed+((pitnrun_ha&8)<<5)+3;
dy=128-pitnrun_v_heed+((pitnrun_ha&0x10)<<4);
dx=128-state->h_heed+((state->ha&8)<<5)+3;
dy=128-state->v_heed+((state->ha&0x10)<<4);
if (flip_screen_x_get(screen->machine))
dx=128-dx+16;
@ -268,14 +270,14 @@ VIDEO_UPDATE( pitnrun )
if(myclip.max_y>cliprect->max_y)myclip.max_y=cliprect->max_y;
if(myclip.max_x>cliprect->max_x)myclip.max_x=cliprect->max_x;
tilemap_draw(bitmap,&myclip,bg, 0,0);
tilemap_draw(bitmap,&myclip,state->bg, 0,0);
}
draw_sprites(screen->machine,bitmap,&myclip);
if(pitnrun_ha&4)
copybitmap_trans(bitmap,tmp_bitmap[pitnrun_ha&3],flip_screen_x_get(screen->machine),flip_screen_y_get(screen->machine),dx,dy,&myclip, 1);
tilemap_draw(bitmap,cliprect,fg, 0,0);
if(state->ha&4)
copybitmap_trans(bitmap,state->tmp_bitmap[state->ha&3],flip_screen_x_get(screen->machine),flip_screen_y_get(screen->machine),dx,dy,&myclip, 1);
tilemap_draw(bitmap,cliprect,state->fg, 0,0);
return 0;
}

View File

@ -341,7 +341,7 @@ static void draw_bglayer( running_machine *machine, int layer, bitmap_t *bitmap,
}
/* populate state->bg_bitmap for the given bank if it's not already */
/* populate bg_bitmap for the given bank if it's not already */
static void cache_bitmap(int scanline, psikyosh_state *state, gfx_element *gfx, int size, int tilebank, int alpha, int *last_bank)
{
// test if the tile row is the cached one or not

View File

@ -215,8 +215,6 @@ static WRITE8_HANDLER( slither_addresslatch_w )
*
*************************************/
#define NUM_PENS (0x100)
static WRITE8_HANDLER( qix_paletteram_w )
{
@ -316,11 +314,9 @@ static MC6845_BEGIN_UPDATE( begin_update )
#endif
/* create the pens */
static pen_t pens[NUM_PENS];
get_pens(state, state->pens);
get_pens(state, pens);
return pens;
return state->pens;
}

View File

@ -16,31 +16,6 @@
#define NUM_BITMAP_PENS 8
/*************************************
*
* Global variables
*
*************************************/
UINT8 *redalert_bitmap_videoram;
UINT8 *redalert_bitmap_color;
UINT8 *redalert_charmap_videoram;
UINT8 *redalert_video_control;
/*************************************
*
* Local variable
*
*************************************/
static UINT8 *redalert_bitmap_colorram;
static UINT8 redalert_control_xor;
/*************************************
*
* Bitmap videoram write handler
@ -49,8 +24,9 @@ static UINT8 redalert_control_xor;
WRITE8_HANDLER( redalert_bitmap_videoram_w )
{
redalert_bitmap_videoram[offset ] = data;
redalert_bitmap_colorram[offset >> 3] = *redalert_bitmap_color & 0x07;
redalert_state *state = space->machine->driver_data<redalert_state>();
state->bitmap_videoram[offset ] = data;
state->bitmap_colorram[offset >> 3] = *state->bitmap_color & 0x07;
}
@ -187,18 +163,20 @@ static void get_panther_pens(running_machine *machine, pen_t *pens)
static VIDEO_START( redalert )
{
redalert_bitmap_colorram = auto_alloc_array(machine, UINT8, 0x0400);
redalert_state *state = machine->driver_data<redalert_state>();
state->bitmap_colorram = auto_alloc_array(machine, UINT8, 0x0400);
state_save_register_global_pointer(machine, redalert_bitmap_colorram, 0x0400);
state_save_register_global_pointer(machine, state->bitmap_colorram, 0x0400);
redalert_control_xor = 0x00;
state->control_xor = 0x00;
}
static VIDEO_START( ww3 )
{
redalert_state *state = machine->driver_data<redalert_state>();
VIDEO_START_CALL( redalert );
redalert_control_xor = 0x04;
state->control_xor = 0x04;
}
@ -210,6 +188,7 @@ static VIDEO_START( ww3 )
static VIDEO_UPDATE( redalert )
{
redalert_state *state = screen->machine->driver_data<redalert_state>();
pen_t pens[NUM_CHARMAP_PENS + NUM_BITMAP_PENS + 1];
offs_t offs;
@ -224,22 +203,22 @@ static VIDEO_UPDATE( redalert )
UINT8 y = offs & 0xff;
UINT8 x = (~offs >> 8) << 3;
UINT8 bitmap_data = redalert_bitmap_videoram[offs];
UINT8 bitmap_color = redalert_bitmap_colorram[offs >> 3];
UINT8 bitmap_data = state->bitmap_videoram[offs];
UINT8 bitmap_color = state->bitmap_colorram[offs >> 3];
UINT8 charmap_code = redalert_charmap_videoram[0x0000 | (offs >> 3)];
UINT8 charmap_code = state->charmap_videoram[0x0000 | (offs >> 3)];
offs_t charmap_data_base = ((charmap_code & 0x7f) << 3) | (offs & 0x07);
/* D7 of the char code selects the char set to use */
if (charmap_code & 0x80)
{
charmap_data_1 = redalert_charmap_videoram[0x0400 | charmap_data_base];
charmap_data_2 = redalert_charmap_videoram[0x0c00 | charmap_data_base];
charmap_data_1 = state->charmap_videoram[0x0400 | charmap_data_base];
charmap_data_2 = state->charmap_videoram[0x0c00 | charmap_data_base];
}
else
{
charmap_data_1 = 0; /* effectively disables A0 of the color PROM */
charmap_data_2 = redalert_charmap_videoram[0x0800 | charmap_data_base];
charmap_data_2 = state->charmap_videoram[0x0800 | charmap_data_base];
}
for (i = 0; i < 8; i++)
@ -255,7 +234,7 @@ static VIDEO_UPDATE( redalert )
else
pen = pens[((charmap_code & 0xfe) << 1) | color_prom_a0_a1];
if ((*redalert_video_control ^ redalert_control_xor) & 0x04)
if ((*state->video_control ^ state->control_xor) & 0x04)
*BITMAP_ADDR32(bitmap, y, x) = pen;
else
*BITMAP_ADDR32(bitmap, y ^ 0xff, x ^ 0xff) = pen;
@ -282,6 +261,7 @@ static VIDEO_UPDATE( redalert )
static VIDEO_UPDATE( demoneye )
{
redalert_state *state = screen->machine->driver_data<redalert_state>();
pen_t pens[NUM_CHARMAP_PENS + NUM_BITMAP_PENS + 1];
offs_t offs;
@ -296,27 +276,27 @@ static VIDEO_UPDATE( demoneye )
UINT8 y = offs & 0xff;
UINT8 x = (~offs >> 8) << 3;
UINT8 bitmap_data = redalert_bitmap_videoram[offs];
UINT8 bitmap_color = redalert_bitmap_colorram[offs >> 3];
UINT8 bitmap_data = state->bitmap_videoram[offs];
UINT8 bitmap_color = state->bitmap_colorram[offs >> 3];
UINT8 charmap_code = redalert_charmap_videoram[0x1000 | (offs >> 3)];
UINT8 charmap_code = state->charmap_videoram[0x1000 | (offs >> 3)];
offs_t charmap_data_base = ((charmap_code & 0x7f) << 3) | (offs & 0x07);
/* D7 of the char code selects the char set to use */
if (charmap_code & 0x80)
{
charmap_data_1 = redalert_charmap_videoram[0x0400 | charmap_data_base];
charmap_data_2 = redalert_charmap_videoram[0x0c00 | charmap_data_base];
charmap_data_1 = state->charmap_videoram[0x0400 | charmap_data_base];
charmap_data_2 = state->charmap_videoram[0x0c00 | charmap_data_base];
}
else
{
charmap_data_1 = redalert_charmap_videoram[0x0000 | charmap_data_base];
charmap_data_2 = redalert_charmap_videoram[0x0800 | charmap_data_base];
charmap_data_1 = state->charmap_videoram[0x0000 | charmap_data_base];
charmap_data_2 = state->charmap_videoram[0x0800 | charmap_data_base];
}
/* this is the mapping of the 3rd char set */
//charmap_data_1 = redalert_charmap_videoram[0x1400 | charmap_data_base];
//charmap_data_2 = redalert_charmap_videoram[0x1c00 | charmap_data_base];
//charmap_data_1 = state->charmap_videoram[0x1400 | charmap_data_base];
//charmap_data_2 = state->charmap_videoram[0x1c00 | charmap_data_base];
for (i = 0; i < 8; i++)
{
@ -331,7 +311,7 @@ static VIDEO_UPDATE( demoneye )
else
pen = pens[((charmap_code & 0xfe) << 1) | color_prom_a0_a1];
if (*redalert_video_control & 0x04)
if (*state->video_control & 0x04)
*BITMAP_ADDR32(bitmap, y ^ 0xff, x ^ 0xff) = pen;
else
*BITMAP_ADDR32(bitmap, y, x) = pen;
@ -356,6 +336,7 @@ static VIDEO_UPDATE( demoneye )
static VIDEO_UPDATE( panther )
{
redalert_state *state = screen->machine->driver_data<redalert_state>();
pen_t pens[NUM_CHARMAP_PENS + NUM_BITMAP_PENS + 1];
offs_t offs;
@ -370,22 +351,22 @@ static VIDEO_UPDATE( panther )
UINT8 y = offs & 0xff;
UINT8 x = (~offs >> 8) << 3;
UINT8 bitmap_data = redalert_bitmap_videoram[offs];
UINT8 bitmap_color = redalert_bitmap_colorram[offs >> 3];
UINT8 bitmap_data = state->bitmap_videoram[offs];
UINT8 bitmap_color = state->bitmap_colorram[offs >> 3];
UINT8 charmap_code = redalert_charmap_videoram[0x0000 | (offs >> 3)];
UINT8 charmap_code = state->charmap_videoram[0x0000 | (offs >> 3)];
offs_t charmap_data_base = ((charmap_code & 0x7f) << 3) | (offs & 0x07);
/* D7 of the char code selects the char set to use */
if (charmap_code & 0x80)
{
charmap_data_1 = redalert_charmap_videoram[0x0400 | charmap_data_base];
charmap_data_2 = redalert_charmap_videoram[0x0c00 | charmap_data_base];
charmap_data_1 = state->charmap_videoram[0x0400 | charmap_data_base];
charmap_data_2 = state->charmap_videoram[0x0c00 | charmap_data_base];
}
else
{
charmap_data_1 = 0; /* effectively disables A0 of the color PROM */
charmap_data_2 = redalert_charmap_videoram[0x0800 | charmap_data_base];
charmap_data_2 = state->charmap_videoram[0x0800 | charmap_data_base];
}
for (i = 0; i < 8; i++)
@ -401,7 +382,7 @@ static VIDEO_UPDATE( panther )
else
pen = pens[((charmap_code & 0xfe) << 1) | color_prom_a0_a1];
if ((*redalert_video_control ^ redalert_control_xor) & 0x04)
if ((*state->video_control ^ state->control_xor) & 0x04)
*BITMAP_ADDR32(bitmap, y, x) = pen;
else
*BITMAP_ADDR32(bitmap, y ^ 0xff, x ^ 0xff) = pen;

View File

@ -9,14 +9,6 @@
#include "emu.h"
#include "includes/retofinv.h"
UINT8 *retofinv_bg_videoram;
UINT8 *retofinv_fg_videoram;
UINT8 *retofinv_sharedram;
static int fg_bank,bg_bank;
static tilemap_t *bg_tilemap,*fg_tilemap;
PALETTE_INIT( retofinv )
{
@ -81,22 +73,24 @@ static TILEMAP_MAPPER( tilemap_scan )
static TILE_GET_INFO( bg_get_tile_info )
{
retofinv_state *state = machine->driver_data<retofinv_state>();
SET_TILE_INFO(
2,
retofinv_bg_videoram[tile_index] + 256 * bg_bank,
retofinv_bg_videoram[0x400 + tile_index] & 0x3f,
state->bg_videoram[tile_index] + 256 * state->bg_bank,
state->bg_videoram[0x400 + tile_index] & 0x3f,
0);
}
static TILE_GET_INFO( fg_get_tile_info )
{
int color = retofinv_fg_videoram[0x400 + tile_index];
retofinv_state *state = machine->driver_data<retofinv_state>();
int color = state->fg_videoram[0x400 + tile_index];
tileinfo->group = color;
SET_TILE_INFO(
0,
retofinv_fg_videoram[tile_index] + 256 * fg_bank,
state->fg_videoram[tile_index] + 256 * state->fg_bank,
color,
0);
}
@ -111,10 +105,11 @@ static TILE_GET_INFO( fg_get_tile_info )
VIDEO_START( retofinv )
{
bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan,8,8,36,28);
fg_tilemap = tilemap_create(machine, fg_get_tile_info,tilemap_scan,8,8,36,28);
retofinv_state *state = machine->driver_data<retofinv_state>();
state->bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan,8,8,36,28);
state->fg_tilemap = tilemap_create(machine, fg_get_tile_info,tilemap_scan,8,8,36,28);
colortable_configure_tilemap_groups(machine->colortable, fg_tilemap, machine->gfx[0], 0);
colortable_configure_tilemap_groups(machine->colortable, state->fg_tilemap, machine->gfx[0], 0);
}
@ -127,18 +122,21 @@ VIDEO_START( retofinv )
WRITE8_HANDLER( retofinv_bg_videoram_w )
{
retofinv_bg_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset & 0x3ff);
retofinv_state *state = space->machine->driver_data<retofinv_state>();
state->bg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap,offset & 0x3ff);
}
WRITE8_HANDLER( retofinv_fg_videoram_w )
{
retofinv_fg_videoram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff);
retofinv_state *state = space->machine->driver_data<retofinv_state>();
state->fg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap,offset & 0x3ff);
}
WRITE8_HANDLER( retofinv_gfx_ctrl_w )
{
retofinv_state *state = space->machine->driver_data<retofinv_state>();
switch (offset)
{
case 0:
@ -146,18 +144,18 @@ WRITE8_HANDLER( retofinv_gfx_ctrl_w )
break;
case 1:
if (fg_bank != (data & 1))
if (state->fg_bank != (data & 1))
{
fg_bank = data & 1;
tilemap_mark_all_tiles_dirty(fg_tilemap);
state->fg_bank = data & 1;
tilemap_mark_all_tiles_dirty(state->fg_tilemap);
}
break;
case 2:
if (bg_bank != (data & 1))
if (state->bg_bank != (data & 1))
{
bg_bank = data & 1;
tilemap_mark_all_tiles_dirty(bg_tilemap);
state->bg_bank = data & 1;
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
break;
}
@ -173,9 +171,10 @@ WRITE8_HANDLER( retofinv_gfx_ctrl_w )
static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
{
UINT8 *spriteram = retofinv_sharedram + 0x0780;
UINT8 *spriteram_2 = retofinv_sharedram + 0x0f80;
UINT8 *spriteram_3 = retofinv_sharedram + 0x1780;
retofinv_state *state = machine->driver_data<retofinv_state>();
UINT8 *spriteram = state->sharedram + 0x0780;
UINT8 *spriteram_2 = state->sharedram + 0x0f80;
UINT8 *spriteram_3 = state->sharedram + 0x1780;
int offs;
static const rectangle spritevisiblearea =
{
@ -232,8 +231,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
VIDEO_UPDATE( retofinv )
{
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
retofinv_state *state = screen->machine->driver_data<retofinv_state>();
tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
draw_sprites(screen->machine, bitmap);
tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0);
return 0;
}

View File

@ -1,18 +1,7 @@
#include "emu.h"
#include "includes/rollrace.h"
UINT8 *rollrace_videoram;
UINT8 *rollrace_colorram;
static int ra_charbank[2] = { 0,0 };
static int ra_bkgpage = 0;
static int ra_bkgflip = 0;
static int ra_chrbank = 0;
static int ra_bkgpen = 0;
static int ra_bkgcol = 0;
static int ra_flipy = 0;
static int ra_flipx = 0;
static int ra_spritebank =0 ;
#define RA_FGCHAR_BASE 0
#define RA_BGCHAR_BASE 4
@ -20,48 +9,56 @@ static int ra_spritebank =0 ;
WRITE8_HANDLER( rollrace_charbank_w)
{
rollrace_state *state = space->machine->driver_data<rollrace_state>();
ra_charbank[offset&1] = data;
ra_chrbank = ra_charbank[0] | (ra_charbank[1] << 1) ;
state->ra_charbank[offset&1] = data;
state->ra_chrbank = state->ra_charbank[0] | (state->ra_charbank[1] << 1) ;
}
WRITE8_HANDLER( rollrace_bkgpen_w)
{
ra_bkgpen = data;
rollrace_state *state = space->machine->driver_data<rollrace_state>();
state->ra_bkgpen = data;
}
WRITE8_HANDLER(rollrace_spritebank_w)
{
ra_spritebank = data;
rollrace_state *state = space->machine->driver_data<rollrace_state>();
state->ra_spritebank = data;
}
WRITE8_HANDLER(rollrace_backgroundpage_w)
{
rollrace_state *state = space->machine->driver_data<rollrace_state>();
ra_bkgpage = data & 0x1f;
ra_bkgflip = ( data & 0x80 ) >> 7;
state->ra_bkgpage = data & 0x1f;
state->ra_bkgflip = ( data & 0x80 ) >> 7;
/* 0x80 flip vertical */
}
WRITE8_HANDLER( rollrace_backgroundcolor_w )
{
ra_bkgcol = data;
rollrace_state *state = space->machine->driver_data<rollrace_state>();
state->ra_bkgcol = data;
}
WRITE8_HANDLER( rollrace_flipy_w )
{
ra_flipy = data & 0x01;
rollrace_state *state = space->machine->driver_data<rollrace_state>();
state->ra_flipy = data & 0x01;
}
WRITE8_HANDLER( rollrace_flipx_w )
{
ra_flipx = data & 0x01;
rollrace_state *state = space->machine->driver_data<rollrace_state>();
state->ra_flipx = data & 0x01;
}
VIDEO_UPDATE( rollrace )
{
rollrace_state *state = screen->machine->driver_data<rollrace_state>();
UINT8 *spriteram = screen->machine->generic.spriteram.u8;
int offs;
int sx, sy;
@ -70,12 +67,12 @@ VIDEO_UPDATE( rollrace )
const UINT8 *mem = screen->machine->region("user1")->base();
/* fill in background colour*/
bitmap_fill(bitmap,cliprect,ra_bkgpen);
bitmap_fill(bitmap,cliprect,state->ra_bkgpen);
/* draw road */
for (offs = 0x3ff; offs >= 0; offs--)
{
if(!(ra_bkgflip))
if(!(state->ra_bkgflip))
{
sy = ( 31 - offs / 32 ) ;
}
@ -84,18 +81,18 @@ VIDEO_UPDATE( rollrace )
sx = ( offs%32 ) ;
if(ra_flipx)
if(state->ra_flipx)
sx = 31-sx ;
if(ra_flipy)
if(state->ra_flipy)
sy = 31-sy ;
drawgfx_transpen(bitmap,
cliprect,screen->machine->gfx[RA_BGCHAR_BASE],
mem[offs + ( ra_bkgpage * 1024 )]
+ ((( mem[offs + 0x4000 + ( ra_bkgpage * 1024 )] & 0xc0 ) >> 6 ) * 256 ) ,
ra_bkgcol,
ra_flipx,(ra_bkgflip^ra_flipy),
mem[offs + ( state->ra_bkgpage * 1024 )]
+ ((( mem[offs + 0x4000 + ( state->ra_bkgpage * 1024 )] & 0xc0 ) >> 6 ) * 256 ) ,
state->ra_bkgcol,
state->ra_flipx,(state->ra_bkgflip^state->ra_flipy),
sx*8,sy*8,0);
@ -116,9 +113,9 @@ VIDEO_UPDATE( rollrace )
if(sx && sy)
{
if(ra_flipx)
if(state->ra_flipx)
sx = 224 - sx;
if(ra_flipy)
if(state->ra_flipy)
sy = 224 - sy;
if(spriteram[offs+1] & 0x80)
@ -127,12 +124,12 @@ VIDEO_UPDATE( rollrace )
bank = (( spriteram[offs+1] & 0x40 ) >> 6 ) ;
if(bank)
bank += ra_spritebank;
bank += state->ra_spritebank;
drawgfx_transpen(bitmap, cliprect,screen->machine->gfx[ RA_SP_BASE + bank ],
spriteram[offs+1] & 0x3f ,
spriteram[offs+2] & 0x1f,
ra_flipx,!(s_flipy^ra_flipy),
state->ra_flipx,!(s_flipy^state->ra_flipy),
sx,sy,0);
}
}
@ -147,20 +144,20 @@ VIDEO_UPDATE( rollrace )
sx = offs % 32;
sy = offs / 32;
scroll = ( 8 * sy + rollrace_colorram[2 * sx] ) % 256;
col = rollrace_colorram[ sx * 2 + 1 ]&0x1f;
scroll = ( 8 * sy + state->colorram[2 * sx] ) % 256;
col = state->colorram[ sx * 2 + 1 ]&0x1f;
if (!ra_flipy)
if (!state->ra_flipy)
{
scroll = (248 - scroll) % 256;
}
if (ra_flipx) sx = 31 - sx;
if (state->ra_flipx) sx = 31 - sx;
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[RA_FGCHAR_BASE + ra_chrbank] ,
rollrace_videoram[ offs ] ,
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[RA_FGCHAR_BASE + state->ra_chrbank] ,
state->videoram[ offs ] ,
col,
ra_flipx,ra_flipy,
state->ra_flipx,state->ra_flipy,
8*sx,scroll,0);
}

View File

@ -462,39 +462,35 @@ VIDEO_UPDATE( slapshot )
UINT8 spritepri[4];
UINT16 priority;
#ifdef MAME_DEBUG
static int dislayer[5]; /* Layer toggles to help get the layers correct */
#endif
#ifdef MAME_DEBUG
if (input_code_pressed_once (screen->machine, KEYCODE_Z))
{
dislayer[0] ^= 1;
popmessage("bg0: %01x",dislayer[0]);
state->dislayer[0] ^= 1;
popmessage("bg0: %01x",state->dislayer[0]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_X))
{
dislayer[1] ^= 1;
popmessage("bg1: %01x",dislayer[1]);
state->dislayer[1] ^= 1;
popmessage("bg1: %01x",state->dislayer[1]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_C))
{
dislayer[2] ^= 1;
popmessage("bg2: %01x",dislayer[2]);
state->dislayer[2] ^= 1;
popmessage("bg2: %01x",state->dislayer[2]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_V))
{
dislayer[3] ^= 1;
popmessage("bg3: %01x",dislayer[3]);
state->dislayer[3] ^= 1;
popmessage("bg3: %01x",state->dislayer[3]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_B))
{
dislayer[4] ^= 1;
popmessage("text: %01x",dislayer[4]);
state->dislayer[4] ^= 1;
popmessage("text: %01x",state->dislayer[4]);
}
#endif
@ -527,22 +523,22 @@ VIDEO_UPDATE( slapshot )
bitmap_fill(bitmap, cliprect, 0);
#ifdef MAME_DEBUG
if (dislayer[layer[0]] == 0)
if (state->dislayer[layer[0]] == 0)
#endif
tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[0], 0, 1);
#ifdef MAME_DEBUG
if (dislayer[layer[1]] == 0)
if (state->dislayer[layer[1]] == 0)
#endif
tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[1], 0, 2);
#ifdef MAME_DEBUG
if (dislayer[layer[2]] == 0)
if (state->dislayer[layer[2]] == 0)
#endif
tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[2], 0, 4);
#ifdef MAME_DEBUG
if (dislayer[layer[3]] == 0)
if (state->dislayer[layer[3]] == 0)
#endif
tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[3], 0, 8);
@ -568,7 +564,7 @@ VIDEO_UPDATE( slapshot )
*/
#ifdef MAME_DEBUG
if (dislayer[layer[4]] == 0)
if (state->dislayer[layer[4]] == 0)
#endif
tc0480scp_tilemap_draw(state->tc0480scp, bitmap, cliprect, layer[4], 0, 0);
return 0;

View File

@ -2,20 +2,10 @@
#include "video/taitoic.h"
#include "includes/superchs.h"
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int primask;
};
static struct tempsprite *spritelist;
VIDEO_START( superchs )
{
spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
superchs_state *state = machine->driver_data<superchs_state>();
state->spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
}
/************************************************************
@ -66,6 +56,7 @@ Heavy use is made of sprite zooming.
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,const int *primasks,int x_offs,int y_offs)
{
superchs_state *state = machine->driver_data<superchs_state>();
UINT32 *spriteram32 = machine->generic.spriteram.u32;
UINT16 *spritemap = (UINT16 *)machine->region("user1")->base();
int offs, data, tilenum, color, flipx, flipy;
@ -77,7 +68,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
/* pdrawgfx() needs us to draw sprites front to back, so we have to build a list
while processing sprite ram and then draw them all at the end */
struct tempsprite *sprite_ptr = spritelist;
struct tempsprite *sprite_ptr = state->spritelist;
for (offs = (machine->generic.spriteram_size/4-4);offs >= 0;offs -= 4)
{
@ -189,7 +180,7 @@ logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
}
/* this happens only if primsks != NULL */
while (sprite_ptr != spritelist)
while (sprite_ptr != state->spritelist)
{
sprite_ptr--;

View File

@ -9,15 +9,7 @@
#include "emu.h"
#include "includes/superqix.h"
UINT8 *superqix_videoram;
UINT8 *superqix_bitmapram,*superqix_bitmapram2;
int pbillian_show_power;
static int gfxbank;
static bitmap_t *fg_bitmap[2];
static int show_bitmap;
static tilemap_t *bg_tilemap;
static int last_power[2];
/***************************************************************************
@ -28,20 +20,22 @@ static int last_power[2];
static TILE_GET_INFO( pb_get_bg_tile_info )
{
int attr = superqix_videoram[tile_index + 0x400];
int code = superqix_videoram[tile_index] + 256 * (attr & 0x7);
superqix_state *state = machine->driver_data<superqix_state>();
int attr = state->videoram[tile_index + 0x400];
int code = state->videoram[tile_index] + 256 * (attr & 0x7);
int color = (attr & 0xf0) >> 4;
SET_TILE_INFO(0, code, color, 0);
}
static TILE_GET_INFO( sqix_get_bg_tile_info )
{
int attr = superqix_videoram[tile_index + 0x400];
superqix_state *state = machine->driver_data<superqix_state>();
int attr = state->videoram[tile_index + 0x400];
int bank = (attr & 0x04) ? 0 : 1;
int code = superqix_videoram[tile_index] + 256 * (attr & 0x03);
int code = state->videoram[tile_index] + 256 * (attr & 0x03);
int color = (attr & 0xf0) >> 4;
if (bank) code += 1024 * gfxbank;
if (bank) code += 1024 * state->gfxbank;
SET_TILE_INFO(bank, code, color, 0);
tileinfo->group = (attr & 0x08) >> 3;
@ -57,27 +51,29 @@ static TILE_GET_INFO( sqix_get_bg_tile_info )
VIDEO_START( pbillian )
{
bg_tilemap = tilemap_create(machine, pb_get_bg_tile_info, tilemap_scan_rows, 8, 8,32,32);
superqix_state *state = machine->driver_data<superqix_state>();
state->bg_tilemap = tilemap_create(machine, pb_get_bg_tile_info, tilemap_scan_rows, 8, 8,32,32);
/* Need to do save state here */
state_save_register_global(machine, last_power[0]);
state_save_register_global(machine, last_power[1]);
state_save_register_global(machine, pbillian_show_power);
state_save_register_global(machine, state->last_power[0]);
state_save_register_global(machine, state->last_power[1]);
state_save_register_global(machine, state->pbillian_show_power);
}
VIDEO_START( superqix )
{
fg_bitmap[0] = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format());
fg_bitmap[1] = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format());
bg_tilemap = tilemap_create(machine, sqix_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
superqix_state *state = machine->driver_data<superqix_state>();
state->fg_bitmap[0] = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format());
state->fg_bitmap[1] = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format());
state->bg_tilemap = tilemap_create(machine, sqix_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transmask(bg_tilemap,0,0xffff,0x0000); /* split type 0 is totally transparent in front half */
tilemap_set_transmask(bg_tilemap,1,0x0001,0xfffe); /* split type 1 has pen 0 transparent in front half */
tilemap_set_transmask(state->bg_tilemap,0,0xffff,0x0000); /* split type 0 is totally transparent in front half */
tilemap_set_transmask(state->bg_tilemap,1,0x0001,0xfffe); /* split type 1 has pen 0 transparent in front half */
state_save_register_global(machine, gfxbank);
state_save_register_global(machine, show_bitmap);
state_save_register_global_bitmap(machine, fg_bitmap[0]);
state_save_register_global_bitmap(machine, fg_bitmap[1]);
state_save_register_global(machine, state->gfxbank);
state_save_register_global(machine, state->show_bitmap);
state_save_register_global_bitmap(machine, state->fg_bitmap[0]);
state_save_register_global_bitmap(machine, state->fg_bitmap[1]);
}
@ -90,35 +86,38 @@ VIDEO_START( superqix )
WRITE8_HANDLER( superqix_videoram_w )
{
superqix_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset & 0x3ff);
superqix_state *state = space->machine->driver_data<superqix_state>();
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset & 0x3ff);
}
WRITE8_HANDLER( superqix_bitmapram_w )
{
if (superqix_bitmapram[offset] != data)
superqix_state *state = space->machine->driver_data<superqix_state>();
if (state->bitmapram[offset] != data)
{
int x = 2 * (offset % 128);
int y = offset / 128 + 16;
superqix_bitmapram[offset] = data;
state->bitmapram[offset] = data;
*BITMAP_ADDR16(fg_bitmap[0], y, x) = data >> 4;
*BITMAP_ADDR16(fg_bitmap[0], y, x + 1) = data & 0x0f;
*BITMAP_ADDR16(state->fg_bitmap[0], y, x) = data >> 4;
*BITMAP_ADDR16(state->fg_bitmap[0], y, x + 1) = data & 0x0f;
}
}
WRITE8_HANDLER( superqix_bitmapram2_w )
{
if (data != superqix_bitmapram2[offset])
superqix_state *state = space->machine->driver_data<superqix_state>();
if (data != state->bitmapram2[offset])
{
int x = 2 * (offset % 128);
int y = offset / 128 + 16;
superqix_bitmapram2[offset] = data;
state->bitmapram2[offset] = data;
*BITMAP_ADDR16(fg_bitmap[1], y, x) = data >> 4;
*BITMAP_ADDR16(fg_bitmap[1], y, x + 1) = data & 0x0f;
*BITMAP_ADDR16(state->fg_bitmap[1], y, x) = data >> 4;
*BITMAP_ADDR16(state->fg_bitmap[1], y, x + 1) = data & 0x0f;
}
}
@ -144,15 +143,16 @@ WRITE8_HANDLER( pbillian_0410_w )
WRITE8_HANDLER( superqix_0410_w )
{
superqix_state *state = space->machine->driver_data<superqix_state>();
/* bits 0-1 select the tile bank */
if (gfxbank != (data & 0x03))
if (state->gfxbank != (data & 0x03))
{
gfxbank = data & 0x03;
tilemap_mark_all_tiles_dirty(bg_tilemap);
state->gfxbank = data & 0x03;
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
/* bit 2 selects which of the two bitmaps to display (for 2 players game) */
show_bitmap = (data & 0x04) >> 2;
state->show_bitmap = (data & 0x04) >> 2;
/* bit 3 enables NMI */
interrupt_enable_w(space,offset,data & 0x08);
@ -229,25 +229,26 @@ static void superqix_draw_sprites(running_machine *machine, bitmap_t *bitmap,con
VIDEO_UPDATE( pbillian )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
superqix_state *state = screen->machine->driver_data<superqix_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
pbillian_draw_sprites(screen->machine, bitmap,cliprect);
if (pbillian_show_power)
if (state->pbillian_show_power)
{
int curr_power;
curr_power = ((input_port_read(screen->machine, "PADDLE1") & 0x3f) * 100) / 0x3f;
if (last_power[0] != curr_power)
if (state->last_power[0] != curr_power)
{
popmessage ("Power %d%%", curr_power);
last_power[0] = curr_power;
state->last_power[0] = curr_power;
}
curr_power = ((input_port_read(screen->machine, "PADDLE2") & 0x3f) * 100) / 0x3f;
if (last_power[1] != curr_power)
if (state->last_power[1] != curr_power)
{
popmessage ("Power %d%%", curr_power);
last_power[1] = curr_power;
state->last_power[1] = curr_power;
}
}
return 0;
@ -255,9 +256,10 @@ VIDEO_UPDATE( pbillian )
VIDEO_UPDATE( superqix )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, TILEMAP_DRAW_LAYER1, 0);
copybitmap_trans(bitmap,fg_bitmap[show_bitmap],flip_screen_get(screen->machine),flip_screen_get(screen->machine),0,0,cliprect,0);
superqix_state *state = screen->machine->driver_data<superqix_state>();
tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1, 0);
copybitmap_trans(bitmap,state->fg_bitmap[state->show_bitmap],flip_screen_get(screen->machine),flip_screen_get(screen->machine),0,0,cliprect,0);
superqix_draw_sprites(screen->machine, bitmap,cliprect);
tilemap_draw(bitmap, cliprect, bg_tilemap, TILEMAP_DRAW_LAYER0, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0, 0);
return 0;
}

View File

@ -11,31 +11,13 @@
#include "includes/taitosj.h"
#define GLOBAL_FLIP_X (*taitosj_video_mode & 0x01)
#define GLOBAL_FLIP_Y (*taitosj_video_mode & 0x02)
#define SPRITE_RAM_PAGE_OFFSET ((*taitosj_video_mode & 0x04) ? 0x80 : 0x00)
#define SPRITES_ON (*taitosj_video_mode & 0x80)
#define GLOBAL_FLIP_X (*state->video_mode & 0x01)
#define GLOBAL_FLIP_Y (*state->video_mode & 0x02)
#define SPRITE_RAM_PAGE_OFFSET ((*state->video_mode & 0x04) ? 0x80 : 0x00)
#define SPRITES_ON (*state->video_mode & 0x80)
#define TRANSPARENT_PEN (0x40)
UINT8 *taitosj_videoram_1;
UINT8 *taitosj_videoram_2;
UINT8 *taitosj_videoram_3;
UINT8 *taitosj_spriteram;
UINT8 *taitosj_paletteram;
UINT8 *taitosj_characterram;
UINT8 *taitosj_scroll;
UINT8 *taitosj_colscrolly;
UINT8 *taitosj_gfxpointer;
UINT8 *taitosj_colorbank;
UINT8 *taitosj_video_mode;
UINT8 *taitosj_video_priority;
UINT8 *taitosj_collision_reg;
UINT8 *kikstart_scrollram;
static bitmap_t *taitosj_layer_bitmap[3];
static bitmap_t *sprite_sprite_collbitmap1,*sprite_sprite_collbitmap2;
static bitmap_t *sprite_layer_collbitmap1;
static bitmap_t *sprite_layer_collbitmap2[3];
static const int layer_enable_mask[3] = { 0x10, 0x20, 0x40 };
@ -85,7 +67,6 @@ typedef void (*copy_layer_func_t)(running_machine *, bitmap_t *,
***************************************************************************/
static int draw_order[32][4];
/***************************************************************************
@ -111,6 +92,7 @@ static int draw_order[32][4];
static void set_pens(running_machine *machine)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
static const int resistances[3] = { 1000, 470, 270 };
double rweights[3], gweights[3], bweights[3];
int i;
@ -127,22 +109,22 @@ static void set_pens(running_machine *machine)
int r, g, b, val;
/* red component */
val = taitosj_paletteram[(i << 1) | 0x01];
val = state->paletteram[(i << 1) | 0x01];
bit0 = (~val >> 6) & 0x01;
bit1 = (~val >> 7) & 0x01;
val = taitosj_paletteram[(i << 1) | 0x00];
val = state->paletteram[(i << 1) | 0x00];
bit2 = (~val >> 0) & 0x01;
r = combine_3_weights(rweights, bit0, bit1, bit2);
/* green component */
val = taitosj_paletteram[(i << 1) | 0x01];
val = state->paletteram[(i << 1) | 0x01];
bit0 = (~val >> 3) & 0x01;
bit1 = (~val >> 4) & 0x01;
bit2 = (~val >> 5) & 0x01;
g = combine_3_weights(gweights, bit0, bit1, bit2);
/* blue component */
val = taitosj_paletteram[(i << 1) | 0x01];
val = state->paletteram[(i << 1) | 0x01];
bit0 = (~val >> 0) & 0x01;
bit1 = (~val >> 1) & 0x01;
bit2 = (~val >> 2) & 0x01;
@ -160,6 +142,7 @@ static void set_pens(running_machine *machine)
static void compute_draw_order(running_machine *machine)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
int i;
UINT8 *color_prom = machine->region("proms")->base();
@ -182,7 +165,7 @@ static void compute_draw_order(running_machine *machine)
mask |= (1 << data); /* in next loop, we'll see which of the remaining */
/* layers has top priority when this one is transparent */
draw_order[i][j] = data;
state->draw_order[i][j] = data;
}
}
}
@ -190,23 +173,24 @@ static void compute_draw_order(running_machine *machine)
VIDEO_START( taitosj )
{
taitosj_state *state = machine->driver_data<taitosj_state>();
int i;
sprite_layer_collbitmap1 = auto_bitmap_alloc(machine,16,16,machine->primary_screen->format());
state->sprite_layer_collbitmap1 = auto_bitmap_alloc(machine,16,16,machine->primary_screen->format());
for (i = 0; i < 3; i++)
{
taitosj_layer_bitmap[i] = machine->primary_screen->alloc_compatible_bitmap();
sprite_layer_collbitmap2[i] = machine->primary_screen->alloc_compatible_bitmap();
state->layer_bitmap[i] = machine->primary_screen->alloc_compatible_bitmap();
state->sprite_layer_collbitmap2[i] = machine->primary_screen->alloc_compatible_bitmap();
}
sprite_sprite_collbitmap1 = auto_bitmap_alloc(machine,32,32,machine->primary_screen->format());
sprite_sprite_collbitmap2 = auto_bitmap_alloc(machine,32,32,machine->primary_screen->format());
state->sprite_sprite_collbitmap1 = auto_bitmap_alloc(machine,32,32,machine->primary_screen->format());
state->sprite_sprite_collbitmap2 = auto_bitmap_alloc(machine,32,32,machine->primary_screen->format());
gfx_element_set_source(machine->gfx[0], taitosj_characterram);
gfx_element_set_source(machine->gfx[1], taitosj_characterram);
gfx_element_set_source(machine->gfx[2], taitosj_characterram + 0x1800);
gfx_element_set_source(machine->gfx[3], taitosj_characterram + 0x1800);
gfx_element_set_source(machine->gfx[0], state->characterram);
gfx_element_set_source(machine->gfx[1], state->characterram);
gfx_element_set_source(machine->gfx[2], state->characterram + 0x1800);
gfx_element_set_source(machine->gfx[3], state->characterram + 0x1800);
compute_draw_order(machine);
}
@ -215,9 +199,10 @@ VIDEO_START( taitosj )
READ8_HANDLER( taitosj_gfxrom_r )
{
taitosj_state *state = space->machine->driver_data<taitosj_state>();
UINT8 ret;
offs_t offs = taitosj_gfxpointer[0] | (taitosj_gfxpointer[1] << 8);
offs_t offs = state->gfxpointer[0] | (state->gfxpointer[1] << 8);
if (offs < 0x8000)
ret = space->machine->region("gfx1")->base()[offs];
@ -226,8 +211,8 @@ READ8_HANDLER( taitosj_gfxrom_r )
offs = offs + 1;
taitosj_gfxpointer[0] = offs & 0xff;
taitosj_gfxpointer[1] = offs >> 8;
state->gfxpointer[0] = offs & 0xff;
state->gfxpointer[1] = offs >> 8;
return ret;
}
@ -236,7 +221,8 @@ READ8_HANDLER( taitosj_gfxrom_r )
WRITE8_HANDLER( taitosj_characterram_w )
{
if (taitosj_characterram[offset] != data)
taitosj_state *state = space->machine->driver_data<taitosj_state>();
if (state->characterram[offset] != data)
{
if (offset < 0x1800)
{
@ -249,7 +235,7 @@ WRITE8_HANDLER( taitosj_characterram_w )
gfx_element_mark_dirty(space->machine->gfx[3], (offset / 32) & 0x3f);
}
taitosj_characterram[offset] = data;
state->characterram[offset] = data;
}
}
@ -261,19 +247,20 @@ WRITE8_HANDLER( junglhbr_characterram_w )
WRITE8_HANDLER( taitosj_collision_reg_clear_w )
{
taitosj_collision_reg[0] = 0;
taitosj_collision_reg[1] = 0;
taitosj_collision_reg[2] = 0;
taitosj_collision_reg[3] = 0;
taitosj_state *state = space->machine->driver_data<taitosj_state>();
state->collision_reg[0] = 0;
state->collision_reg[1] = 0;
state->collision_reg[2] = 0;
state->collision_reg[3] = 0;
}
INLINE int get_sprite_xy(UINT8 which, UINT8* sx, UINT8* sy)
INLINE int get_sprite_xy(taitosj_state *state, UINT8 which, UINT8* sx, UINT8* sy)
{
offs_t offs = which * 4;
*sx = taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 0] - 1;
*sy = 240 - taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 1];
*sx = state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 0] - 1;
*sy = 240 - state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 1];
return (*sy < 240);
}
@ -281,9 +268,10 @@ INLINE int get_sprite_xy(UINT8 which, UINT8* sx, UINT8* sy)
INLINE const gfx_element *get_sprite_gfx_element(running_machine *machine, UINT8 which)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
offs_t offs = which * 4;
return machine->gfx[(taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x40) ? 3 : 1];
return machine->gfx[(state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x40) ? 3 : 1];
}
@ -291,6 +279,7 @@ static int check_sprite_sprite_bitpattern(running_machine *machine,
int sx1, int sy1, int which1,
int sx2, int sy2, int which2)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
int x, y, minx, miny, maxx = 16, maxy = 16;
offs_t offs1 = which1 * 4;
@ -324,26 +313,26 @@ static int check_sprite_sprite_bitpattern(running_machine *machine,
}
/* draw the sprites into seperate bitmaps and check overlapping region */
bitmap_fill(sprite_layer_collbitmap1, NULL, TRANSPARENT_PEN);
drawgfx_transpen(sprite_sprite_collbitmap1, 0, get_sprite_gfx_element(machine, which1),
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 3] & 0x3f,
bitmap_fill(state->sprite_layer_collbitmap1, NULL, TRANSPARENT_PEN);
drawgfx_transpen(state->sprite_sprite_collbitmap1, 0, get_sprite_gfx_element(machine, which1),
state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 3] & 0x3f,
0,
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x01,
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x02,
state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x01,
state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs1 + 2] & 0x02,
sx1, sy1, 0);
bitmap_fill(sprite_sprite_collbitmap2, NULL, TRANSPARENT_PEN);
drawgfx_transpen(sprite_sprite_collbitmap2, 0, get_sprite_gfx_element(machine, which2),
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 3] & 0x3f,
bitmap_fill(state->sprite_sprite_collbitmap2, NULL, TRANSPARENT_PEN);
drawgfx_transpen(state->sprite_sprite_collbitmap2, 0, get_sprite_gfx_element(machine, which2),
state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 3] & 0x3f,
0,
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x01,
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x02,
state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x01,
state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs2 + 2] & 0x02,
sx2, sy2, 0);
for (y = miny; y < maxy; y++)
for (x = minx; x < maxx; x++)
if ((*BITMAP_ADDR16(sprite_sprite_collbitmap1, y, x) != TRANSPARENT_PEN) &&
(*BITMAP_ADDR16(sprite_sprite_collbitmap2, y, x) != TRANSPARENT_PEN))
if ((*BITMAP_ADDR16(state->sprite_sprite_collbitmap1, y, x) != TRANSPARENT_PEN) &&
(*BITMAP_ADDR16(state->sprite_sprite_collbitmap2, y, x) != TRANSPARENT_PEN))
return 1; /* collided */
return 0;
@ -352,6 +341,7 @@ static int check_sprite_sprite_bitpattern(running_machine *machine,
static void check_sprite_sprite_collision(running_machine *machine)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
if (SPRITES_ON)
{
int which1;
@ -364,7 +354,7 @@ static void check_sprite_sprite_collision(running_machine *machine)
if ((which1 >= 0x10) && (which1 <= 0x17)) continue; /* no sprites here */
if (!get_sprite_xy(which1, &sx1, &sy1)) continue;
if (!get_sprite_xy(state, which1, &sx1, &sy1)) continue;
for (which2 = which1 + 1; which2 < 0x20; which2++)
{
@ -372,7 +362,7 @@ static void check_sprite_sprite_collision(running_machine *machine)
if ((which2 >= 0x10) && (which2 <= 0x17)) continue; /* no sprites here */
if (!get_sprite_xy(which2, &sx2, &sy2)) continue;
if (!get_sprite_xy(state, which2, &sx2, &sy2)) continue;
/* quickly rule out any pairs that cannot be touching */
if ((abs((INT8)sx1 - (INT8)sx2) < 16) &&
@ -393,14 +383,14 @@ static void check_sprite_sprite_collision(running_machine *machine)
reg = which1 >> 3;
if (reg == 3) reg = 2;
taitosj_collision_reg[reg] |= (1 << (which1 & 0x07));
state->collision_reg[reg] |= (1 << (which1 & 0x07));
}
else
{
reg = which2 >> 3;
if (reg == 3) reg = 2;
taitosj_collision_reg[reg] |= (1 << (which2 & 0x07));
state->collision_reg[reg] |= (1 << (which2 & 0x07));
}
}
}
@ -411,6 +401,7 @@ static void check_sprite_sprite_collision(running_machine *machine)
static void calculate_sprite_areas(running_machine *machine, int *sprites_on, rectangle *sprite_areas)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
int which;
int width = machine->primary_screen->width();
int height = machine->primary_screen->height();
@ -421,7 +412,7 @@ static void calculate_sprite_areas(running_machine *machine, int *sprites_on, re
if ((which >= 0x10) && (which <= 0x17)) continue; /* no sprites here */
if (get_sprite_xy(which, &sx, &sy))
if (get_sprite_xy(state, which, &sx, &sy))
{
int minx, miny, maxx, maxy;
@ -461,41 +452,42 @@ static void calculate_sprite_areas(running_machine *machine, int *sprites_on, re
static int check_sprite_layer_bitpattern(running_machine *machine, int which, rectangle *sprite_areas)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
int y, x;
offs_t offs = which * 4;
int result = 0; /* no collisions */
int check_layer_1 = *taitosj_video_mode & layer_enable_mask[0];
int check_layer_2 = *taitosj_video_mode & layer_enable_mask[1];
int check_layer_3 = *taitosj_video_mode & layer_enable_mask[2];
int check_layer_1 = *state->video_mode & layer_enable_mask[0];
int check_layer_2 = *state->video_mode & layer_enable_mask[1];
int check_layer_3 = *state->video_mode & layer_enable_mask[2];
int minx = sprite_areas[which].min_x;
int miny = sprite_areas[which].min_y;
int maxx = sprite_areas[which].max_x + 1;
int maxy = sprite_areas[which].max_y + 1;
int flip_x = (taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01) ^ GLOBAL_FLIP_X;
int flip_y = (taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02) ^ GLOBAL_FLIP_Y;
int flip_x = (state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01) ^ GLOBAL_FLIP_X;
int flip_y = (state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02) ^ GLOBAL_FLIP_Y;
/* draw sprite into a bitmap and check if layers collide */
bitmap_fill(sprite_layer_collbitmap1, NULL, TRANSPARENT_PEN);
drawgfx_transpen(sprite_layer_collbitmap1, 0,get_sprite_gfx_element(machine, which),
taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f,
bitmap_fill(state->sprite_layer_collbitmap1, NULL, TRANSPARENT_PEN);
drawgfx_transpen(state->sprite_layer_collbitmap1, 0,get_sprite_gfx_element(machine, which),
state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f,
0,
flip_x, flip_y,
0,0,0);
for (y = miny; y < maxy; y++)
for (x = minx; x < maxx; x++)
if (*BITMAP_ADDR16(sprite_layer_collbitmap1, y - miny, x - minx) != TRANSPARENT_PEN) /* is there anything to check for ? */
if (*BITMAP_ADDR16(state->sprite_layer_collbitmap1, y - miny, x - minx) != TRANSPARENT_PEN) /* is there anything to check for ? */
{
if (check_layer_1 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[0], y, x) != TRANSPARENT_PEN))
if (check_layer_1 && (*BITMAP_ADDR16(state->sprite_layer_collbitmap2[0], y, x) != TRANSPARENT_PEN))
result |= 0x01; /* collided with layer 1 */
if (check_layer_2 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[1], y, x) != TRANSPARENT_PEN))
if (check_layer_2 && (*BITMAP_ADDR16(state->sprite_layer_collbitmap2[1], y, x) != TRANSPARENT_PEN))
result |= 0x02; /* collided with layer 2 */
if (check_layer_3 && (*BITMAP_ADDR16(sprite_layer_collbitmap2[2], y, x) != TRANSPARENT_PEN))
if (check_layer_3 && (*BITMAP_ADDR16(state->sprite_layer_collbitmap2[2], y, x) != TRANSPARENT_PEN))
result |= 0x04; /* collided with layer 3 */
}
@ -505,6 +497,7 @@ static int check_sprite_layer_bitpattern(running_machine *machine, int which, re
static void check_sprite_layer_collision(running_machine *machine, int *sprites_on, rectangle *sprite_areas)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
if (SPRITES_ON)
{
int which;
@ -515,7 +508,7 @@ static void check_sprite_layer_collision(running_machine *machine, int *sprites_
if ((which >= 0x10) && (which <= 0x17)) continue; /* no sprites here */
if (sprites_on[which])
taitosj_collision_reg[3] |= check_sprite_layer_bitpattern(machine, which, sprite_areas);
state->collision_reg[3] |= check_sprite_layer_bitpattern(machine, which, sprite_areas);
}
}
}
@ -523,11 +516,12 @@ static void check_sprite_layer_collision(running_machine *machine, int *sprites_
static void draw_layers(running_machine *machine)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
offs_t offs;
bitmap_fill(taitosj_layer_bitmap[0], NULL, TRANSPARENT_PEN);
bitmap_fill(taitosj_layer_bitmap[1], NULL, TRANSPARENT_PEN);
bitmap_fill(taitosj_layer_bitmap[2], NULL, TRANSPARENT_PEN);
bitmap_fill(state->layer_bitmap[0], NULL, TRANSPARENT_PEN);
bitmap_fill(state->layer_bitmap[1], NULL, TRANSPARENT_PEN);
bitmap_fill(state->layer_bitmap[2], NULL, TRANSPARENT_PEN);
for (offs = 0; offs < 0x0400; offs++)
{
@ -537,21 +531,21 @@ static void draw_layers(running_machine *machine)
if (GLOBAL_FLIP_X) sx = 31 - sx;
if (GLOBAL_FLIP_Y) sy = 31 - sy;
drawgfx_transpen(taitosj_layer_bitmap[0],0,machine->gfx[taitosj_colorbank[0] & 0x08 ? 2 : 0],
taitosj_videoram_1[offs],
taitosj_colorbank[0] & 0x07,
drawgfx_transpen(state->layer_bitmap[0],0,machine->gfx[state->colorbank[0] & 0x08 ? 2 : 0],
state->videoram_1[offs],
state->colorbank[0] & 0x07,
GLOBAL_FLIP_X,GLOBAL_FLIP_Y,
8*sx,8*sy,0);
drawgfx_transpen(taitosj_layer_bitmap[1],0,machine->gfx[taitosj_colorbank[0] & 0x80 ? 2 : 0],
taitosj_videoram_2[offs],
(taitosj_colorbank[0] >> 4) & 0x07,
drawgfx_transpen(state->layer_bitmap[1],0,machine->gfx[state->colorbank[0] & 0x80 ? 2 : 0],
state->videoram_2[offs],
(state->colorbank[0] >> 4) & 0x07,
GLOBAL_FLIP_X,GLOBAL_FLIP_Y,
8*sx,8*sy,0);
drawgfx_transpen(taitosj_layer_bitmap[2],0,machine->gfx[taitosj_colorbank[1] & 0x08 ? 2 : 0],
taitosj_videoram_3[offs],
taitosj_colorbank[1] & 0x07,
drawgfx_transpen(state->layer_bitmap[2],0,machine->gfx[state->colorbank[1] & 0x08 ? 2 : 0],
state->videoram_3[offs],
state->colorbank[1] & 0x07,
GLOBAL_FLIP_X,GLOBAL_FLIP_Y,
8*sx,8*sy,0);
}
@ -560,6 +554,7 @@ static void draw_layers(running_machine *machine)
static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
/*
sprite visibility area is missing 4 pixels from the sides, surely to reduce
wraparound side effects. This was verified on a real Elevator Action.
@ -591,12 +586,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
if ((which >= 0x10) && (which <= 0x17)) continue; /* no sprites here */
if (get_sprite_xy(which, &sx, &sy))
if (get_sprite_xy(state, which, &sx, &sy))
{
int code = taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f;
int color = 2 * ((taitosj_colorbank[1] >> 4) & 0x03) + ((taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] >> 2) & 0x01);
int flip_x = taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01;
int flip_y = taitosj_spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02;
int code = state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 3] & 0x3f;
int color = 2 * ((state->colorbank[1] >> 4) & 0x03) + ((state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] >> 2) & 0x01);
int flip_x = state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x01;
int flip_y = state->spriteram[SPRITE_RAM_PAGE_OFFSET + offs + 2] & 0x02;
if (GLOBAL_FLIP_X)
{
@ -625,14 +620,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap)
static void taitosj_copy_layer(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,
int which, int *sprites_on, rectangle *sprite_areas)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
static const int fudge1[3] = { 3, 1, -1 };
static const int fudge2[3] = { 8, 10, 12 };
if (*taitosj_video_mode & layer_enable_mask[which])
if (*state->video_mode & layer_enable_mask[which])
{
int i, scrollx, scrolly[32];
scrollx = taitosj_scroll[2 * which];
scrollx = state->scroll[2 * which];
if (GLOBAL_FLIP_X)
scrollx = (scrollx & 0xf8) + ((scrollx + fudge1[which]) & 7) + fudge2[which];
@ -641,12 +637,12 @@ static void taitosj_copy_layer(running_machine *machine, bitmap_t *bitmap, const
if (GLOBAL_FLIP_Y)
for (i = 0;i < 32;i++)
scrolly[31 - i] = taitosj_colscrolly[32 * which + i] + taitosj_scroll[2 * which + 1];
scrolly[31 - i] = state->colscrolly[32 * which + i] + state->scroll[2 * which + 1];
else
for (i = 0;i < 32;i++)
scrolly[i] = -taitosj_colscrolly[32 * which + i] - taitosj_scroll[2 * which + 1];
scrolly[i] = -state->colscrolly[32 * which + i] - state->scroll[2 * which + 1];
copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 1, &scrollx, 32, scrolly, cliprect, TRANSPARENT_PEN);
copyscrollbitmap_trans(bitmap, state->layer_bitmap[which], 1, &scrollx, 32, scrolly, cliprect, TRANSPARENT_PEN);
/* store parts covered with sprites for sprites/layers collision detection */
for (i = 0; i < 0x20; i++)
@ -654,7 +650,7 @@ static void taitosj_copy_layer(running_machine *machine, bitmap_t *bitmap, const
if ((i >= 0x10) && (i <= 0x17)) continue; /* no sprites here */
if (sprites_on[i])
copyscrollbitmap(sprite_layer_collbitmap2[which], taitosj_layer_bitmap[which], 1, &scrollx, 32, scrolly, &sprite_areas[i]);
copyscrollbitmap(state->sprite_layer_collbitmap2[which], state->layer_bitmap[which], 1, &scrollx, 32, scrolly, &sprite_areas[i]);
}
}
}
@ -663,7 +659,8 @@ static void taitosj_copy_layer(running_machine *machine, bitmap_t *bitmap, const
static void kikstart_copy_layer(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,
int which, int *sprites_on, rectangle *sprite_areas)
{
if (*taitosj_video_mode & layer_enable_mask[which])
taitosj_state *state = machine->driver_data<taitosj_state>();
if (*state->video_mode & layer_enable_mask[which])
{
int i, scrolly, scrollx[32 * 8];
@ -672,19 +669,19 @@ static void kikstart_copy_layer(running_machine *machine, bitmap_t *bitmap, cons
switch (which)
{
case 0: scrollx[32 * 8 - i] = 0 ;break;
case 1: scrollx[32 * 8 - i] = kikstart_scrollram[i] + ((taitosj_scroll[2 * which] + 0x0a) & 0xff);break;
case 2: scrollx[32 * 8 - i] = kikstart_scrollram[0x100 + i] + ((taitosj_scroll[2 * which] + 0xc) & 0xff);break;
case 1: scrollx[32 * 8 - i] = state->kikstart_scrollram[i] + ((state->scroll[2 * which] + 0x0a) & 0xff);break;
case 2: scrollx[32 * 8 - i] = state->kikstart_scrollram[0x100 + i] + ((state->scroll[2 * which] + 0xc) & 0xff);break;
}
else
switch (which)
{
case 0: scrollx[i] = 0 ;break;
case 1: scrollx[i] = 0xff - kikstart_scrollram[i - 1] - ((taitosj_scroll[2 * which] - 0x10) & 0xff);break;
case 2: scrollx[i] = 0xff - kikstart_scrollram[0x100 + i - 1] - ((taitosj_scroll[2 * which] - 0x12) & 0xff);break;
case 1: scrollx[i] = 0xff - state->kikstart_scrollram[i - 1] - ((state->scroll[2 * which] - 0x10) & 0xff);break;
case 2: scrollx[i] = 0xff - state->kikstart_scrollram[0x100 + i - 1] - ((state->scroll[2 * which] - 0x12) & 0xff);break;
}
scrolly = taitosj_scroll[2 * which + 1]; /* always 0 */
copyscrollbitmap_trans(bitmap, taitosj_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, cliprect, TRANSPARENT_PEN);
scrolly = state->scroll[2 * which + 1]; /* always 0 */
copyscrollbitmap_trans(bitmap, state->layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, cliprect, TRANSPARENT_PEN);
/* store parts covered with sprites for sprites/layers collision detection */
for (i = 0; i < 0x20; i++)
@ -692,7 +689,7 @@ static void kikstart_copy_layer(running_machine *machine, bitmap_t *bitmap, cons
if ((i >= 0x10) && (i <= 0x17)) continue; /* no sprites here */
if (sprites_on[i])
copyscrollbitmap(sprite_layer_collbitmap2[which], taitosj_layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, &sprite_areas[i]);
copyscrollbitmap(state->sprite_layer_collbitmap2[which], state->layer_bitmap[which], 32 * 8, scrollx, 1, &scrolly, &sprite_areas[i]);
}
}
}
@ -711,14 +708,15 @@ static void copy_layer(running_machine *machine, bitmap_t *bitmap, const rectang
static void copy_layers(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,
copy_layer_func_t copy_layer_func, int *sprites_on, rectangle *sprite_areas)
{
taitosj_state *state = machine->driver_data<taitosj_state>();
int i = 0;
/* fill the screen with the background color */
bitmap_fill(bitmap, cliprect, 8 * (taitosj_colorbank[1] & 0x07));
bitmap_fill(bitmap, cliprect, 8 * (state->colorbank[1] & 0x07));
for (i = 0; i < 4; i++)
{
int which = draw_order[*taitosj_video_priority & 0x1f][i];
int which = state->draw_order[*state->video_priority & 0x1f][i];
copy_layer(machine, bitmap, cliprect, copy_layer_func, which, sprites_on, sprite_areas);
}

View File

@ -114,39 +114,35 @@ VIDEO_UPDATE( topspeed )
topspeed_state *state = screen->machine->driver_data<topspeed_state>();
UINT8 layer[4];
#ifdef MAME_DEBUG
static UINT8 dislayer[5];
#endif
#ifdef MAME_DEBUG
if (input_code_pressed_once (screen->machine, KEYCODE_V))
{
dislayer[0] ^= 1;
popmessage("bg: %01x", dislayer[0]);
state->dislayer[0] ^= 1;
popmessage("bg: %01x", state->dislayer[0]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_B))
{
dislayer[1] ^= 1;
popmessage("fg: %01x", dislayer[1]);
state->dislayer[1] ^= 1;
popmessage("fg: %01x", state->dislayer[1]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_N))
{
dislayer[2] ^= 1;
popmessage("bg2: %01x", dislayer[2]);
state->dislayer[2] ^= 1;
popmessage("bg2: %01x", state->dislayer[2]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_M))
{
dislayer[3] ^= 1;
popmessage("fg2: %01x", dislayer[3]);
state->dislayer[3] ^= 1;
popmessage("fg2: %01x", state->dislayer[3]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_C))
{
dislayer[4] ^= 1;
popmessage("sprites: %01x", dislayer[4]);
state->dislayer[4] ^= 1;
popmessage("sprites: %01x", state->dislayer[4]);
}
#endif
@ -163,27 +159,27 @@ VIDEO_UPDATE( topspeed )
bitmap_fill(bitmap, cliprect, 0);
#ifdef MAME_DEBUG
if (dislayer[3] == 0)
if (state->dislayer[3] == 0)
#endif
pc080sn_tilemap_draw(state->pc080sn_2, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1);
#ifdef MAME_DEBUG
if (dislayer[2] == 0)
if (state->dislayer[2] == 0)
#endif
pc080sn_tilemap_draw_special(state->pc080sn_2, bitmap, cliprect, layer[1], 0, 2, state->raster_ctrl);
#ifdef MAME_DEBUG
if (dislayer[1] == 0)
if (state->dislayer[1] == 0)
#endif
pc080sn_tilemap_draw_special(state->pc080sn_1, bitmap, cliprect, layer[2], 0, 4, state->raster_ctrl + 0x100);
#ifdef MAME_DEBUG
if (dislayer[0] == 0)
if (state->dislayer[0] == 0)
#endif
pc080sn_tilemap_draw(state->pc080sn_1, bitmap, cliprect, layer[3], 0, 8);
#ifdef MAME_DEBUG
if (dislayer[4] == 0)
if (state->dislayer[4] == 0)
#endif
draw_sprites(screen->machine, bitmap,cliprect);

View File

@ -9,13 +9,7 @@
/*
** variables
*/
UINT8 *tsamurai_videoram;
UINT8 *tsamurai_colorram;
UINT8 *tsamurai_bg_videoram;
static int bgcolor;
static int textbank1, textbank2;
static tilemap_t *background, *foreground;
/***************************************************************************
@ -26,8 +20,9 @@ static tilemap_t *background, *foreground;
static TILE_GET_INFO( get_bg_tile_info )
{
UINT8 attributes = tsamurai_bg_videoram[2*tile_index+1];
int tile_number = tsamurai_bg_videoram[2*tile_index];
tsamurai_state *state = machine->driver_data<tsamurai_state>();
UINT8 attributes = state->bg_videoram[2*tile_index+1];
int tile_number = state->bg_videoram[2*tile_index];
tile_number += (( attributes & 0xc0 ) >> 6 ) * 256; /* legacy */
tile_number += (( attributes & 0x20 ) >> 5 ) * 1024; /* Mission 660 add-on*/
SET_TILE_INFO(
@ -39,13 +34,14 @@ static TILE_GET_INFO( get_bg_tile_info )
static TILE_GET_INFO( get_fg_tile_info )
{
int tile_number = tsamurai_videoram[tile_index];
if (textbank1 & 0x01) tile_number += 256; /* legacy */
if (textbank2 & 0x01) tile_number += 512; /* Mission 660 add-on */
tsamurai_state *state = machine->driver_data<tsamurai_state>();
int tile_number = state->videoram[tile_index];
if (state->textbank1 & 0x01) tile_number += 256; /* legacy */
if (state->textbank2 & 0x01) tile_number += 512; /* Mission 660 add-on */
SET_TILE_INFO(
1,
tile_number,
tsamurai_colorram[((tile_index&0x1f)*2)+1] & 0x1f,
state->colorram[((tile_index&0x1f)*2)+1] & 0x1f,
0);
}
@ -58,11 +54,12 @@ static TILE_GET_INFO( get_fg_tile_info )
VIDEO_START( tsamurai )
{
background = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,32,32);
foreground = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
tsamurai_state *state = machine->driver_data<tsamurai_state>();
state->background = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,32,32);
state->foreground = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_transparent_pen(background,0);
tilemap_set_transparent_pen(foreground,0);
tilemap_set_transparent_pen(state->background,0);
tilemap_set_transparent_pen(state->foreground,0);
}
@ -74,59 +71,67 @@ VIDEO_START( tsamurai )
WRITE8_HANDLER( tsamurai_scrolly_w )
{
tilemap_set_scrolly( background, 0, data );
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
tilemap_set_scrolly( state->background, 0, data );
}
WRITE8_HANDLER( tsamurai_scrollx_w )
{
tilemap_set_scrollx( background, 0, data );
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
tilemap_set_scrollx( state->background, 0, data );
}
WRITE8_HANDLER( tsamurai_bgcolor_w )
{
bgcolor = data;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
state->bgcolor = data;
}
WRITE8_HANDLER( tsamurai_textbank1_w )
{
if( textbank1!=data )
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
if( state->textbank1!=data )
{
textbank1 = data;
tilemap_mark_all_tiles_dirty( foreground );
state->textbank1 = data;
tilemap_mark_all_tiles_dirty( state->foreground );
}
}
WRITE8_HANDLER( tsamurai_textbank2_w )
{
if( textbank2!=data )
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
if( state->textbank2!=data )
{
textbank2 = data;
tilemap_mark_all_tiles_dirty( foreground );
state->textbank2 = data;
tilemap_mark_all_tiles_dirty( state->foreground );
}
}
WRITE8_HANDLER( tsamurai_bg_videoram_w )
{
tsamurai_bg_videoram[offset]=data;
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
state->bg_videoram[offset]=data;
offset = offset/2;
tilemap_mark_tile_dirty(background,offset);
tilemap_mark_tile_dirty(state->background,offset);
}
WRITE8_HANDLER( tsamurai_fg_videoram_w )
{
tsamurai_videoram[offset]=data;
tilemap_mark_tile_dirty(foreground,offset);
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
state->videoram[offset]=data;
tilemap_mark_tile_dirty(state->foreground,offset);
}
WRITE8_HANDLER( tsamurai_fg_colorram_w )
{
if( tsamurai_colorram[offset]!=data )
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
if( state->colorram[offset]!=data )
{
tsamurai_colorram[offset]=data;
state->colorram[offset]=data;
if (offset & 1)
{
int col = offset/2;
int row;
for (row = 0;row < 32;row++)
tilemap_mark_tile_dirty(foreground,32*row+col);
tilemap_mark_tile_dirty(state->foreground,32*row+col);
}
}
}
@ -140,12 +145,12 @@ WRITE8_HANDLER( tsamurai_fg_colorram_w )
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
tsamurai_state *state = machine->driver_data<tsamurai_state>();
UINT8 *spriteram = machine->generic.spriteram.u8;
gfx_element *gfx = machine->gfx[2];
const UINT8 *source = spriteram+32*4-4;
const UINT8 *finish = spriteram; /* ? */
static int flicker;
flicker = 1-flicker;
state->flicker = 1-state->flicker;
while( source>=finish )
{
@ -200,28 +205,29 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( tsamurai )
{
tsamurai_state *state = screen->machine->driver_data<tsamurai_state>();
int i;
/* Do the column scroll used for the "660" logo on the title screen */
tilemap_set_scroll_cols(foreground, 32);
tilemap_set_scroll_cols(state->foreground, 32);
for (i = 0 ; i < 32 ; i++)
{
tilemap_set_scrolly(foreground, i, tsamurai_colorram[i*2]);
tilemap_set_scrolly(state->foreground, i, state->colorram[i*2]);
}
/* end of column scroll code */
/*
This following isn't particularly efficient. We'd be better off to
dynamically change every 8th palette to the background color, so we
could draw the background as an opaque tilemap.
dynamically change every 8th palette to the state->background color, so we
could draw the state->background as an opaque tilemap.
Note that the background color register isn't well understood
Note that the state->background color register isn't well understood
(screenshots would be helpful)
*/
bitmap_fill(bitmap,cliprect,bgcolor);
tilemap_draw(bitmap,cliprect,background,0,0);
bitmap_fill(bitmap,cliprect,state->bgcolor);
tilemap_draw(bitmap,cliprect,state->background,0,0);
draw_sprites(screen->machine, bitmap,cliprect);
tilemap_draw(bitmap,cliprect,foreground,0,0);
tilemap_draw(bitmap,cliprect,state->foreground,0,0);
return 0;
}
@ -231,23 +237,24 @@ VS Gong Fight runs on older hardware
***************************************************************************/
static int vsgongf_color;
WRITE8_HANDLER( vsgongf_color_w )
{
if( vsgongf_color != data )
tsamurai_state *state = space->machine->driver_data<tsamurai_state>();
if( state->vsgongf_color != data )
{
vsgongf_color = data;
tilemap_mark_all_tiles_dirty( foreground );
state->vsgongf_color = data;
tilemap_mark_all_tiles_dirty( state->foreground );
}
}
static TILE_GET_INFO( get_vsgongf_tile_info )
{
int tile_number = tsamurai_videoram[tile_index];
int color = vsgongf_color&0x1f;
if( textbank1 ) tile_number += 0x100;
tsamurai_state *state = machine->driver_data<tsamurai_state>();
int tile_number = state->videoram[tile_index];
int color = state->vsgongf_color&0x1f;
if( state->textbank1 ) tile_number += 0x100;
SET_TILE_INFO(
1,
tile_number,
@ -257,23 +264,24 @@ static TILE_GET_INFO( get_vsgongf_tile_info )
VIDEO_START( vsgongf )
{
foreground = tilemap_create(machine, get_vsgongf_tile_info,tilemap_scan_rows,8,8,32,32);
tsamurai_state *state = machine->driver_data<tsamurai_state>();
state->foreground = tilemap_create(machine, get_vsgongf_tile_info,tilemap_scan_rows,8,8,32,32);
}
VIDEO_UPDATE( vsgongf )
{
tsamurai_state *state = screen->machine->driver_data<tsamurai_state>();
#ifdef MAME_DEBUG
static int k;
if( input_code_pressed( screen->machine, KEYCODE_Q ) ){
while( input_code_pressed( screen->machine, KEYCODE_Q ) ){
k++;
vsgongf_color = k;
tilemap_mark_all_tiles_dirty( foreground );
state->key_count++;
state->vsgongf_color = state->key_count;
tilemap_mark_all_tiles_dirty( state->foreground );
}
}
#endif
tilemap_draw(bitmap,cliprect,foreground,0,0);
tilemap_draw(bitmap,cliprect,state->foreground,0,0);
draw_sprites(screen->machine,bitmap,cliprect);
return 0;
}

View File

@ -2,27 +2,16 @@
#include "video/taitoic.h"
#include "includes/undrfire.h"
UINT16 undrfire_rotate_ctrl[8];
struct tempsprite
{
int gfx;
int code,color;
int flipx,flipy;
int x,y;
int zoomx,zoomy;
int primask;
};
static struct tempsprite *spritelist;
/******************************************************************/
VIDEO_START( undrfire )
{
undrfire_state *state = machine->driver_data<undrfire_state>();
int i;
spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
state->spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000);
for (i = 0; i < 16384; i++) /* Fix later - some weird colours in places */
palette_set_color(machine, i, MAKE_RGB(0,0,0));
@ -77,6 +66,7 @@ Heavy use is made of sprite zooming.
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,const int *primasks,int x_offs,int y_offs)
{
undrfire_state *state = machine->driver_data<undrfire_state>();
UINT32 *spriteram32 = machine->generic.spriteram.u32;
UINT16 *spritemap = (UINT16 *)machine->region("user1")->base();
int offs, data, tilenum, color, flipx, flipy;
@ -88,7 +78,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
/* pdrawgfx() needs us to draw sprites front to back, so we have to build a list
while processing sprite ram and then draw them all at the end */
struct tempsprite *sprite_ptr = spritelist;
struct tempsprite *sprite_ptr = state->spritelist;
for (offs = (machine->generic.spriteram_size/4-4);offs >= 0;offs -= 4)
{
@ -203,7 +193,7 @@ logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
}
/* this happens only if primsks != NULL */
while (sprite_ptr != spritelist)
while (sprite_ptr != state->spritelist)
{
sprite_ptr--;
@ -220,6 +210,7 @@ logerror("Sprite number %04x had %02x invalid chunks\n",tilenum,bad_chunks);
static void draw_sprites_cbombers(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,const int *primasks,int x_offs,int y_offs)
{
undrfire_state *state = machine->driver_data<undrfire_state>();
UINT32 *spriteram32 = machine->generic.spriteram.u32;
UINT16 *spritemap = (UINT16 *)machine->region("user1")->base();
UINT8 *spritemapHibit = (UINT8 *)machine->region("user2")->base();
@ -233,7 +224,7 @@ static void draw_sprites_cbombers(running_machine *machine, bitmap_t *bitmap,con
/* pdrawgfx() needs us to draw sprites front to back, so we have to build a list
while processing sprite ram and then draw them all at the end */
struct tempsprite *sprite_ptr = spritelist;
struct tempsprite *sprite_ptr = state->spritelist;
for (offs = (machine->generic.spriteram_size/4-4);offs >= 0;offs -= 4)
{
@ -337,7 +328,7 @@ static void draw_sprites_cbombers(running_machine *machine, bitmap_t *bitmap,con
}
/* this happens only if primsks != NULL */
while (sprite_ptr != spritelist)
while (sprite_ptr != state->spritelist)
{
sprite_ptr--;
@ -365,43 +356,40 @@ VIDEO_UPDATE( undrfire )
UINT16 priority;
#ifdef MAME_DEBUG
static UINT8 dislayer[6]; /* Layer toggles to help get layers correct */
#endif
#ifdef MAME_DEBUG
undrfire_state *state = screen->machine->driver_data<undrfire_state>();
if (input_code_pressed_once (screen->machine, KEYCODE_X))
{
dislayer[5] ^= 1;
popmessage("piv text: %01x",dislayer[5]);
state->dislayer[5] ^= 1;
popmessage("piv text: %01x",state->dislayer[5]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_C))
{
dislayer[0] ^= 1;
popmessage("bg0: %01x",dislayer[0]);
state->dislayer[0] ^= 1;
popmessage("bg0: %01x",state->dislayer[0]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_V))
{
dislayer[1] ^= 1;
popmessage("bg1: %01x",dislayer[1]);
state->dislayer[1] ^= 1;
popmessage("bg1: %01x",state->dislayer[1]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_B))
{
dislayer[2] ^= 1;
popmessage("bg2: %01x",dislayer[2]);
state->dislayer[2] ^= 1;
popmessage("bg2: %01x",state->dislayer[2]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_N))
{
dislayer[3] ^= 1;
popmessage("bg3: %01x",dislayer[3]);
state->dislayer[3] ^= 1;
popmessage("bg3: %01x",state->dislayer[3]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_M))
{
dislayer[4] ^= 1;
popmessage("sprites: %01x",dislayer[4]);
state->dislayer[4] ^= 1;
popmessage("sprites: %01x",state->dislayer[4]);
}
#endif
@ -434,27 +422,27 @@ VIDEO_UPDATE( undrfire )
tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, pivlayer[1], 0, 0);
#ifdef MAME_DEBUG
if (dislayer[layer[0]]==0)
if (state->dislayer[layer[0]]==0)
#endif
tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[0], 0, 1);
#ifdef MAME_DEBUG
if (dislayer[layer[1]]==0)
if (state->dislayer[layer[1]]==0)
#endif
tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[1], 0, 2);
#ifdef MAME_DEBUG
if (dislayer[layer[2]]==0)
if (state->dislayer[layer[2]]==0)
#endif
tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[2], 0, 4);
#ifdef MAME_DEBUG
if (dislayer[layer[3]]==0)
if (state->dislayer[layer[3]]==0)
#endif
tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[3], 0, 8);
#ifdef MAME_DEBUG
if (dislayer[4]==0)
if (state->dislayer[4]==0)
#endif
/* Sprites have variable priority (we kludge this on road levels) */
{
@ -471,7 +459,7 @@ VIDEO_UPDATE( undrfire )
}
#ifdef MAME_DEBUG
if (dislayer[5]==0)
if (state->dislayer[5]==0)
#endif
tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, pivlayer[2], 0, 0); /* piv text layer */
@ -493,7 +481,7 @@ VIDEO_UPDATE( undrfire )
for (i = 0; i < 8; i += 1)
{
sprintf (buf, "%02x: %04x", i, undrfire_rotate_ctrl[i]);
sprintf (buf, "%02x: %04x", i, state->rotate_ctrl[i]);
ui_draw_text (buf, 0, i*8);
}
}
@ -511,43 +499,40 @@ VIDEO_UPDATE( cbombers )
UINT16 priority;
#ifdef MAME_DEBUG
static UINT8 dislayer[6]; /* Layer toggles to help get layers correct */
#endif
#ifdef MAME_DEBUG
undrfire_state *state = screen->machine->driver_data<undrfire_state>();
if (input_code_pressed_once (screen->machine, KEYCODE_X))
{
dislayer[5] ^= 1;
popmessage("piv text: %01x",dislayer[5]);
state->dislayer[5] ^= 1;
popmessage("piv text: %01x",state->dislayer[5]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_C))
{
dislayer[0] ^= 1;
popmessage("bg0: %01x",dislayer[0]);
state->dislayer[0] ^= 1;
popmessage("bg0: %01x",state->dislayer[0]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_V))
{
dislayer[1] ^= 1;
popmessage("bg1: %01x",dislayer[1]);
state->dislayer[1] ^= 1;
popmessage("bg1: %01x",state->dislayer[1]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_B))
{
dislayer[2] ^= 1;
popmessage("bg2: %01x",dislayer[2]);
state->dislayer[2] ^= 1;
popmessage("bg2: %01x",state->dislayer[2]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_N))
{
dislayer[3] ^= 1;
popmessage("bg3: %01x",dislayer[3]);
state->dislayer[3] ^= 1;
popmessage("bg3: %01x",state->dislayer[3]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_M))
{
dislayer[4] ^= 1;
popmessage("sprites: %01x",dislayer[4]);
state->dislayer[4] ^= 1;
popmessage("sprites: %01x",state->dislayer[4]);
}
#endif
@ -580,27 +565,27 @@ VIDEO_UPDATE( cbombers )
tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, pivlayer[1], 0, 0);
#ifdef MAME_DEBUG
if (dislayer[layer[0]]==0)
if (state->dislayer[layer[0]]==0)
#endif
tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[0], 0, 1);
#ifdef MAME_DEBUG
if (dislayer[layer[1]]==0)
if (state->dislayer[layer[1]]==0)
#endif
tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[1], 0, 2);
#ifdef MAME_DEBUG
if (dislayer[layer[2]]==0)
if (state->dislayer[layer[2]]==0)
#endif
tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[2], 0, 4);
#ifdef MAME_DEBUG
if (dislayer[layer[3]]==0)
if (state->dislayer[layer[3]]==0)
#endif
tc0480scp_tilemap_draw(tc0480scp, bitmap, cliprect, layer[3], 0, 8);
#ifdef MAME_DEBUG
if (dislayer[4]==0)
if (state->dislayer[4]==0)
#endif
/* Sprites have variable priority (we kludge this on road levels) */
{
@ -617,7 +602,7 @@ VIDEO_UPDATE( cbombers )
}
#ifdef MAME_DEBUG
if (dislayer[5]==0)
if (state->dislayer[5]==0)
#endif
tc0100scn_tilemap_draw(tc0100scn, bitmap, cliprect, pivlayer[2], 0, 0); /* piv text layer */
@ -631,7 +616,7 @@ VIDEO_UPDATE( cbombers )
for (i = 0; i < 8; i += 1)
{
sprintf (buf, "%02x: %04x", i, undrfire_rotate_ctrl[i]);
sprintf (buf, "%02x: %04x", i, state->rotate_ctrl[i]);
ui_draw_text (buf, 0, i*8);
}
}

View File

@ -649,33 +649,29 @@ VIDEO_UPDATE( wgp )
int i;
UINT8 layer[3];
#ifdef MAME_DEBUG
static UINT8 dislayer[4];
#endif
#ifdef MAME_DEBUG
if (input_code_pressed_once (screen->machine, KEYCODE_V))
{
dislayer[0] ^= 1;
popmessage("piv0: %01x",dislayer[0]);
state->dislayer[0] ^= 1;
popmessage("piv0: %01x",state->dislayer[0]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_B))
{
dislayer[1] ^= 1;
popmessage("piv1: %01x",dislayer[1]);
state->dislayer[1] ^= 1;
popmessage("piv1: %01x",state->dislayer[1]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_N))
{
dislayer[2] ^= 1;
popmessage("piv2: %01x",dislayer[2]);
state->dislayer[2] ^= 1;
popmessage("piv2: %01x",state->dislayer[2]);
}
if (input_code_pressed_once (screen->machine, KEYCODE_M))
{
dislayer[3] ^= 1;
popmessage("TC0100SCN top bg layer: %01x",dislayer[3]);
state->dislayer[3] ^= 1;
popmessage("TC0100SCN top bg layer: %01x",state->dislayer[3]);
}
#endif
@ -702,17 +698,17 @@ VIDEO_UPDATE( wgp )
/* We should draw the following on a 1024x1024 bitmap... */
#ifdef MAME_DEBUG
if (dislayer[layer[0]] == 0)
if (state->dislayer[layer[0]] == 0)
#endif
wgp_piv_layer_draw(screen->machine, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1);
#ifdef MAME_DEBUG
if (dislayer[layer[1]] == 0)
if (state->dislayer[layer[1]] == 0)
#endif
wgp_piv_layer_draw(screen->machine, bitmap, cliprect, layer[1], 0, 2);
#ifdef MAME_DEBUG
if (dislayer[layer[2]] == 0)
if (state->dislayer[layer[2]] == 0)
#endif
wgp_piv_layer_draw(screen->machine, bitmap, cliprect, layer[2], 0, 4);
@ -726,7 +722,7 @@ VIDEO_UPDATE( wgp )
tc0100scn_tilemap_draw(state->tc0100scn, bitmap, cliprect, layer[0], 0, 0);
#ifdef MAME_DEBUG
if (dislayer[3] == 0)
if (state->dislayer[3] == 0)
#endif
tc0100scn_tilemap_draw(state->tc0100scn, bitmap, cliprect, layer[1], 0, 0);
tc0100scn_tilemap_draw(state->tc0100scn, bitmap, cliprect, layer[2], 0, 0);