Moved targ/spectar audio functions into driver state while having no luck in fixing MT05217. (nw)

This commit is contained in:
Ivan Vangelista 2013-08-05 16:51:59 +00:00
parent fd66b2953f
commit daf47bf3c2
5 changed files with 89 additions and 94 deletions

1
.gitattributes vendored
View File

@ -4580,7 +4580,6 @@ src/mame/includes/tank8.h svneol=native#text/plain
src/mame/includes/tankbatt.h svneol=native#text/plain
src/mame/includes/tankbust.h svneol=native#text/plain
src/mame/includes/taotaido.h svneol=native#text/plain
src/mame/includes/targ.h svneol=native#text/plain
src/mame/includes/targeth.h svneol=native#text/plain
src/mame/includes/tatsumi.h svneol=native#text/plain
src/mame/includes/taxidriv.h svneol=native#text/plain

View File

@ -12,26 +12,13 @@
*/
#include "emu.h"
#include "sound/samples.h"
#include "sound/dac.h"
#include "includes/targ.h"
#include "includes/exidy.h"
#define SPECTAR_MAXFREQ 525000
#define TARG_MAXFREQ 125000
static int max_freq;
static UINT8 port_1_last;
static UINT8 port_2_last;
static UINT8 tone_freq;
static UINT8 tone_active;
static UINT8 tone_pointer;
static const INT16 sine_wave[32] =
{
0x0f0f, 0x0f0f, 0x0f0f, 0x0606, 0x0606, 0x0909, 0x0909, 0x0606, 0x0606, 0x0909, 0x0606, 0x0d0d, 0x0f0f, 0x0f0f, 0x0d0d, 0x0000,
@ -40,96 +27,91 @@ static const INT16 sine_wave[32] =
/* some macros to make detecting bit changes easier */
#define RISING_EDGE(bit) ( (data & bit) && !(port_1_last & bit))
#define FALLING_EDGE(bit) (!(data & bit) && (port_1_last & bit))
#define RISING_EDGE(bit) ( (data & bit) && !(m_port_1_last & bit))
#define FALLING_EDGE(bit) (!(data & bit) && (m_port_1_last & bit))
static void adjust_sample(samples_device *samples, UINT8 freq)
void exidy_state::adjust_sample(UINT8 freq)
{
tone_freq = freq;
m_tone_freq = freq;
if ((tone_freq == 0xff) || (tone_freq == 0x00))
samples->set_volume(3, 0);
if ((m_tone_freq == 0xff) || (m_tone_freq == 0x00))
m_samples->set_volume(3, 0);
else
{
samples->set_frequency(3, 1.0 * max_freq / (0xff - tone_freq));
samples->set_volume(3, tone_active);
m_samples->set_frequency(3, 1.0 * m_max_freq / (0xff - m_tone_freq));
m_samples->set_volume(3, m_tone_active);
}
}
WRITE8_HANDLER( targ_audio_1_w )
WRITE8_MEMBER( exidy_state::targ_audio_1_w )
{
samples_device *samples = space.machine().device<samples_device>("samples");
/* CPU music */
if ((data & 0x01) != (port_1_last & 0x01))
space.machine().device<dac_device>("dac")->write_unsigned8((data & 0x01) * 0xff);
if ((data & 0x01) != (m_port_1_last & 0x01))
m_dac->write_unsigned8((data & 0x01) * 0xff);
/* shot */
if (FALLING_EDGE(0x02) && !samples->playing(0)) samples->start(0,1);
if (RISING_EDGE(0x02)) samples->stop(0);
if (FALLING_EDGE(0x02) && !m_samples->playing(0)) m_samples->start(0,1);
if (RISING_EDGE(0x02)) m_samples->stop(0);
/* crash */
if (RISING_EDGE(0x20))
{
if (data & 0x40)
samples->start(1,2);
m_samples->start(1,2);
else
samples->start(1,0);
m_samples->start(1,0);
}
/* Sspec */
if (data & 0x10)
samples->stop(2);
m_samples->stop(2);
else
{
if ((data & 0x08) != (port_1_last & 0x08))
if ((data & 0x08) != (m_port_1_last & 0x08))
{
if (data & 0x08)
samples->start(2,3,true);
m_samples->start(2,3,true);
else
samples->start(2,4,true);
m_samples->start(2,4,true);
}
}
/* Game (tone generator enable) */
if (FALLING_EDGE(0x80))
{
tone_pointer = 0;
tone_active = 0;
m_tone_pointer = 0;
m_tone_active = 0;
adjust_sample(samples, tone_freq);
adjust_sample(m_tone_freq);
}
if (RISING_EDGE(0x80))
tone_active=1;
m_tone_active=1;
port_1_last = data;
m_port_1_last = data;
}
WRITE8_HANDLER( targ_audio_2_w )
WRITE8_MEMBER( exidy_state::targ_audio_2_w )
{
if ((data & 0x01) && !(port_2_last & 0x01))
if ((data & 0x01) && !(m_port_2_last & 0x01))
{
samples_device *samples = space.machine().device<samples_device>("samples");
UINT8 *prom = space.machine().root_device().memregion("targ")->base();
UINT8 *prom = memregion("targ")->base();
tone_pointer = (tone_pointer + 1) & 0x0f;
m_tone_pointer = (m_tone_pointer + 1) & 0x0f;
adjust_sample(samples, prom[((data & 0x02) << 3) | tone_pointer]);
adjust_sample(prom[((data & 0x02) << 3) | m_tone_pointer]);
}
port_2_last = data;
m_port_2_last = data;
}
WRITE8_HANDLER( spectar_audio_2_w )
WRITE8_MEMBER( exidy_state::spectar_audio_2_w )
{
samples_device *samples = space.machine().device<samples_device>("samples");
adjust_sample(samples, data);
adjust_sample(data);
}
@ -145,38 +127,42 @@ static const char *const sample_names[] =
};
static void common_audio_start(running_machine &machine, int freq)
void exidy_state::common_audio_start(int freq)
{
samples_device *samples = machine.device<samples_device>("samples");
max_freq = freq;
m_max_freq = freq;
tone_freq = 0;
tone_active = 0;
m_tone_freq = 0;
m_tone_active = 0;
samples->set_volume(3, 0);
samples->start_raw(3, sine_wave, 32, 1000, true);
m_samples->set_volume(3, 0);
m_samples->start_raw(3, sine_wave, 32, 1000, true);
machine.save().save_item(NAME(port_1_last));
machine.save().save_item(NAME(port_2_last));
machine.save().save_item(NAME(tone_freq));
machine.save().save_item(NAME(tone_active));
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));
}
static SAMPLES_START( spectar_audio_start )
{
common_audio_start(device.machine(), SPECTAR_MAXFREQ);
running_machine &machine = device.machine();
exidy_state *state = machine.driver_data<exidy_state>();
state->common_audio_start(SPECTAR_MAXFREQ);
}
static SAMPLES_START( targ_audio_start )
{
running_machine &machine = device.machine();
common_audio_start(machine, TARG_MAXFREQ);
exidy_state *state = machine.driver_data<exidy_state>();
state->common_audio_start(TARG_MAXFREQ);
tone_pointer = 0;
state->m_tone_pointer = 0;
machine.save().save_item(NAME(tone_pointer));
state->save_item(NAME(state->m_tone_pointer));
}

View File

@ -220,8 +220,8 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( sidetrac_map, AS_PROGRAM, 8, exidy_state )
AM_RANGE(0x0800, 0x3fff) AM_ROM
AM_RANGE(0x4800, 0x4fff) AM_ROM AM_SHARE("characterram")
AM_RANGE(0x5200, 0x5200) AM_WRITE_LEGACY(targ_audio_1_w)
AM_RANGE(0x5201, 0x5201) AM_WRITE_LEGACY(spectar_audio_2_w)
AM_RANGE(0x5200, 0x5200) AM_WRITE(targ_audio_1_w)
AM_RANGE(0x5201, 0x5201) AM_WRITE(spectar_audio_2_w)
AM_RANGE(0xff00, 0xffff) AM_ROM AM_REGION("maincpu", 0x3f00)
AM_IMPORT_FROM(exidy_map)
ADDRESS_MAP_END
@ -230,8 +230,8 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( targ_map, AS_PROGRAM, 8, exidy_state )
AM_RANGE(0x0800, 0x3fff) AM_ROM
AM_RANGE(0x4800, 0x4fff) AM_RAM AM_SHARE("characterram")
AM_RANGE(0x5200, 0x5200) AM_WRITE_LEGACY(targ_audio_1_w)
AM_RANGE(0x5201, 0x5201) AM_WRITE_LEGACY(targ_audio_2_w)
AM_RANGE(0x5200, 0x5200) AM_WRITE(targ_audio_1_w)
AM_RANGE(0x5201, 0x5201) AM_WRITE(targ_audio_2_w)
AM_RANGE(0xff00, 0xffff) AM_ROM AM_REGION("maincpu", 0x3f00)
AM_IMPORT_FROM(exidy_map)
ADDRESS_MAP_END
@ -240,8 +240,8 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( spectar_map, AS_PROGRAM, 8, exidy_state )
AM_RANGE(0x0800, 0x3fff) AM_ROM
AM_RANGE(0x4800, 0x4fff) AM_RAM AM_SHARE("characterram")
AM_RANGE(0x5200, 0x5200) AM_WRITE_LEGACY(targ_audio_1_w)
AM_RANGE(0x5201, 0x5201) AM_WRITE_LEGACY(spectar_audio_2_w)
AM_RANGE(0x5200, 0x5200) AM_WRITE(targ_audio_1_w)
AM_RANGE(0x5201, 0x5201) AM_WRITE(spectar_audio_2_w)
AM_RANGE(0xff00, 0xffff) AM_ROM AM_REGION("maincpu", 0x3f00)
AM_IMPORT_FROM(exidy_map)
ADDRESS_MAP_END
@ -259,8 +259,8 @@ static ADDRESS_MAP_START( rallys_map, AS_PROGRAM, 8, exidy_state )
AM_RANGE(0x5101, 0x5101) AM_MIRROR(0x00fc) AM_READ_PORT("IN0")
AM_RANGE(0x5101, 0x5101) AM_MIRROR(0x00fc) AM_WRITEONLY AM_SHARE("sprite_enable")
AM_RANGE(0x5103, 0x5103) AM_MIRROR(0x00fc) AM_READ(exidy_interrupt_r)
AM_RANGE(0x5200, 0x5200) AM_WRITE_LEGACY(targ_audio_1_w)
AM_RANGE(0x5201, 0x5201) AM_WRITE_LEGACY(spectar_audio_2_w)
AM_RANGE(0x5200, 0x5200) AM_WRITE(targ_audio_1_w)
AM_RANGE(0x5201, 0x5201) AM_WRITE(spectar_audio_2_w)
AM_RANGE(0x5210, 0x5212) AM_WRITEONLY AM_SHARE("color_latch")
AM_RANGE(0x5213, 0x5213) AM_READ_PORT("IN2")
AM_RANGE(0x5300, 0x5300) AM_WRITEONLY AM_SHARE("sprite2_xpos")

View File

@ -4,6 +4,9 @@
*************************************************************************/
#include "sound/dac.h"
#include "sound/samples.h"
#define EXIDY_MASTER_CLOCK (XTAL_11_289MHz)
#define EXIDY_CPU_CLOCK (EXIDY_MASTER_CLOCK / 16)
#define EXIDY_PIXEL_CLOCK (EXIDY_MASTER_CLOCK / 2)
@ -38,9 +41,11 @@ public:
m_sprite_enable(*this, "sprite_enable"),
m_color_latch(*this, "color_latch"),
m_characterram(*this, "characterram"),
m_maincpu(*this, "maincpu") { }
m_maincpu(*this, "maincpu"),
m_dac(*this, "dac"),
m_samples(*this, "samples") { }
UINT8 m_last_dial;
required_shared_ptr<UINT8> m_videoram;
required_shared_ptr<UINT8> m_sprite1_xpos;
required_shared_ptr<UINT8> m_sprite1_ypos;
@ -50,6 +55,12 @@ public:
required_shared_ptr<UINT8> m_sprite_enable;
required_shared_ptr<UINT8> m_color_latch;
required_shared_ptr<UINT8> m_characterram;
required_device<cpu_device> m_maincpu;
optional_device<dac_device> m_dac;
optional_device<samples_device> m_samples;
UINT8 m_last_dial;
UINT8 m_collision_mask;
UINT8 m_collision_invert;
int m_is_2bpp;
@ -83,12 +94,24 @@ public:
inline int sprite_1_enabled();
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
void check_collision();
required_device<cpu_device> m_maincpu;
/* Targ and Spectar samples */
int m_max_freq;
UINT8 m_port_1_last;
UINT8 m_port_2_last;
UINT8 m_tone_freq;
UINT8 m_tone_active;
UINT8 m_tone_pointer;
DECLARE_WRITE8_MEMBER(targ_audio_1_w);
DECLARE_WRITE8_MEMBER(targ_audio_2_w);
DECLARE_WRITE8_MEMBER(spectar_audio_2_w);
void adjust_sample(UINT8 freq);
void common_audio_start(int freq);
protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
};
/*----------- defined in video/exidy.c -----------*/
void exidy_video_config(running_machine &machine, UINT8 _collision_mask, UINT8 _collision_invert, int _is_2bpp);
MACHINE_CONFIG_EXTERN( spectar_audio );
MACHINE_CONFIG_EXTERN( targ_audio );

View File

@ -1,13 +0,0 @@
/*************************************************************************
Targ hardware
*************************************************************************/
/*----------- defined in audio/targ.c -----------*/
DECLARE_WRITE8_HANDLER( targ_audio_1_w );
DECLARE_WRITE8_HANDLER( targ_audio_2_w );
DECLARE_WRITE8_HANDLER( spectar_audio_2_w );
MACHINE_CONFIG_EXTERN( spectar_audio );
MACHINE_CONFIG_EXTERN( targ_audio );