summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2020-11-28 12:12:54 +0100
committer Olivier Galibert <galibert@pobox.com>2020-11-28 12:12:54 +0100
commit3ae7e0f52831054008572fabd4da610826884e58 (patch)
tree4a84f040897dcf268fcf279cb2ebb57c75a2c838 /src
parentf9eb33db4d8e155a191b206c1b5bb667a4b41361 (diff)
Make exidy compilable with SOURCES= and fix sidetrac
Diffstat (limited to 'src')
-rw-r--r--src/mame/audio/targ.cpp202
-rw-r--r--src/mame/drivers/exidy.cpp198
-rw-r--r--src/mame/includes/exidy.h2
-rw-r--r--src/mame/video/exidy.cpp7
4 files changed, 202 insertions, 207 deletions
diff --git a/src/mame/audio/targ.cpp b/src/mame/audio/targ.cpp
deleted file mode 100644
index 12c799c8776..00000000000
--- a/src/mame/audio/targ.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*************************************************************************
-
- Targ hardware
-
-*************************************************************************/
-
-/* Sound channel usage
- 0 = CPU music, Shoot
- 1 = Crash
- 2 = Spectar sound
- 3 = Tone generator
-*/
-
-#include "emu.h"
-#include "includes/exidy.h"
-#include "speaker.h"
-
-
-
-#define SPECTAR_MAXFREQ 525000
-#define TARG_MAXFREQ 125000
-
-static const int16_t sine_wave[32] =
-{
- 0x0f0f, 0x0f0f, 0x0f0f, 0x0606, 0x0606, 0x0909, 0x0909, 0x0606, 0x0606, 0x0909, 0x0606, 0x0d0d, 0x0f0f, 0x0f0f, 0x0d0d, 0x0000,
- -0x191a, -0x2122, -0x1e1f, -0x191a, -0x1314, -0x191a, -0x1819, -0x1819, -0x1819, -0x1314, -0x1314, -0x1314, -0x1819, -0x1e1f, -0x1e1f, -0x1819
-};
-
-
-/* some macros to make detecting bit changes easier */
-#define RISING_EDGE(bit) ( (data & bit) && !(m_port_1_last & bit))
-#define FALLING_EDGE(bit) (!(data & bit) && (m_port_1_last & bit))
-
-
-void exidy_state::adjust_sample(uint8_t freq)
-{
- m_tone_freq = freq;
-
- if (!m_samples->playing(3))
- {
- m_samples->set_volume(3, 0);
- m_samples->start_raw(3, sine_wave, 32, 1000, true);
- }
-
- if ((m_tone_freq == 0xff) || (m_tone_freq == 0x00))
- m_samples->set_volume(3, 0);
- else
- {
- m_samples->set_frequency(3, 1.0 * m_max_freq / (0xff - m_tone_freq));
- m_samples->set_volume(3, m_tone_active);
- }
-}
-
-
-void exidy_state::targ_audio_1_w(uint8_t data)
-{
- /* CPU music */
- if (BIT(m_port_1_last ^ data, 0))
- m_dac->write(BIT(data, 0));
-
- /* shot */
- if (FALLING_EDGE(0x02) && !m_samples->playing(0)) m_samples->start(0,1);
- if (RISING_EDGE(0x02)) m_samples->start(0,1);
-
- /* crash */
- if (RISING_EDGE(0x20))
- {
- if (data & 0x40)
- m_samples->start(1,0);
- else
- m_samples->start(1,2);
- }
-
- /* Sspec */
- if (data & 0x10)
- m_samples->stop(2);
- else
- {
- if ((data & 0x08) != (m_port_1_last & 0x08))
- {
- if (data & 0x08)
- m_samples->start(2,3,true);
- else
- m_samples->start(2,4,true);
- }
- }
-
- /* Game (tone generator enable) */
- if (FALLING_EDGE(0x80))
- {
- m_tone_pointer = 0;
- m_tone_active = 0;
-
- adjust_sample(m_tone_freq);
- }
-
- if (RISING_EDGE(0x80))
- m_tone_active=1;
-
- m_port_1_last = data;
-}
-
-
-void exidy_state::targ_audio_2_w(uint8_t data)
-{
- if ((data & 0x01) && !(m_port_2_last & 0x01))
- {
- uint8_t *prom = memregion("targ")->base();
-
- m_tone_pointer = (m_tone_pointer + 1) & 0x0f;
-
- adjust_sample(prom[((data & 0x02) << 3) | m_tone_pointer]);
- }
-
- m_port_2_last = data;
-}
-
-
-void exidy_state::spectar_audio_2_w(uint8_t data)
-{
- adjust_sample(data);
-}
-
-
-static const char *const sample_names[] =
-{
- "*targ",
- "expl",
- "shot",
- "sexpl",
- "spslow",
- "spfast",
- nullptr
-};
-
-
-
-void exidy_state::common_audio_start(int freq)
-{
- m_max_freq = freq;
-
- m_tone_freq = 0;
- m_tone_active = 0;
-
- /* start_raw can't be called here: chan.source will be set by
- samples_device::device_start and then nulled out by samples_device::device_reset
- at the soft_reset stage of init_machine() and will never be set again.
- Thus, I've moved it to exidy_state::adjust_sample() were it will be set after
- machine initialization. */
- //m_samples->set_volume(3, 0);
- //m_samples->start_raw(3, sine_wave, 32, 1000, true);
-
- save_item(NAME(m_port_1_last));
- save_item(NAME(m_port_2_last));
- save_item(NAME(m_tone_freq));
- save_item(NAME(m_tone_active));
-}
-
-
-SAMPLES_START_CB_MEMBER(exidy_state::spectar_audio_start)
-{
- common_audio_start(SPECTAR_MAXFREQ);
-}
-
-
-SAMPLES_START_CB_MEMBER(exidy_state::targ_audio_start)
-{
- common_audio_start(TARG_MAXFREQ);
-
- m_tone_pointer = 0;
-
- save_item(NAME(m_tone_pointer));
-}
-
-
-void exidy_state::spectar_audio(machine_config &config)
-{
- SPEAKER(config, "speaker").front_center();
-
- SAMPLES(config, m_samples);
- m_samples->set_channels(4);
- m_samples->set_samples_names(sample_names);
- m_samples->set_samples_start_callback(FUNC(exidy_state::spectar_audio_start));
- m_samples->add_route(ALL_OUTPUTS, "speaker", 0.25);
-
- DAC_1BIT(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.99);
-}
-
-void exidy_state::targ_audio(machine_config &config)
-{
- SPEAKER(config, "speaker").front_center();
-
- SAMPLES(config, m_samples);
- m_samples->set_channels(4);
- m_samples->set_samples_names(sample_names);
- m_samples->set_samples_start_callback(FUNC(exidy_state::targ_audio_start));
- m_samples->add_route(ALL_OUTPUTS, "speaker", 0.25);
-
- DAC_1BIT(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.99);
-}
diff --git a/src/mame/drivers/exidy.cpp b/src/mame/drivers/exidy.cpp
index 4f69a08d194..5f745de412c 100644
--- a/src/mame/drivers/exidy.cpp
+++ b/src/mame/drivers/exidy.cpp
@@ -153,6 +153,7 @@ Fax 1982 6502 FXL, FLA
#include "machine/6821pia.h"
#include "audio/exidy.h"
#include "includes/exidy.h"
+#include "speaker.h"
/*************************************
@@ -234,7 +235,7 @@ void exidy_state::sidetrac_map(address_map &map)
{
exidy_map(map);
map(0x0800, 0x3fff).rom();
- map(0x4800, 0x4fff).rom().share("characterram");
+ map(0x4800, 0x4fff).rom();
map(0x5200, 0x5200).w(FUNC(exidy_state::targ_audio_1_w));
map(0x5201, 0x5201).w(FUNC(exidy_state::spectar_audio_2_w));
map(0xff00, 0xffff).rom().region("maincpu", 0x3f00);
@@ -977,6 +978,201 @@ void exidy_state::fax(machine_config &config)
m_maincpu->set_addrmap(AS_PROGRAM, &exidy_state::fax_map);
}
+/*************************************************************************
+
+ Targ hardware
+
+*************************************************************************/
+
+/* Sound channel usage
+ 0 = CPU music, Shoot
+ 1 = Crash
+ 2 = Spectar sound
+ 3 = Tone generator
+*/
+
+#define SPECTAR_MAXFREQ 525000
+#define TARG_MAXFREQ 125000
+
+static const int16_t sine_wave[32] =
+{
+ 0x0f0f, 0x0f0f, 0x0f0f, 0x0606, 0x0606, 0x0909, 0x0909, 0x0606, 0x0606, 0x0909, 0x0606, 0x0d0d, 0x0f0f, 0x0f0f, 0x0d0d, 0x0000,
+ -0x191a, -0x2122, -0x1e1f, -0x191a, -0x1314, -0x191a, -0x1819, -0x1819, -0x1819, -0x1314, -0x1314, -0x1314, -0x1819, -0x1e1f, -0x1e1f, -0x1819
+};
+
+
+/* some macros to make detecting bit changes easier */
+#define RISING_EDGE(bit) ( (data & bit) && !(m_port_1_last & bit))
+#define FALLING_EDGE(bit) (!(data & bit) && (m_port_1_last & bit))
+
+
+void exidy_state::adjust_sample(uint8_t freq)
+{
+ m_tone_freq = freq;
+
+ if (!m_samples->playing(3))
+ {
+ m_samples->set_volume(3, 0);
+ m_samples->start_raw(3, sine_wave, 32, 1000, true);
+ }
+
+ if ((m_tone_freq == 0xff) || (m_tone_freq == 0x00))
+ m_samples->set_volume(3, 0);
+ else
+ {
+ m_samples->set_frequency(3, 1.0 * m_max_freq / (0xff - m_tone_freq));
+ m_samples->set_volume(3, m_tone_active);
+ }
+}
+
+
+void exidy_state::targ_audio_1_w(uint8_t data)
+{
+ /* CPU music */
+ if (BIT(m_port_1_last ^ data, 0))
+ m_dac->write(BIT(data, 0));
+
+ /* shot */
+ if (FALLING_EDGE(0x02) && !m_samples->playing(0)) m_samples->start(0,1);
+ if (RISING_EDGE(0x02)) m_samples->start(0,1);
+
+ /* crash */
+ if (RISING_EDGE(0x20))
+ {
+ if (data & 0x40)
+ m_samples->start(1,0);
+ else
+ m_samples->start(1,2);
+ }
+
+ /* Sspec */
+ if (data & 0x10)
+ m_samples->stop(2);
+ else
+ {
+ if ((data & 0x08) != (m_port_1_last & 0x08))
+ {
+ if (data & 0x08)
+ m_samples->start(2,3,true);
+ else
+ m_samples->start(2,4,true);
+ }
+ }
+
+ /* Game (tone generator enable) */
+ if (FALLING_EDGE(0x80))
+ {
+ m_tone_pointer = 0;
+ m_tone_active = 0;
+
+ adjust_sample(m_tone_freq);
+ }
+
+ if (RISING_EDGE(0x80))
+ m_tone_active=1;
+
+ m_port_1_last = data;
+}
+
+
+void exidy_state::targ_audio_2_w(uint8_t data)
+{
+ if ((data & 0x01) && !(m_port_2_last & 0x01))
+ {
+ uint8_t *prom = memregion("targ")->base();
+
+ m_tone_pointer = (m_tone_pointer + 1) & 0x0f;
+
+ adjust_sample(prom[((data & 0x02) << 3) | m_tone_pointer]);
+ }
+
+ m_port_2_last = data;
+}
+
+
+void exidy_state::spectar_audio_2_w(uint8_t data)
+{
+ adjust_sample(data);
+}
+
+
+static const char *const sample_names[] =
+{
+ "*targ",
+ "expl",
+ "shot",
+ "sexpl",
+ "spslow",
+ "spfast",
+ nullptr
+};
+
+
+
+void exidy_state::common_audio_start(int freq)
+{
+ m_max_freq = freq;
+
+ m_tone_freq = 0;
+ m_tone_active = 0;
+
+ /* start_raw can't be called here: chan.source will be set by
+ samples_device::device_start and then nulled out by samples_device::device_reset
+ at the soft_reset stage of init_machine() and will never be set again.
+ Thus, I've moved it to exidy_state::adjust_sample() were it will be set after
+ machine initialization. */
+ //m_samples->set_volume(3, 0);
+ //m_samples->start_raw(3, sine_wave, 32, 1000, true);
+
+ save_item(NAME(m_port_1_last));
+ save_item(NAME(m_port_2_last));
+ save_item(NAME(m_tone_freq));
+ save_item(NAME(m_tone_active));
+}
+
+
+SAMPLES_START_CB_MEMBER(exidy_state::spectar_audio_start)
+{
+ common_audio_start(SPECTAR_MAXFREQ);
+}
+
+
+SAMPLES_START_CB_MEMBER(exidy_state::targ_audio_start)
+{
+ common_audio_start(TARG_MAXFREQ);
+
+ m_tone_pointer = 0;
+
+ save_item(NAME(m_tone_pointer));
+}
+
+
+void exidy_state::spectar_audio(machine_config &config)
+{
+ SPEAKER(config, "speaker").front_center();
+
+ SAMPLES(config, m_samples);
+ m_samples->set_channels(4);
+ m_samples->set_samples_names(sample_names);
+ m_samples->set_samples_start_callback(FUNC(exidy_state::spectar_audio_start));
+ m_samples->add_route(ALL_OUTPUTS, "speaker", 0.25);
+
+ DAC_1BIT(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.99);
+}
+
+void exidy_state::targ_audio(machine_config &config)
+{
+ SPEAKER(config, "speaker").front_center();
+
+ SAMPLES(config, m_samples);
+ m_samples->set_channels(4);
+ m_samples->set_samples_names(sample_names);
+ m_samples->set_samples_start_callback(FUNC(exidy_state::targ_audio_start));
+ m_samples->add_route(ALL_OUTPUTS, "speaker", 0.25);
+
+ DAC_1BIT(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.99);
+}
+
/*************************************
diff --git a/src/mame/includes/exidy.h b/src/mame/includes/exidy.h
index 93257d9f082..227d51a635a 100644
--- a/src/mame/includes/exidy.h
+++ b/src/mame/includes/exidy.h
@@ -94,7 +94,7 @@ private:
required_shared_ptr<uint8_t> m_spriteno;
required_shared_ptr<uint8_t> m_sprite_enable;
required_shared_ptr<uint8_t> m_color_latch;
- required_shared_ptr<uint8_t> m_characterram;
+ optional_shared_ptr<uint8_t> m_characterram;
uint8_t m_last_dial;
uint8_t m_collision_mask;
diff --git a/src/mame/video/exidy.cpp b/src/mame/video/exidy.cpp
index 2df9ef5470d..e5cc24134e7 100644
--- a/src/mame/video/exidy.cpp
+++ b/src/mame/video/exidy.cpp
@@ -128,6 +128,7 @@ void exidy_state::set_colors()
void exidy_state::draw_background()
{
+ const u8 *cram = m_characterram ? (u8 *)m_characterram : memregion("maincpu")->base() + 0x4800;
offs_t offs;
pen_t off_pen = 0;
@@ -155,8 +156,8 @@ void exidy_state::draw_background()
if (m_is_2bpp)
{
- uint8_t data1 = m_characterram[0x000 | (code << 3) | cy];
- uint8_t data2 = m_characterram[0x800 | (code << 3) | cy];
+ uint8_t data1 = cram[0x000 | (code << 3) | cy];
+ uint8_t data2 = cram[0x800 | (code << 3) | cy];
for (int i = 0; i < 8; i++)
{
@@ -173,7 +174,7 @@ void exidy_state::draw_background()
/* 1bpp */
else
{
- uint8_t data = m_characterram[(code << 3) | cy];
+ uint8_t data = cram[(code << 3) | cy];
for (int i = 0; i < 8; i++)
{