irobot.cpp: Eliminate machine().device; use X2212 device for NVRAM (nw)

This commit is contained in:
AJR 2018-06-11 21:47:34 -04:00
parent 07b70fec34
commit 7f06e4f6c2
3 changed files with 35 additions and 36 deletions

View File

@ -89,19 +89,6 @@
#define MAIN_CLOCK 12.096_MHz_XTAL
#define VIDEO_CLOCK 20_MHz_XTAL
/*************************************
*
* NVRAM handler
*
*************************************/
WRITE8_MEMBER(irobot_state::irobot_nvram_w)
{
m_nvram[offset] = data & 0x0f;
}
/*************************************
*
* IRQ acknowledgement
@ -157,7 +144,7 @@ void irobot_state::irobot_map(address_map &map)
map(0x1140, 0x1140).w(FUNC(irobot_state::irobot_statwr_w));
map(0x1180, 0x1180).w(FUNC(irobot_state::irobot_out0_w));
map(0x11c0, 0x11c0).w(FUNC(irobot_state::irobot_rom_banksel_w));
map(0x1200, 0x12ff).ram().w(FUNC(irobot_state::irobot_nvram_w)).share("nvram");
map(0x1200, 0x12ff).rw("nvram", FUNC(x2212_device::read), FUNC(x2212_device::write));
map(0x1300, 0x1300).mirror(0xff).r("adc", FUNC(adc0809_device::data_r));
map(0x1400, 0x143f).rw(FUNC(irobot_state::quad_pokeyn_r), FUNC(irobot_state::quad_pokeyn_w));
map(0x1800, 0x18ff).w(FUNC(irobot_state::irobot_paletteram_w));
@ -305,7 +292,7 @@ MACHINE_CONFIG_START(irobot_state::irobot)
MCFG_ADC0808_IN0_CB(IOPORT("AN0"))
MCFG_ADC0808_IN1_CB(IOPORT("AN1"))
MCFG_NVRAM_ADD_0FILL("nvram")
MCFG_X2212_ADD_AUTOSAVE("nvram")
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)

View File

@ -11,6 +11,7 @@
#pragma once
#include "machine/timer.h"
#include "machine/x2212.h"
#include "sound/pokey.h"
#include "screen.h"
@ -35,12 +36,16 @@ public:
irobot_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_nvram(*this, "nvram") ,
m_videoram(*this, "videoram"),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_palette(*this, "palette"),
#if IR_TIMING
m_irvg_timer(*this, "irvg_timer"),
m_irmb_timer(*this, "irmb_timer"),
#endif
m_novram(*this, "nvram"),
m_pokey(*this, "pokey%u", 1U),
m_leds(*this, "led%u", 0U)
{ }
@ -50,12 +55,11 @@ public:
void irobot(machine_config &config);
protected:
virtual void machine_start() override { m_leds.resolve(); }
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
void irobot_map(address_map &map);
DECLARE_WRITE8_MEMBER(irobot_nvram_w);
DECLARE_WRITE8_MEMBER(irobot_clearirq_w);
DECLARE_WRITE8_MEMBER(irobot_clearfirq_w);
DECLARE_READ8_MEMBER(irobot_sharedmem_r);
@ -82,7 +86,6 @@ protected:
void irmb_run();
private:
required_shared_ptr<uint8_t> m_nvram;
required_shared_ptr<uint8_t> m_videoram;
uint8_t m_vg_clear;
uint8_t m_bufsel;
@ -91,10 +94,6 @@ private:
uint8_t m_irvg_vblank;
uint8_t m_irvg_running;
uint8_t m_irmb_running;
#if IR_TIMING
timer_device *m_irvg_timer;
timer_device *m_irmb_timer;
#endif
uint8_t *m_comRAM[2];
uint8_t *m_mbRAM;
uint8_t *m_mbROM;
@ -118,6 +117,11 @@ private:
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
#if IR_TIMING
required_device<timer_device> m_irvg_timer;
required_device<timer_device> m_irmb_timer;
#endif
required_device<x2212_device> m_novram;
required_device_array<pokey_device, 4> m_pokey;
output_finder<2> m_leds;
};

View File

@ -67,15 +67,15 @@ WRITE8_MEMBER(irobot_state::irobot_statwr_w)
logerror("write %2x ", data);
IR_CPU_STATE();
m_combase = m_comRAM[data >> 7];
m_combase_mb = m_comRAM[(data >> 7) ^ 1];
m_bufsel = data & 0x02;
if (((data & 0x01) == 0x01) && (m_vg_clear == 0))
m_combase = m_comRAM[BIT(data, 7)];
m_combase_mb = m_comRAM[BIT(data, 7) ^ 1];
m_bufsel = BIT(data, 1);
if (BIT(data, 0) && (m_vg_clear == 0))
irobot_poly_clear();
m_vg_clear = data & 0x01;
m_vg_clear = BIT(data, 0);
if ((data & 0x04) && !(m_statwr & 0x04))
if (BIT(data, 2) && !BIT(m_statwr, 2))
{
irobot_run_video();
#if IR_TIMING
@ -88,8 +88,11 @@ WRITE8_MEMBER(irobot_state::irobot_statwr_w)
#endif
m_irvg_running=1;
}
if ((data & 0x10) && !(m_statwr & 0x10))
if (BIT(data, 4) && !BIT(m_statwr, 4))
irmb_run();
m_novram->recall(!BIT(data, 6));
m_statwr = data;
}
@ -160,6 +163,13 @@ TIMER_CALLBACK_MEMBER(irobot_state::scanline_callback)
machine().scheduler().timer_set(m_screen->time_until_pos(scanline), timer_expired_delegate(FUNC(irobot_state::scanline_callback),this), scanline);
}
void irobot_state::machine_start()
{
m_leds.resolve();
m_vg_clear = 0;
m_statwr = 0;
}
void irobot_state::machine_reset()
{
uint8_t *MB = memregion("mathbox")->base();
@ -172,17 +182,15 @@ void irobot_state::machine_reset()
m_irvg_vblank=0;
m_irvg_running = 0;
m_irvg_timer = machine().device<timer_device>("irvg_timer");
m_irmb_running = 0;
m_irmb_timer = machine().device<timer_device>("irmb_timer");
/* set an initial timer to go off on scanline 0 */
machine().scheduler().timer_set(m_screen->time_until_pos(0), timer_expired_delegate(FUNC(irobot_state::scanline_callback),this));
irobot_rom_banksel_w(m_maincpu->space(AS_PROGRAM),0,0);
irobot_out0_w(m_maincpu->space(AS_PROGRAM),0,0);
m_combase = m_comRAM[0];
m_combase_mb = m_comRAM[1];
address_space &space = machine().dummy_space();
irobot_rom_banksel_w(space, 0, 0);
irobot_out0_w(space, 0, 0);
irobot_statwr_w(space, 0, 0);
m_outx = 0;
}