get rid of some global stuff by making this a device, need this step for now, will improve further later (nw)

This commit is contained in:
mamehaze 2014-11-05 22:26:26 +00:00
parent 05aa20a523
commit bb3fdab8da
22 changed files with 327 additions and 164 deletions

View File

@ -428,6 +428,8 @@ static MACHINE_CONFIG_START( atarig1, atarig1_state )
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", atarigen_state, video_int_gen)
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_MACHINE_START_OVERRIDE(atarig1_state,atarig1)
MCFG_MACHINE_RESET_OVERRIDE(atarig1_state,atarig1)

View File

@ -713,6 +713,8 @@ static MACHINE_CONFIG_START( atarisy1, atarisy1_state )
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", atarigen_state, video_int_gen)
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_CPU_ADD("audiocpu", M6502, ATARI_CLOCK_14MHz/8)
MCFG_CPU_PROGRAM_MAP(sound_map)

View File

@ -126,7 +126,6 @@
#include "emu.h"
#include "includes/slapstic.h"
#include "includes/atarisy2.h"
#include "sound/tms5220.h"
#include "sound/2151intf.h"
@ -222,7 +221,7 @@ MACHINE_START_MEMBER(atarisy2_state,atarisy2)
MACHINE_RESET_MEMBER(atarisy2_state,atarisy2)
{
atarigen_state::machine_reset();
slapstic_reset();
m_slapstic->slapstic_reset();
scanline_timer_reset(*m_screen, 64);
m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(atarisy2_state::atarisy2_direct_handler), this));
@ -1208,6 +1207,8 @@ static MACHINE_CONFIG_START( atarisy2, atarisy2_state )
MCFG_CPU_PROGRAM_MAP(sound_map)
MCFG_DEVICE_PERIODIC_INT_DEVICE("soundcomm", atari_sound_comm_device, sound_irq_gen, (double)MASTER_CLOCK/2/16/16/16/10)
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_MACHINE_START_OVERRIDE(atarisy2_state,atarisy2)
MCFG_MACHINE_RESET_OVERRIDE(atarisy2_state,atarisy2)
@ -3143,7 +3144,7 @@ DRIVER_INIT_MEMBER(atarisy2_state,paperboy)
int i;
UINT8 *cpu1 = memregion("maincpu")->base();
slapstic_init(machine(), 105);
m_slapstic->slapstic_init(machine(), 105);
/* expand the 16k program ROMs into full 64k chunks */
for (i = 0x10000; i < 0x90000; i += 0x20000)
@ -3164,7 +3165,7 @@ DRIVER_INIT_MEMBER(atarisy2_state,720)
/* without the default EEPROM, 720 hangs at startup due to communication
issues with the sound CPU; temporarily increasing the sound CPU frequency
to ~2.2MHz "fixes" the problem */
slapstic_init(machine(), 107);
m_slapstic->slapstic_init(machine(), 107);
m_pedal_count = -1;
m_has_tms5220 = 1;
@ -3177,7 +3178,7 @@ DRIVER_INIT_MEMBER(atarisy2_state,ssprint)
int i;
UINT8 *cpu1 = memregion("maincpu")->base();
slapstic_init(machine(), 108);
m_slapstic->slapstic_init(machine(), 108);
/* expand the 32k program ROMs into full 64k chunks */
for (i = 0x10000; i < 0x90000; i += 0x20000)
@ -3193,7 +3194,7 @@ DRIVER_INIT_MEMBER(atarisy2_state,csprint)
int i;
UINT8 *cpu1 = memregion("maincpu")->base();
slapstic_init(machine(), 109);
m_slapstic->slapstic_init(machine(), 109);
/* expand the 32k program ROMs into full 64k chunks */
for (i = 0x10000; i < 0x90000; i += 0x20000)
@ -3206,7 +3207,7 @@ DRIVER_INIT_MEMBER(atarisy2_state,csprint)
DRIVER_INIT_MEMBER(atarisy2_state,apb)
{
slapstic_init(machine(), 110);
m_slapstic->slapstic_init(machine(), 110);
m_pedal_count = 2;
m_has_tms5220 = 1;

View File

@ -49,7 +49,6 @@
#include "emu.h"
#include "cpu/m6502/m6502.h"
#include "includes/slapstic.h"
#include "includes/atetris.h"
#include "sound/sn76496.h"
#include "sound/pokey.h"
@ -115,8 +114,8 @@ void atetris_state::machine_start()
void atetris_state::machine_reset()
{
/* reset the slapstic */
slapstic_reset();
m_current_bank = slapstic_bank() & 1;
m_slapstic_device->slapstic_reset();
m_current_bank = m_slapstic_device->slapstic_bank() & 1;
reset_bank();
/* start interrupts going (32V clocked by 16V) */
@ -134,7 +133,7 @@ void atetris_state::machine_reset()
READ8_MEMBER(atetris_state::atetris_slapstic_r)
{
int result = m_slapstic_base[0x2000 + offset];
int new_bank = slapstic_tweak(space, offset) & 1;
int new_bank = m_slapstic_device->slapstic_tweak(space, offset) & 1;
/* update for the new bank */
if (new_bank != m_current_bank)
@ -308,6 +307,8 @@ static MACHINE_CONFIG_START( atetris, atetris_state )
MCFG_CPU_ADD("maincpu", M6502,MASTER_CLOCK/8)
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_NVRAM_ADD_1FILL("nvram")
/* video hardware */
@ -456,7 +457,7 @@ DRIVER_INIT_MEMBER(atetris_state,atetris)
{
UINT8 *rgn = memregion("maincpu")->base();
slapstic_init(machine(), 101);
m_slapstic_device->slapstic_init(machine(), 101);
m_slapstic_source = &rgn[0x10000];
m_slapstic_base = &rgn[0x04000];
}

View File

@ -389,6 +389,8 @@ static MACHINE_CONFIG_START( cyberbal, cyberbal_state )
MCFG_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2)
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_CPU_ADD("audiocpu", M6502, ATARI_CLOCK_14MHz/8)
MCFG_CPU_PROGRAM_MAP(sound_map)
MCFG_DEVICE_PERIODIC_INT_DEVICE("soundcomm", atari_sound_comm_device, sound_irq_gen, (double)ATARI_CLOCK_14MHz/4/4/16/16/14)

View File

@ -499,6 +499,8 @@ static MACHINE_CONFIG_START( gauntlet, gauntlet_state )
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", atarigen_state, video_int_gen)
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_CPU_ADD("audiocpu", M6502, ATARI_CLOCK_14MHz/8)
MCFG_CPU_PROGRAM_MAP(sound_map)

View File

@ -1232,6 +1232,9 @@ static MACHINE_CONFIG_START( driver_nomsp, harddriv_state )
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", atarigen_state, video_int_gen)
MCFG_CPU_PERIODIC_INT_DRIVER(harddriv_state, hd68k_irq_gen, (double)HARDDRIV_MASTER_CLOCK/16/16/16/16/2)
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_SLAPSTIC_68K_ACCESS(1)
MCFG_CPU_ADD("gsp", TMS34010, HARDDRIV_GSP_CLOCK)
MCFG_CPU_PROGRAM_MAP(driver_gsp_map)
MCFG_TMS340X0_HALT_ON_RESET(TRUE) /* halt on reset */
@ -4403,7 +4406,7 @@ DRIVER_INIT_MEMBER(harddriv_state,racedriv)
init_driver_sound();
/* set up the slapstic */
slapstic_init(machine(), 117);
m_slapstic_device->slapstic_init(machine(), 117);
m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::rd68k_slapstic_r), this), write16_delegate(FUNC(harddriv_state::rd68k_slapstic_w), this));
/* synchronization */
@ -4424,7 +4427,7 @@ void harddriv_state::racedrivc_init_common(offs_t gsp_protection)
init_driver_sound();
/* set up the slapstic */
slapstic_init(machine(), 117);
m_slapstic_device->slapstic_init(machine(), 117);
m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::rd68k_slapstic_r), this), write16_delegate(FUNC(harddriv_state::rd68k_slapstic_w), this));
/* synchronization */
@ -4523,7 +4526,7 @@ DRIVER_INIT_MEMBER(harddriv_state,strtdriv)
init_dsk();
/* set up the slapstic */
slapstic_init(machine(), 117);
m_slapstic_device->slapstic_init(machine(), 117);
m_m68k_slapstic_base = m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xe0000, 0xfffff, read16_delegate(FUNC(harddriv_state::rd68k_slapstic_r), this), write16_delegate(FUNC(harddriv_state::rd68k_slapstic_w), this));
m_maincpu->space(AS_PROGRAM).install_read_handler(0xa80000, 0xafffff, read16_delegate(FUNC(harddriv_state::hda68k_port1_r), this));

View File

@ -339,6 +339,8 @@ static MACHINE_CONFIG_START( rampart, rampart_state )
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", atarigen_state, video_int_gen)
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_MACHINE_RESET_OVERRIDE(rampart_state,rampart)
MCFG_ATARI_EEPROM_2816_ADD("eeprom")

View File

@ -62,8 +62,8 @@ void starwars_state::machine_reset()
address_space &space = m_maincpu->space(AS_PROGRAM);
/* reset the slapstic */
slapstic_reset();
m_slapstic_current_bank = slapstic_bank();
m_slapstic_device->slapstic_reset();
m_slapstic_current_bank = m_slapstic_device->slapstic_bank();
memcpy(m_slapstic_base, &m_slapstic_source[m_slapstic_current_bank * 0x2000], 0x2000);
/* reset all the banks */
@ -97,7 +97,7 @@ WRITE8_MEMBER(starwars_state::irq_ack_w)
void starwars_state::esb_slapstic_tweak(address_space &space, offs_t offset)
{
int new_bank = slapstic_tweak(space, offset);
int new_bank = m_slapstic_device->slapstic_tweak(space, offset);
/* update for the new bank */
if (new_bank != m_slapstic_current_bank)
@ -331,6 +331,8 @@ static MACHINE_CONFIG_START( starwars, starwars_state )
MCFG_CPU_PERIODIC_INT_DRIVER(starwars_state, irq0_line_assert, CLOCK_3KHZ / 12)
MCFG_WATCHDOG_TIME_INIT(attotime::from_hz(CLOCK_3KHZ / 128))
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_CPU_ADD("audiocpu", M6809, MASTER_CLOCK / 8)
MCFG_CPU_PROGRAM_MAP(sound_map)
@ -524,7 +526,7 @@ DRIVER_INIT_MEMBER(starwars_state,esb)
UINT8 *rom = memregion("maincpu")->base();
/* init the slapstic */
slapstic_init(machine(), 101);
m_slapstic_device->slapstic_init(machine(), 101);
m_slapstic_source = &rom[0x14000];
m_slapstic_base = &rom[0x08000];

View File

@ -184,6 +184,8 @@ static MACHINE_CONFIG_START( vindictr, vindictr_state )
MCFG_CPU_ADD("maincpu", M68010, ATARI_CLOCK_14MHz/2)
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_SLAPSTIC_ADD("slapstic") // where is this hooked up here?
MCFG_MACHINE_RESET_OVERRIDE(vindictr_state,vindictr)
MCFG_ATARI_EEPROM_2804_ADD("eeprom")

View File

@ -184,6 +184,8 @@ static MACHINE_CONFIG_START( xybots, xybots_state )
MCFG_CPU_PROGRAM_MAP(main_map)
MCFG_DEVICE_VBLANK_INT_DRIVER("screen", atarigen_state, video_int_gen)
MCFG_SLAPSTIC_ADD("slapstic")
MCFG_MACHINE_RESET_OVERRIDE(xybots_state,xybots)
MCFG_ATARI_EEPROM_2804_ADD("eeprom")

View File

@ -8,6 +8,8 @@
#include "machine/atarigen.h"
#include "audio/atarijsa.h"
#include "includes/slapstic.h"
class atarigx2_state : public atarigen_state
{
@ -19,7 +21,8 @@ public:
m_protection_base(*this, "protection_base"),
m_playfield_tilemap(*this, "playfield"),
m_alpha_tilemap(*this, "alpha"),
m_rle(*this, "rle") { }
m_rle(*this, "rle")
{ }
UINT16 m_playfield_base;

View File

@ -10,6 +10,7 @@
#include "video/atarimo.h"
#include "cpu/m6502/m6502.h"
#include "cpu/t11/t11.h"
#include "slapstic.h"
class atarisy2_state : public atarigen_state
{
@ -25,7 +26,9 @@ public:
m_alpha_tilemap(*this, "alpha"),
m_rombank1(*this, "rombank1"),
m_rombank2(*this, "rombank2"),
m_generic_paletteram_16(*this, "paletteram") { }
m_generic_paletteram_16(*this, "paletteram"),
m_slapstic(*this, "slapstic")
{ }
required_device<t11_device> m_maincpu;
required_device<m6502_device> m_audiocpu;
@ -50,6 +53,7 @@ public:
required_shared_ptr<UINT16> m_rombank1;
required_shared_ptr<UINT16> m_rombank2;
required_shared_ptr<UINT16> m_generic_paletteram_16;
required_device<atari_slapstic_device> m_slapstic;
UINT8 m_sound_reset_state;

View File

@ -4,6 +4,8 @@
*************************************************************************/
#include "includes/slapstic.h"
class atetris_state : public driver_device
{
public:
@ -13,7 +15,9 @@ public:
m_videoram(*this, "videoram"),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen") { }
m_screen(*this, "screen"),
m_slapstic_device(*this, "slapstic")
{ }
required_shared_ptr<UINT8> m_nvram;
required_shared_ptr<UINT8> m_videoram;
@ -40,4 +44,5 @@ public:
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
optional_device<atari_slapstic_device> m_slapstic_device;
};

View File

@ -59,7 +59,9 @@ public:
m_ds3xdsp_internal_timer(*this, "ds3xdsp_timer"),
m_dac(*this, "dac"),
m_duart(*this, "duartn68681"),
m_asic65(*this, "asic65") {}
m_asic65(*this, "asic65"),
m_slapstic_device(*this, "slapstic")
{}
required_device<cpu_device> m_maincpu;
required_device<tms34010_device> m_gsp;
@ -469,4 +471,6 @@ public:
TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_driver);
TMS340X0_SCANLINE_IND16_CB_MEMBER(scanline_multisync);
optional_device<atari_slapstic_device> m_slapstic_device;
};

View File

@ -9,10 +9,173 @@
*************************************************************************/
/*----------- defined in machine/slapstic.c -----------*/
#pragma once
void slapstic_init(running_machine &machine, int chip);
void slapstic_reset(void);
#ifndef __SLAPSTIC__
#define __SLAPSTIC__
int slapstic_bank(void);
int slapstic_tweak(address_space &space, offs_t offset);
#include "emu.h"
#include "cpu/m6800/m6800.h"
#include "cpu/m68000/m68000.h"
extern const device_type SLAPSTIC;
#define MCFG_SLAPSTIC_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, SLAPSTIC, 0)
/*************************************
*
* Debugging
*
*************************************/
#define LOG_SLAPSTIC (0)
/*************************************
*
* Structure of slapstic params
*
*************************************/
struct mask_value
{
int mask, value;
};
struct slapstic_data
{
int bankstart;
int bank[4];
struct mask_value alt1;
struct mask_value alt2;
struct mask_value alt3;
struct mask_value alt4;
int altshift;
struct mask_value bit1;
struct mask_value bit2c0;
struct mask_value bit2s0;
struct mask_value bit2c1;
struct mask_value bit2s1;
struct mask_value bit3;
struct mask_value add1;
struct mask_value add2;
struct mask_value addplus1;
struct mask_value addplus2;
struct mask_value add3;
};
/*************************************
*
* Shorthand
*
*************************************/
#define UNKNOWN 0xffff
#define NO_BITWISE \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }
#define NO_ADDITIVE \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }
#define MATCHES_MASK_VALUE(val, maskval) (((val) & (maskval).mask) == (maskval).value)
/*************************************
*
* Constants
*
*************************************/
enum
{
DISABLED,
ENABLED,
ALTERNATE1,
ALTERNATE2,
ALTERNATE3,
BITWISE1,
BITWISE2,
BITWISE3,
ADDITIVE1,
ADDITIVE2,
ADDITIVE3
};
#define MCFG_SLAPSTIC_68K_ACCESS(_type) \
atari_slapstic_device::static_set_access68k(*device, _type);
class atari_slapstic_device : public device_t
{
public:
// construction/destruction
atari_slapstic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
void slapstic_init(running_machine &machine, int chip);
void slapstic_reset(void);
int slapstic_bank(void);
int slapstic_tweak(address_space &space, offs_t offset);
int alt2_kludge(address_space &space, offs_t offset);
static void static_set_access68k(device_t &device, int type)
{
atari_slapstic_device &dev = downcast<atari_slapstic_device &>(device);
dev.access_68k = type;
}
UINT8 state;
UINT8 current_bank;
int access_68k;
UINT8 alt_bank;
UINT8 bit_bank;
UINT8 add_bank;
UINT8 bit_xor;
struct slapstic_data slapstic;
void slapstic_log(running_machine &machine, offs_t offset);
FILE *slapsticlog;
protected:
virtual void device_start();
virtual void device_reset();
private:
};
#endif

View File

@ -5,6 +5,7 @@
***************************************************************************/
#include "machine/6532riot.h"
#include "includes/slapstic.h"
class starwars_state : public driver_device
@ -15,7 +16,9 @@ public:
m_riot(*this, "riot"),
m_mathram(*this, "mathram"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu") { }
m_audiocpu(*this, "audiocpu"),
m_slapstic_device(*this, "slapstic")
{ }
UINT8 m_sound_data;
UINT8 m_main_data;
@ -78,4 +81,5 @@ public:
void esb_slapstic_tweak(address_space &space, offs_t offset);
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
optional_device<atari_slapstic_device> m_slapstic_device;
};

View File

@ -16,7 +16,6 @@
#include "sound/okim6295.h"
#include "sound/pokey.h"
#include "video/atarimo.h"
#include "includes/slapstic.h"
#include "atarigen.h"
@ -975,7 +974,8 @@ atarigen_state::atarigen_state(const machine_config &mconfig, device_type type,
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_palette(*this, "palette"),
m_generic_paletteram_16(*this, "paletteram")
m_generic_paletteram_16(*this, "paletteram"),
m_slapstic_device(*this, ":slapstic")
{
}
@ -1022,8 +1022,11 @@ void atarigen_state::machine_reset()
// reset the slapstic
if (m_slapstic_num != 0)
{
slapstic_reset();
slapstic_update_bank(slapstic_bank());
if (!m_slapstic_device)
fatalerror("Slapstic device is missing?\n");
m_slapstic_device->slapstic_reset();
slapstic_update_bank(m_slapstic_device->slapstic_bank());
}
}
@ -1192,7 +1195,10 @@ inline void atarigen_state::slapstic_update_bank(int bank)
void atarigen_state::device_post_load()
{
slapstic_update_bank(slapstic_bank());
if (!m_slapstic_device)
fatalerror("Slapstic device is missing?\n");
slapstic_update_bank(m_slapstic_device->slapstic_bank());
}
@ -1232,8 +1238,11 @@ void atarigen_state::slapstic_configure(cpu_device &device, offs_t base, offs_t
// if we have a chip, install it
if (chipnum != 0)
{
if (!m_slapstic_device)
fatalerror("Slapstic device is missing\n");
// initialize the slapstic
slapstic_init(machine(), chipnum);
m_slapstic_device->slapstic_init(machine(), chipnum);
// install the memory handlers
address_space &program = device.space(AS_PROGRAM);
@ -1262,7 +1271,10 @@ void atarigen_state::slapstic_configure(cpu_device &device, offs_t base, offs_t
WRITE16_MEMBER(atarigen_state::slapstic_w)
{
slapstic_update_bank(slapstic_tweak(space, offset));
if (!m_slapstic_device)
fatalerror("Slapstic device is missing?\n");
slapstic_update_bank(m_slapstic_device->slapstic_tweak(space, offset));
}
@ -1273,11 +1285,14 @@ WRITE16_MEMBER(atarigen_state::slapstic_w)
READ16_MEMBER(atarigen_state::slapstic_r)
{
if (!m_slapstic_device)
fatalerror("Slapstic device is missing?\n");
// fetch the result from the current bank first
int result = m_slapstic[offset & 0xfff];
// then determine the new one
slapstic_update_bank(slapstic_tweak(space, offset));
slapstic_update_bank(m_slapstic_device->slapstic_tweak(space, offset));
return result;
}

View File

@ -17,6 +17,7 @@
#include "video/atarimo.h"
#include "cpu/m6502/m6502.h"
#include "sound/okim6295.h"
#include "includes/slapstic.h"
/***************************************************************************
@ -431,6 +432,7 @@ public:
optional_device<screen_device> m_screen;
optional_device<palette_device> m_palette;
optional_shared_ptr<UINT16> m_generic_paletteram_16;
optional_device<atari_slapstic_device> m_slapstic_device;
};

View File

@ -51,7 +51,7 @@ MACHINE_RESET_MEMBER(harddriv_state,harddriv)
{
/* generic reset */
atarigen_state::machine_reset();
slapstic_reset();
m_slapstic_device->slapstic_reset();
/* halt several of the DSPs to start */
if (m_adsp != NULL) m_adsp->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
@ -1671,13 +1671,13 @@ WRITE16_MEMBER( harddriv_state::hddspcom_control_w )
WRITE16_MEMBER( harddriv_state::rd68k_slapstic_w )
{
slapstic_tweak(space, offset & 0x3fff);
m_slapstic_device->slapstic_tweak(space, offset & 0x3fff);
}
READ16_MEMBER( harddriv_state::rd68k_slapstic_r )
{
int bank = slapstic_tweak(space, offset & 0x3fff) * 0x4000;
int bank = m_slapstic_device->slapstic_tweak(space, offset & 0x3fff) * 0x4000;
return m_m68k_slapstic_base[bank + (offset & 0x3fff)];
}

View File

@ -180,108 +180,68 @@
*************************************************************************/
#include "emu.h"
#include "cpu/m6800/m6800.h"
#include "includes/slapstic.h"
#include "cpu/m68000/m68000.h"
/*************************************
*
* Debugging
*
*************************************/
extern const device_type SLAPSTIC = &device_creator<atari_slapstic_device>;
#define LOG_SLAPSTIC (0)
/*************************************
*
* Structure of slapstic params
*
*************************************/
struct mask_value
atari_slapstic_device::atari_slapstic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, SLAPSTIC, "Atari Slapstic", tag, owner, clock, "slapstic", __FILE__),
state(0),
current_bank(0),
access_68k(-1),
alt_bank(0),
bit_bank(0),
add_bank(0),
bit_xor(0)
{
int mask, value;
};
slapstic.bankstart = 0;
slapstic.bank[0] = slapstic.bank[1] = slapstic.bank[2] = slapstic.bank[3] = 0;
slapstic.alt1.mask = 0;
slapstic.alt1.value = 0;
slapstic.alt2.mask = 0;
slapstic.alt2.value = 0;
slapstic.alt3.mask = 0;
slapstic.alt3.value = 0;
slapstic.alt4.mask = 0;
slapstic.alt4.value = 0;
slapstic.altshift = 0;
slapstic.bit1.mask = 0;
slapstic.bit1.value = 0;
slapstic.bit2c0.mask = 0;
slapstic.bit2c0.value = 0;
slapstic.bit2s0.mask = 0;
slapstic.bit2s0.value = 0;
slapstic.bit2c1.mask = 0;
slapstic.bit2c1.value = 0;
slapstic.bit2s1.mask = 0;
slapstic.bit2s1.value = 0;
slapstic.bit3.mask = 0;
slapstic.bit3.value = 0;
slapstic.add1.mask = 0;
slapstic.add1.value = 0;
slapstic.add2.mask = 0;
slapstic.add2.value = 0;
slapstic.addplus1.mask = 0;
slapstic.addplus1.value = 0;
slapstic.addplus2.mask = 0;
slapstic.addplus2.value = 0;
slapstic.add3.mask = 0;
slapstic.add3.value = 0;
}
struct slapstic_data
void atari_slapstic_device::device_start()
{
int bankstart;
int bank[4];
struct mask_value alt1;
struct mask_value alt2;
struct mask_value alt3;
struct mask_value alt4;
int altshift;
}
struct mask_value bit1;
struct mask_value bit2c0;
struct mask_value bit2s0;
struct mask_value bit2c1;
struct mask_value bit2s1;
struct mask_value bit3;
struct mask_value add1;
struct mask_value add2;
struct mask_value addplus1;
struct mask_value addplus2;
struct mask_value add3;
};
/*************************************
*
* Shorthand
*
*************************************/
#define UNKNOWN 0xffff
#define NO_BITWISE \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }
#define NO_ADDITIVE \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }, \
{ UNKNOWN,UNKNOWN }
#define MATCHES_MASK_VALUE(val, maskval) (((val) & (maskval).mask) == (maskval).value)
/*************************************
*
* Constants
*
*************************************/
enum
void atari_slapstic_device::device_reset()
{
DISABLED,
ENABLED,
ALTERNATE1,
ALTERNATE2,
ALTERNATE3,
BITWISE1,
BITWISE2,
BITWISE3,
ADDITIVE1,
ADDITIVE2,
ADDITIVE3
};
}
/*************************************
*
@ -779,27 +739,6 @@ static const struct slapstic_data *const slapstic_table[] =
/*************************************
*
* Statics
*
*************************************/
static UINT8 state;
static UINT8 current_bank;
static UINT8 access_68k;
static UINT8 alt_bank;
static UINT8 bit_bank;
static UINT8 add_bank;
static UINT8 bit_xor;
static struct slapstic_data slapstic;
static void slapstic_log(running_machine &machine, offs_t offset);
static FILE *slapsticlog;
/*************************************
*
@ -807,9 +746,13 @@ static FILE *slapsticlog;
*
*************************************/
void slapstic_init(running_machine &machine, int chip)
void atari_slapstic_device::slapstic_init(running_machine &machine, int chip)
{
device_type cputype = machine.device("maincpu")->type();
if (access_68k == -1)
{
device_type cputype = machine.device(":maincpu")->type();
access_68k = (cputype == M68000 || cputype == M68010);
}
/* only a small number of chips are known to exist */
if (chip < 101 || chip > 118)
@ -824,7 +767,6 @@ void slapstic_init(running_machine &machine, int chip)
slapstic_reset();
/* see if we're 68k or 6502/6809 based */
access_68k = (cputype == M68000 || cputype == M68010);
/* save state */
state_save_register_item(machine, "slapstic", NULL, 0, state);
@ -836,7 +778,7 @@ void slapstic_init(running_machine &machine, int chip)
}
void slapstic_reset(void)
void atari_slapstic_device::slapstic_reset(void)
{
/* reset the chip */
state = DISABLED;
@ -853,7 +795,7 @@ void slapstic_reset(void)
*
*************************************/
int slapstic_bank(void)
int atari_slapstic_device::slapstic_bank(void)
{
return current_bank;
}
@ -866,7 +808,7 @@ int slapstic_bank(void)
*
*************************************/
static int alt2_kludge(address_space &space, offs_t offset)
int atari_slapstic_device::alt2_kludge(address_space &space, offs_t offset)
{
/* Of the 3 alternate addresses, only the middle one needs to actually hit
in the slapstic region; the first and third ones can be anywhere in the
@ -913,7 +855,7 @@ static int alt2_kludge(address_space &space, offs_t offset)
*
*************************************/
int slapstic_tweak(address_space &space, offs_t offset)
int atari_slapstic_device::slapstic_tweak(address_space &space, offs_t offset)
{
/* reset is universal */
if (offset == 0x0000)
@ -1137,7 +1079,7 @@ int slapstic_tweak(address_space &space, offs_t offset)
*
*************************************/
static void slapstic_log(running_machine &machine, offs_t offset)
void atari_slapstic_device::slapstic_log(running_machine &machine, offs_t offset)
{
static attotime last_time;

View File

@ -208,20 +208,20 @@ WRITE16_MEMBER( atarisy2_state::paletteram_w )
READ16_MEMBER( atarisy2_state::slapstic_r )
{
int result = m_slapstic_base[offset];
slapstic_tweak(space, offset);
m_slapstic->slapstic_tweak(space, offset);
/* an extra tweak for the next opcode fetch */
m_videobank = slapstic_tweak(space, 0x1234) * 0x1000;
m_videobank = m_slapstic->slapstic_tweak(space, 0x1234) * 0x1000;
return result;
}
WRITE16_MEMBER( atarisy2_state::slapstic_w )
{
slapstic_tweak(space, offset);
m_slapstic->slapstic_tweak(space, offset);
/* an extra tweak for the next opcode fetch */
m_videobank = slapstic_tweak(space, 0x1234) * 0x1000;
m_videobank = m_slapstic->slapstic_tweak(space, 0x1234) * 0x1000;
}