Added driver data struct and save states to fantland.c and firetrap.c

Added driver data struct to dcheese.c
This commit is contained in:
Fabio Priuli 2009-11-27 10:08:26 +00:00
parent 7e6ff401f5
commit 5ea417d583
9 changed files with 623 additions and 377 deletions

2
.gitattributes vendored
View File

@ -2435,10 +2435,12 @@ src/mame/includes/exidy440.h svneol=native#text/plain
src/mame/includes/exprraid.h svneol=native#text/plain
src/mame/includes/exterm.h svneol=native#text/plain
src/mame/includes/f1gp.h svneol=native#text/plain
src/mame/includes/fantland.h svneol=native#text/plain
src/mame/includes/fastfred.h svneol=native#text/plain
src/mame/includes/fcombat.h svneol=native#text/plain
src/mame/includes/fgoal.h svneol=native#text/plain
src/mame/includes/finalizr.h svneol=native#text/plain
src/mame/includes/firetrap.h svneol=native#text/plain
src/mame/includes/firetrk.h svneol=native#text/plain
src/mame/includes/fitfight.h svneol=native#text/plain
src/mame/includes/flower.h svneol=native#text/plain

View File

@ -31,7 +31,7 @@
#include "driver.h"
#include "cpu/m6809/m6809.h"
#include "cpu/m68000/m68000.h"
#include "machine/eeprom.h"
#include "machine/eepromdev.h"
#include "machine/ticket.h"
#include "sound/bsmt2000.h"
#include "dcheese.h"
@ -41,38 +41,28 @@
#define SOUND_OSC 24000000
/*************************************
*
* Local variables
*
*************************************/
static UINT8 irq_state[5];
static UINT8 soundlatch_full;
static UINT8 sound_control;
static UINT8 sound_msb_latch;
/*************************************
*
* Interrupts
*
*************************************/
static void update_irq_state(const device_config *cpu)
static void update_irq_state( const device_config *cpu )
{
dcheese_state *state = (dcheese_state *)cpu->machine->driver_data;
int i;
for (i = 1; i < 5; i++)
cpu_set_input_line(cpu, i, irq_state[i] ? ASSERT_LINE : CLEAR_LINE);
cpu_set_input_line(cpu, i, state->irq_state[i] ? ASSERT_LINE : CLEAR_LINE);
}
static IRQ_CALLBACK(irq_callback)
static IRQ_CALLBACK( irq_callback )
{
dcheese_state *state = (dcheese_state *)device->machine->driver_data;
/* auto-ack the IRQ */
irq_state[irqline] = 0;
state->irq_state[irqline] = 0;
update_irq_state(device);
/* vector is 0x40 + index */
@ -80,10 +70,12 @@ static IRQ_CALLBACK(irq_callback)
}
void dcheese_signal_irq(running_machine *machine, int which)
void dcheese_signal_irq( running_machine *machine, int which )
{
irq_state[which] = 1;
update_irq_state(cputag_get_cpu(machine, "maincpu"));
dcheese_state *state = (dcheese_state *)machine->driver_data;
state->irq_state[which] = 1;
update_irq_state(state->maincpu);
}
@ -103,12 +95,18 @@ static INTERRUPT_GEN( dcheese_vblank )
static MACHINE_START( dcheese )
{
cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), irq_callback);
dcheese_state *state = (dcheese_state *)machine->driver_data;
state_save_register_global_array(machine, irq_state);
state_save_register_global(machine, soundlatch_full);
state_save_register_global(machine, sound_control);
state_save_register_global(machine, sound_msb_latch);
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
state->bsmt = devtag_get_device(machine, "bsmt");
cpu_set_irq_callback(state->maincpu, irq_callback);
state_save_register_global_array(machine, state->irq_state);
state_save_register_global(machine, state->soundlatch_full);
state_save_register_global(machine, state->sound_control);
state_save_register_global(machine, state->sound_msb_latch);
}
@ -121,7 +119,8 @@ static MACHINE_START( dcheese )
static CUSTOM_INPUT( sound_latch_state_r )
{
return soundlatch_full;
dcheese_state *state = (dcheese_state *)field->port->machine->driver_data;
return state->soundlatch_full;
}
@ -131,9 +130,7 @@ static WRITE16_HANDLER( eeprom_control_w )
/* bits $0080-$0010 are probably lamps */
if (ACCESSING_BITS_0_7)
{
eeprom_set_cs_line(~data & 8);
eeprom_write_bit(data & 2);
eeprom_set_clock_line(data & 4);
input_port_write(space->machine, "EEPROMOUT", data, 0xff);
ticket_dispenser_w(space, 0, (data & 1) << 7);
}
}
@ -141,11 +138,13 @@ static WRITE16_HANDLER( eeprom_control_w )
static WRITE16_HANDLER( sound_command_w )
{
dcheese_state *state = (dcheese_state *)space->machine->driver_data;
if (ACCESSING_BITS_0_7)
{
/* write the latch and set the IRQ */
soundlatch_full = 1;
cputag_set_input_line(space->machine, "audiocpu", 0, ASSERT_LINE);
state->soundlatch_full = 1;
cpu_set_input_line(state->audiocpu, 0, ASSERT_LINE);
soundlatch_w(space, 0, data & 0xff);
}
}
@ -160,9 +159,11 @@ static WRITE16_HANDLER( sound_command_w )
static READ8_HANDLER( sound_command_r )
{
dcheese_state *state = (dcheese_state *)space->machine->driver_data;
/* read the latch and clear the IRQ */
soundlatch_full = 0;
cputag_set_input_line(space->machine, "audiocpu", 0, CLEAR_LINE);
state->soundlatch_full = 0;
cpu_set_input_line(state->audiocpu, 0, CLEAR_LINE);
return soundlatch_r(space, 0);
}
@ -176,13 +177,14 @@ static READ8_HANDLER( sound_status_r )
static WRITE8_HANDLER( sound_control_w )
{
UINT8 diff = data ^ sound_control;
sound_control = data;
dcheese_state *state = (dcheese_state *)space->machine->driver_data;
UINT8 diff = data ^ state->sound_control;
state->sound_control = data;
/* bit 0x20 = LED */
/* bit 0x40 = BSMT2000 reset */
if ((diff & 0x40) && (data & 0x40))
devtag_reset(space->machine, "bsmt");
device_reset(state->bsmt);
if (data != 0x40 && data != 0x60)
logerror("%04X:sound_control_w = %02X\n", cpu_get_pc(space->cpu), data);
}
@ -190,11 +192,13 @@ static WRITE8_HANDLER( sound_control_w )
static WRITE8_DEVICE_HANDLER( bsmt_data_w )
{
dcheese_state *state = (dcheese_state *)device->machine->driver_data;
/* writes come in pairs; even bytes latch, odd bytes write */
if (offset % 2 == 0)
sound_msb_latch = data;
state->sound_msb_latch = data;
else
bsmt2000_data_w(device, offset/2, (sound_msb_latch << 8) | data, 0xffff);
bsmt2000_data_w(device, offset / 2, (state->sound_msb_latch << 8) | data, 0xffff);
}
@ -252,7 +256,7 @@ static INPUT_PORTS_START( dcheese )
PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SERVICE ) /* says tilt */
PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_TILT ) /* says test */
PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON3 ) /* bump left */
PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON4 ) /* bump right */
@ -288,6 +292,11 @@ static INPUT_PORTS_START( dcheese )
PORT_START("2a000e")
PORT_BIT( 0x00ff, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(100) PORT_KEYDELTA(30) PORT_REVERSE
PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START( "EEPROMOUT" )
PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
INPUT_PORTS_END
@ -299,7 +308,7 @@ static INPUT_PORTS_START( lottof2 )
PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SERVICE )
PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
PORT_BIT( 0x1f00, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON1 ) /* button */
PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON2 ) /* ticket */
@ -331,6 +340,11 @@ static INPUT_PORTS_START( lottof2 )
PORT_START("2a000e")
PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START( "EEPROMOUT" )
PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
INPUT_PORTS_END
@ -342,7 +356,7 @@ static INPUT_PORTS_START( fredmem )
PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SERVICE )
PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
PORT_BIT( 0x1f00, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_5_PAD)
PORT_BIT( 0xc000, IP_ACTIVE_LOW, IPT_UNUSED )
@ -376,6 +390,11 @@ static INPUT_PORTS_START( fredmem )
PORT_START("2a000e")
PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START( "EEPROMOUT" )
PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
INPUT_PORTS_END
@ -388,6 +407,9 @@ INPUT_PORTS_END
static MACHINE_DRIVER_START( dcheese )
/* driver data */
MDRV_DRIVER_DATA(dcheese_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, MAIN_OSC)
MDRV_CPU_PROGRAM_MAP(main_cpu_map)
@ -399,7 +421,7 @@ static MACHINE_DRIVER_START( dcheese )
MDRV_MACHINE_START(dcheese)
MDRV_NVRAM_HANDLER(93C46)
MDRV_EEPROM_93C46_NODEFAULT_ADD("eeprom")
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)

View File

@ -47,15 +47,11 @@ Year + Game Main CPU Sound CPU Sound Video
#include "cpu/z80/z80.h"
#include "cpu/nec/nec.h"
#include "cpu/i86/i86.h"
#include "cpu/i86/i86.h"
#include "sound/2151intf.h"
#include "sound/3526intf.h"
#include "sound/dac.h"
#include "sound/msm5205.h"
VIDEO_UPDATE( fantland );
static const char *const msm_name[4] = { "msm1", "msm2", "msm3", "msm4" };
#include "fantland.h"
/***************************************************************************
@ -63,32 +59,32 @@ static const char *const msm_name[4] = { "msm1", "msm2", "msm3", "msm4" };
***************************************************************************/
static UINT8 fantland_nmi_enable;
static WRITE8_HANDLER( fantland_nmi_enable_w )
{
fantland_nmi_enable = data;
fantland_state *state = (fantland_state *)space->machine->driver_data;
state->nmi_enable = data;
if ((fantland_nmi_enable != 0) && (fantland_nmi_enable != 8))
if ((state->nmi_enable != 0) && (state->nmi_enable != 8))
logerror("CPU #0 PC = %04X: nmi_enable = %02x\n", cpu_get_pc(space->cpu), data);
}
static WRITE16_HANDLER( fantland_nmi_enable_16_w )
{
if (ACCESSING_BITS_0_7)
fantland_nmi_enable_w(space,offset*2,data);
fantland_nmi_enable_w(space, offset * 2, data);
}
static WRITE8_HANDLER( fantland_soundlatch_w )
{
fantland_state *state = (fantland_state *)space->machine->driver_data;
soundlatch_w(space, 0, data);
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
cpu_set_input_line(state->audio_cpu, INPUT_LINE_NMI, PULSE_LINE);
}
static WRITE16_HANDLER( fantland_soundlatch_16_w )
{
if (ACCESSING_BITS_0_7)
fantland_soundlatch_w(space, offset*2, data);
fantland_soundlatch_w(space, offset * 2, data);
}
/***************************************************************************
@ -97,28 +93,28 @@ static WRITE16_HANDLER( fantland_soundlatch_16_w )
static READ16_HANDLER( spriteram_16_r )
{
return spriteram[2*offset+0] | (spriteram[2*offset+1] << 8);
return spriteram[2 * offset + 0] | (spriteram[2 * offset + 1] << 8);
}
static READ16_HANDLER( spriteram2_16_r )
{
return spriteram_2[2*offset+0] | (spriteram_2[2*offset+1] << 8);
return spriteram_2[2 * offset + 0] | (spriteram_2[2 * offset + 1] << 8);
}
static WRITE16_HANDLER( spriteram_16_w )
{
if (ACCESSING_BITS_0_7)
spriteram[2*offset+0] = data;
spriteram[2 * offset + 0] = data;
if (ACCESSING_BITS_8_15)
spriteram[2*offset+1] = data >> 8;
spriteram[2 * offset + 1] = data >> 8;
}
static WRITE16_HANDLER( spriteram2_16_w )
{
if (ACCESSING_BITS_0_7)
spriteram_2[2*offset+0] = data;
spriteram_2[2 * offset + 0] = data;
if (ACCESSING_BITS_8_15)
spriteram_2[2*offset+1] = data >> 8;
spriteram_2[2 * offset + 1] = data >> 8;
}
static ADDRESS_MAP_START( fantland_map, ADDRESS_SPACE_PROGRAM, 16 )
@ -166,23 +162,22 @@ ADDRESS_MAP_END
static WRITE8_HANDLER( borntofi_nmi_enable_w )
{
fantland_nmi_enable = data;
fantland_state *state = (fantland_state *)space->machine->driver_data;
state->nmi_enable = data;
// data & 0x31 changes when lightgun fires
if ((fantland_nmi_enable != 0) && (fantland_nmi_enable != 8))
if ((state->nmi_enable != 0) && (state->nmi_enable != 8))
logerror("CPU #0 PC = %04X: nmi_enable = %02x\n", cpu_get_pc(space->cpu), data);
// popmessage("%02X",data);
// popmessage("%02X", data);
}
// Trackball doesn't work correctly
static READ8_HANDLER( borntofi_inputs_r )
{
int x,y,f;
static int old_x[2], old_y[2], old_f[2];
static UINT8 ret[2];
fantland_state *state = (fantland_state *)space->machine->driver_data;
int x, y, f;
switch (input_port_read(space->machine, "Controls") & 0x03)
{
@ -197,27 +192,43 @@ static READ8_HANDLER( borntofi_inputs_r )
y = input_port_read(space->machine, offset ? "P2 Trackball Y" : "P1 Trackball Y");
f = video_screen_get_frame_number(space->machine->primary_screen);
ret[offset] = (ret[offset] & 0x14) | (input_port_read(space->machine, offset ? "P2_TRACK" : "P1_TRACK") & 0xc3);
state->input_ret[offset] = (state->input_ret[offset] & 0x14) | (input_port_read(space->machine, offset ? "P2_TRACK" : "P1_TRACK") & 0xc3);
x = (x & 0x7f) - (x & 0x80);
y = (y & 0x7f) - (y & 0x80);
x = (x & 0x7f) - (x & 0x80);
y = (y & 0x7f) - (y & 0x80);
if (old_x[offset] > 0) { ret[offset] = (ret[offset] ^ 0x04) | (( ret[offset] & 0x04) << 1); old_x[offset]--; }
else if (old_x[offset] < 0) { ret[offset] = (ret[offset] ^ 0x04) | (((~ret[offset]) & 0x04) << 1); old_x[offset]++; }
if (old_y[offset] > 0) { ret[offset] = (ret[offset] ^ 0x10) | (( ret[offset] & 0x10) << 1); old_y[offset]--; }
else if (old_y[offset] < 0) { ret[offset] = (ret[offset] ^ 0x10) | (((~ret[offset]) & 0x10) << 1); old_y[offset]++; }
// if (offset == 0) popmessage("x %02d y %02d",old_x[offset], old_y[offset]);
if ((f - old_f[offset]) > 0)
if (state->old_x[offset] > 0)
{
old_x[offset] = x;
old_y[offset] = y;
old_f[offset] = f;
state->input_ret[offset] = (state->input_ret[offset] ^ 0x04) | ((state->input_ret[offset] & 0x04) << 1);
state->old_x[offset]--;
}
else if (state->old_x[offset] < 0)
{
state->input_ret[offset] = (state->input_ret[offset] ^ 0x04) | (((~state->input_ret[offset]) & 0x04) << 1);
state->old_x[offset]++;
}
return ret[offset];
if (state->old_y[offset] > 0)
{
state->input_ret[offset] = (state->input_ret[offset] ^ 0x10) | ((state->input_ret[offset] & 0x10) << 1);
state->old_y[offset]--;
}
else if (state->old_y[offset] < 0)
{
state->input_ret[offset] = (state->input_ret[offset] ^ 0x10) | (((~state->input_ret[offset]) & 0x10) << 1);
state->old_y[offset]++;
}
// if (offset == 0) popmessage("x %02d y %02d", state->old_x[offset], state->old_y[offset]);
if ((f - state->old_f[offset]) > 0)
{
state->old_x[offset] = x;
state->old_y[offset] = y;
state->old_f[offset] = f;
}
return state->input_ret[offset];
}
static ADDRESS_MAP_START( borntofi_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -296,68 +307,73 @@ ADDRESS_MAP_END
Born To Fight
***************************************************************************/
static struct
static void borntofi_adpcm_start( const device_config *device, int voice )
{
int playing;
int addr[2];
int nibble;
} borntofi_adpcm[4];
static void borntofi_adpcm_start(const device_config *device, int voice)
{
msm5205_reset_w(device,0);
borntofi_adpcm[voice].playing = 1;
borntofi_adpcm[voice].nibble = 0;
// logerror("%s: adpcm start = %06x, stop = %06x\n", cpuexec_describe_context(device->machine), borntofi_adpcm[voice].addr[0], borntofi_adpcm[voice].addr[1]);
fantland_state *state = (fantland_state *)device->machine->driver_data;
msm5205_reset_w(device, 0);
state->adpcm_playing[voice] = 1;
state->adpcm_nibble[voice] = 0;
// logerror("%s: adpcm start = %06x, stop = %06x\n", cpuexec_describe_context(device->machine), state->adpcm_addr[0][voice], state->adpcm_addr[1][voice]);
}
static void borntofi_adpcm_stop(const device_config *device, int voice)
static void borntofi_adpcm_stop( const device_config *device, int voice )
{
msm5205_reset_w(device,1);
borntofi_adpcm[voice].playing = 0;
fantland_state *state = (fantland_state *)device->machine->driver_data;
msm5205_reset_w(device, 1);
state->adpcm_playing[voice] = 0;
}
static WRITE8_HANDLER( borntofi_msm5205_w )
{
fantland_state *state = (fantland_state *)space->machine->driver_data;
int voice = offset / 8;
int reg = offset % 8;
int reg = offset % 8;
const device_config *msm;
switch (voice)
{
default:
case 0: msm = state->msm1; break;
case 1: msm = state->msm2; break;
case 2: msm = state->msm3; break;
case 3: msm = state->msm4; break;
}
if (reg == 0)
{
// Play / Stop
switch(data)
{
case 0x00: borntofi_adpcm_stop(devtag_get_device(space->machine, msm_name[voice]), voice); break;
case 0x03: borntofi_adpcm_start(devtag_get_device(space->machine, msm_name[voice]), voice); break;
case 0x00: borntofi_adpcm_stop(msm, voice); break;
case 0x03: borntofi_adpcm_start(msm, voice); break;
default: logerror("CPU #0 PC = %04X: adpcm reg %d <- %02x\n", cpu_get_pc(space->cpu), reg, data);
}
}
else
{
int shift = (reg - 1) * 4;
int mask = ~(0xf << shift);
int mask = ~(0xf << shift);
borntofi_adpcm[voice].addr[0] = (borntofi_adpcm[voice].addr[0] & mask) | (((data & 0xf0) >> 4) << shift);
borntofi_adpcm[voice].addr[1] = (borntofi_adpcm[voice].addr[1] & mask) | (((data & 0x0f) >> 0) << shift);
state->adpcm_addr[0][voice] = (state->adpcm_addr[0][voice] & mask) | (((data & 0xf0) >> 4) << shift);
state->adpcm_addr[1][voice] = (state->adpcm_addr[1][voice] & mask) | (((data & 0x0f) >> 0) << shift);
}
}
static void borntofi_adpcm_int(const device_config *device, int voice)
static void borntofi_adpcm_int( const device_config *device, int voice )
{
fantland_state *state = (fantland_state *)device->machine->driver_data;
UINT8 *rom;
size_t len;
size_t len;
int start, stop;
if (!borntofi_adpcm[voice].playing)
if (!state->adpcm_playing[voice])
return;
rom = memory_region( device->machine, "adpcm" );
len = memory_region_length( device->machine, "adpcm" ) * 2;
rom = memory_region(device->machine, "adpcm");
len = memory_region_length(device->machine, "adpcm") * 2;
start = borntofi_adpcm[voice].addr[0] + borntofi_adpcm[voice].nibble;
stop = borntofi_adpcm[voice].addr[1];
start = state->adpcm_addr[0][voice] + state->adpcm_nibble[voice];
stop = state->adpcm_addr[1][voice];
if (start >= len)
{
@ -372,8 +388,8 @@ static void borntofi_adpcm_int(const device_config *device, int voice)
}
else
{
msm5205_data_w( device, rom[start/2] >> ((start & 1) * 4) );
borntofi_adpcm[voice].nibble++;
msm5205_data_w(device, rom[start / 2] >> ((start & 1) * 4));
state->adpcm_nibble[voice]++;
}
}
@ -385,8 +401,8 @@ static void borntofi_adpcm_int_3(const device_config *device) { borntofi_adpcm_i
static ADDRESS_MAP_START( borntofi_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE( 0x00000, 0x003ff ) AM_RAM
AM_RANGE( 0x04000, 0x04000 ) AM_READ( soundlatch_r )
AM_RANGE( 0x04000, 0x0401f ) AM_WRITE( borntofi_msm5205_w )
AM_RANGE( 0x04000, 0x04000 ) AM_READ(soundlatch_r)
AM_RANGE( 0x04000, 0x0401f ) AM_WRITE(borntofi_msm5205_w)
AM_RANGE( 0x08000, 0x0ffff ) AM_ROM
AM_RANGE( 0xf8000, 0xfffff ) AM_ROM
ADDRESS_MAP_END
@ -805,23 +821,38 @@ GFXDECODE_END
***************************************************************************/
static MACHINE_START( fantland )
{
fantland_state *state = (fantland_state *)machine->driver_data;
state->audio_cpu = devtag_get_device(machine, "audiocpu");
state_save_register_global(machine, state->nmi_enable);
}
static MACHINE_RESET( fantland )
{
fantland_nmi_enable = 0;
fantland_state *state = (fantland_state *)machine->driver_data;
state->nmi_enable = 0;
}
static INTERRUPT_GEN( fantland_irq )
{
if (fantland_nmi_enable & 8)
fantland_state *state = (fantland_state *)device->machine->driver_data;
if (state->nmi_enable & 8)
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}
static INTERRUPT_GEN( fantland_sound_irq )
{
cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0x80/4);
cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0x80 / 4);
}
static MACHINE_DRIVER_START( fantland )
/* driver data */
MDRV_DRIVER_DATA(fantland_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", I8086, 8000000) // ?
MDRV_CPU_PROGRAM_MAP(fantland_map)
@ -833,6 +864,7 @@ static MACHINE_DRIVER_START( fantland )
MDRV_CPU_PERIODIC_INT(fantland_sound_irq, 8000)
// NMI when soundlatch is written
MDRV_MACHINE_START(fantland)
MDRV_MACHINE_RESET(fantland)
MDRV_QUANTUM_TIME(HZ(8000)) // sound irq must feed the DAC at 8kHz
@ -862,9 +894,10 @@ static MACHINE_DRIVER_START( fantland )
MACHINE_DRIVER_END
static void galaxygn_sound_irq(const device_config *device, int line)
static void galaxygn_sound_irq( const device_config *device, int line )
{
cputag_set_input_line_and_vector(device->machine, "audiocpu", 0, line ? ASSERT_LINE : CLEAR_LINE, 0x80/4);
fantland_state *state = (fantland_state *)device->machine->driver_data;
cpu_set_input_line_and_vector(state->audio_cpu, 0, line ? ASSERT_LINE : CLEAR_LINE, 0x80/4);
}
static const ym2151_interface galaxygn_ym2151_interface =
@ -873,6 +906,10 @@ static const ym2151_interface galaxygn_ym2151_interface =
};
static MACHINE_DRIVER_START( galaxygn )
/* driver data */
MDRV_DRIVER_DATA(fantland_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", I8088, 8000000) // ?
MDRV_CPU_PROGRAM_MAP(galaxygn_map)
@ -883,6 +920,7 @@ static MACHINE_DRIVER_START( galaxygn )
MDRV_CPU_IO_MAP(galaxygn_sound_iomap)
// IRQ by YM2151, NMI when soundlatch is written
MDRV_MACHINE_START(fantland)
MDRV_MACHINE_RESET(fantland)
/* video hardware */
@ -930,17 +968,61 @@ static const msm5205_interface msm5205_config_3 =
MSM5205_S48_4B /* 8 kHz, 4 Bits */
};
static MACHINE_START( borntofi )
{
fantland_state *state = (fantland_state *)machine->driver_data;
MACHINE_START_CALL(fantland);
state->msm1 = devtag_get_device(machine, "msm1");
state->msm2 = devtag_get_device(machine, "msm2");
state->msm3 = devtag_get_device(machine, "msm3");
state->msm4 = devtag_get_device(machine, "msm4");
state_save_register_global_array(machine, state->old_x);
state_save_register_global_array(machine, state->old_y);
state_save_register_global_array(machine, state->old_f);
state_save_register_global_array(machine, state->input_ret);
state_save_register_global_array(machine, state->adpcm_playing);
state_save_register_global_array(machine, state->adpcm_addr[0]);
state_save_register_global_array(machine, state->adpcm_addr[1]);
state_save_register_global_array(machine, state->adpcm_nibble);
}
static MACHINE_RESET( borntofi )
{
int voice;
fantland_state *state = (fantland_state *)machine->driver_data;
int i;
MACHINE_RESET_CALL(fantland);
for (voice = 0; voice < 4; voice++)
borntofi_adpcm_stop(devtag_get_device(machine, msm_name[voice]), voice);
for (i = 0; i < 2; i++)
{
state->old_x[i] = 0;
state->old_y[i] = 0;
state->old_f[i] = 0;
state->input_ret[i] = 0;
}
for (i = 0; i < 4; i++)
{
state->adpcm_playing[i] = 1;
state->adpcm_addr[0][i] = 0;
state->adpcm_addr[1][i] = 0;
state->adpcm_nibble[i] = 0;
}
borntofi_adpcm_stop(devtag_get_device(machine, "msm1"), 0);
borntofi_adpcm_stop(devtag_get_device(machine, "msm2"), 1);
borntofi_adpcm_stop(devtag_get_device(machine, "msm3"), 2);
borntofi_adpcm_stop(devtag_get_device(machine, "msm4"), 3);
}
static MACHINE_DRIVER_START( borntofi )
/* driver data */
MDRV_DRIVER_DATA(fantland_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", V20, 16000000/2) // D701080C-8 - NEC D70108C-8 V20 CPU, running at 8.000MHz [16/2]
MDRV_CPU_PROGRAM_MAP(borntofi_map)
@ -949,6 +1031,7 @@ static MACHINE_DRIVER_START( borntofi )
MDRV_CPU_ADD("audiocpu", I8088, 18432000/3) // 8088 - AMD P8088-2 CPU, running at 6.144MHz [18.432/3]
MDRV_CPU_PROGRAM_MAP(borntofi_sound_map)
MDRV_MACHINE_START(borntofi)
MDRV_MACHINE_RESET(borntofi)
/* video hardware */
@ -975,9 +1058,10 @@ MACHINE_DRIVER_END
static void wheelrun_ym3526_irqhandler(const device_config *device, int state)
static void wheelrun_ym3526_irqhandler( const device_config *device, int state )
{
cputag_set_input_line(device->machine, "audiocpu", INPUT_LINE_IRQ0, state);
fantland_state *driver = (fantland_state *)device->machine->driver_data;
cpu_set_input_line(driver->audio_cpu, INPUT_LINE_IRQ0, state);
}
static const ym3526_interface wheelrun_ym3526_interface =
@ -986,6 +1070,10 @@ static const ym3526_interface wheelrun_ym3526_interface =
};
static MACHINE_DRIVER_START( wheelrun )
/* driver data */
MDRV_DRIVER_DATA(fantland_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", V20, XTAL_18MHz/2) // D701080C-8 (V20)
MDRV_CPU_PROGRAM_MAP(wheelrun_map)
@ -995,6 +1083,7 @@ static MACHINE_DRIVER_START( wheelrun )
MDRV_CPU_PROGRAM_MAP(wheelrun_sound_map)
// IRQ by YM3526, NMI when soundlatch is written
MDRV_MACHINE_START(fantland)
MDRV_MACHINE_RESET(fantland)
/* video hardware */
@ -1371,8 +1460,8 @@ ROM_START( wheelrun )
ROM_END
GAME( 19??, borntofi, 0, borntofi, borntofi, 0, ROT0, "International Games", "Born To Fight", 0 )
GAME( 19??, fantland, 0, fantland, fantland, 0, ROT0, "Electronic Devices Italy", "Fantasy Land (set 1)", 0 )
GAME( 19??, fantlanda,fantland, fantland, fantland, 0, ROT0, "Electronic Devices Italy", "Fantasy Land (set 2)", 0 )
GAME( 19??, wheelrun, 0, wheelrun, wheelrun, 0, ROT0, "International Games", "Wheels Runner", 0 )
GAME( 1989, galaxygn, 0, galaxygn, galaxygn, 0, ROT90, "Electronics Devices Italy", "Galaxy Gunners", GAME_IMPERFECT_SOUND )
GAME( 19??, borntofi, 0, borntofi, borntofi, 0, ROT0, "International Games", "Born To Fight", GAME_SUPPORTS_SAVE )
GAME( 19??, fantland, 0, fantland, fantland, 0, ROT0, "Electronic Devices Italy", "Fantasy Land (set 1)", GAME_SUPPORTS_SAVE )
GAME( 19??, fantlanda, fantland, fantland, fantland, 0, ROT0, "Electronic Devices Italy", "Fantasy Land (set 2)", GAME_SUPPORTS_SAVE )
GAME( 19??, wheelrun, 0, wheelrun, wheelrun, 0, ROT0, "International Games", "Wheels Runner", GAME_SUPPORTS_SAVE )
GAME( 1989, galaxygn, 0, galaxygn, galaxygn, 0, ROT90, "Electronics Devices Italy", "Galaxy Gunners", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )

View File

@ -62,39 +62,18 @@ write:
#include "cpu/m6502/m6502.h"
#include "sound/3526intf.h"
#include "sound/msm5205.h"
#include "firetrap.h"
extern UINT8 *firetrap_bg1videoram;
extern UINT8 *firetrap_bg2videoram;
extern UINT8 *firetrap_fgvideoram;
WRITE8_HANDLER( firetrap_fgvideoram_w );
WRITE8_HANDLER( firetrap_bg1videoram_w );
WRITE8_HANDLER( firetrap_bg2videoram_w );
WRITE8_HANDLER( firetrap_bg1_scrollx_w );
WRITE8_HANDLER( firetrap_bg1_scrolly_w );
WRITE8_HANDLER( firetrap_bg2_scrollx_w );
WRITE8_HANDLER( firetrap_bg2_scrolly_w );
VIDEO_START( firetrap );
PALETTE_INIT( firetrap );
VIDEO_UPDATE( firetrap );
static int firetrap_irq_enable = 0;
static int firetrap_nmi_enable;
static WRITE8_HANDLER( firetrap_nmi_disable_w )
{
firetrap_nmi_enable=~data & 1;
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
state->nmi_enable = ~data & 1;
}
static WRITE8_HANDLER( firetrap_bankselect_w )
{
int bankaddress;
UINT8 *RAM = memory_region(space->machine, "maincpu");
bankaddress = 0x10000 + (data & 0x03) * 0x4000;
memory_set_bankptr(space->machine, 1,&RAM[bankaddress]);
memory_set_bank(space->machine, 1, data & 0x03);
}
static READ8_HANDLER( firetrap_8751_bootleg_r )
@ -102,26 +81,21 @@ static READ8_HANDLER( firetrap_8751_bootleg_r )
/* Check for coin insertion */
/* the following only works in the bootleg version, which doesn't have an */
/* 8751 - the real thing is much more complicated than that. */
if ((input_port_read(space->machine, "IN2") & 0x70) != 0x70) return 0xff;
if ((input_port_read(space->machine, "IN2") & 0x70) != 0x70)
return 0xff;
return 0;
}
static int i8751_return,i8751_current_command;
static MACHINE_RESET( firetrap )
{
i8751_current_command=0;
}
static READ8_HANDLER( firetrap_8751_r )
{
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
//logerror("PC:%04x read from 8751\n",cpu_get_pc(space->cpu));
return i8751_return;
return state->i8751_return;
}
static WRITE8_HANDLER( firetrap_8751_w )
{
static int i8751_init_ptr=0;
static const UINT8 i8751_init_data[]={
0xf5,0xd5,0xdd,0x21,0x05,0xc1,0x87,0x5f,0x87,0x83,0x5f,0x16,0x00,0xdd,0x19,0xd1,
0xf1,0xc9,0xf5,0xd5,0xfd,0x21,0x2f,0xc1,0x87,0x5f,0x16,0x00,0xfd,0x19,0xd1,0xf1,
@ -142,100 +116,103 @@ static WRITE8_HANDLER( firetrap_8751_w )
};
static const int i8751_coin_data[]={ 0x00, 0xb7 };
static const int i8751_36_data[]={ 0x00, 0xbc };
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
/* End of command - important to note, as coin input is supressed while commands are pending */
if (data==0x26) {
i8751_current_command=0;
i8751_return=0xff; /* This value is XOR'd and must equal 0 */
cputag_set_input_line_and_vector(space->machine, "maincpu", 0, HOLD_LINE, 0xff);
if (data == 0x26)
{
state->i8751_current_command = 0;
state->i8751_return = 0xff; /* This value is XOR'd and must equal 0 */
cpu_set_input_line_and_vector(state->maincpu, 0, HOLD_LINE, 0xff);
return;
}
/* Init sequence command */
else if (data==0x13) {
if (!i8751_current_command)
i8751_init_ptr=0;
i8751_return=i8751_init_data[i8751_init_ptr++];
else if (data == 0x13)
{
if (!state->i8751_current_command)
state->i8751_init_ptr = 0;
state->i8751_return = i8751_init_data[state->i8751_init_ptr++];
}
/* Used to calculate a jump address when coins are inserted */
else if (data==0xbd) {
if (!i8751_current_command)
i8751_init_ptr=0;
i8751_return=i8751_coin_data[i8751_init_ptr++];
else if (data == 0xbd)
{
if (!state->i8751_current_command)
state->i8751_init_ptr = 0;
state->i8751_return = i8751_coin_data[state->i8751_init_ptr++];
}
else if (data==0x36) {
if (!i8751_current_command)
i8751_init_ptr=0;
i8751_return=i8751_36_data[i8751_init_ptr++];
else if (data == 0x36)
{
if (!state->i8751_current_command)
state->i8751_init_ptr = 0;
state->i8751_return = i8751_36_data[state->i8751_init_ptr++];
}
/* Static value commands */
else if (data==0x14)
i8751_return=1;
else if (data==0x02)
i8751_return=0;
else if (data==0x72)
i8751_return=3;
else if (data==0x69)
i8751_return=2;
else if (data==0xcb)
i8751_return=0;
else if (data==0x49)
i8751_return=1;
else if (data==0x17)
i8751_return=2;
else if (data==0x88)
i8751_return=3;
else {
i8751_return=0xff;
else if (data == 0x14)
state->i8751_return = 1;
else if (data == 0x02)
state->i8751_return = 0;
else if (data == 0x72)
state->i8751_return = 3;
else if (data == 0x69)
state->i8751_return = 2;
else if (data == 0xcb)
state->i8751_return = 0;
else if (data == 0x49)
state->i8751_return = 1;
else if (data == 0x17)
state->i8751_return = 2;
else if (data == 0x88)
state->i8751_return = 3;
else
{
state->i8751_return = 0xff;
logerror("%04x: Unknown i8751 command %02x!\n",cpu_get_pc(space->cpu),data);
}
/* Signal main cpu task is complete */
cputag_set_input_line_and_vector(space->machine, "maincpu", 0, HOLD_LINE, 0xff);
i8751_current_command=data;
cpu_set_input_line_and_vector(state->maincpu, 0, HOLD_LINE, 0xff);
state->i8751_current_command=data;
}
static WRITE8_HANDLER( firetrap_sound_command_w )
{
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
soundlatch_w(space, offset, data);
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
}
static WRITE8_HANDLER( firetrap_sound_2400_w )
{
msm5205_reset_w(devtag_get_device(space->machine, "msm"),~data & 0x01);
firetrap_irq_enable = data & 0x02;
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
msm5205_reset_w(state->msm, ~data & 0x01);
state->irq_enable = data & 0x02;
}
static WRITE8_HANDLER( firetrap_sound_bankselect_w )
{
int bankaddress;
UINT8 *RAM = memory_region(space->machine, "audiocpu");
bankaddress = 0x10000 + (data & 0x01) * 0x4000;
memory_set_bankptr(space->machine, 2, &RAM[bankaddress]);
memory_set_bank(space->machine, 2, data & 0x01);
}
static int msm5205next;
static void firetrap_adpcm_int (const device_config *device)
static void firetrap_adpcm_int( const device_config *device )
{
static int toggle = 0;
firetrap_state *state = (firetrap_state *)device->machine->driver_data;
msm5205_data_w(device, msm5205next >> 4);
msm5205next <<= 4;
msm5205_data_w(device, state->msm5205next >> 4);
state->msm5205next <<= 4;
toggle ^= 1;
if (firetrap_irq_enable && toggle)
cputag_set_input_line (device->machine, "audiocpu", M6502_IRQ_LINE, HOLD_LINE);
state->adpcm_toggle ^= 1;
if (state->irq_enable && state->adpcm_toggle)
cpu_set_input_line(state->audiocpu, M6502_IRQ_LINE, HOLD_LINE);
}
static WRITE8_HANDLER( firetrap_adpcm_data_w )
{
msm5205next = data;
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
state->msm5205next = data;
}
static WRITE8_HANDLER( flip_screen_w )
@ -248,10 +225,10 @@ static ADDRESS_MAP_START( firetrap_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK(1)
AM_RANGE(0xc000, 0xcfff) AM_RAM
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(firetrap_bg1videoram_w) AM_BASE(&firetrap_bg1videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(firetrap_bg2videoram_w) AM_BASE(&firetrap_bg2videoram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(firetrap_fgvideoram_w) AM_BASE(&firetrap_fgvideoram)
AM_RANGE(0xe800, 0xe97f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(firetrap_bg1videoram_w) AM_BASE_MEMBER(firetrap_state, bg1videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(firetrap_bg2videoram_w) AM_BASE_MEMBER(firetrap_state, bg2videoram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(firetrap_fgvideoram_w) AM_BASE_MEMBER(firetrap_state, fgvideoram)
AM_RANGE(0xe800, 0xe97f) AM_RAM AM_BASE_MEMBER(firetrap_state, spriteram) AM_SIZE(&spriteram_size)
AM_RANGE(0xf000, 0xf000) AM_WRITENOP /* IRQ acknowledge */
AM_RANGE(0xf001, 0xf001) AM_WRITE(firetrap_sound_command_w)
AM_RANGE(0xf002, 0xf002) AM_WRITE(firetrap_bankselect_w)
@ -274,10 +251,10 @@ static ADDRESS_MAP_START( firetrap_bootleg_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK(1)
AM_RANGE(0xc000, 0xcfff) AM_RAM
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(firetrap_bg1videoram_w) AM_BASE(&firetrap_bg1videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(firetrap_bg2videoram_w) AM_BASE(&firetrap_bg2videoram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(firetrap_fgvideoram_w) AM_BASE(&firetrap_fgvideoram)
AM_RANGE(0xe800, 0xe97f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(firetrap_bg1videoram_w) AM_BASE_MEMBER(firetrap_state, bg1videoram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(firetrap_bg2videoram_w) AM_BASE_MEMBER(firetrap_state, bg2videoram)
AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(firetrap_fgvideoram_w) AM_BASE_MEMBER(firetrap_state, fgvideoram)
AM_RANGE(0xe800, 0xe97f) AM_RAM AM_BASE_MEMBER(firetrap_state, spriteram) AM_SIZE(&spriteram_size)
AM_RANGE(0xf000, 0xf000) AM_WRITENOP /* IRQ acknowledge */
AM_RANGE(0xf001, 0xf001) AM_WRITE(firetrap_sound_command_w)
AM_RANGE(0xf002, 0xf002) AM_WRITE(firetrap_bankselect_w)
@ -524,41 +501,99 @@ static const msm5205_interface msm5205_config =
static INTERRUPT_GEN( firetrap )
{
static int latch=0;
static int coin_command_pending=0;
firetrap_state *state = (firetrap_state *)device->machine->driver_data;
/* Check for coin IRQ */
if (cpu_getiloops(device))
{
if ((input_port_read(device->machine, "COIN") & 0x7) != 0x7 && !latch)
if ((input_port_read(device->machine, "COIN") & 0x7) != 0x7 && !state->int_latch)
{
coin_command_pending = ~input_port_read(device->machine, "COIN");
latch=1;
state->coin_command_pending = ~input_port_read(device->machine, "COIN");
state->int_latch = 1;
}
if ((input_port_read(device->machine, "COIN") & 0x7) == 0x7)
latch=0;
state->int_latch = 0;
/* Make sure coin IRQ's aren't generated when another command is pending, the main cpu
definitely doesn't expect them as it locks out the coin routine */
if (coin_command_pending && !i8751_current_command) {
i8751_return=coin_command_pending;
cpu_set_input_line_and_vector(device,0,HOLD_LINE,0xff);
coin_command_pending=0;
if (state->coin_command_pending && !state->i8751_current_command)
{
state->i8751_return = state->coin_command_pending;
cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xff);
state->coin_command_pending = 0;
}
}
if (firetrap_nmi_enable && !cpu_getiloops(device))
cpu_set_input_line (device, INPUT_LINE_NMI, PULSE_LINE);
if (state->nmi_enable && !cpu_getiloops(device))
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
}
static INTERRUPT_GEN( bootleg )
{
if (firetrap_nmi_enable)
firetrap_state *state = (firetrap_state *)device->machine->driver_data;
if (state->nmi_enable)
cpu_set_input_line (device, INPUT_LINE_NMI, PULSE_LINE);
}
static MACHINE_START( firetrap )
{
firetrap_state *state = (firetrap_state *)machine->driver_data;
UINT8 *MAIN = memory_region(machine, "maincpu");
UINT8 *SOUND = memory_region(machine, "audiocpu");
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
state->msm = devtag_get_device(machine, "msm");
memory_configure_bank(machine, 1, 0, 4, &MAIN[0x10000], 0x4000);
memory_configure_bank(machine, 2, 0, 2, &SOUND[0x10000], 0x4000);
state_save_register_global(machine, state->i8751_current_command);
state_save_register_global(machine, state->irq_enable);
state_save_register_global(machine, state->nmi_enable);
state_save_register_global(machine, state->i8751_return);
state_save_register_global(machine, state->i8751_init_ptr);
state_save_register_global(machine, state->msm5205next);
state_save_register_global(machine, state->adpcm_toggle);
state_save_register_global(machine, state->int_latch);
state_save_register_global(machine, state->coin_command_pending);
state_save_register_global_array(machine, state->scroll1_x);
state_save_register_global_array(machine, state->scroll1_y);
state_save_register_global_array(machine, state->scroll2_x);
state_save_register_global_array(machine, state->scroll2_y);
}
static MACHINE_RESET( firetrap )
{
firetrap_state *state = (firetrap_state *)machine->driver_data;
int i;
for (i = 0; i < 2; i++)
{
state->scroll1_x[i] = 0;
state->scroll1_y[i] = 0;
state->scroll2_x[i] = 0;
state->scroll2_y[i] = 0;
}
state->i8751_current_command = 0;
state->irq_enable = 0;
state->nmi_enable = 0;
state->i8751_return = 0;
state->i8751_init_ptr = 0;
state->msm5205next = 0xff;
state->adpcm_toggle = 0;
state->int_latch = 0;
state->coin_command_pending = 0;
}
static MACHINE_DRIVER_START( firetrap )
/* driver data */
MDRV_DRIVER_DATA(firetrap_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 6000000) /* 6 MHz */
MDRV_CPU_PROGRAM_MAP(firetrap_map)
@ -568,6 +603,8 @@ static MACHINE_DRIVER_START( firetrap )
MDRV_CPU_PROGRAM_MAP(sound_map)
/* IRQs are caused by the ADPCM chip */
/* NMIs are caused by the main CPU */
MDRV_MACHINE_START(firetrap)
MDRV_MACHINE_RESET(firetrap)
/* video hardware */
@ -598,6 +635,9 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( firetpbl )
/* driver data */
MDRV_DRIVER_DATA(firetrap_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 6000000) /* 6 MHz */
MDRV_CPU_PROGRAM_MAP(firetrap_bootleg_map)
@ -608,6 +648,9 @@ static MACHINE_DRIVER_START( firetpbl )
/* IRQs are caused by the ADPCM chip */
/* NMIs are caused by the main CPU */
MDRV_MACHINE_START(firetrap)
MDRV_MACHINE_RESET(firetrap)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@ -767,5 +810,5 @@ ROM_END
GAME( 1986, firetrap, 0, firetrap, firetrap, 0, ROT90, "Data East USA", "Fire Trap (US)", 0 )
GAME( 1986, firetpbl, firetrap, firetpbl, firetpbl, 0, ROT90, "bootleg", "Fire Trap (Japan bootleg)", 0 )
GAME( 1986, firetrap, 0, firetrap, firetrap, 0, ROT90, "Data East USA", "Fire Trap (US)", GAME_SUPPORTS_SAVE )
GAME( 1986, firetpbl, firetrap, firetpbl, firetpbl, 0, ROT90, "bootleg", "Fire Trap (Japan bootleg)", GAME_SUPPORTS_SAVE )

View File

@ -5,6 +5,31 @@
**************************************************************************/
typedef struct _dcheese_state dcheese_state;
struct _dcheese_state
{
/* video-related */
UINT16 blitter_color[2];
UINT16 blitter_xparam[16];
UINT16 blitter_yparam[16];
UINT16 blitter_vidparam[32];
bitmap_t *dstbitmap;
emu_timer *blitter_timer;
/* misc */
UINT8 irq_state[5];
UINT8 soundlatch_full;
UINT8 sound_control;
UINT8 sound_msb_latch;
/* devices */
const device_config *maincpu;
const device_config *audiocpu;
const device_config *bsmt;
};
/*----------- defined in drivers/dcheese.c -----------*/
void dcheese_signal_irq(running_machine *machine, int which);

View File

@ -0,0 +1,30 @@
typedef struct _fantland_state fantland_state;
struct _fantland_state
{
/* memory pointers */
// UINT8 * spriteram; // currently directly used in a 16bit map...
// UINT8 * spriteram_2; // currently directly used in a 16bit map...
// UINT8 * paletteram; // currently this uses generic palette handling
/* misc */
UINT8 nmi_enable;
int old_x[2], old_y[2], old_f[2];
UINT8 input_ret[2];
int adpcm_playing[4];
int adpcm_addr[2][4];
int adpcm_nibble[4];
/* devices */
const device_config *audio_cpu;
const device_config *msm1;
const device_config *msm2;
const device_config *msm3;
const device_config *msm4;
};
/*----------- defined in video/fantland.c -----------*/
VIDEO_UPDATE( fantland );

View File

@ -0,0 +1,49 @@
/***************************************************************************
Fire Trap
***************************************************************************/
typedef struct _firetrap_state firetrap_state;
struct _firetrap_state
{
/* memory pointers */
UINT8 * bg1videoram;
UINT8 * bg2videoram;
UINT8 * fgvideoram;
UINT8 * spriteram;
/* video-related */
tilemap *fg_tilemap, *bg1_tilemap, *bg2_tilemap;
UINT8 scroll1_x[2], scroll1_y[2];
UINT8 scroll2_x[2], scroll2_y[2];
/* misc */
int irq_enable, nmi_enable;
int i8751_return, i8751_current_command;
int i8751_init_ptr;
int msm5205next;
int adpcm_toggle;
int int_latch;
int coin_command_pending;
/* devices */
const device_config *maincpu;
const device_config *audiocpu;
const device_config *msm;
};
/*----------- defined in video/firetrap.c -----------*/
WRITE8_HANDLER( firetrap_fgvideoram_w );
WRITE8_HANDLER( firetrap_bg1videoram_w );
WRITE8_HANDLER( firetrap_bg2videoram_w );
WRITE8_HANDLER( firetrap_bg1_scrollx_w );
WRITE8_HANDLER( firetrap_bg1_scrolly_w );
WRITE8_HANDLER( firetrap_bg2_scrollx_w );
WRITE8_HANDLER( firetrap_bg2_scrolly_w );
PALETTE_INIT( firetrap );
VIDEO_START( firetrap );
VIDEO_UPDATE( firetrap );

View File

@ -19,23 +19,6 @@
#define DSTBITMAP_HEIGHT 512
/*************************************
*
* Local variables
*
*************************************/
static UINT16 blitter_color[2];
static UINT16 blitter_xparam[16];
static UINT16 blitter_yparam[16];
static UINT16 blitter_vidparam[32];
static bitmap_t *dstbitmap;
static emu_timer *blitter_timer;
/*************************************
*
* Palette translation
@ -64,24 +47,26 @@ PALETTE_INIT( dcheese )
*
*************************************/
static void update_scanline_irq(running_machine *machine)
static void update_scanline_irq( running_machine *machine )
{
dcheese_state *state = (dcheese_state *)machine->driver_data;
/* if not in range, don't bother */
if (blitter_vidparam[0x22/2] <= blitter_vidparam[0x1e/2])
if (state->blitter_vidparam[0x22/2] <= state->blitter_vidparam[0x1e/2])
{
int effscan;
attotime time;
/* compute the effective scanline of the interrupt */
effscan = blitter_vidparam[0x22/2] - blitter_vidparam[0x1a/2];
effscan = state->blitter_vidparam[0x22/2] - state->blitter_vidparam[0x1a/2];
if (effscan < 0)
effscan += blitter_vidparam[0x1e/2];
effscan += state->blitter_vidparam[0x1e/2];
/* determine the time; if it's in this scanline, bump to the next frame */
time = video_screen_get_time_until_pos(machine->primary_screen, effscan, 0);
if (attotime_compare(time, video_screen_get_scan_period(machine->primary_screen)) < 0)
time = attotime_add(time, video_screen_get_frame_period(machine->primary_screen));
timer_adjust_oneshot(blitter_timer, time, 0);
timer_adjust_oneshot(state->blitter_timer, time, 0);
}
}
@ -107,18 +92,20 @@ static TIMER_CALLBACK( dcheese_signal_irq_callback )
VIDEO_START( dcheese )
{
dcheese_state *state = (dcheese_state *)machine->driver_data;
/* the destination bitmap is not directly accessible to the CPU */
dstbitmap = auto_bitmap_alloc(machine, DSTBITMAP_WIDTH, DSTBITMAP_HEIGHT, video_screen_get_format(machine->primary_screen));
state->dstbitmap = auto_bitmap_alloc(machine, DSTBITMAP_WIDTH, DSTBITMAP_HEIGHT, video_screen_get_format(machine->primary_screen));
/* create a timer */
blitter_timer = timer_alloc(machine, blitter_scanline_callback, NULL);
state->blitter_timer = timer_alloc(machine, blitter_scanline_callback, NULL);
/* register for saving */
state_save_register_global_array(machine, blitter_color);
state_save_register_global_array(machine, blitter_xparam);
state_save_register_global_array(machine, blitter_yparam);
state_save_register_global_array(machine, blitter_vidparam);
state_save_register_global_bitmap(machine, dstbitmap);
state_save_register_global_array(machine, state->blitter_color);
state_save_register_global_array(machine, state->blitter_xparam);
state_save_register_global_array(machine, state->blitter_yparam);
state_save_register_global_array(machine, state->blitter_vidparam);
state_save_register_global_bitmap(machine, state->dstbitmap);
}
@ -131,13 +118,14 @@ VIDEO_START( dcheese )
VIDEO_UPDATE( dcheese )
{
dcheese_state *state = (dcheese_state *)screen->machine->driver_data;
int x, y;
/* update the pixels */
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
{
UINT16 *dest = BITMAP_ADDR16(bitmap, y, 0);
UINT16 *src = BITMAP_ADDR16(dstbitmap, (y + blitter_vidparam[0x28/2]) % DSTBITMAP_HEIGHT, 0);
UINT16 *src = BITMAP_ADDR16(state->dstbitmap, (y + state->blitter_vidparam[0x28/2]) % DSTBITMAP_HEIGHT, 0);
for (x = cliprect->min_x; x <= cliprect->max_x; x++)
dest[x] = src[x];
@ -153,46 +141,48 @@ VIDEO_UPDATE( dcheese )
*
*************************************/
static void do_clear(running_machine *machine)
static void do_clear( running_machine *machine )
{
dcheese_state *state = (dcheese_state *)machine->driver_data;
int y;
/* clear the requested scanlines */
for (y = blitter_vidparam[0x2c/2]; y < blitter_vidparam[0x2a/2]; y++)
memset(BITMAP_ADDR16(dstbitmap, y % DSTBITMAP_HEIGHT, 0), 0, DSTBITMAP_WIDTH * 2);
for (y = state->blitter_vidparam[0x2c/2]; y < state->blitter_vidparam[0x2a/2]; y++)
memset(BITMAP_ADDR16(state->dstbitmap, y % DSTBITMAP_HEIGHT, 0), 0, DSTBITMAP_WIDTH * 2);
/* signal an IRQ when done (timing is just a guess) */
timer_set(machine, video_screen_get_scan_period(machine->primary_screen), NULL, 1, dcheese_signal_irq_callback);
}
static void do_blit(running_machine *machine)
static void do_blit( running_machine *machine )
{
INT32 srcminx = blitter_xparam[0] << 12;
INT32 srcmaxx = blitter_xparam[1] << 12;
INT32 srcminy = blitter_yparam[0] << 12;
INT32 srcmaxy = blitter_yparam[1] << 12;
INT32 srcx = ((blitter_xparam[2] & 0x0fff) | ((blitter_xparam[3] & 0x0fff) << 12)) << 7;
INT32 srcy = ((blitter_yparam[2] & 0x0fff) | ((blitter_yparam[3] & 0x0fff) << 12)) << 7;
INT32 dxdx = (INT32)(((blitter_xparam[4] & 0x0fff) | ((blitter_xparam[5] & 0x0fff) << 12)) << 12) >> 12;
INT32 dxdy = (INT32)(((blitter_xparam[6] & 0x0fff) | ((blitter_xparam[7] & 0x0fff) << 12)) << 12) >> 12;
INT32 dydx = (INT32)(((blitter_yparam[4] & 0x0fff) | ((blitter_yparam[5] & 0x0fff) << 12)) << 12) >> 12;
INT32 dydy = (INT32)(((blitter_yparam[6] & 0x0fff) | ((blitter_yparam[7] & 0x0fff) << 12)) << 12) >> 12;
dcheese_state *state = (dcheese_state *)machine->driver_data;
INT32 srcminx = state->blitter_xparam[0] << 12;
INT32 srcmaxx = state->blitter_xparam[1] << 12;
INT32 srcminy = state->blitter_yparam[0] << 12;
INT32 srcmaxy = state->blitter_yparam[1] << 12;
INT32 srcx = ((state->blitter_xparam[2] & 0x0fff) | ((state->blitter_xparam[3] & 0x0fff) << 12)) << 7;
INT32 srcy = ((state->blitter_yparam[2] & 0x0fff) | ((state->blitter_yparam[3] & 0x0fff) << 12)) << 7;
INT32 dxdx = (INT32)(((state->blitter_xparam[4] & 0x0fff) | ((state->blitter_xparam[5] & 0x0fff) << 12)) << 12) >> 12;
INT32 dxdy = (INT32)(((state->blitter_xparam[6] & 0x0fff) | ((state->blitter_xparam[7] & 0x0fff) << 12)) << 12) >> 12;
INT32 dydx = (INT32)(((state->blitter_yparam[4] & 0x0fff) | ((state->blitter_yparam[5] & 0x0fff) << 12)) << 12) >> 12;
INT32 dydy = (INT32)(((state->blitter_yparam[6] & 0x0fff) | ((state->blitter_yparam[7] & 0x0fff) << 12)) << 12) >> 12;
UINT8 *src = memory_region(machine, "gfx1");
UINT32 pagemask = (memory_region_length(machine, "gfx1") - 1) / 0x40000;
int xstart = blitter_xparam[14];
int xend = blitter_xparam[15] + 1;
int ystart = blitter_yparam[14];
int yend = blitter_yparam[15];
int color = (blitter_color[0] << 8) & 0xff00;
int mask = (blitter_color[0] >> 8) & 0x00ff;
int xstart = state->blitter_xparam[14];
int xend = state->blitter_xparam[15] + 1;
int ystart = state->blitter_yparam[14];
int yend = state->blitter_yparam[15];
int color = (state->blitter_color[0] << 8) & 0xff00;
int mask = (state->blitter_color[0] >> 8) & 0x00ff;
int opaque = (dxdx | dxdy | dydx | dydy) == 0; /* bit of a hack for fredmem */
int x, y;
/* loop over target rows */
for (y = ystart; y <= yend; y++)
{
UINT16 *dst = BITMAP_ADDR16(dstbitmap, y % DSTBITMAP_HEIGHT, 0);
UINT16 *dst = BITMAP_ADDR16(state->dstbitmap, y % DSTBITMAP_HEIGHT, 0);
/* loop over target columns */
for (x = xstart; x <= xend; x++)
@ -219,20 +209,20 @@ static void do_blit(running_machine *machine)
timer_set(machine, attotime_make(0, attotime_to_attoseconds(video_screen_get_scan_period(machine->primary_screen)) / 2), NULL, 2, dcheese_signal_irq_callback);
/* these extra parameters are written but they are always zero, so I don't know what they do */
if (blitter_xparam[8] != 0 || blitter_xparam[9] != 0 || blitter_xparam[10] != 0 || blitter_xparam[11] != 0 ||
blitter_yparam[8] != 0 || blitter_yparam[9] != 0 || blitter_yparam[10] != 0 || blitter_yparam[11] != 0)
if (state->blitter_xparam[8] != 0 || state->blitter_xparam[9] != 0 || state->blitter_xparam[10] != 0 || state->blitter_xparam[11] != 0 ||
state->blitter_yparam[8] != 0 || state->blitter_yparam[9] != 0 || state->blitter_yparam[10] != 0 || state->blitter_yparam[11] != 0)
{
logerror("%s:blit! (%04X)\n", cpuexec_describe_context(machine), blitter_color[0]);
logerror("%s:blit! (%04X)\n", cpuexec_describe_context(machine), state->blitter_color[0]);
logerror(" %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X\n",
blitter_xparam[0], blitter_xparam[1], blitter_xparam[2], blitter_xparam[3],
blitter_xparam[4], blitter_xparam[5], blitter_xparam[6], blitter_xparam[7],
blitter_xparam[8], blitter_xparam[9], blitter_xparam[10], blitter_xparam[11],
blitter_xparam[12], blitter_xparam[13], blitter_xparam[14], blitter_xparam[15]);
state->blitter_xparam[0], state->blitter_xparam[1], state->blitter_xparam[2], state->blitter_xparam[3],
state->blitter_xparam[4], state->blitter_xparam[5], state->blitter_xparam[6], state->blitter_xparam[7],
state->blitter_xparam[8], state->blitter_xparam[9], state->blitter_xparam[10], state->blitter_xparam[11],
state->blitter_xparam[12], state->blitter_xparam[13], state->blitter_xparam[14], state->blitter_xparam[15]);
logerror(" %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X - %04X %04X %04X %04X\n",
blitter_yparam[0], blitter_yparam[1], blitter_yparam[2], blitter_yparam[3],
blitter_yparam[4], blitter_yparam[5], blitter_yparam[6], blitter_yparam[7],
blitter_yparam[8], blitter_yparam[9], blitter_yparam[10], blitter_yparam[11],
blitter_yparam[12], blitter_yparam[13], blitter_yparam[14], blitter_yparam[15]);
state->blitter_yparam[0], state->blitter_yparam[1], state->blitter_yparam[2], state->blitter_yparam[3],
state->blitter_yparam[4], state->blitter_yparam[5], state->blitter_yparam[6], state->blitter_yparam[7],
state->blitter_yparam[8], state->blitter_yparam[9], state->blitter_yparam[10], state->blitter_yparam[11],
state->blitter_yparam[12], state->blitter_yparam[13], state->blitter_yparam[14], state->blitter_yparam[15]);
}
}
@ -246,25 +236,29 @@ static void do_blit(running_machine *machine)
WRITE16_HANDLER( madmax_blitter_color_w )
{
COMBINE_DATA(&blitter_color[offset]);
dcheese_state *state = (dcheese_state *)space->machine->driver_data;
COMBINE_DATA(&state->blitter_color[offset]);
}
WRITE16_HANDLER( madmax_blitter_xparam_w )
{
COMBINE_DATA(&blitter_xparam[offset]);
dcheese_state *state = (dcheese_state *)space->machine->driver_data;
COMBINE_DATA(&state->blitter_xparam[offset]);
}
WRITE16_HANDLER( madmax_blitter_yparam_w )
{
COMBINE_DATA(&blitter_yparam[offset]);
dcheese_state *state = (dcheese_state *)space->machine->driver_data;
COMBINE_DATA(&state->blitter_yparam[offset]);
}
WRITE16_HANDLER( madmax_blitter_vidparam_w )
{
COMBINE_DATA(&blitter_vidparam[offset]);
dcheese_state *state = (dcheese_state *)space->machine->driver_data;
COMBINE_DATA(&state->blitter_vidparam[offset]);
switch (offset)
{
@ -309,7 +303,7 @@ WRITE16_HANDLER( madmax_blitter_vidparam_w )
WRITE16_HANDLER( madmax_blitter_unknown_w )
{
/* written to just before the blitter command register is written */
logerror("%06X:write to %06X = %04X & %04X\n", cpu_get_pc(space->cpu), 0x300000 + 2 * offset, data, mem_mask);
logerror("%06X:write to %06X = %04X & %04X\n", cpu_get_pc(space->cpu), 0x300000 + 2 * offset, data, mem_mask);
}

View File

@ -7,15 +7,7 @@
***************************************************************************/
#include "driver.h"
UINT8 *firetrap_bg1videoram;
UINT8 *firetrap_bg2videoram;
UINT8 *firetrap_fgvideoram;
static tilemap *fg_tilemap, *bg1_tilemap, *bg2_tilemap;
#include "firetrap.h"
/***************************************************************************
@ -47,9 +39,9 @@ PALETTE_INIT( firetrap )
int i;
for (i = 0;i < machine->config->total_colors;i++)
for (i = 0; i < machine->config->total_colors; i++)
{
int bit0,bit1,bit2,bit3,r,g,b;
int bit0, bit1, bit2, bit3, r, g, b;
bit0 = (color_prom[i] >> 0) & 0x01;
@ -68,7 +60,7 @@ PALETTE_INIT( firetrap )
bit3 = (color_prom[i + machine->config->total_colors] >> 3) & 0x01;
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
palette_set_color(machine,i,MAKE_RGB(r,g,b));
palette_set_color(machine, i, MAKE_RGB(r,g,b));
}
}
@ -93,10 +85,9 @@ static TILEMAP_MAPPER( get_bg_memory_offset )
static TILE_GET_INFO( get_fg_tile_info )
{
int code, color;
code = firetrap_fgvideoram[tile_index];
color = firetrap_fgvideoram[tile_index + 0x400];
firetrap_state *state = (firetrap_state *)machine->driver_data;
int code = state->fgvideoram[tile_index];
int color = state->fgvideoram[tile_index + 0x400];
SET_TILE_INFO(
0,
code | ((color & 0x01) << 8),
@ -106,10 +97,8 @@ static TILE_GET_INFO( get_fg_tile_info )
INLINE void get_bg_tile_info(running_machine *machine, tile_data *tileinfo, int tile_index, UINT8 *bgvideoram, int gfx_region)
{
int code, color;
code = bgvideoram[tile_index];
color = bgvideoram[tile_index + 0x100];
int code = bgvideoram[tile_index];
int color = bgvideoram[tile_index + 0x100];
SET_TILE_INFO(
gfx_region,
code + ((color & 0x03) << 8),
@ -119,12 +108,14 @@ INLINE void get_bg_tile_info(running_machine *machine, tile_data *tileinfo, int
static TILE_GET_INFO( get_bg1_tile_info )
{
get_bg_tile_info(machine, tileinfo, tile_index, firetrap_bg1videoram, 1);
firetrap_state *state = (firetrap_state *)machine->driver_data;
get_bg_tile_info(machine, tileinfo, tile_index, state->bg1videoram, 1);
}
static TILE_GET_INFO( get_bg2_tile_info )
{
get_bg_tile_info(machine, tileinfo, tile_index, firetrap_bg2videoram, 2);
firetrap_state *state = (firetrap_state *)machine->driver_data;
get_bg_tile_info(machine, tileinfo, tile_index, state->bg2videoram, 2);
}
@ -136,12 +127,13 @@ static TILE_GET_INFO( get_bg2_tile_info )
VIDEO_START( firetrap )
{
fg_tilemap = tilemap_create(machine, get_fg_tile_info, get_fg_memory_offset, 8, 8,32,32);
bg1_tilemap = tilemap_create(machine, get_bg1_tile_info,get_bg_memory_offset,16,16,32,32);
bg2_tilemap = tilemap_create(machine, get_bg2_tile_info,get_bg_memory_offset, 16,16,32,32);
firetrap_state *state = (firetrap_state *)machine->driver_data;
state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, get_fg_memory_offset, 8, 8, 32, 32);
state->bg1_tilemap = tilemap_create(machine, get_bg1_tile_info, get_bg_memory_offset, 16, 16, 32, 32);
state->bg2_tilemap = tilemap_create(machine, get_bg2_tile_info, get_bg_memory_offset, 16, 16, 32, 32);
tilemap_set_transparent_pen(fg_tilemap,0);
tilemap_set_transparent_pen(bg1_tilemap,0);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
tilemap_set_transparent_pen(state->bg1_tilemap, 0);
}
@ -153,53 +145,52 @@ VIDEO_START( firetrap )
WRITE8_HANDLER( firetrap_fgvideoram_w )
{
firetrap_fgvideoram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff);
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
state->fgvideoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff);
}
WRITE8_HANDLER( firetrap_bg1videoram_w )
{
firetrap_bg1videoram[offset] = data;
tilemap_mark_tile_dirty(bg1_tilemap,offset & 0x6ff);
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
state->bg1videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg1_tilemap, offset & 0x6ff);
}
WRITE8_HANDLER( firetrap_bg2videoram_w )
{
firetrap_bg2videoram[offset] = data;
tilemap_mark_tile_dirty(bg2_tilemap,offset & 0x6ff);
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
state->bg2videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg2_tilemap, offset & 0x6ff);
}
WRITE8_HANDLER( firetrap_bg1_scrollx_w )
{
static UINT8 scroll[2];
scroll[offset] = data;
tilemap_set_scrollx(bg1_tilemap,0,scroll[0] | (scroll[1] << 8));
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
state->scroll1_x[offset] = data;
tilemap_set_scrollx(state->bg1_tilemap, 0, state->scroll1_x[0] | (state->scroll1_x[1] << 8));
}
WRITE8_HANDLER( firetrap_bg1_scrolly_w )
{
static UINT8 scroll[2];
scroll[offset] = data;
tilemap_set_scrolly(bg1_tilemap,0,-(scroll[0] | (scroll[1] << 8)));
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
state->scroll1_y[offset] = data;
tilemap_set_scrolly(state->bg1_tilemap, 0, -(state->scroll1_y[0] | (state->scroll1_y[1] << 8)));
}
WRITE8_HANDLER( firetrap_bg2_scrollx_w )
{
static UINT8 scroll[2];
scroll[offset] = data;
tilemap_set_scrollx(bg2_tilemap,0,scroll[0] | (scroll[1] << 8));
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
state->scroll2_x[offset] = data;
tilemap_set_scrollx(state->bg2_tilemap, 0, state->scroll2_x[0] | (state->scroll2_x[1] << 8));
}
WRITE8_HANDLER( firetrap_bg2_scrolly_w )
{
static UINT8 scroll[2];
scroll[offset] = data;
tilemap_set_scrolly(bg2_tilemap,0,-(scroll[0] | (scroll[1] << 8)));
firetrap_state *state = (firetrap_state *)space->machine->driver_data;
state->scroll2_y[offset] = data;
tilemap_set_scrolly(state->bg2_tilemap, 0, -(state->scroll2_y[0] | (state->scroll2_y[1] << 8)));
}
@ -209,24 +200,24 @@ WRITE8_HANDLER( firetrap_bg2_scrolly_w )
***************************************************************************/
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
firetrap_state *state = (firetrap_state *)machine->driver_data;
int offs;
for (offs = 0;offs < spriteram_size; offs += 4)
for (offs = 0; offs < spriteram_size; offs += 4)
{
int sx,sy,flipx,flipy,code,color;
int sx, sy, flipx, flipy, code, color;
/* the meaning of bit 3 of [offs] is unknown */
sy = spriteram[offs];
sx = spriteram[offs + 2];
code = spriteram[offs + 3] + 4 * (spriteram[offs + 1] & 0xc0);
color = ((spriteram[offs + 1] & 0x08) >> 2) | (spriteram[offs + 1] & 0x01);
flipx = spriteram[offs + 1] & 0x04;
flipy = spriteram[offs + 1] & 0x02;
sy = state->spriteram[offs];
sx = state->spriteram[offs + 2];
code = state->spriteram[offs + 3] + 4 * (state->spriteram[offs + 1] & 0xc0);
color = ((state->spriteram[offs + 1] & 0x08) >> 2) | (state->spriteram[offs + 1] & 0x01);
flipx = state->spriteram[offs + 1] & 0x04;
flipy = state->spriteram[offs + 1] & 0x02;
if (flip_screen_get(machine))
{
sx = 240 - sx;
@ -235,7 +226,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
flipy = !flipy;
}
if (spriteram[offs + 1] & 0x10) /* double width */
if (state->spriteram[offs + 1] & 0x10) /* double width */
{
if (flip_screen_get(machine)) sy -= 16;
@ -282,9 +273,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( firetrap )
{
tilemap_draw(bitmap,cliprect,bg2_tilemap,0,0);
tilemap_draw(bitmap,cliprect,bg1_tilemap,0,0);
draw_sprites(screen->machine,bitmap,cliprect);
tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
firetrap_state *state = (firetrap_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg2_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg1_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}