atarigen: Transfer legacy slapstic handling routines to device (nw)

slapstic: Move header file to src/mame/machine (nw)
This commit is contained in:
AJR 2020-05-20 17:34:37 -04:00
parent 9c236064ed
commit 3db88f070d
25 changed files with 208 additions and 202 deletions

View File

@ -1103,7 +1103,6 @@ files {
MAME_DIR .. "src/mame/drivers/atarig1.cpp",
MAME_DIR .. "src/mame/includes/atarig1.h",
MAME_DIR .. "src/mame/video/atarig1.cpp",
MAME_DIR .. "src/mame/includes/slapstic.h",
MAME_DIR .. "src/mame/drivers/atarig42.cpp",
MAME_DIR .. "src/mame/includes/atarig42.h",
MAME_DIR .. "src/mame/video/atarig42.cpp",
@ -1367,6 +1366,7 @@ files {
MAME_DIR .. "src/mame/machine/mathbox.cpp",
MAME_DIR .. "src/mame/machine/mathbox.h",
MAME_DIR .. "src/mame/machine/slapstic.cpp",
MAME_DIR .. "src/mame/machine/slapstic.h",
MAME_DIR .. "src/mame/machine/atarixga.cpp",
MAME_DIR .. "src/mame/machine/atarixga.h",
MAME_DIR .. "src/mame/audio/atarijsa.cpp",

View File

@ -1327,7 +1327,7 @@ ROM_END
void atarig1_state::init_hydra()
{
slapstic_configure(*m_maincpu, 0x078000, 0, memregion("maincpu")->base() + 0x78000);
m_slapstic->legacy_configure(*m_maincpu, 0x078000, 0, memregion("maincpu")->base() + 0x78000);
m_is_pitfight = false;
}
@ -1338,7 +1338,7 @@ void atarig1_state::init_hydrap()
void atarig1_state::init_pitfight()
{
slapstic_configure(*m_maincpu, 0x038000, 0, memregion("maincpu")->base() + 0x38000);
m_slapstic->legacy_configure(*m_maincpu, 0x038000, 0, memregion("maincpu")->base() + 0x38000);
m_is_pitfight = true;
}

View File

@ -220,14 +220,11 @@ void atarisy1_state::video_int_ack_w(uint8_t data)
void atarisy1_state::machine_start()
{
atarigen_state::machine_start();
}
void atarisy1_state::machine_reset()
{
atarigen_state::machine_reset();
bankselect_w(0);
if (m_adc.found())
@ -2484,7 +2481,7 @@ ROM_END
void atarisy1_state::init_marble()
{
slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_slapstic->legacy_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_trackball_type = 1; /* rotated */
}
@ -2492,7 +2489,7 @@ void atarisy1_state::init_marble()
void atarisy1_state::init_peterpak()
{
slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_slapstic->legacy_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_trackball_type = 0; /* none */
}
@ -2500,7 +2497,7 @@ void atarisy1_state::init_peterpak()
void atarisy1_state::init_indytemp()
{
slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_slapstic->legacy_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_trackball_type = 0; /* none */
}
@ -2508,7 +2505,7 @@ void atarisy1_state::init_indytemp()
void atarisy1_state::init_roadrunn()
{
slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_slapstic->legacy_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_trackball_type = 0; /* none */
}
@ -2516,7 +2513,7 @@ void atarisy1_state::init_roadrunn()
void atarisy1_state::init_roadblst()
{
slapstic_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_slapstic->legacy_configure(*m_maincpu, 0x080000, 0, memregion("maincpu")->base() + 0x80000);
m_trackball_type = 2; /* steering wheel */
}

View File

@ -415,7 +415,7 @@ void cyberbal_state::cyberbalt(machine_config &config)
cyberbal_base(config);
EEPROM_2816(config, "eeprom").lock_after_write(true);
SLAPSTIC(config, "slapstic", 116, true);
SLAPSTIC(config, m_slapstic, 116, true);
}
void cyberbal2p_state::cyberbal2p(machine_config &config)
@ -994,7 +994,7 @@ ROM_END
void cyberbal_state::init_cyberbalt()
{
slapstic_configure(*m_maincpu, 0x018000, 0, memregion("maincpu")->base() + 0x18000);
m_slapstic->legacy_configure(*m_maincpu, 0x018000, 0, memregion("maincpu")->base() + 0x18000);
}

View File

@ -548,28 +548,28 @@ void gauntlet_state::gauntlet_base(machine_config &config)
void gauntlet_state::gauntlet(machine_config & config)
{
gauntlet_base(config);
SLAPSTIC(config, m_slapstic_device, 104, true);
SLAPSTIC(config, m_slapstic, 104, true);
}
void gauntlet_state::gaunt2p(machine_config & config)
{
gauntlet_base(config);
SLAPSTIC(config, m_slapstic_device, 107, true);
SLAPSTIC(config, m_slapstic, 107, true);
}
void gauntlet_state::gauntlet2(machine_config & config)
{
gauntlet_base(config);
SLAPSTIC(config, m_slapstic_device, 106, true);
SLAPSTIC(config, m_slapstic, 106, true);
}
void gauntlet_state::vindctr2(machine_config & config)
{
gauntlet_base(config);
SLAPSTIC(config, m_slapstic_device, 118, true);
SLAPSTIC(config, m_slapstic, 118, true);
}
@ -1654,7 +1654,7 @@ void gauntlet_state::swap_memory(void *ptr1, void *ptr2, int bytes)
void gauntlet_state::common_init(int vindctr2)
{
uint8_t *rom = memregion("maincpu")->base();
slapstic_configure(*m_maincpu, 0x038000, 0, memregion("maincpu")->base() + 0x38000);
m_slapstic->legacy_configure(*m_maincpu, 0x038000, 0, memregion("maincpu")->base() + 0x38000);
// swap the top and bottom halves of the main CPU ROM images
swap_memory(rom + 0x000000, rom + 0x008000, 0x8000);

View File

@ -327,7 +327,6 @@ Notes:
#include "emu.h"
#include "includes/harddriv.h"
#include "includes/slapstic.h"
#include "machine/timer.h"
#include "machine/watchdog.h"
#include "sound/volt_reg.h"

View File

@ -340,7 +340,7 @@ void rampart_state::rampart(machine_config &config)
M68000(config, m_maincpu, MASTER_CLOCK/2);
m_maincpu->set_addrmap(AS_PROGRAM, &rampart_state::main_map);
SLAPSTIC(config, m_slapstic_device, 118, true);
SLAPSTIC(config, m_slapstic, 118, true);
TIMER(config, "scantimer").configure_scanline(FUNC(rampart_state::scanline_interrupt), m_screen, 0, 32);
@ -508,7 +508,7 @@ void rampart_state::init_rampart()
uint8_t *rom = memregion("maincpu")->base();
memcpy(&rom[0x140000], &rom[0x40000], 0x8000);
slapstic_configure(*m_maincpu, 0x140000, 0x438000, memregion("maincpu")->base() + 0x140000);
m_slapstic->legacy_configure(*m_maincpu, 0x140000, 0x438000, memregion("maincpu")->base() + 0x140000);
}

View File

@ -26,7 +26,6 @@
#include "emu.h"
#include "includes/starwars.h"
#include "includes/slapstic.h"
#include "cpu/m6809/m6809.h"
#include "machine/74259.h"

View File

@ -387,7 +387,7 @@ ROM_END
void xybots_state::init_xybots()
{
m_h256 = 0x0400;
slapstic_configure(*m_maincpu, 0x008000, 0, memregion("maincpu")->base() + 0x8000);
m_slapstic->legacy_configure(*m_maincpu, 0x008000, 0, memregion("maincpu")->base() + 0x8000);
}

View File

@ -9,6 +9,7 @@
#include "audio/atarijsa.h"
#include "machine/adc0808.h"
#include "machine/atarigen.h"
#include "machine/slapstic.h"
#include "machine/timer.h"
#include "video/atarirle.h"
#include "cpu/m68000/m68000.h"
@ -19,6 +20,7 @@ class atarig1_state : public atarigen_state
public:
atarig1_state(const machine_config &mconfig, device_type type, const char *tag)
: atarigen_state(mconfig, type, tag),
m_slapstic(*this, "slapstic"),
m_jsa(*this, "jsa"),
m_playfield_tilemap(*this, "playfield"),
m_alpha_tilemap(*this, "alpha"),
@ -27,6 +29,7 @@ public:
m_in1(*this, "IN1"),
m_mo_command(*this, "mo_command") { }
optional_device<atari_slapstic_device> m_slapstic;
required_device<atari_jsa_ii_device> m_jsa;
required_device<tilemap_device> m_playfield_tilemap;
required_device<tilemap_device> m_alpha_tilemap;

View File

@ -13,24 +13,29 @@
#include "machine/6522via.h"
#include "machine/74259.h"
#include "machine/adc0808.h"
#include "machine/atarigen.h"
#include "machine/gen_latch.h"
#include "machine/input_merger.h"
#include "machine/slapstic.h"
#include "machine/timer.h"
#include "sound/tms5220.h"
#include "sound/ym2151.h"
#include "video/atarimo.h"
#include "emupal.h"
#include "screen.h"
#include "tilemap.h"
class atarisy1_state : public atarigen_state
class atarisy1_state : public driver_device
{
public:
atarisy1_state(const machine_config &mconfig, device_type type, const char *tag)
: atarigen_state(mconfig, type, tag)
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_audiocpu(*this, "audiocpu")
, m_soundlatch(*this, "soundlatch")
, m_mainlatch(*this, "mainlatch")
, m_slapstic(*this, "slapstic")
, m_gfxdecode(*this, "gfxdecode")
, m_screen(*this, "screen")
, m_mob(*this, "mob")
, m_palette(*this, "palette")
, m_adc(*this, "adc")
@ -65,10 +70,14 @@ protected:
virtual void machine_reset() override;
virtual void video_start() override;
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<generic_latch_8_device> m_soundlatch;
required_device<generic_latch_8_device> m_mainlatch;
required_device<atari_slapstic_device> m_slapstic;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<atari_motion_objects_device> m_mob;
required_device<palette_device> m_palette;

View File

@ -10,6 +10,7 @@
#include "cpu/t11/t11.h"
#include "machine/bankdev.h"
#include "machine/gen_latch.h"
#include "machine/slapstic.h"
#include "machine/timer.h"
#include "machine/watchdog.h"
#include "sound/ym2151.h"
@ -18,7 +19,6 @@
#include "video/atarimo.h"
#include "emupal.h"
#include "screen.h"
#include "slapstic.h"
#include "tilemap.h"
class atarisy2_state : public driver_device

View File

@ -10,9 +10,9 @@
#pragma once
#include "includes/slapstic.h"
#include "cpu/mcs48/mcs48.h"
#include "machine/gen_latch.h"
#include "machine/slapstic.h"
#include "sound/sn76496.h"
#include "screen.h"
#include "tilemap.h"

View File

@ -10,7 +10,7 @@
#pragma once
#include "machine/atarigen.h"
#include "machine/slapstic.h"
#include "audio/atarijsa.h"
#include "audio/atarisac.h"
#include "video/atarimo.h"
@ -20,11 +20,13 @@
#include "screen.h"
#include "tilemap.h"
class cyberbal_base_state : public atarigen_state
class cyberbal_base_state : public driver_device
{
protected:
cyberbal_base_state(const machine_config &mconfig, device_type type, const char *tag) :
atarigen_state(mconfig, type, tag),
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_playfield(*this, "playfield"),
m_alpha(*this, "alpha"),
m_mob(*this, "mob")
@ -40,6 +42,8 @@ protected:
static const atari_motion_objects_config s_mob_config;
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<tilemap_device> m_playfield;
required_device<tilemap_device> m_alpha;
required_device<atari_motion_objects_device> m_mob;
@ -58,6 +62,7 @@ class cyberbal2p_state : public cyberbal_base_state
public:
cyberbal2p_state(const machine_config &mconfig, device_type type, const char *tag) :
cyberbal_base_state(mconfig, type, tag),
m_screen(*this, "screen"),
m_jsa(*this, "jsa")
{ }
@ -79,6 +84,7 @@ private:
TIMER_DEVICE_CALLBACK_MEMBER(scanline_update);
required_device<screen_device> m_screen;
required_device<atari_jsa_ii_device> m_jsa;
};
@ -88,6 +94,7 @@ class cyberbal_state : public cyberbal_base_state
public:
cyberbal_state(const machine_config &mconfig, device_type type, const char *tag) :
cyberbal_base_state(mconfig, type, tag),
m_slapstic(*this, "slapstic"),
m_extracpu(*this, "extra"),
m_sac(*this, "sac"),
m_playfield2(*this, "playfield2"),
@ -124,6 +131,7 @@ private:
TIMER_DEVICE_CALLBACK_MEMBER(scanline_update);
optional_device<atari_slapstic_device> m_slapstic;
required_device<cpu_device> m_extracpu;
required_device<atari_sac_device> m_sac;
required_device<tilemap_device> m_playfield2;

View File

@ -10,21 +10,23 @@
#pragma once
#include "machine/atarigen.h"
#include "machine/74259.h"
#include "machine/gen_latch.h"
#include "machine/slapstic.h"
#include "machine/timer.h"
#include "video/atarimo.h"
#include "sound/ym2151.h"
#include "sound/pokey.h"
#include "sound/tms5220.h"
#include "screen.h"
#include "tilemap.h"
class gauntlet_state : public atarigen_state
class gauntlet_state : public driver_device
{
public:
gauntlet_state(const machine_config &mconfig, device_type type, const char *tag) :
atarigen_state(mconfig, type, tag),
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_soundlatch(*this, "soundlatch"),
m_mainlatch(*this, "mainlatch"),
@ -32,6 +34,9 @@ public:
m_pokey(*this, "pokey"),
m_tms5220(*this, "tms"),
m_soundctl(*this, "soundctl"),
m_slapstic(*this, "slapstic"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_playfield_tilemap(*this, "playfield"),
m_alpha_tilemap(*this, "alpha"),
m_xscroll(*this, "xscroll"),
@ -72,6 +77,7 @@ private:
void main_map(address_map &map);
void sound_map(address_map &map);
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<generic_latch_8_device> m_soundlatch;
required_device<generic_latch_8_device> m_mainlatch;
@ -79,7 +85,10 @@ private:
required_device<pokey_device> m_pokey;
required_device<tms5220_device> m_tms5220;
required_device<ls259_device> m_soundctl;
required_device<atari_slapstic_device> m_slapstic;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<tilemap_device> m_playfield_tilemap;
required_device<tilemap_device> m_alpha_tilemap;
required_shared_ptr<uint16_t> m_xscroll;

View File

@ -11,7 +11,7 @@
#pragma once
#include "audio/atarijsa.h"
#include "includes/slapstic.h"
#include "machine/slapstic.h"
#include "bus/rs232/rs232.h"

View File

@ -10,17 +10,22 @@
#pragma once
#include "machine/atarigen.h"
#include "machine/slapstic.h"
#include "machine/timer.h"
#include "sound/okim6295.h"
#include "sound/ym2413.h"
#include "video/atarimo.h"
#include "screen.h"
class rampart_state : public atarigen_state
class rampart_state : public driver_device
{
public:
rampart_state(const machine_config &mconfig, device_type type, const char *tag) :
atarigen_state(mconfig, type, tag),
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_slapstic(*this, "slapstic"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_mob(*this, "mob"),
m_oki(*this, "oki"),
m_ym2413(*this, "ymsnd"),
@ -43,6 +48,10 @@ private:
void main_map(address_map &map);
required_device<cpu_device> m_maincpu;
required_device<atari_slapstic_device> m_slapstic;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<atari_motion_objects_device> m_mob;
required_device<okim6295_device> m_oki;
required_device<ym2413_device> m_ym2413;

View File

@ -12,10 +12,10 @@
#include "machine/6532riot.h"
#include "machine/gen_latch.h"
#include "machine/slapstic.h"
#include "machine/x2212.h"
#include "sound/pokey.h"
#include "sound/tms5220.h"
#include "includes/slapstic.h"
class starwars_state : public driver_device

View File

@ -10,17 +10,22 @@
#pragma once
#include "machine/atarigen.h"
#include "machine/slapstic.h"
#include "audio/atarijsa.h"
#include "video/atarimo.h"
#include "screen.h"
#include "tilemap.h"
class xybots_state : public atarigen_state
class xybots_state : public driver_device
{
public:
xybots_state(const machine_config &mconfig, device_type type, const char *tag) :
atarigen_state(mconfig, type, tag),
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_slapstic(*this, "slapstic"),
m_jsa(*this, "jsa"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_playfield_tilemap(*this, "playfield"),
m_alpha_tilemap(*this, "alpha"),
m_mob(*this, "mob")
@ -38,7 +43,11 @@ private:
uint32_t screen_update_xybots(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void main_map(address_map &map);
required_device<cpu_device> m_maincpu;
required_device<atari_slapstic_device> m_slapstic;
required_device<atari_jsa_i_device> m_jsa;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<tilemap_device> m_playfield_tilemap;
required_device<tilemap_device> m_alpha_tilemap;
required_device<atari_motion_objects_device> m_mob;

View File

@ -19,40 +19,19 @@
atarigen_state::atarigen_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_slapstic_num(0)
, m_slapstic(nullptr)
, m_slapstic_bank(0)
, m_slapstic_last_pc(0)
, m_slapstic_last_address(0)
, m_slapstic_base(0)
, m_slapstic_mirror(0)
, m_maincpu(*this, "maincpu")
, m_gfxdecode(*this, "gfxdecode")
, m_screen(*this, "screen")
, m_slapstic_device(*this, ":slapstic")
{
}
void atarigen_state::machine_start()
{
save_item(NAME(m_slapstic_num));
save_item(NAME(m_slapstic_bank));
save_item(NAME(m_slapstic_last_pc));
save_item(NAME(m_slapstic_last_address));
}
void atarigen_state::machine_reset()
{
// reset the slapstic
if (m_slapstic_num != 0)
{
if (!m_slapstic_device.found())
fatalerror("Slapstic device is missing?\n");
m_slapstic_device->slapstic_reset();
slapstic_update_bank(m_slapstic_device->slapstic_bank());
}
}
@ -68,108 +47,6 @@ void atarigen_state::device_timer(emu_timer &timer, device_timer_id id, int para
}
/***************************************************************************
SLAPSTIC HANDLING
***************************************************************************/
inline void atarigen_state::slapstic_update_bank(int bank)
{
// if the bank has changed, copy the memory; Pit Fighter needs this
if (bank != m_slapstic_bank)
{
// bank 0 comes from the copy we made earlier
if (bank == 0)
memcpy(m_slapstic, &m_slapstic_bank0[0], 0x2000);
else
memcpy(m_slapstic, &m_slapstic[bank * 0x1000], 0x2000);
// remember the current bank
m_slapstic_bank = bank;
}
}
void atarigen_state::device_post_load()
{
if (m_slapstic_num != 0)
{
if (!m_slapstic_device.found())
fatalerror("Slapstic device is missing?\n");
slapstic_update_bank(m_slapstic_device->slapstic_bank());
}
}
//-------------------------------------------------
// slapstic_configure: Installs memory handlers for the
// slapstic and sets the chip number.
//-------------------------------------------------
void atarigen_state::slapstic_configure(cpu_device &device, offs_t base, offs_t mirror, u8 *mem)
{
if (!m_slapstic_device.found())
fatalerror("Slapstic device is missing\n");
// initialize the slapstic
m_slapstic_num = m_slapstic_device->m_chipnum;
m_slapstic_device->slapstic_init();
// install the memory handlers
address_space &program = device.space(AS_PROGRAM);
program.install_readwrite_handler(base, base + 0x7fff, 0, mirror, 0, read16_delegate(*this, FUNC(atarigen_state::slapstic_r)), write16_delegate(*this, FUNC(atarigen_state::slapstic_w)));
m_slapstic = (u16 *)mem;
// allocate memory for a copy of bank 0
m_slapstic_bank0.resize(0x2000);
memcpy(&m_slapstic_bank0[0], m_slapstic, 0x2000);
// ensure we recopy memory for the bank
m_slapstic_bank = 0xff;
// install an opcode base handler if we are a 68000 or variant
m_slapstic_base = base;
m_slapstic_mirror = mirror;
}
//-------------------------------------------------
// slapstic_w: Assuming that the slapstic sits in
// ROM memory space, we just simply tweak the slapstic at this
// address and do nothing more.
//-------------------------------------------------
WRITE16_MEMBER(atarigen_state::slapstic_w)
{
if (!m_slapstic_device.found())
fatalerror("Slapstic device is missing?\n");
slapstic_update_bank(m_slapstic_device->slapstic_tweak(space, offset));
}
//-------------------------------------------------
// slapstic_r: Tweaks the slapstic at the appropriate
// address and then reads a word from the underlying memory.
//-------------------------------------------------
READ16_MEMBER(atarigen_state::slapstic_r)
{
if (!m_slapstic_device.found())
fatalerror("Slapstic device is missing?\n");
// fetch the result from the current bank first
int result = m_slapstic[offset & 0xfff];
if (!machine().side_effects_disabled())
{
// then determine the new one
slapstic_update_bank(m_slapstic_device->slapstic_tweak(space, offset));
}
return result;
}
/***************************************************************************
VIDEO HELPERS

View File

@ -11,7 +11,6 @@
#ifndef MAME_MACHINE_ATARIGEN_H
#define MAME_MACHINE_ATARIGEN_H
#include "includes/slapstic.h"
#include "screen.h"
@ -29,15 +28,8 @@ protected:
// users must call through to these
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void device_post_load() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
// slapstic helpers
void slapstic_configure(cpu_device &device, offs_t base, offs_t mirror, u8 *mem);
void slapstic_update_bank(int bank);
DECLARE_WRITE16_MEMBER(slapstic_w);
DECLARE_READ16_MEMBER(slapstic_r);
// video helpers
void halt_until_hblank_0(device_t &device, screen_device &screen);
@ -51,22 +43,10 @@ protected:
TID_ATARIGEN_LAST
};
/* internal state */
u8 m_slapstic_num;
u16 * m_slapstic;
u8 m_slapstic_bank;
std::vector<u8> m_slapstic_bank0;
offs_t m_slapstic_last_pc;
offs_t m_slapstic_last_address;
offs_t m_slapstic_base;
offs_t m_slapstic_mirror;
required_device<cpu_device> m_maincpu;
optional_device<gfxdecode_device> m_gfxdecode;
optional_device<screen_device> m_screen;
optional_device<atari_slapstic_device> m_slapstic_device;
};

View File

@ -7,7 +7,6 @@
****************************************************************************/
#include "emu.h"
#include "includes/slapstic.h"
#include "includes/harddriv.h"

View File

@ -183,9 +183,8 @@
#include "emu.h"
#include "includes/slapstic.h"
#include "machine/slapstic.h"
#include "cpu/m6800/m6800.h"
#include "cpu/m68000/m68000.h"
@ -201,7 +200,7 @@
DEFINE_DEVICE_TYPE(SLAPSTIC, atari_slapstic_device, "slapstic", "Atari Slapstic")
atari_slapstic_device::atari_slapstic_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
atari_slapstic_device::atari_slapstic_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, SLAPSTIC, tag, owner, clock),
state(0),
current_bank(0),
@ -209,7 +208,10 @@ atari_slapstic_device::atari_slapstic_device(const machine_config &mconfig, cons
alt_bank(0),
bit_bank(0),
add_bank(0),
bit_xor(0)
bit_xor(0),
m_legacy_configured(false),
m_legacy_memptr(nullptr),
m_legacy_bank(0)
{
slapstic.bankstart = 0;
slapstic.bank[0] = slapstic.bank[1] = slapstic.bank[2] = slapstic.bank[3] = 0;
@ -254,6 +256,18 @@ void atari_slapstic_device::device_start()
void atari_slapstic_device::device_reset()
{
// reset the slapstic
if (m_legacy_configured)
{
slapstic_reset();
legacy_update_bank(slapstic_bank());
}
}
void atari_slapstic_device::device_post_load()
{
if (m_legacy_configured)
legacy_update_bank(slapstic_bank());
}
/*************************************
@ -829,12 +843,12 @@ int atari_slapstic_device::alt2_kludge(address_space &space, offs_t offset)
if (MATCHES_MASK_VALUE(space.device().state().pc() >> 1, slapstic.alt1))
{
/* now look for a move.w (An),(An) or cmpm.w (An)+,(An)+ */
uint16_t opcode = space.read_word(space.device().state().pcbase() & 0xffffff);
u16 opcode = space.read_word(space.device().state().pcbase() & 0xffffff);
if ((opcode & 0xf1f8) == 0x3090 || (opcode & 0xf1f8) == 0xb148)
{
/* fetch the value of the register for the second operand, and see */
/* if it matches the third alternate */
uint32_t regval = space.device().state().state_int(M68K_A0 + ((opcode >> 9) & 7)) >> 1;
u32 regval = space.device().state().state_int(M68K_A0 + ((opcode >> 9) & 7)) >> 1;
if (MATCHES_MASK_VALUE(regval, slapstic.alt3))
{
alt_bank = (regval >> slapstic.altshift) & 3;
@ -1139,3 +1153,85 @@ void atari_slapstic_device::slapstic_log(running_machine &machine, offs_t offset
fflush(slapsticlog);
}
}
//**************************************************************************
// LEGACY HANDLING
//**************************************************************************
void atari_slapstic_device::legacy_update_bank(int bank)
{
// if the bank has changed, copy the memory; Pit Fighter needs this
if (bank != m_legacy_bank)
{
// bank 0 comes from the copy we made earlier
if (bank == 0)
memcpy(m_legacy_memptr, &m_legacy_bank0[0], 0x2000);
else
memcpy(m_legacy_memptr, &m_legacy_memptr[bank * 0x1000], 0x2000);
// remember the current bank
m_legacy_bank = bank;
}
}
//-------------------------------------------------
// legacy_configure: Installs memory handlers for the
// slapstic
//-------------------------------------------------
void atari_slapstic_device::legacy_configure(cpu_device &device, offs_t base, offs_t mirror, u8 *mem)
{
// initialize the slapstic
m_legacy_configured = true;
slapstic_init();
save_item(NAME(m_legacy_bank));
// install the memory handlers
address_space &program = device.space(AS_PROGRAM);
program.install_readwrite_handler(base, base + 0x7fff, 0, mirror, 0, read16_delegate(*this, FUNC(atari_slapstic_device::slapstic_r)), write16_delegate(*this, FUNC(atari_slapstic_device::slapstic_w)));
m_legacy_memptr = (u16 *)mem;
// allocate memory for a copy of bank 0
m_legacy_bank0.resize(0x2000);
memcpy(&m_legacy_bank0[0], m_legacy_memptr, 0x2000);
// ensure we recopy memory for the bank
m_legacy_bank = 0xff;
}
//-------------------------------------------------
// slapstic_w: Assuming that the slapstic sits in
// ROM memory space, we just simply tweak the slapstic at this
// address and do nothing more.
//-------------------------------------------------
void atari_slapstic_device::slapstic_w(address_space &space, offs_t offset, u16 data, u16 mem_mask)
{
assert(m_legacy_configured);
legacy_update_bank(slapstic_tweak(space, offset));
}
//-------------------------------------------------
// slapstic_r: Tweaks the slapstic at the appropriate
// address and then reads a word from the underlying memory.
//-------------------------------------------------
u16 atari_slapstic_device::slapstic_r(address_space &space, offs_t offset, u16 mem_mask)
{
assert(m_legacy_configured);
// fetch the result from the current bank first
u16 result = m_legacy_memptr[offset & 0xfff];
if (!machine().side_effects_disabled())
{
// then determine the new one
legacy_update_bank(slapstic_tweak(space, offset));
}
return result;
}

View File

@ -110,13 +110,13 @@ class atari_slapstic_device : public device_t
public:
// construction/destruction
atari_slapstic_device(const machine_config &mconfig, const char *tag, device_t *owner, int chipnum, bool m68k_mode)
: atari_slapstic_device(mconfig, tag, owner, (uint32_t)0)
: atari_slapstic_device(mconfig, tag, owner, u32(0))
{
set_chipnum(chipnum);
set_access68k(m68k_mode ? 1 : 0);
}
atari_slapstic_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
atari_slapstic_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
void slapstic_init();
void slapstic_reset();
@ -132,14 +132,14 @@ public:
int m_chipnum;
uint8_t state;
uint8_t current_bank;
u8 state;
u8 current_bank;
int access_68k;
uint8_t alt_bank;
uint8_t bit_bank;
uint8_t add_bank;
uint8_t bit_xor;
u8 alt_bank;
u8 bit_bank;
u8 add_bank;
u8 bit_xor;
struct slapstic_data slapstic;
@ -147,11 +147,25 @@ public:
void slapstic_log(running_machine &machine, offs_t offset);
FILE *slapsticlog;
// legacy interface
void legacy_configure(cpu_device &device, offs_t base, offs_t mirror, u8 *mem);
protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_post_load() override;
virtual void device_validity_check(validity_checker &valid) const override;
private:
// legacy helpers
void legacy_update_bank(int bank);
void slapstic_w(address_space &space, offs_t offset, u16 data, u16 mem_mask);
uint16_t slapstic_r(address_space &space, offs_t offset, u16 mem_mask);
bool m_legacy_configured;
u16 * m_legacy_memptr;
u8 m_legacy_bank;
std::vector<u8> m_legacy_bank0;
};
#endif // MAME_INCLUDES_SLAPSTIC_H

View File

@ -7,8 +7,6 @@
****************************************************************************/
#include "emu.h"
#include "video/atarimo.h"
#include "includes/slapstic.h"
#include "includes/atarisy2.h"