summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cam900 <dbtlrchl@naver.com>2019-02-23 13:11:31 +0900
committer cam900 <dbtlrchl@naver.com>2019-02-23 13:11:31 +0900
commit2ca01b91eea08c6ef511649a64492e65ac6d2bfa (patch)
tree892080b0c1e3f01f89a0a3495a8e419ed000b630
parent1d866d320312f8f9afc6f517a625b3f314d91ee0 (diff)
devices/sound/gaelco.cpp : Updates
Add device_rom_interface for sound data, Correct sound pitch (related to clock), Minor code style fixes gaelco2.cpp : Minor XTAL correction, Add notes Reference of sound pitch : (snowboar* - https://youtu.be/9ISkG2ggfEc)
-rw-r--r--src/devices/sound/gaelco.cpp107
-rw-r--r--src/devices/sound/gaelco.h10
-rw-r--r--src/mame/drivers/gaelco2.cpp39
3 files changed, 98 insertions, 58 deletions
diff --git a/src/devices/sound/gaelco.cpp b/src/devices/sound/gaelco.cpp
index c8109ce5acd..af34c9ee80f 100644
--- a/src/devices/sound/gaelco.cpp
+++ b/src/devices/sound/gaelco.cpp
@@ -64,8 +64,8 @@ gaelco_gae1_device::gaelco_gae1_device(const machine_config &mconfig, const char
gaelco_gae1_device::gaelco_gae1_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock)
, device_sound_interface(mconfig, *this)
+ , device_rom_interface(mconfig, *this, 27) // Unknown address bits
, m_stream(nullptr)
- , m_snd_data(*this, finder_base::DUMMY_TAG)
{
}
@@ -78,26 +78,26 @@ gaelco_gae1_device::gaelco_gae1_device(const machine_config &mconfig, device_typ
void gaelco_gae1_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
- int j, ch;
-
/* fill all data needed */
- for(j = 0; j < samples; j++){
+ for (int j = 0; j < samples; j++)
+ {
int output_l = 0, output_r = 0;
/* for each channel */
- for (ch = 0; ch < NUM_CHANNELS; ch ++){
+ for (int ch = 0; ch < NUM_CHANNELS; ch++)
+ {
int ch_data_l = 0, ch_data_r = 0;
sound_channel *channel = &m_channel[ch];
/* if the channel is playing */
- if (channel->active == 1){
+ if (channel->active == 1)
+ {
int data, chunkNum = 0;
int base_offset, type, bank, vol_r, vol_l, end_pos;
/* if the channel is looping, get current chunk to play */
- if (channel->loop == 1){
+ if (channel->loop == 1)
chunkNum = channel->chunkNum;
- }
base_offset = ch*8 + chunkNum*4;
@@ -109,27 +109,31 @@ void gaelco_gae1_device::sound_stream_update(sound_stream &stream, stream_sample
end_pos = (m_sndregs[base_offset + 2] << 8) - 1;
/* generates output data (range 0x00000..0xffff) */
- if (type == 0x08){
- /* PCM, 8 bits mono */
- data = m_snd_data[bank + end_pos + m_sndregs[base_offset + 3]];
+ if (type == 0x08) /* PCM, 8 bits mono */
+ {
+ data = read_byte(bank + end_pos + m_sndregs[base_offset + 3]);
ch_data_l = m_volume_table[vol_l][data];
ch_data_r = m_volume_table[vol_r][data];
m_sndregs[base_offset + 3]--;
- } else if (type == 0x0c){
- /* PCM, 8 bits stereo */
- data = m_snd_data[bank + end_pos + m_sndregs[base_offset + 3]];
+ }
+ else if (type == 0x0c) /* PCM, 8 bits stereo */
+ {
+ data = read_byte(bank + end_pos + m_sndregs[base_offset + 3]);
ch_data_l = m_volume_table[vol_l][data];
m_sndregs[base_offset + 3]--;
- if (m_sndregs[base_offset + 3] > 0){
- data = m_snd_data[bank + end_pos + m_sndregs[base_offset + 3]];
+ if (m_sndregs[base_offset + 3] > 0)
+ {
+ data = read_byte(bank + end_pos + m_sndregs[base_offset + 3]);
ch_data_r = m_volume_table[vol_r][data];
m_sndregs[base_offset + 3]--;
}
- } else {
+ }
+ else
+ {
LOG_SOUND(("(GAE1) Playing unknown sample format in channel: %02d, type: %02x, bank: %02x, end: %08x, Length: %04x\n", ch, type, bank, end_pos, m_sndregs[base_offset + 3]));
//channel->active = 0;
// play2000 expects these to expire, are they valid? this is unrelated to the missing sounds in touchgo which never hits here
@@ -137,16 +141,20 @@ void gaelco_gae1_device::sound_stream_update(sound_stream &stream, stream_sample
}
/* check if the current sample has finished playing */
- if (m_sndregs[base_offset + 3] == 0){
- if (channel->loop == 0){ /* if no looping, we're done */
+ if (m_sndregs[base_offset + 3] == 0)
+ {
+ if (channel->loop == 0) /* if no looping, we're done */
+ {
channel->active = 0;
- } else { /* if we're looping, swap chunks */
+ }
+ else /* if we're looping, swap chunks */
+ {
channel->chunkNum = (channel->chunkNum + 1) & 0x01;
/* if the length of the next chunk is 0, we're done */
- if (m_sndregs[ch*8 + channel->chunkNum*4 + 3] == 0){
+ if (m_sndregs[ch*8 + channel->chunkNum*4 + 3] == 0)
channel->active = 0;
- }
+
}
}
}
@@ -206,29 +214,33 @@ WRITE16_MEMBER( gaelco_gae1_device::gaelcosnd_w )
COMBINE_DATA(&m_sndregs[offset]);
- switch(offset & 0x07){
+ switch(offset & 0x07)
+ {
case 0x03:
/* trigger sound */
- if ((m_sndregs[offset - 1] != 0) && (data != 0)){
- if (!channel->active){
+ if ((m_sndregs[offset - 1] != 0) && (data != 0))
+ {
+ if (!channel->active)
+ {
channel->active = 1;
channel->chunkNum = 0;
channel->loop = 0;
LOG_SOUND(("(GAE1) Playing sample channel: %02d, type: %02x, bank: %02x, end: %08x, Length: %04x\n", offset >> 3, (m_sndregs[offset - 2] >> 4) & 0x0f, m_sndregs[offset - 2] & 0x03, m_sndregs[offset - 1] << 8, data));
}
- } else {
- channel->active = 0;
}
+ else
+ channel->active = 0;
break;
case 0x07: /* enable/disable looping */
- if ((m_sndregs[offset - 1] != 0) && (data != 0)){
+ if ((m_sndregs[offset - 1] != 0) && (data != 0))
+ {
LOG_SOUND(("(GAE1) Looping in channel: %02d, type: %02x, bank: %02x, end: %08x, Length: %04x\n", offset >> 3, (m_sndregs[offset - 2] >> 4) & 0x0f, m_sndregs[offset - 2] & 0x03, m_sndregs[offset - 1] << 8, data));
channel->loop = 1;
- } else {
- channel->loop = 0;
}
+ else
+ channel->loop = 0;
break;
}
@@ -240,17 +252,16 @@ WRITE16_MEMBER( gaelco_gae1_device::gaelcosnd_w )
void gaelco_gae1_device::device_start()
{
- m_stream = stream_alloc(0, 2, 8000);
+ u32 rate = clock() / 128;
+ m_stream = stream_alloc(0, 2, rate);
/* init volume table */
- for (int vol = 0; vol < VOLUME_LEVELS; vol++){
- for (int j = -128; j <= 127; j++){
+ for (int vol = 0; vol < VOLUME_LEVELS; vol++)
+ for (int j = -128; j <= 127; j++)
m_volume_table[vol][(j ^ 0x80) & 0xff] = (vol*j*256)/(VOLUME_LEVELS - 1);
- }
- }
if (LOG_WAVE)
- wavraw = wav_open("gae1_snd.wav", 8000, 2);
+ wavraw = wav_open("gae1_snd.wav", rate, 2);
}
@@ -262,6 +273,30 @@ void gaelco_gae1_device::device_stop()
}
+void gaelco_gae1_device::device_post_load()
+{
+ device_clock_changed();
+}
+
+
+void gaelco_gae1_device::device_clock_changed()
+{
+ u32 rate = clock() / 128;
+ m_stream->set_sample_rate(rate);
+ if (wavraw)
+ wav_close(wavraw);
+
+ if (LOG_WAVE)
+ wavraw = wav_open("gae1_snd.wav", rate, 2);
+}
+
+
+void gaelco_gae1_device::rom_bank_updated()
+{
+ m_stream->update();
+}
+
+
/*============================================================================
Gaelco CG-1V sound device
============================================================================*/
diff --git a/src/devices/sound/gaelco.h b/src/devices/sound/gaelco.h
index 01fcae1c8dc..5d26292d086 100644
--- a/src/devices/sound/gaelco.h
+++ b/src/devices/sound/gaelco.h
@@ -13,12 +13,12 @@
// ======================> gaelco_gae1_device
class gaelco_gae1_device : public device_t,
- public device_sound_interface
+ public device_sound_interface,
+ public device_rom_interface
{
public:
gaelco_gae1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
- void set_snd_data_tag(const char *tag) { m_snd_data.set_tag(tag); }
void set_bank_offsets(int offs1, int offs2, int offs3, int offs4)
{
m_banks[0] = offs1;
@@ -36,10 +36,15 @@ protected:
// device-level overrides
virtual void device_start() override;
virtual void device_stop() override;
+ virtual void device_post_load() override;
+ virtual void device_clock_changed() override;
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
+ // device_rom_interface overrides
+ virtual void rom_bank_updated() override;
+
private:
static constexpr int NUM_CHANNELS = 0x07;
static constexpr int VOLUME_LEVELS = 0x10;
@@ -52,7 +57,6 @@ private:
};
sound_stream *m_stream; /* our stream */
- required_region_ptr<uint8_t> m_snd_data; /* PCM data */
int m_banks[4]; /* start of each ROM bank */
sound_channel m_channel[NUM_CHANNELS]; /* 7 stereo channels */
diff --git a/src/mame/drivers/gaelco2.cpp b/src/mame/drivers/gaelco2.cpp
index 92edc4b4387..1db0b69facd 100644
--- a/src/mame/drivers/gaelco2.cpp
+++ b/src/mame/drivers/gaelco2.cpp
@@ -181,7 +181,7 @@ INPUT_PORTS_END
void gaelco2_state::maniacsq(machine_config &config)
{
/* basic machine hardware */
- M68000(config, m_maincpu, XTAL(26'000'000) / 2); /* 13 MHz? */
+ M68000(config, m_maincpu, XTAL(24'000'000) / 2); /* 12 MHz */
m_maincpu->set_addrmap(AS_PROGRAM, &gaelco2_state::maniacsq_map);
m_maincpu->set_vblank_int("screen", FUNC(gaelco2_state::irq6_line_hold));
@@ -206,8 +206,8 @@ void gaelco2_state::maniacsq(machine_config &config)
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
- gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco"));
- gaelco.set_snd_data_tag("gfx1");
+ gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(30'000'000) / 30));
+ gaelco.set_device_rom_tag("gfx1");
gaelco.set_bank_offsets(0 * 0x0080000, 1 * 0x0080000, 0, 0);
gaelco.add_route(0, "lspeaker", 1.0);
gaelco.add_route(1, "rspeaker", 1.0);
@@ -489,8 +489,9 @@ void gaelco2_state::saltcrdi(machine_config &config)
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
- gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco")); /* unused? ROMs contain no sound data */
- gaelco.set_snd_data_tag("gfx1");
+ /* unused? ROMs contain no sound data */
+ gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(24'000'000) / 24)); // TODO : Correct OSC?
+ gaelco.set_device_rom_tag("gfx1");
gaelco.set_bank_offsets(0 * 0x0080000, 1 * 0x0080000, 0, 0);
gaelco.add_route(0, "lspeaker", 1.0);
gaelco.add_route(1, "rspeaker", 1.0);
@@ -745,8 +746,8 @@ void gaelco2_state::play2000(machine_config &config)
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
- gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco"));
- gaelco.set_snd_data_tag("gfx1");
+ gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(34'000'000) / 34));
+ gaelco.set_device_rom_tag("gfx1");
gaelco.set_bank_offsets(0 * 0x080000, 0 * 0x080000, 0 * 0x080000, 0 * 0x080000);
gaelco.add_route(0, "lspeaker", 1.0);
gaelco.add_route(1, "rspeaker", 1.0);
@@ -851,8 +852,8 @@ void bang_state::bang(machine_config &config)
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
- gaelco_cg1v_device &gaelco(GAELCO_CG1V(config, "gaelco"));
- gaelco.set_snd_data_tag("gfx1");
+ gaelco_cg1v_device &gaelco(GAELCO_CG1V(config, "gaelco", XTAL(30'000'000) / 30));
+ gaelco.set_device_rom_tag("gfx1");
gaelco.set_bank_offsets(0 * 0x0200000, 1 * 0x0200000, 2 * 0x0200000, 3 * 0x0200000);
gaelco.add_route(0, "lspeaker", 1.0);
gaelco.add_route(1, "rspeaker", 1.0);
@@ -1090,8 +1091,8 @@ void gaelco2_state::alighunt(machine_config &config)
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
- gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco"));
- gaelco.set_snd_data_tag("gfx1");
+ gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(30'000'000) / 30));
+ gaelco.set_device_rom_tag("gfx1");
gaelco.set_bank_offsets(0 * 0x0400000, 1 * 0x0400000, 2 * 0x0400000, 3 * 0x0400000);
gaelco.add_route(0, "lspeaker", 1.0);
gaelco.add_route(1, "rspeaker", 1.0);
@@ -1406,8 +1407,8 @@ void gaelco2_state::touchgo(machine_config &config)
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
- gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco"));
- gaelco.set_snd_data_tag("gfx1");
+ gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(40'000'000) / 40));
+ gaelco.set_device_rom_tag("gfx1");
gaelco.set_bank_offsets(0 * 0x0400000, 1 * 0x0400000, 0, 0);
gaelco.add_route(0, "rspeaker", 1.0);
gaelco.add_route(1, "lspeaker", 1.0);
@@ -1704,8 +1705,8 @@ void gaelco2_state::snowboar(machine_config &config)
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
- gaelco_cg1v_device &gaelco(GAELCO_CG1V(config, "gaelco"));
- gaelco.set_snd_data_tag("gfx1");
+ gaelco_cg1v_device &gaelco(GAELCO_CG1V(config, "gaelco", XTAL(34'000'000) / 34));
+ gaelco.set_device_rom_tag("gfx1");
gaelco.set_bank_offsets(0 * 0x0400000, 1 * 0x0400000, 0, 0);
gaelco.add_route(0, "lspeaker", 1.0);
gaelco.add_route(1, "rspeaker", 1.0);
@@ -1748,8 +1749,8 @@ void gaelco2_state::maniacsqs(machine_config &config)
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
- gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco"));
- gaelco.set_snd_data_tag("gfx1");
+ gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(30'000'000) / 30));
+ gaelco.set_device_rom_tag("gfx1");
gaelco.set_bank_offsets(0 * 0x0080000, 1 * 0x0080000, 0, 0);
gaelco.add_route(0, "lspeaker", 1.0);
gaelco.add_route(1, "rspeaker", 1.0);
@@ -2004,8 +2005,8 @@ void wrally2_state::wrally2(machine_config &config)
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
- gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco"));
- gaelco.set_snd_data_tag("gfx1");
+ gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(34'000'000) / 34));
+ gaelco.set_device_rom_tag("gfx1");
gaelco.set_bank_offsets(0 * 0x0200000, 1 * 0x0200000, 0, 0);
gaelco.add_route(0, "lspeaker", 1.0);
gaelco.add_route(1, "rspeaker", 1.0);