cchasm.c: added save state support (nw)

This commit is contained in:
Ivan Vangelista 2015-05-18 19:17:18 +02:00
parent e3363e97e8
commit aa8c7eee25
5 changed files with 54 additions and 46 deletions

View File

@ -14,7 +14,7 @@
#include "sound/dac.h"
WRITE8_MEMBER(cchasm_state::cchasm_reset_coin_flag_w)
WRITE8_MEMBER(cchasm_state::reset_coin_flag_w)
{
if (m_coin_flag)
{
@ -23,7 +23,7 @@ WRITE8_MEMBER(cchasm_state::cchasm_reset_coin_flag_w)
}
}
INPUT_CHANGED_MEMBER(cchasm_state::cchasm_set_coin_flag )
INPUT_CHANGED_MEMBER(cchasm_state::set_coin_flag )
{
if (!newval && !m_coin_flag)
{
@ -32,27 +32,27 @@ INPUT_CHANGED_MEMBER(cchasm_state::cchasm_set_coin_flag )
}
}
READ8_MEMBER(cchasm_state::cchasm_coin_sound_r)
READ8_MEMBER(cchasm_state::coin_sound_r)
{
UINT8 coin = (ioport("IN3")->read() >> 4) & 0x7;
return m_sound_flags | (m_coin_flag << 3) | coin;
}
READ8_MEMBER(cchasm_state::cchasm_soundlatch2_r)
READ8_MEMBER(cchasm_state::soundlatch2_r)
{
m_sound_flags &= ~0x80;
m_ctc->trg2(0);
return soundlatch2_byte_r(space, offset);
}
WRITE8_MEMBER(cchasm_state::cchasm_soundlatch4_w)
WRITE8_MEMBER(cchasm_state::soundlatch4_w)
{
m_sound_flags |= 0x40;
soundlatch4_byte_w(space, offset, data);
m_maincpu->set_input_line(1, HOLD_LINE);
}
WRITE16_MEMBER(cchasm_state::cchasm_io_w)
WRITE16_MEMBER(cchasm_state::io_w)
{
//static int led;
@ -77,7 +77,7 @@ WRITE16_MEMBER(cchasm_state::cchasm_io_w)
}
}
READ16_MEMBER(cchasm_state::cchasm_io_r)
READ16_MEMBER(cchasm_state::io_r)
{
switch (offset & 0xf)
{
@ -122,5 +122,11 @@ void cchasm_state::sound_start()
{
m_coin_flag = 0;
m_sound_flags = 0;
m_output[0] = 0; m_output[1] = 0;
m_output[0] = 0;
m_output[1] = 0;
save_item(NAME(m_sound_flags));
save_item(NAME(m_coin_flag));
save_item(NAME(m_channel_active));
save_item(NAME(m_output));
}

View File

@ -35,10 +35,10 @@
static ADDRESS_MAP_START( memmap, AS_PROGRAM, 16, cchasm_state )
AM_RANGE(0x000000, 0x00ffff) AM_ROM
AM_RANGE(0x040000, 0x04000f) AM_DEVREADWRITE8("6840ptm", ptm6840_device, read, write, 0xff)
AM_RANGE(0x050000, 0x050001) AM_WRITE(cchasm_refresh_control_w)
AM_RANGE(0x060000, 0x060001) AM_READ_PORT("DSW") AM_WRITE(cchasm_led_w)
AM_RANGE(0x050000, 0x050001) AM_WRITE(refresh_control_w)
AM_RANGE(0x060000, 0x060001) AM_READ_PORT("DSW") AM_WRITE(led_w)
AM_RANGE(0x070000, 0x070001) AM_WRITE(watchdog_reset16_w)
AM_RANGE(0xf80000, 0xf800ff) AM_READWRITE(cchasm_io_r,cchasm_io_w)
AM_RANGE(0xf80000, 0xf800ff) AM_READWRITE(io_r,io_w)
AM_RANGE(0xffb000, 0xffffff) AM_RAM AM_SHARE("ram")
ADDRESS_MAP_END
@ -53,13 +53,13 @@ static ADDRESS_MAP_START( sound_memmap, AS_PROGRAM, 8, cchasm_state )
AM_RANGE(0x4000, 0x43ff) AM_RAM
AM_RANGE(0x5000, 0x53ff) AM_RAM
AM_RANGE(0x6000, 0x6001) AM_MIRROR(0xf9e) AM_DEVWRITE("ay1", ay8910_device, address_data_w)
AM_RANGE(0x6000, 0x6000) AM_MIRROR(0xf9e) AM_READ(cchasm_coin_sound_r)
AM_RANGE(0x6000, 0x6000) AM_MIRROR(0xf9e) AM_READ(coin_sound_r)
AM_RANGE(0x6001, 0x6001) AM_MIRROR(0xf9e) AM_DEVREAD("ay1", ay8910_device, data_r)
AM_RANGE(0x6020, 0x6021) AM_MIRROR(0xf9e) AM_DEVWRITE("ay2", ay8910_device, address_data_w)
AM_RANGE(0x6021, 0x6021) AM_MIRROR(0xf9e) AM_DEVREAD("ay2", ay8910_device, data_r)
AM_RANGE(0x6040, 0x6040) AM_MIRROR(0xf9e) AM_READWRITE(soundlatch_byte_r, soundlatch3_byte_w)
AM_RANGE(0x6041, 0x6041) AM_MIRROR(0xf9e) AM_READWRITE(cchasm_soundlatch2_r, cchasm_soundlatch4_w)
AM_RANGE(0x6061, 0x6061) AM_MIRROR(0xf9e) AM_WRITE(cchasm_reset_coin_flag_w)
AM_RANGE(0x6041, 0x6041) AM_MIRROR(0xf9e) AM_READWRITE(soundlatch2_r, soundlatch4_w)
AM_RANGE(0x6061, 0x6061) AM_MIRROR(0xf9e) AM_WRITE(reset_coin_flag_w)
AM_RANGE(0x7041, 0x7041) AM_NOP // TODO
ADDRESS_MAP_END
@ -68,11 +68,6 @@ static ADDRESS_MAP_START( sound_portmap, AS_IO, 8, cchasm_state )
AM_RANGE(0x00, 0x03) AM_DEVREADWRITE("ctc", z80ctc_device, read, write)
ADDRESS_MAP_END
WRITE_LINE_MEMBER(cchasm_state::cchasm_6840_irq)
{
m_maincpu->set_input_line(4, state ? ASSERT_LINE : CLEAR_LINE);
}
/*************************************
*
* Port definitions
@ -117,9 +112,9 @@ static INPUT_PORTS_START( cchasm )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
PORT_START("IN3")
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, cchasm_state, cchasm_set_coin_flag, 0)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, cchasm_state, cchasm_set_coin_flag, 0)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, cchasm_state, cchasm_set_coin_flag, 0)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, cchasm_state, set_coin_flag, 0)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, cchasm_state, set_coin_flag, 0)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, cchasm_state, set_coin_flag, 0)
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Test 1") PORT_CODE(KEYCODE_F1)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) /* Test 2, not used in cchasm */
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Test 3, not used in cchasm */
@ -189,7 +184,7 @@ static MACHINE_CONFIG_START( cchasm, cchasm_state )
MCFG_DEVICE_ADD("6840ptm", PTM6840, 0)
MCFG_PTM6840_INTERNAL_CLOCK(CCHASM_68K_CLOCK/10)
MCFG_PTM6840_EXTERNAL_CLOCKS(0, CCHASM_68K_CLOCK / 10, 0)
MCFG_PTM6840_IRQ_CB(WRITELINE(cchasm_state, cchasm_6840_irq))
MCFG_PTM6840_IRQ_CB(INPUTLINE("maincpu", 4))
MACHINE_CONFIG_END
@ -259,5 +254,5 @@ ROM_END
*
*************************************/
GAME( 1983, cchasm, 0, cchasm, cchasm, driver_device, 0, ROT270, "Cinematronics / GCE", "Cosmic Chasm (set 1)", 0 )
GAME( 1983, cchasm1, cchasm, cchasm, cchasm, driver_device, 0, ROT270, "Cinematronics / GCE", "Cosmic Chasm (set 2)", 0 )
GAME( 1983, cchasm, 0, cchasm, cchasm, driver_device, 0, ROT270, "Cinematronics / GCE", "Cosmic Chasm (set 1)", GAME_SUPPORTS_SAVE )
GAME( 1983, cchasm1, cchasm, cchasm, cchasm, driver_device, 0, ROT270, "Cinematronics / GCE", "Cosmic Chasm (set 2)", GAME_SUPPORTS_SAVE )

View File

@ -20,16 +20,15 @@ public:
cchasm_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_ram(*this, "ram"),
m_maincpu(*this, "maincpu"),
m_ctc(*this, "ctc"),
m_audiocpu(*this, "audiocpu"),
m_dac1(*this, "dac1"),
m_dac2(*this, "dac2"),
m_vector(*this, "vector"),
m_screen(*this, "screen") { }
m_screen(*this, "screen"),
m_ram(*this, "ram") { }
required_shared_ptr<UINT16> m_ram;
required_device<cpu_device> m_maincpu;
required_device<z80ctc_device> m_ctc;
required_device<cpu_device> m_audiocpu;
@ -37,6 +36,8 @@ public:
required_device<dac_device> m_dac2;
required_device<vector_device> m_vector;
required_device<screen_device> m_screen;
required_shared_ptr<UINT16> m_ram;
int m_sound_flags;
int m_coin_flag;
@ -44,21 +45,25 @@ public:
int m_output[2];
int m_xcenter;
int m_ycenter;
DECLARE_WRITE16_MEMBER(cchasm_led_w);
DECLARE_WRITE16_MEMBER(cchasm_refresh_control_w);
DECLARE_WRITE8_MEMBER(cchasm_reset_coin_flag_w);
DECLARE_READ8_MEMBER(cchasm_coin_sound_r);
DECLARE_READ8_MEMBER(cchasm_soundlatch2_r);
DECLARE_WRITE8_MEMBER(cchasm_soundlatch4_w);
DECLARE_WRITE16_MEMBER(cchasm_io_w);
DECLARE_READ16_MEMBER(cchasm_io_r);
INPUT_CHANGED_MEMBER(cchasm_set_coin_flag);
DECLARE_WRITE_LINE_MEMBER(cchasm_6840_irq);
virtual void video_start();
virtual void sound_start();
emu_timer *m_refresh_end_timer;
DECLARE_WRITE16_MEMBER(led_w);
DECLARE_WRITE16_MEMBER(refresh_control_w);
DECLARE_WRITE8_MEMBER(reset_coin_flag_w);
DECLARE_READ8_MEMBER(coin_sound_r);
DECLARE_READ8_MEMBER(soundlatch2_r);
DECLARE_WRITE8_MEMBER(soundlatch4_w);
DECLARE_WRITE16_MEMBER(io_w);
DECLARE_READ16_MEMBER(io_r);
DECLARE_WRITE_LINE_MEMBER(ctc_timer_1_w);
DECLARE_WRITE_LINE_MEMBER(ctc_timer_2_w);
void cchasm_refresh ();
INPUT_CHANGED_MEMBER(set_coin_flag);
virtual void video_start();
virtual void sound_start();
void refresh();
protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);

View File

@ -9,7 +9,7 @@
#include "emu.h"
#include "includes/cchasm.h"
WRITE16_MEMBER(cchasm_state::cchasm_led_w)
WRITE16_MEMBER(cchasm_state::led_w)
{
/*logerror("LED write %x to %x\n", data, offset);*/
}

View File

@ -32,7 +32,7 @@ void cchasm_state::device_timer(emu_timer &timer, device_timer_id id, int param,
}
void cchasm_state::cchasm_refresh ()
void cchasm_state::refresh ()
{
int pc = 0;
int done = 0;
@ -105,18 +105,18 @@ void cchasm_state::cchasm_refresh ()
}
}
/* Refresh processor runs with 6 MHz */
timer_set(attotime::from_hz(6000000) * total_length, TIMER_REFRESH_END);
m_refresh_end_timer->adjust(attotime::from_hz(6000000) * total_length);
}
WRITE16_MEMBER(cchasm_state::cchasm_refresh_control_w)
WRITE16_MEMBER(cchasm_state::refresh_control_w)
{
if (ACCESSING_BITS_8_15)
{
switch (data >> 8)
{
case 0x37:
cchasm_refresh();
refresh();
break;
case 0xf7:
m_maincpu->set_input_line(2, CLEAR_LINE);
@ -131,4 +131,6 @@ void cchasm_state::video_start()
m_xcenter=visarea.xcenter() << 16;
m_ycenter=visarea.ycenter() << 16;
m_refresh_end_timer = timer_alloc(TIMER_REFRESH_END);
}