summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2017-11-07 21:38:25 +0100
committer hap <happppp@users.noreply.github.com>2017-11-07 21:38:25 +0100
commit976a98cfc5f00a5bac5fe177a6a18baec2e4b326 (patch)
treef0eadb54525f6b70075596bb357ad966672b2bc0
parent9ee00a90969f810f022f67e7361331862d200e3e (diff)
flower/wiping sound: added guessed clock() (nw)
-rw-r--r--src/mame/audio/flower.cpp62
-rw-r--r--src/mame/audio/flower.h15
-rw-r--r--src/mame/audio/wiping.cpp16
-rw-r--r--src/mame/audio/wiping.h2
-rw-r--r--src/mame/drivers/clshroad.cpp16
-rw-r--r--src/mame/drivers/flower.cpp44
-rw-r--r--src/mame/drivers/wiping.cpp2
7 files changed, 69 insertions, 88 deletions
diff --git a/src/mame/audio/flower.cpp b/src/mame/audio/flower.cpp
index e2b6ce47472..51c7640cc1f 100644
--- a/src/mame/audio/flower.cpp
+++ b/src/mame/audio/flower.cpp
@@ -3,26 +3,25 @@
/***************************************************************************
Flower custom sound chip
-
+
Similar to Wiping and Namco 15xx designs
TODO:
- several unknown registers (effects and unknown register tied to repeat port);
- repeat certainly needs a cutoff, which is unknown about how it works;
-
+
***************************************************************************/
#include "emu.h"
#include "flower.h"
-
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
// device type definition
-DEFINE_DEVICE_TYPE(FLOWER_CUSTOM, flower_sound_device, "flower_sound", "Flower Custom Audio")
+DEFINE_DEVICE_TYPE(FLOWER_CUSTOM, flower_sound_device, "flower_sound", "Flower Custom Sound")
// TODO: AM_SELECT unsupported by DEVICE_ADDRESS_MAP, so we need a trampoline here
static ADDRESS_MAP_START( regs_map, AS_IO, 8, flower_sound_device )
@@ -62,20 +61,18 @@ flower_sound_device::flower_sound_device(const machine_config &mconfig, const ch
void flower_sound_device::device_start()
{
- int i;
m_iospace = &space(AS_IO);
- // TODO: clock
- m_stream = machine().sound().stream_alloc(*this, 0, 1, samplerate);
-
- m_mixer_buffer = make_unique_clear<short[]>(samplerate);
+ m_stream = machine().sound().stream_alloc(*this, 0, 1, clock()/2);
+
+ m_mixer_buffer = make_unique_clear<short[]>(clock()/2);
make_mixer_table(MAX_VOICES, defgain);
m_last_channel = m_channel_list + MAX_VOICES;
-
+
m_sample_rom = machine().root_device().memregion("samples")->base();
m_volume_rom = machine().root_device().memregion("soundvol")->base();
-
- for (i = 0; i < MAX_VOICES; i++)
+
+ for (int i = 0; i < MAX_VOICES; i++)
{
save_item(NAME(m_channel_list[i].start_address), i);
save_item(NAME(m_channel_list[i].position), i);
@@ -85,7 +82,7 @@ void flower_sound_device::device_start()
save_item(NAME(m_channel_list[i].effect), i);
save_item(NAME(m_channel_list[i].enable), i);
save_item(NAME(m_channel_list[i].repeat), i);
-
+
// assign a channel number (debugger aid)
m_channel_list[i].channel_number = i;
}
@@ -95,9 +92,6 @@ void flower_sound_device::device_start()
/* build a table to divide by the number of voices; gain is specified as gain*16 */
void flower_sound_device::make_mixer_table(int voices, int gain)
{
- int count = voices * 128;
- int i;
-
/* allocate memory */
m_mixer_table = make_unique_clear<int16_t[]>(256 * voices);
@@ -105,7 +99,7 @@ void flower_sound_device::make_mixer_table(int voices, int gain)
m_mixer_lookup = m_mixer_table.get() + (128 * voices);
/* fill in the table - 16 bit case */
- for (i = 0; i < count; i++)
+ for (int i = 0; i < voices * 128; i++)
{
int val = i * gain * 16 / voices;
if (val > 32767) val = 32767;
@@ -137,26 +131,26 @@ void flower_sound_device::sound_stream_update(sound_stream &stream, stream_sampl
stream_sample_t *buffer = outputs[0];
short *mix;
uint8_t raw_sample;
-
+
memset(m_mixer_buffer.get(), 0, samples * sizeof(short));
for (fl_sound_channel *voice = m_channel_list; voice < m_last_channel; voice++)
{
int ch_volume = voice->volume;
int ch_frequency = voice->frequency;
-
- if(voice->enable == false)
+
+ if (voice->enable == false)
continue;
-
+
mix = m_mixer_buffer.get();
- for(int i=0;i<samples;i++)
+ for (int i = 0; i < samples; i++)
{
- if(voice->repeat == true)
+ if (voice->repeat == true)
{
raw_sample = m_sample_rom[((voice->start_address >> 7) & 0x7e00) | ((voice->position >> 7) & 0x1ff)];
- // guess: cut off after a number of repetitions
- if((voice->position >> 7) & 0x20000)
+ // guess: cut off after a number of repetitions
+ if ((voice->position >> 7) & 0x20000)
{
voice->enable = false;
break;
@@ -165,21 +159,19 @@ void flower_sound_device::sound_stream_update(sound_stream &stream, stream_sampl
else
{
raw_sample = m_sample_rom[((voice->start_address + voice->position) >> 7) & 0x7fff];
- if(raw_sample == 0xff)
+ if (raw_sample == 0xff)
{
voice->enable = false;
break;
}
}
ch_volume |= voice->volume_bank;
-
+
*mix++ += m_volume_rom[(ch_volume << 8 | raw_sample) & 0x3fff] - 0x80;
voice->position += ch_frequency;
}
}
-
-
/* mix it down */
mix = m_mixer_buffer.get();
for (int i = 0; i < samples; i++)
@@ -203,13 +195,13 @@ device_memory_interface::space_config_vector flower_sound_device::memory_space_c
//**************************************************************************
WRITE8_MEMBER( flower_sound_device::lower_write )
-{
+{
m_stream->update();
m_iospace->write_byte(offset,data);
}
WRITE8_MEMBER( flower_sound_device::upper_write )
-{
+{
m_stream->update();
m_iospace->write_byte(offset|0x40,data);
}
@@ -220,9 +212,9 @@ WRITE8_MEMBER( flower_sound_device::frequency_w )
fl_sound_channel *voice;
voice = &m_channel_list[ch];
-
+
voice->raw_frequency[offset & 3] = data & 0xf;
-
+
voice->frequency = voice->raw_frequency[2] << 12;
voice->frequency|= voice->raw_frequency[3] << 8;
voice->frequency|= voice->raw_frequency[0] << 4;
@@ -259,7 +251,7 @@ WRITE8_MEMBER( flower_sound_device::start_address_w )
voice = &m_channel_list[ch];
voice->start_nibbles[offset & 7] = data & 0xf;
- if((offset & 7) == 4)
+ if ((offset & 7) == 4)
voice->effect = data >> 4;
}
@@ -274,7 +266,7 @@ WRITE8_MEMBER( flower_sound_device::sample_trigger_w )
voice->volume_bank = (data & 3) << 4;
voice->start_address = 0;
voice->position = 0;
- for(int i=5;i>=0;i--)
+ for (int i = 5; i >= 0; i--)
{
voice->start_address = (voice->start_address << 4) | voice->start_nibbles[i];
}
diff --git a/src/mame/audio/flower.h b/src/mame/audio/flower.h
index e9d221833d3..6d70f1c3867 100644
--- a/src/mame/audio/flower.h
+++ b/src/mame/audio/flower.h
@@ -25,7 +25,7 @@
// ======================> flower_sound_device
-class flower_sound_device : public device_t,
+class flower_sound_device : public device_t,
public device_sound_interface,
public device_memory_interface
{
@@ -59,15 +59,14 @@ private:
const address_space_config m_io_space_config;
sound_stream *m_stream;
-
+
static constexpr unsigned MAX_VOICES = 8;
- static constexpr int samplerate = 48000;
static constexpr int defgain = 48;
-
+
std::unique_ptr<int16_t[]> m_mixer_table;
int16_t *m_mixer_lookup;
std::unique_ptr<short[]> m_mixer_buffer;
-
+
struct fl_sound_channel
{
uint8_t start_nibbles[6];
@@ -82,13 +81,13 @@ private:
bool repeat;
int channel_number;
};
-
+
/* data about the sound system */
fl_sound_channel m_channel_list[MAX_VOICES];
fl_sound_channel *m_last_channel;
-
+
void make_mixer_table(int voices, int gain);
-
+
const uint8_t *m_sample_rom;
const uint8_t *m_volume_rom;
};
diff --git a/src/mame/audio/wiping.cpp b/src/mame/audio/wiping.cpp
index 458348cfe34..ea44f6b0945 100644
--- a/src/mame/audio/wiping.cpp
+++ b/src/mame/audio/wiping.cpp
@@ -4,20 +4,19 @@
Wiping sound driver (quick hack of the Namco sound driver)
- used by wiping.c and clshroad.c
+ used by wiping.cpp and clshroad.cpp
***************************************************************************/
#include "emu.h"
#include "audio/wiping.h"
-static constexpr int samplerate = 48000;
static constexpr int defgain = 48;
-DEFINE_DEVICE_TYPE(WIPING, wiping_sound_device, "wiping_sound", "Wiping Audio Custom")
+DEFINE_DEVICE_TYPE(WIPING_CUSTOM, wiping_sound_device, "wiping_sound", "Wiping Audio Custom")
wiping_sound_device::wiping_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, WIPING, tag, owner, clock),
+ : device_t(mconfig, WIPING_CUSTOM, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_last_channel(nullptr),
m_sound_prom(nullptr),
@@ -43,10 +42,10 @@ void wiping_sound_device::device_start()
wp_sound_channel *voice;
/* get stream channels */
- m_stream = machine().sound().stream_alloc(*this, 0, 1, samplerate);
+ m_stream = machine().sound().stream_alloc(*this, 0, 1, clock()/2);
/* allocate a buffer to mix into - 1 second's worth should be more than enough */
- m_mixer_buffer = make_unique_clear<short[]>(samplerate);
+ m_mixer_buffer = make_unique_clear<short[]>(clock()/2);
/* build the mixer table */
make_mixer_table(8, defgain);
@@ -85,9 +84,6 @@ void wiping_sound_device::device_start()
/* build a table to divide by the number of voices; gain is specified as gain*16 */
void wiping_sound_device::make_mixer_table(int voices, int gain)
{
- int count = voices * 128;
- int i;
-
/* allocate memory */
m_mixer_table = make_unique_clear<int16_t[]>(256 * voices);
@@ -95,7 +91,7 @@ void wiping_sound_device::make_mixer_table(int voices, int gain)
m_mixer_lookup = m_mixer_table.get() + (128 * voices);
/* fill in the table - 16 bit case */
- for (i = 0; i < count; i++)
+ for (int i = 0; i < voices * 128; i++)
{
int val = i * gain * 16 / voices;
if (val > 32767) val = 32767;
diff --git a/src/mame/audio/wiping.h b/src/mame/audio/wiping.h
index 11924852bd9..367ff408044 100644
--- a/src/mame/audio/wiping.h
+++ b/src/mame/audio/wiping.h
@@ -58,6 +58,6 @@ private:
void make_mixer_table(int voices, int gain);
};
-DECLARE_DEVICE_TYPE(WIPING, wiping_sound_device)
+DECLARE_DEVICE_TYPE(WIPING_CUSTOM, wiping_sound_device)
#endif // MAME_AUDIO_WIPING_H
diff --git a/src/mame/drivers/clshroad.cpp b/src/mame/drivers/clshroad.cpp
index 5eb316ab9f2..6dda2467f64 100644
--- a/src/mame/drivers/clshroad.cpp
+++ b/src/mame/drivers/clshroad.cpp
@@ -306,7 +306,7 @@ static MACHINE_CONFIG_START( firebatl )
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
- MCFG_SOUND_ADD("custom", WIPING, 0)
+ MCFG_SOUND_ADD("custom", WIPING_CUSTOM, 96000)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_CONFIG_END
@@ -346,7 +346,7 @@ static MACHINE_CONFIG_START( clshroad )
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
- MCFG_SOUND_ADD("custom", WIPING, 0)
+ MCFG_SOUND_ADD("custom", WIPING_CUSTOM, 96000)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_CONFIG_END
@@ -560,15 +560,9 @@ ROM_END
DRIVER_INIT_MEMBER(clshroad_state,firebatl)
{
-/*
-Pugsy> firebatl:0:05C6:C3:100:Fix the Game:It's a hack but seems to make it work!
-Pugsy> firebatl:0:05C7:8D:600:Fix the Game (2/3)
-Pugsy> firebatl:0:05C8:23:600:Fix the Game (3/3)
-
-without this the death sequence never ends so the game is unplayable after you
-die once, it would be nice to avoid the hack however
-
-*/
+ // applying HACK to fix the game
+ // without this the death sequence never ends so the game is unplayable after you
+ // die once, it would be nice to avoid the hack however
uint8_t *ROM = memregion("maincpu")->base();
ROM[0x05C6] = 0xc3;
diff --git a/src/mame/drivers/flower.cpp b/src/mame/drivers/flower.cpp
index 6d35a7d99e9..c374a2249c4 100644
--- a/src/mame/drivers/flower.cpp
+++ b/src/mame/drivers/flower.cpp
@@ -8,10 +8,10 @@
original "wiped off due of not anymore licenseable" driver by insideoutboy.
TODO:
- - priority might be wrong in some places (title screen stars around the
+ - priority might be wrong in some places (title screen stars around the
galaxy, planet ship 3rd boss, 2nd boss);
- sound chips (similar to Namco custom chips?)
-
+
===============================================================================
Flower (c)1986 Komax (USA license)
@@ -116,8 +116,8 @@ public:
DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
INTERRUPT_GEN_MEMBER(master_vblank_irq);
INTERRUPT_GEN_MEMBER(slave_vblank_irq);
- TILE_GET_INFO_MEMBER(get_bg_tile_info);
- TILE_GET_INFO_MEMBER(get_fg_tile_info);
+ TILE_GET_INFO_MEMBER(get_bg_tile_info);
+ TILE_GET_INFO_MEMBER(get_fg_tile_info);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
protected:
@@ -126,7 +126,7 @@ protected:
virtual void machine_reset() override;
virtual void video_start() override;
-
+
private:
required_device<cpu_device> m_mastercpu;
required_device<cpu_device> m_slavecpu;
@@ -142,10 +142,10 @@ private:
required_shared_ptr<uint8_t> m_fgscroll;
required_device<generic_latch_8_device> m_soundlatch;
bitmap_ind16 m_temp_bitmap;
-
+
void draw_legacy_text(bitmap_ind16 &bitmap,const rectangle &cliprect);
void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect);
-
+
bool m_audio_nmi_enable;
bool m_flip_screen;
tilemap_t *m_bg_tilemap;
@@ -155,7 +155,7 @@ private:
TILE_GET_INFO_MEMBER(flower_state::get_bg_tile_info)
{
int code = m_bgvram[tile_index];
- int color = (m_bgvram[tile_index+0x100] & 0xf0) >> 4;
+ int color = (m_bgvram[tile_index+0x100] & 0xf0) >> 4;
SET_TILE_INFO_MEMBER(1, code, color, 0);
}
@@ -163,8 +163,8 @@ TILE_GET_INFO_MEMBER(flower_state::get_bg_tile_info)
TILE_GET_INFO_MEMBER(flower_state::get_fg_tile_info)
{
int code = m_fgvram[tile_index];
- int color = (m_fgvram[tile_index+0x100] & 0xf0) >> 4;
-
+ int color = (m_fgvram[tile_index+0x100] & 0xf0) >> 4;
+
SET_TILE_INFO_MEMBER(1, code, color, 0);
}
@@ -172,12 +172,12 @@ void flower_state::video_start()
{
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(flower_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 16, 16);
m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(flower_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 16, 16);
-
- m_screen->register_screen_bitmap(m_temp_bitmap);
+
+ m_screen->register_screen_bitmap(m_temp_bitmap);
m_fg_tilemap->set_transparent_pen(15);
save_item(NAME(m_flip_screen));
-
+
m_bg_tilemap->set_scrolldx(16, 0);
m_fg_tilemap->set_scrolldx(16, 0);
}
@@ -230,7 +230,7 @@ void flower_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
{
uint8_t *spr_ptr = &m_workram[0x1e08];
gfx_element *gfx_2 = m_gfxdecode->gfx(2);
-
+
// traverse from top to bottom
for(int i=0x1f0;i>=0;i-=8)
{
@@ -249,12 +249,12 @@ void flower_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
uint32_t xshrink_zoom = ((spr_ptr[i+3] & 0x07) >> 0) + 1;
yshrink_zoom <<= 13;
xshrink_zoom <<= 13;
- int ypixels = (yshrink_zoom*16) >> 16;
+ int ypixels = (yshrink_zoom*16) >> 16;
int xpixels = (xshrink_zoom*16) >> 16;
-
+
tile |= (attr & 1) << 6;
tile |= (attr & 8) << 4;
-
+
if(flip_screen())
{
x += xsize*16;
@@ -264,16 +264,16 @@ void flower_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect)
if(ysize == 2)
y-=16;
-
+
for(int yi=0;yi<ysize;yi++)
{
int yoffs = (16-ypixels)/ydiv;
-
+
for(int xi=0;xi<xsize;xi++)
{
int tile_offs;
int xoffs = (16-xpixels)/xdiv;
-
+
tile_offs = fx ? (xsize-xi-1) * 8 : xi*8;
tile_offs+= fy ? (ysize-yi-1) : yi;
@@ -511,10 +511,10 @@ static MACHINE_CONFIG_START( flower )
MCFG_PALETTE_ADD_RRRRGGGGBBBB_PROMS("palette", "proms", 256)
MCFG_GENERIC_LATCH_8_ADD("soundlatch")
-
+
MCFG_SPEAKER_STANDARD_MONO("mono")
- MCFG_SOUND_ADD("flower", FLOWER_CUSTOM, 0)
+ MCFG_SOUND_ADD("flower", FLOWER_CUSTOM, 96000)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_CONFIG_END
diff --git a/src/mame/drivers/wiping.cpp b/src/mame/drivers/wiping.cpp
index 64d31775af3..75ba2093546 100644
--- a/src/mame/drivers/wiping.cpp
+++ b/src/mame/drivers/wiping.cpp
@@ -319,7 +319,7 @@ static MACHINE_CONFIG_START( wiping )
/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
- MCFG_SOUND_ADD("wiping", WIPING, 0)
+ MCFG_SOUND_ADD("wiping", WIPING_CUSTOM, 96000)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_CONFIG_END