Skip to content

Commit

Permalink
Added netlist-based audio to early Cinematronics vector games (#6979)
Browse files Browse the repository at this point in the history
* Added netlist simulations for the following games: Space War, Barrier, Star Hawk, Speed Freak, Star Castle, War of the Worlds, Sundance, Tail Gunner, Rip Off, Armor Attack, Warrior, Solar Quest, Boxing Bugs. Removed previous samples-based sound. [Aaron Giles, Couriersud]

* Added built-in minimal artwork for Warrior. [Aaron Giles]

* Changed speaker maximum sample tracking to be based on new compile-time define SPEAKER_TRACK_MAX_SAMPLE instead of MAME_DEBUG. [Aaron Giles]

* Modernized 74164 and 74393 netlist TTL devices. [Aaron Giles]
  • Loading branch information
aaronsgiles authored Jul 22, 2020
1 parent 1c4da1d commit f23db5d
Show file tree
Hide file tree
Showing 39 changed files with 35,189 additions and 7,740 deletions.
28 changes: 27 additions & 1 deletion scripts/target/mame/arcade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,33 @@ files {
MAME_DIR .. "src/mame/drivers/cinemat.cpp",
MAME_DIR .. "src/mame/includes/cinemat.h",
MAME_DIR .. "src/mame/audio/cinemat.cpp",
MAME_DIR .. "src/mame/audio/cinemat.h",
MAME_DIR .. "src/mame/video/cinemat.cpp",
MAME_DIR .. "src/mame/audio/nl_armora.cpp",
MAME_DIR .. "src/mame/audio/nl_armora.h",
MAME_DIR .. "src/mame/audio/nl_barrier.cpp",
MAME_DIR .. "src/mame/audio/nl_barrier.h",
MAME_DIR .. "src/mame/audio/nl_boxingb.cpp",
MAME_DIR .. "src/mame/audio/nl_boxingb.h",
MAME_DIR .. "src/mame/audio/nl_cinemat_common.h",
MAME_DIR .. "src/mame/audio/nl_ripoff.cpp",
MAME_DIR .. "src/mame/audio/nl_ripoff.h",
MAME_DIR .. "src/mame/audio/nl_solarq.cpp",
MAME_DIR .. "src/mame/audio/nl_solarq.h",
MAME_DIR .. "src/mame/audio/nl_spacewar.cpp",
MAME_DIR .. "src/mame/audio/nl_spacewar.h",
MAME_DIR .. "src/mame/audio/nl_speedfrk.cpp",
MAME_DIR .. "src/mame/audio/nl_speedfrk.h",
MAME_DIR .. "src/mame/audio/nl_starcas.cpp",
MAME_DIR .. "src/mame/audio/nl_starcas.h",
MAME_DIR .. "src/mame/audio/nl_starhawk.cpp",
MAME_DIR .. "src/mame/audio/nl_starhawk.h",
MAME_DIR .. "src/mame/audio/nl_sundance.cpp",
MAME_DIR .. "src/mame/audio/nl_sundance.h",
MAME_DIR .. "src/mame/audio/nl_tailg.cpp",
MAME_DIR .. "src/mame/audio/nl_tailg.h",
MAME_DIR .. "src/mame/audio/nl_warrior.cpp",
MAME_DIR .. "src/mame/audio/nl_warrior.h",
MAME_DIR .. "src/mame/drivers/cchasm.cpp",
MAME_DIR .. "src/mame/includes/cchasm.h",
MAME_DIR .. "src/mame/machine/cchasm.cpp",
Expand Down Expand Up @@ -4991,7 +5017,7 @@ files {
MAME_DIR .. "src/mame/drivers/sothello.cpp",
MAME_DIR .. "src/mame/drivers/special_gambl.cpp",
MAME_DIR .. "src/mame/audio/special.cpp",
MAME_DIR .. "src/mame/audio/special.h",
MAME_DIR .. "src/mame/audio/special.h",
MAME_DIR .. "src/mame/drivers/spool99.cpp",
MAME_DIR .. "src/mame/drivers/sprcros2.cpp",
MAME_DIR .. "src/mame/drivers/sshot.cpp",
Expand Down
31 changes: 31 additions & 0 deletions scripts/target/mame/nl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,37 @@ files{
MAME_DIR .. "src/mame/includes/cheekyms.h",
MAME_DIR .. "src/mame/video/cheekyms.cpp",

MAME_DIR .. "src/mame/drivers/cinemat.cpp",
MAME_DIR .. "src/mame/includes/cinemat.h",
MAME_DIR .. "src/mame/audio/cinemat.cpp",
MAME_DIR .. "src/mame/audio/cinemat.h",
MAME_DIR .. "src/mame/video/cinemat.cpp",
MAME_DIR .. "src/mame/audio/nl_armora.cpp",
MAME_DIR .. "src/mame/audio/nl_armora.h",
MAME_DIR .. "src/mame/audio/nl_barrier.cpp",
MAME_DIR .. "src/mame/audio/nl_barrier.h",
MAME_DIR .. "src/mame/audio/nl_boxingb.cpp",
MAME_DIR .. "src/mame/audio/nl_boxingb.h",
MAME_DIR .. "src/mame/audio/nl_cinemat_common.h",
MAME_DIR .. "src/mame/audio/nl_ripoff.cpp",
MAME_DIR .. "src/mame/audio/nl_ripoff.h",
MAME_DIR .. "src/mame/audio/nl_solarq.cpp",
MAME_DIR .. "src/mame/audio/nl_solarq.h",
MAME_DIR .. "src/mame/audio/nl_spacewar.cpp",
MAME_DIR .. "src/mame/audio/nl_spacewar.h",
MAME_DIR .. "src/mame/audio/nl_speedfrk.cpp",
MAME_DIR .. "src/mame/audio/nl_speedfrk.h",
MAME_DIR .. "src/mame/audio/nl_starcas.cpp",
MAME_DIR .. "src/mame/audio/nl_starcas.h",
MAME_DIR .. "src/mame/audio/nl_starhawk.cpp",
MAME_DIR .. "src/mame/audio/nl_starhawk.h",
MAME_DIR .. "src/mame/audio/nl_sundance.cpp",
MAME_DIR .. "src/mame/audio/nl_sundance.h",
MAME_DIR .. "src/mame/audio/nl_tailg.cpp",
MAME_DIR .. "src/mame/audio/nl_tailg.h",
MAME_DIR .. "src/mame/audio/nl_warrior.cpp",
MAME_DIR .. "src/mame/audio/nl_Warrior.h",

MAME_DIR .. "src/mame/drivers/galaxian.cpp",
MAME_DIR .. "src/mame/includes/galaxian.h",
MAME_DIR .. "src/mame/audio/galaxian.cpp",
Expand Down
33 changes: 19 additions & 14 deletions src/emu/speaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ speaker_device::speaker_device(const machine_config &mconfig, const char *tag, d
, m_x(0.0)
, m_y(0.0)
, m_z(0.0)
#ifdef MAME_DEBUG
#if SPEAKER_TRACK_MAX_SAMPLE
, m_max_sample(0)
, m_clipped_samples(0)
, m_total_samples(0)
Expand All @@ -51,10 +51,10 @@ speaker_device::speaker_device(const machine_config &mconfig, const char *tag, d

speaker_device::~speaker_device()
{
#ifdef MAME_DEBUG
#if SPEAKER_TRACK_MAX_SAMPLE
// log the maximum sample values for all speakers
if (m_max_sample > 0)
osd_printf_debug("Speaker \"%s\" - max = %d (gain *= %f) - %d%% samples clipped\n", tag(), m_max_sample, 32767.0 / (m_max_sample ? m_max_sample : 1), (int)((double)m_clipped_samples * 100.0 / m_total_samples));
osd_printf_verbose("Speaker \"%s\" - max = %d (gain *= %f) - %d%% samples clipped\n", tag(), m_max_sample, 32767.0 / (m_max_sample ? m_max_sample : 1), (int)((double)m_clipped_samples * 100.0 / m_total_samples));
#endif
}

Expand Down Expand Up @@ -84,18 +84,23 @@ void speaker_device::mix(s32 *leftmix, s32 *rightmix, int &samples_this_update,
}
assert(samples_this_update == numsamples);

#ifdef MAME_DEBUG
#if SPEAKER_TRACK_MAX_SAMPLE
// debug version: keep track of the maximum sample
for (int sample = 0; sample < samples_this_update; sample++)
{
if (stream_buf[sample] > m_max_sample)
m_max_sample = stream_buf[sample];
else if (-stream_buf[sample] > m_max_sample)
m_max_sample = -stream_buf[sample];
if (stream_buf[sample] > 32767 || stream_buf[sample] < -32768)
m_clipped_samples++;
m_total_samples++;
}
// ignore the first 100k or so samples to avoid biasing in favor
// of initial sound glitches
if (m_total_samples < 100000)
m_total_samples += samples_this_update;
else
for (int sample = 0; sample < samples_this_update; sample++)
{
if (stream_buf[sample] > m_max_sample)
m_max_sample = stream_buf[sample];
else if (-stream_buf[sample] > m_max_sample)
m_max_sample = -stream_buf[sample];
if (stream_buf[sample] > 32767 || stream_buf[sample] < -32768)
m_clipped_samples++;
m_total_samples++;
}
#endif

// mix if sound is enabled
Expand Down
11 changes: 10 additions & 1 deletion src/emu/speaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
#pragma once


#ifndef SPEAKER_TRACK_MAX_SAMPLE
#ifdef MAME_DEBUG
#define SPEAKER_TRACK_MAX_SAMPLE (1)
#else
#define SPEAKER_TRACK_MAX_SAMPLE (0)
#endif
#endif


//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
Expand Down Expand Up @@ -81,7 +90,7 @@ class speaker_device : public device_t, public device_mixer_interface
double m_z;

// internal state
#ifdef MAME_DEBUG
#if SPEAKER_TRACK_MAX_SAMPLE
s32 m_max_sample; // largest sample value we've seen
s32 m_clipped_samples; // total number of clipped samples
s32 m_total_samples; // total number of samples
Expand Down
2 changes: 1 addition & 1 deletion src/lib/netlist/build/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ clang:
clang-libc:
#clang-11 currently broken
#$(MAKE) CC=clang++-11 LD=clang++-11 OBJ=obj/clang CEXTRAFLAGS="-march=native
#$(MAKE) CC=clang++-11 LD=clang++-11 OBJ=obj/clang CEXTRAFLAGS="-march=native
$(MAKE) CC=clang++-10 LD=clang++-10 OBJ=obj/clang-libc CEXTRAFLAGS="-march=native \
-stdlib=libc++ -mllvm -inline-threshold=2000 \
-Wunknown-warning-option \
Expand Down
60 changes: 30 additions & 30 deletions src/lib/netlist/devices/nld_74164.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,59 @@ namespace netlist
NETLIB_OBJECT(74164)
{
NETLIB_CONSTRUCTOR(74164)
, m_A(*this, "A", NETLIB_DELEGATE(inputs))
, m_B(*this, "B", NETLIB_DELEGATE(inputs))
, m_CLRQ(*this, "CLRQ", NETLIB_DELEGATE(inputs))
, m_CLK(*this, "CLK", NETLIB_DELEGATE(inputs))
, m_AB(*this, {"A", "B"}, NETLIB_DELEGATE(ab))
, m_CLRQ(*this, "CLRQ", NETLIB_DELEGATE(clrq))
, m_CLK(*this, "CLK", NETLIB_DELEGATE(clk))
, m_cnt(*this, "m_cnt", 0)
, m_last_CLK(*this, "m_last_CLK", 0)
, m_ab(*this, "m_ab", 0)
, m_Q(*this, {"QA", "QB", "QC", "QD", "QE", "QF", "QG", "QH"})
, m_power_pins(*this)
{
}

NETLIB_HANDLERI(inputs)
private:
NETLIB_RESETI()
{
m_CLK.set_state(logic_t::STATE_INP_LH);
m_cnt = 0;
}

NETLIB_HANDLERI(clrq)
{
if (!m_CLRQ())
if (m_CLRQ())
{
m_cnt = 0;
m_CLK.activate_lh();
}
else if (m_CLK() && !m_last_CLK)
else
{
m_cnt = (m_cnt << 1) & 0xfe;
if (m_A() && m_B())
{
m_cnt |= 0x01;
}
else
m_CLK.inactivate();
if (m_cnt != 0)
{
m_cnt &= 0xfe;
m_cnt = 0;
m_Q.push(0, NLTIME_FROM_NS(30));
}
}
}

m_last_CLK = m_CLK();

for (std::size_t i=0; i<8; i++)
{
m_Q[i].push((m_cnt >> i) & 1, NLTIME_FROM_NS(30));
}
NETLIB_HANDLERI(clk)
{
m_cnt = (m_cnt << 1) | m_ab;
m_Q.push(m_cnt, NLTIME_FROM_NS(30));
}

NETLIB_RESETI()
NETLIB_HANDLERI(ab)
{
m_cnt = 0;
m_last_CLK = 0;
m_ab = static_cast<unsigned>((m_AB() == 3) ? 1 : 0);
}

friend class NETLIB_NAME(74164_dip);
private:
logic_input_t m_A;
logic_input_t m_B;
object_array_t<logic_input_t, 2> m_AB;
logic_input_t m_CLRQ;
logic_input_t m_CLK;

state_var<unsigned> m_cnt;
state_var<unsigned> m_last_CLK;
state_var<unsigned> m_ab;

object_array_t<logic_output_t, 8> m_Q;
nld_power_pins m_power_pins;
Expand All @@ -83,8 +83,8 @@ namespace netlist
NETLIB_CONSTRUCTOR(74164_dip)
, A(*this, "A")
{
register_subalias("1", A.m_A);
register_subalias("2", A.m_B);
register_subalias("1", A.m_AB[0]);
register_subalias("2", A.m_AB[1]);
register_subalias("3", A.m_Q[0]);
register_subalias("4", A.m_Q[1]);
register_subalias("5", A.m_Q[2]);
Expand Down
47 changes: 23 additions & 24 deletions src/lib/netlist/devices/nld_74393.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace netlist
NETLIB_OBJECT(74393)
{
NETLIB_CONSTRUCTOR(74393)
, m_CP(*this, "CP", NETLIB_DELEGATE(inputs))
, m_MR(*this, "MR", NETLIB_DELEGATE(inputs))
, m_CP(*this, "CP", NETLIB_DELEGATE(cp))
, m_MR(*this, "MR", NETLIB_DELEGATE(mr))
, m_Q(*this, {"Q0", "Q1", "Q2", "Q3"})
, m_cnt(*this, "m_cnt", 0)
, m_cp(*this, "m_cp", 0)
Expand All @@ -30,30 +30,37 @@ namespace netlist
private:
NETLIB_RESETI()
{
m_CP.set_state(logic_t::STATE_INP_HL);
m_cnt = 0;
}

NETLIB_HANDLERI(inputs)
NETLIB_HANDLERI(mr)
{
netlist_sig_t last_cp = m_cp;
netlist_sig_t last_mr = m_mr;

m_cp = m_CP();
m_mr = m_MR();

if (!last_mr && m_mr)
if (!m_MR())
{
m_cnt = 0;
update_outputs_all(0, NLTIME_FROM_NS(24), NLTIME_FROM_NS(24), NLTIME_FROM_NS(24), NLTIME_FROM_NS(24));
m_CP.activate_hl();
}
else if (!m_mr && last_cp && !m_cp)
else
{
auto cnt = (m_cnt + 1) & MAXCNT;
update_outputs_all(cnt, NLTIME_FROM_NS(13), NLTIME_FROM_NS(22), NLTIME_FROM_NS(31), NLTIME_FROM_NS(40));
m_cnt = cnt;
m_CP.inactivate();
if (m_cnt != 0)
{
m_cnt = 0;
m_Q.push(0, NLTIME_FROM_NS(24));
}
}
}

NETLIB_HANDLERI(cp)
{
auto cnt = (m_cnt + 1) & MAXCNT;
m_cnt = cnt;
m_Q[0].push((cnt >> 0) & 1, NLTIME_FROM_NS(13));
m_Q[1].push((cnt >> 1) & 1, NLTIME_FROM_NS(22));
m_Q[2].push((cnt >> 2) & 1, NLTIME_FROM_NS(31));
m_Q[3].push((cnt >> 3) & 1, NLTIME_FROM_NS(40));
}

logic_input_t m_CP;
logic_input_t m_MR;
object_array_t<logic_output_t, 4> m_Q;
Expand All @@ -63,14 +70,6 @@ namespace netlist
state_var_sig m_mr;

nld_power_pins m_power_pins;

void update_outputs_all(unsigned cnt, netlist_time q0_delay, netlist_time q1_delay, netlist_time q2_delay, netlist_time q3_delay) noexcept
{
m_Q[0].push((cnt >> 0) & 1, q0_delay);
m_Q[1].push((cnt >> 1) & 1, q1_delay);
m_Q[2].push((cnt >> 2) & 1, q2_delay);
m_Q[3].push((cnt >> 3) & 1, q3_delay);
}
};

NETLIB_OBJECT(74393_dip)
Expand Down
Loading

0 comments on commit f23db5d

Please sign in to comment.