cinemat: split out stuff unique to demon and qb3, use virtual methods a bit more (nw)

This commit is contained in:
Vas Crabb 2018-05-17 14:35:40 +10:00
parent f7b6bb6bbb
commit 06d629cb25
4 changed files with 143 additions and 107 deletions

View File

@ -57,10 +57,6 @@ void cinemat_state::sound_start()
save_item(NAME(m_last_shift2));
save_item(NAME(m_current_pitch));
save_item(NAME(m_last_frame));
save_item(NAME(m_sound_fifo));
save_item(NAME(m_sound_fifo_in));
save_item(NAME(m_sound_fifo_out));
save_item(NAME(m_last_portb_write));
}
@ -1303,35 +1299,35 @@ MACHINE_CONFIG_END
*
*************************************/
TIMER_CALLBACK_MEMBER( cinemat_state::synced_sound_w )
TIMER_CALLBACK_MEMBER( demon_state::synced_sound_w )
{
m_sound_fifo[m_sound_fifo_in] = param;
m_sound_fifo_in = (m_sound_fifo_in + 1) % 16;
}
WRITE_LINE_MEMBER(cinemat_state::demon_sound4_w)
WRITE_LINE_MEMBER(demon_state::demon_sound4_w)
{
/* watch for a 0->1 edge on bit 4 ("shift in") to clock in the new data */
if (state)
machine().scheduler().synchronize(timer_expired_delegate(FUNC(cinemat_state::synced_sound_w), this), ~m_outlatch->output_state() & 0x0f);
machine().scheduler().synchronize(timer_expired_delegate(FUNC(demon_state::synced_sound_w), this), ~m_outlatch->output_state() & 0x0f);
}
READ8_MEMBER(cinemat_state::sound_porta_r)
READ8_MEMBER(demon_state::sound_porta_r)
{
/* bits 0-3 are the sound data; bit 4 is the data ready */
return m_sound_fifo[m_sound_fifo_out] | ((m_sound_fifo_in != m_sound_fifo_out) << 4);
}
READ8_MEMBER(cinemat_state::sound_portb_r)
READ8_MEMBER(demon_state::sound_portb_r)
{
return m_last_portb_write;
}
WRITE8_MEMBER(cinemat_state::sound_portb_w)
WRITE8_MEMBER(demon_state::sound_portb_w)
{
/* watch for a 0->1 edge on bit 0 ("shift out") to advance the data pointer */
if ((data & 1) != (m_last_portb_write & 1) && (data & 1) != 0)
@ -1349,15 +1345,27 @@ WRITE8_MEMBER(cinemat_state::sound_portb_w)
m_last_portb_write = data;
}
WRITE8_MEMBER(cinemat_state::sound_output_w)
WRITE8_MEMBER(demon_state::sound_output_w)
{
logerror("sound_output = %02X\n", data);
}
SOUND_RESET_MEMBER( cinemat_state, demon )
void demon_state::sound_start()
{
cinemat_state::sound_start();
/* register for save states */
save_item(NAME(m_sound_fifo));
save_item(NAME(m_sound_fifo_in));
save_item(NAME(m_sound_fifo_out));
save_item(NAME(m_last_portb_write));
}
void demon_state::sound_reset()
{
/* generic init */
sound_reset();
cinemat_state::sound_reset();
/* reset the FIFO */
m_sound_fifo_in = m_sound_fifo_out = 0;
@ -1368,7 +1376,7 @@ SOUND_RESET_MEMBER( cinemat_state, demon )
}
void cinemat_state::demon_sound_map(address_map &map)
void demon_state::demon_sound_map(address_map &map)
{
map(0x0000, 0x1fff).rom();
map(0x3000, 0x33ff).ram();
@ -1382,7 +1390,7 @@ void cinemat_state::demon_sound_map(address_map &map)
}
void cinemat_state::demon_sound_ports(address_map &map)
void demon_state::demon_sound_ports(address_map &map)
{
map.global_mask(0xff);
map(0x00, 0x03).w("ctc", FUNC(z80ctc_device::write));
@ -1397,7 +1405,7 @@ static const z80_daisy_config daisy_chain[] =
};
MACHINE_CONFIG_START(cinemat_state::demon_sound)
MACHINE_CONFIG_START(demon_state::demon_sound)
/* basic machine hardware */
MCFG_DEVICE_ADD("audiocpu", Z80, 3579545)
@ -1408,18 +1416,16 @@ MACHINE_CONFIG_START(cinemat_state::demon_sound)
MCFG_DEVICE_ADD("ctc", Z80CTC, 3579545 /* same as "audiocpu" */)
MCFG_Z80CTC_INTR_CB(INPUTLINE("audiocpu", INPUT_LINE_IRQ0))
MCFG_SOUND_RESET_OVERRIDE(cinemat_state, demon)
MCFG_DEVICE_MODIFY("outlatch")
MCFG_ADDRESSABLE_LATCH_Q4_OUT_CB(WRITELINE(*this, cinemat_state, demon_sound4_w))
MCFG_ADDRESSABLE_LATCH_Q4_OUT_CB(WRITELINE(*this, demon_state, demon_sound4_w))
/* sound hardware */
SPEAKER(config, "mono").front_center();
MCFG_DEVICE_ADD("ay1", AY8910, 3579545)
MCFG_AY8910_PORT_A_READ_CB(READ8(*this, cinemat_state, sound_porta_r))
MCFG_AY8910_PORT_B_READ_CB(READ8(*this, cinemat_state, sound_portb_r))
MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, cinemat_state, sound_portb_w))
MCFG_AY8910_PORT_A_READ_CB(READ8(*this, demon_state, sound_porta_r))
MCFG_AY8910_PORT_B_READ_CB(READ8(*this, demon_state, sound_portb_r))
MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, demon_state, sound_portb_w))
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
MCFG_DEVICE_ADD("ay2", AY8910, 3579545)
@ -1428,7 +1434,7 @@ MACHINE_CONFIG_START(cinemat_state::demon_sound)
MCFG_DEVICE_ADD("ay3", AY8910, 3579545)
MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, cinemat_state, sound_output_w))
MCFG_AY8910_PORT_B_WRITE_CB(WRITE8(*this, demon_state, sound_output_w))
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
MACHINE_CONFIG_END
@ -1440,16 +1446,16 @@ MACHINE_CONFIG_END
*
*************************************/
WRITE8_MEMBER(cinemat_state::qb3_sound_fifo_w)
WRITE8_MEMBER(qb3_state::qb3_sound_fifo_w)
{
uint16_t rega = m_maincpu->state_int(ccpu_cpu_device::CCPU_A);
machine().scheduler().synchronize(timer_expired_delegate(FUNC(cinemat_state::synced_sound_w), this), rega & 0x0f);
machine().scheduler().synchronize(timer_expired_delegate(FUNC(qb3_state::synced_sound_w), this), rega & 0x0f);
}
SOUND_RESET_MEMBER( cinemat_state, qb3 )
void qb3_state::sound_reset()
{
SOUND_RESET_CALL_MEMBER(demon);
demon_state::sound_reset();
/* this patch prevents the sound ROM from eating itself when command $0A is sent */
/* on a cube rotate */
@ -1457,9 +1463,8 @@ SOUND_RESET_MEMBER( cinemat_state, qb3 )
}
MACHINE_CONFIG_START(cinemat_state::qb3_sound)
MACHINE_CONFIG_START(qb3_state::qb3_sound)
demon_sound(config);
MCFG_SOUND_RESET_OVERRIDE(cinemat_state, qb3)
MCFG_DEVICE_MODIFY("outlatch")
MCFG_ADDRESSABLE_LATCH_Q4_OUT_CB(NOOP) // not mapped through LS259

View File

@ -261,7 +261,7 @@ READ8_MEMBER(cinemat_state::boxingb_dial_r)
*
*************************************/
READ8_MEMBER(cinemat_state::qb3_frame_r)
READ8_MEMBER(qb3_state::qb3_frame_r)
{
attotime next_update = m_screen->time_until_update();
attotime frame_period = m_screen->frame_period();
@ -272,7 +272,7 @@ READ8_MEMBER(cinemat_state::qb3_frame_r)
}
WRITE8_MEMBER(cinemat_state::qb3_ram_bank_w)
WRITE8_MEMBER(qb3_state::qb3_ram_bank_w)
{
membank("bank1")->set_entry(m_maincpu->state_int(ccpu_cpu_device::CCPU_P) & 3);
}
@ -316,7 +316,7 @@ void cinemat_state::data_map(address_map &map)
map(0x0000, 0x00ff).ram();
}
void cinemat_state::data_map_qb3(address_map &map)
void qb3_state::data_map_qb3(address_map &map)
{
map(0x0000, 0x03ff).bankrw("bank1").share("rambase");
}
@ -331,13 +331,13 @@ void cinemat_state::io_map(address_map &map)
map(0x00, 0x07).w(m_outlatch, FUNC(ls259_device::write_d0));
}
void cinemat_state::io_map_qb3(address_map &map)
void qb3_state::io_map_qb3(address_map &map)
{
io_map(map);
// Some of the outputs here are definitely not mapped through the LS259, since they use multiple bits of data
map(0x00, 0x00).w(this, FUNC(cinemat_state::qb3_ram_bank_w));
map(0x04, 0x04).w(this, FUNC(cinemat_state::qb3_sound_fifo_w));
map(0x0f, 0x0f).r(this, FUNC(cinemat_state::qb3_frame_r));
map(0x00, 0x00).w(this, FUNC(qb3_state::qb3_ram_bank_w));
map(0x04, 0x04).w(this, FUNC(qb3_state::qb3_sound_fifo_w));
map(0x0f, 0x0f).r(this, FUNC(qb3_state::qb3_frame_r));
}
@ -1141,7 +1141,7 @@ MACHINE_CONFIG_START(cinemat_state::wotwc)
MACHINE_CONFIG_END
MACHINE_CONFIG_START(cinemat_state::demon)
MACHINE_CONFIG_START(demon_state::demon)
cinemat_jmi_16k(config);
demon_sound(config);
MCFG_SCREEN_MODIFY("screen")
@ -1149,7 +1149,7 @@ MACHINE_CONFIG_START(cinemat_state::demon)
MACHINE_CONFIG_END
MACHINE_CONFIG_START(cinemat_state::qb3)
MACHINE_CONFIG_START(qb3_state::qb3)
cinemat_jmi_32k(config);
qb3_sound(config);
MCFG_DEVICE_MODIFY("maincpu")
@ -1157,7 +1157,6 @@ MACHINE_CONFIG_START(cinemat_state::qb3)
MCFG_DEVICE_IO_MAP(io_map_qb3)
MCFG_SCREEN_MODIFY("screen")
MCFG_SCREEN_VISIBLE_AREA(0, 1120, 0, 780)
MCFG_VIDEO_START_OVERRIDE(cinemat_state,cinemat_qb3color)
MACHINE_CONFIG_END
@ -1486,7 +1485,7 @@ void cinemat_state::init_boxingb()
}
void cinemat_state::init_qb3()
void qb3_state::init_qb3()
{
membank("bank1")->configure_entries(0, 4, m_rambase, 0x100*2);
}
@ -1521,5 +1520,5 @@ GAMEL( 1981, solarq, 0, solarq, solarq, cinemat_state, empty_init,
GAME( 1981, boxingb, 0, boxingb, boxingb, cinemat_state, init_boxingb, ORIENTATION_FLIP_Y, "Cinematronics", "Boxing Bugs", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAMEL( 1981, wotw, 0, wotw, wotw, cinemat_state, empty_init, ORIENTATION_FLIP_Y, "Cinematronics", "War of the Worlds", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE, layout_wotw )
GAME( 1981, wotwc, wotw, wotwc, wotw, cinemat_state, empty_init, ORIENTATION_FLIP_Y, "Cinematronics", "War of the Worlds (color)", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )
GAMEL( 1982, demon, 0, demon, demon, cinemat_state, empty_init, ORIENTATION_FLIP_Y, "Rock-Ola", "Demon", MACHINE_SUPPORTS_SAVE, layout_demon )
GAME( 1982, qb3, 0, qb3, qb3, cinemat_state, init_qb3, ORIENTATION_FLIP_Y, "Rock-Ola", "QB-3 (prototype)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE )
GAMEL( 1982, demon, 0, demon, demon, demon_state, empty_init, ORIENTATION_FLIP_Y, "Rock-Ola", "Demon", MACHINE_SUPPORTS_SAVE, layout_demon )
GAME( 1982, qb3, 0, qb3, qb3, qb3_state, init_qb3, ORIENTATION_FLIP_Y, "Rock-Ola", "QB-3 (prototype)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE )

View File

@ -5,6 +5,10 @@
Cinematronics vector hardware
*************************************************************************/
#ifndef MAME_INCLUDES_CINEMAT_H
#define MAME_INCLUDES_CINEMAT_H
#pragma once
#include "cpu/ccpu/ccpu.h"
#include "machine/74259.h"
@ -58,10 +62,6 @@ public:
uint32_t m_last_shift2;
uint32_t m_current_pitch;
uint32_t m_last_frame;
uint8_t m_sound_fifo[16];
uint8_t m_sound_fifo_in;
uint8_t m_sound_fifo_out;
uint8_t m_last_portb_write;
float m_target_volume;
float m_current_volume;
uint8_t m_coin_detected;
@ -73,8 +73,6 @@ public:
int16_t m_lastx;
int16_t m_lasty;
uint8_t m_last_control;
int m_qb3_lastx;
int m_qb3_lasty;
DECLARE_READ8_MEMBER(inputs_r);
DECLARE_READ8_MEMBER(switches_r);
DECLARE_READ8_MEMBER(coin_input_r);
@ -84,33 +82,22 @@ public:
DECLARE_READ8_MEMBER(speedfrk_gear_r);
DECLARE_READ8_MEMBER(sundance_inputs_r);
DECLARE_READ8_MEMBER(boxingb_dial_r);
DECLARE_READ8_MEMBER(qb3_frame_r);
DECLARE_WRITE8_MEMBER(qb3_ram_bank_w);
DECLARE_WRITE_LINE_MEMBER(vector_control_w);
virtual DECLARE_WRITE_LINE_MEMBER(vector_control_w);
DECLARE_READ8_MEMBER(joystick_read);
DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
void init_speedfrk();
void init_boxingb();
void init_sundance();
void init_qb3();
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void sound_start() override;
virtual void sound_reset() override;
virtual void video_start() override;
DECLARE_SOUND_RESET(demon);
DECLARE_SOUND_RESET(qb3);
DECLARE_VIDEO_START(cinemat_16level);
DECLARE_VIDEO_START(cinemat_64level);
DECLARE_VIDEO_START(cinemat_color);
DECLARE_VIDEO_START(cinemat_qb3color);
uint32_t screen_update_cinemat(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
uint32_t screen_update_spacewar(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_READ8_MEMBER(sound_porta_r);
DECLARE_READ8_MEMBER(sound_portb_r);
DECLARE_WRITE8_MEMBER(sound_portb_w);
DECLARE_WRITE8_MEMBER(sound_output_w);
TIMER_CALLBACK_MEMBER(synced_sound_w);
void cinemat_vector_callback(int16_t sx, int16_t sy, int16_t ex, int16_t ey, uint8_t shift);
DECLARE_WRITE_LINE_MEMBER(spacewar_sound0_w);
DECLARE_WRITE_LINE_MEMBER(spacewar_sound1_w);
@ -169,17 +156,13 @@ public:
DECLARE_WRITE_LINE_MEMBER(wotw_sound2_w);
DECLARE_WRITE_LINE_MEMBER(wotw_sound3_w);
DECLARE_WRITE_LINE_MEMBER(wotw_sound4_w);
DECLARE_WRITE_LINE_MEMBER(demon_sound4_w);
DECLARE_WRITE8_MEMBER(qb3_sound_fifo_w);
void cinemat_nojmi_4k(machine_config &config);
void cinemat_jmi_4k(machine_config &config);
void cinemat_nojmi_8k(machine_config &config);
void cinemat_jmi_8k(machine_config &config);
void cinemat_jmi_16k(machine_config &config);
void cinemat_jmi_32k(machine_config &config);
void qb3(machine_config &config);
void ripoff(machine_config &config);
void demon(machine_config &config);
void wotwc(machine_config &config);
void wotw(machine_config &config);
void boxingb(machine_config &config);
@ -206,16 +189,71 @@ public:
void solarq_sound(machine_config &config);
void boxingb_sound(machine_config &config);
void wotw_sound(machine_config &config);
void demon_sound(machine_config &config);
void qb3_sound(machine_config &config);
void data_map(address_map &map);
void data_map_qb3(address_map &map);
void demon_sound_map(address_map &map);
void demon_sound_ports(address_map &map);
void io_map(address_map &map);
void io_map_qb3(address_map &map);
void program_map_16k(address_map &map);
void program_map_32k(address_map &map);
void program_map_4k(address_map &map);
void program_map_8k(address_map &map);
};
class demon_state : public cinemat_state
{
public:
using cinemat_state::cinemat_state;
void demon(machine_config &config);
protected:
TIMER_CALLBACK_MEMBER(synced_sound_w);
DECLARE_WRITE_LINE_MEMBER(demon_sound4_w);
DECLARE_READ8_MEMBER(sound_porta_r);
DECLARE_READ8_MEMBER(sound_portb_r);
DECLARE_WRITE8_MEMBER(sound_portb_w);
DECLARE_WRITE8_MEMBER(sound_output_w);
virtual void sound_start() override;
virtual void sound_reset() override;
void demon_sound(machine_config &config);
void demon_sound_map(address_map &map);
void demon_sound_ports(address_map &map);
private:
uint8_t m_sound_fifo[16];
uint8_t m_sound_fifo_in;
uint8_t m_sound_fifo_out;
uint8_t m_last_portb_write;
};
class qb3_state : public demon_state
{
public:
using demon_state::demon_state;
void init_qb3();
void qb3(machine_config &config);
protected:
virtual DECLARE_WRITE_LINE_MEMBER(vector_control_w) override;
DECLARE_READ8_MEMBER(qb3_frame_r);
DECLARE_WRITE8_MEMBER(qb3_ram_bank_w);
DECLARE_WRITE8_MEMBER(qb3_sound_fifo_w);
virtual void sound_reset() override;
void qb3_sound(machine_config &config);
void data_map_qb3(address_map &map);
void io_map_qb3(address_map &map);
private:
int m_qb3_lastx;
int m_qb3_lasty;
};
#endif // MAME_INCLUDES_CINEMAT_H

View File

@ -22,8 +22,7 @@ enum
COLOR_BILEVEL,
COLOR_16LEVEL,
COLOR_64LEVEL,
COLOR_RGB,
COLOR_QB3
COLOR_RGB
};
@ -71,6 +70,7 @@ void cinemat_state::cinemat_vector_callback(int16_t sx, int16_t sy, int16_t ex,
WRITE_LINE_MEMBER(cinemat_state::vector_control_w)
{
// TODO: turn this into a virtual method and just override for each type
int r, g, b, i;
cpu_device *cpu = m_maincpu;
@ -119,38 +119,38 @@ WRITE_LINE_MEMBER(cinemat_state::vector_control_w)
m_vector_color = rgb_t(r,g,b);
}
break;
}
}
case COLOR_QB3:
{
/* on the falling edge of the data value, remember the original X,Y values */
/* they will be restored on the rising edge; this is to simulate the fact */
/* that the Rockola color hardware did not overwrite the beam X,Y position */
/* on an IV instruction if data == 0 here */
if (!state)
{
m_qb3_lastx = cpu->state_int(ccpu_cpu_device::CCPU_X);
m_qb3_lasty = cpu->state_int(ccpu_cpu_device::CCPU_Y);
}
/* on the rising edge of the data value, latch the Y register */
/* as 2-3-3 BGR values */
if (state)
{
int yval = cpu->state_int(ccpu_cpu_device::CCPU_Y);
r = (~yval >> 0) & 0x07;
r = r * 255 / 7;
g = (~yval >> 3) & 0x07;
g = g * 255 / 7;
b = (~yval >> 6) & 0x03;
b = b * 255 / 3;
m_vector_color = rgb_t(r,g,b);
WRITE_LINE_MEMBER(qb3_state::vector_control_w)
{
/* on the falling edge of the data value, remember the original X,Y values */
/* they will be restored on the rising edge; this is to simulate the fact */
/* that the Rockola color hardware did not overwrite the beam X,Y position */
/* on an IV instruction if data == 0 here */
if (!state)
{
m_qb3_lastx = m_maincpu->state_int(ccpu_cpu_device::CCPU_X);
m_qb3_lasty = m_maincpu->state_int(ccpu_cpu_device::CCPU_Y);
}
/* restore the original X,Y values */
cpu->set_state_int(ccpu_cpu_device::CCPU_X, m_qb3_lastx);
cpu->set_state_int(ccpu_cpu_device::CCPU_Y, m_qb3_lasty);
}
}
break;
/* on the rising edge of the data value, latch the Y register */
/* as 2-3-3 BGR values */
if (state)
{
int yval = m_maincpu->state_int(ccpu_cpu_device::CCPU_Y);
int r = (~yval >> 0) & 0x07;
r = r * 255 / 7;
int g = (~yval >> 3) & 0x07;
g = g * 255 / 7;
int b = (~yval >> 6) & 0x03;
b = b * 255 / 3;
m_vector_color = rgb_t(r,g,b);
/* restore the original X,Y values */
m_maincpu->set_state_int(ccpu_cpu_device::CCPU_X, m_qb3_lastx);
m_maincpu->set_state_int(ccpu_cpu_device::CCPU_Y, m_qb3_lasty);
}
}
@ -186,12 +186,6 @@ VIDEO_START_MEMBER(cinemat_state,cinemat_color)
}
VIDEO_START_MEMBER(cinemat_state,cinemat_qb3color)
{
m_color_mode = COLOR_QB3;
}
/*************************************
*