Update ymfm to latest upstream
This commit is contained in:
@@ -40,11 +40,11 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
namespace ymfm
|
namespace ymfm
|
||||||
{
|
{
|
||||||
@@ -329,7 +329,7 @@ struct ymfm_output
|
|||||||
// ======================> ymfm_wavfile
|
// ======================> ymfm_wavfile
|
||||||
|
|
||||||
// this class is a debugging helper that accumulates data and writes it to wav files
|
// this class is a debugging helper that accumulates data and writes it to wav files
|
||||||
template<int _Channels>
|
template<int Channels>
|
||||||
class ymfm_wavfile
|
class ymfm_wavfile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -361,10 +361,10 @@ public:
|
|||||||
memcpy(&header[12], "fmt ", 4);
|
memcpy(&header[12], "fmt ", 4);
|
||||||
*(uint32_t *)&header[16] = 16;
|
*(uint32_t *)&header[16] = 16;
|
||||||
*(uint16_t *)&header[20] = 1;
|
*(uint16_t *)&header[20] = 1;
|
||||||
*(uint16_t *)&header[22] = _Channels;
|
*(uint16_t *)&header[22] = Channels;
|
||||||
*(uint32_t *)&header[24] = m_samplerate;
|
*(uint32_t *)&header[24] = m_samplerate;
|
||||||
*(uint32_t *)&header[28] = m_samplerate * 2 * _Channels;
|
*(uint32_t *)&header[28] = m_samplerate * 2 * Channels;
|
||||||
*(uint16_t *)&header[32] = 2 * _Channels;
|
*(uint16_t *)&header[32] = 2 * Channels;
|
||||||
*(uint16_t *)&header[34] = 16;
|
*(uint16_t *)&header[34] = 16;
|
||||||
memcpy(&header[36], "data", 4);
|
memcpy(&header[36], "data", 4);
|
||||||
*(uint32_t *)&header[40] = m_buffer.size() * 2 + 44 - 44;
|
*(uint32_t *)&header[40] = m_buffer.size() * 2 + 44 - 44;
|
||||||
@@ -377,24 +377,24 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add data to the file
|
// add data to the file
|
||||||
template<int _Outputs>
|
template<int Outputs>
|
||||||
void add(ymfm_output<_Outputs> output)
|
void add(ymfm_output<Outputs> output)
|
||||||
{
|
{
|
||||||
int16_t sum[_Channels] = { 0 };
|
int16_t sum[Channels] = { 0 };
|
||||||
for (int index = 0; index < _Outputs; index++)
|
for (int index = 0; index < Outputs; index++)
|
||||||
sum[index % _Channels] += output.data[index];
|
sum[index % Channels] += output.data[index];
|
||||||
for (int index = 0; index < _Channels; index++)
|
for (int index = 0; index < Channels; index++)
|
||||||
m_buffer.push_back(sum[index]);
|
m_buffer.push_back(sum[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add data to the file, using a reference
|
// add data to the file, using a reference
|
||||||
template<int _Outputs>
|
template<int Outputs>
|
||||||
void add(ymfm_output<_Outputs> output, ymfm_output<_Outputs> const &ref)
|
void add(ymfm_output<Outputs> output, ymfm_output<Outputs> const &ref)
|
||||||
{
|
{
|
||||||
int16_t sum[_Channels] = { 0 };
|
int16_t sum[Channels] = { 0 };
|
||||||
for (int index = 0; index < _Outputs; index++)
|
for (int index = 0; index < Outputs; index++)
|
||||||
sum[index % _Channels] += output.data[index] - ref.data[index];
|
sum[index % Channels] += output.data[index] - ref.data[index];
|
||||||
for (int index = 0; index < _Channels; index++)
|
for (int index = 0; index < Channels; index++)
|
||||||
m_buffer.push_back(sum[index]);
|
m_buffer.push_back(sum[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define DEBUG_LOG_WAVFILES (0)
|
#define YMFM_DEBUG_LOG_WAVFILES (0)
|
||||||
|
|
||||||
namespace ymfm
|
namespace ymfm
|
||||||
{
|
{
|
||||||
@@ -401,7 +401,7 @@ public:
|
|||||||
// compute sample rate
|
// compute sample rate
|
||||||
uint32_t sample_rate(uint32_t baseclock) const
|
uint32_t sample_rate(uint32_t baseclock) const
|
||||||
{
|
{
|
||||||
#if (DEBUG_LOG_WAVFILES)
|
#if (YMFM_DEBUG_LOG_WAVFILES)
|
||||||
for (uint32_t chnum = 0; chnum < CHANNELS; chnum++)
|
for (uint32_t chnum = 0; chnum < CHANNELS; chnum++)
|
||||||
m_wavfile[chnum].set_samplerate(baseclock / (m_clock_prescale * OPERATORS));
|
m_wavfile[chnum].set_samplerate(baseclock / (m_clock_prescale * OPERATORS));
|
||||||
#endif
|
#endif
|
||||||
@@ -453,7 +453,7 @@ protected:
|
|||||||
RegisterType m_regs; // register accessor
|
RegisterType m_regs; // register accessor
|
||||||
std::unique_ptr<fm_channel<RegisterType>> m_channel[CHANNELS]; // channel pointers
|
std::unique_ptr<fm_channel<RegisterType>> m_channel[CHANNELS]; // channel pointers
|
||||||
std::unique_ptr<fm_operator<RegisterType>> m_operator[OPERATORS]; // operator pointers
|
std::unique_ptr<fm_operator<RegisterType>> m_operator[OPERATORS]; // operator pointers
|
||||||
#if (DEBUG_LOG_WAVFILES)
|
#if (YMFM_DEBUG_LOG_WAVFILES)
|
||||||
mutable ymfm_wavfile<1> m_wavfile[CHANNELS]; // for debugging
|
mutable ymfm_wavfile<1> m_wavfile[CHANNELS]; // for debugging
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@@ -1185,6 +1185,7 @@ fm_engine_base<RegisterType>::fm_engine_base(ymfm_interface &intf) :
|
|||||||
m_irq_mask(STATUS_TIMERA | STATUS_TIMERB),
|
m_irq_mask(STATUS_TIMERA | STATUS_TIMERB),
|
||||||
m_irq_state(0),
|
m_irq_state(0),
|
||||||
m_timer_running{0,0},
|
m_timer_running{0,0},
|
||||||
|
m_total_clocks(0),
|
||||||
m_active_channels(ALL_CHANNELS),
|
m_active_channels(ALL_CHANNELS),
|
||||||
m_modified_channels(ALL_CHANNELS),
|
m_modified_channels(ALL_CHANNELS),
|
||||||
m_prepare_count(0)
|
m_prepare_count(0)
|
||||||
@@ -1200,7 +1201,7 @@ fm_engine_base<RegisterType>::fm_engine_base(ymfm_interface &intf) :
|
|||||||
for (uint32_t opnum = 0; opnum < OPERATORS; opnum++)
|
for (uint32_t opnum = 0; opnum < OPERATORS; opnum++)
|
||||||
m_operator[opnum] = std::make_unique<fm_operator<RegisterType>>(*this, RegisterType::operator_offset(opnum));
|
m_operator[opnum] = std::make_unique<fm_operator<RegisterType>>(*this, RegisterType::operator_offset(opnum));
|
||||||
|
|
||||||
#if (DEBUG_LOG_WAVFILES)
|
#if (YMFM_DEBUG_LOG_WAVFILES)
|
||||||
for (uint32_t chnum = 0; chnum < CHANNELS; chnum++)
|
for (uint32_t chnum = 0; chnum < CHANNELS; chnum++)
|
||||||
m_wavfile[chnum].set_index(chnum);
|
m_wavfile[chnum].set_index(chnum);
|
||||||
#endif
|
#endif
|
||||||
@@ -1332,7 +1333,7 @@ void fm_engine_base<RegisterType>::output(output_data &output, uint32_t rshift,
|
|||||||
chanmask &= debug::GLOBAL_FM_CHANNEL_MASK;
|
chanmask &= debug::GLOBAL_FM_CHANNEL_MASK;
|
||||||
|
|
||||||
// mask out inactive channels
|
// mask out inactive channels
|
||||||
if (!DEBUG_LOG_WAVFILES)
|
if (!YMFM_DEBUG_LOG_WAVFILES)
|
||||||
chanmask &= m_active_channels;
|
chanmask &= m_active_channels;
|
||||||
|
|
||||||
// handle the rhythm case, where some of the operators are dedicated
|
// handle the rhythm case, where some of the operators are dedicated
|
||||||
@@ -1351,7 +1352,7 @@ void fm_engine_base<RegisterType>::output(output_data &output, uint32_t rshift,
|
|||||||
for (uint32_t chnum = 0; chnum < CHANNELS; chnum++)
|
for (uint32_t chnum = 0; chnum < CHANNELS; chnum++)
|
||||||
if (bitfield(chanmask, chnum))
|
if (bitfield(chanmask, chnum))
|
||||||
{
|
{
|
||||||
#if (DEBUG_LOG_WAVFILES)
|
#if (YMFM_DEBUG_LOG_WAVFILES)
|
||||||
auto reference = output;
|
auto reference = output;
|
||||||
#endif
|
#endif
|
||||||
if (chnum == 6)
|
if (chnum == 6)
|
||||||
@@ -1364,7 +1365,7 @@ void fm_engine_base<RegisterType>::output(output_data &output, uint32_t rshift,
|
|||||||
m_channel[chnum]->output_4op(output, rshift, clipmax);
|
m_channel[chnum]->output_4op(output, rshift, clipmax);
|
||||||
else
|
else
|
||||||
m_channel[chnum]->output_2op(output, rshift, clipmax);
|
m_channel[chnum]->output_2op(output, rshift, clipmax);
|
||||||
#if (DEBUG_LOG_WAVFILES)
|
#if (YMFM_DEBUG_LOG_WAVFILES)
|
||||||
m_wavfile[chnum].add(output, reference);
|
m_wavfile[chnum].add(output, reference);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1375,14 +1376,14 @@ void fm_engine_base<RegisterType>::output(output_data &output, uint32_t rshift,
|
|||||||
for (uint32_t chnum = 0; chnum < CHANNELS; chnum++)
|
for (uint32_t chnum = 0; chnum < CHANNELS; chnum++)
|
||||||
if (bitfield(chanmask, chnum))
|
if (bitfield(chanmask, chnum))
|
||||||
{
|
{
|
||||||
#if (DEBUG_LOG_WAVFILES)
|
#if (YMFM_DEBUG_LOG_WAVFILES)
|
||||||
auto reference = output;
|
auto reference = output;
|
||||||
#endif
|
#endif
|
||||||
if (m_channel[chnum]->is4op())
|
if (m_channel[chnum]->is4op())
|
||||||
m_channel[chnum]->output_4op(output, rshift, clipmax);
|
m_channel[chnum]->output_4op(output, rshift, clipmax);
|
||||||
else
|
else
|
||||||
m_channel[chnum]->output_2op(output, rshift, clipmax);
|
m_channel[chnum]->output_2op(output, rshift, clipmax);
|
||||||
#if (DEBUG_LOG_WAVFILES)
|
#if (YMFM_DEBUG_LOG_WAVFILES)
|
||||||
m_wavfile[chnum].add(output, reference);
|
m_wavfile[chnum].add(output, reference);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -100,6 +100,11 @@ opl_registers_base<Revision>::opl_registers_base() :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OPL3/OPL4 have dynamic operators, so initialize the fourop_enable value here
|
||||||
|
// since operator_map() is called right away, prior to reset()
|
||||||
|
if (Revision > 2)
|
||||||
|
m_regdata[0x104 % REGISTERS] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1710,9 +1715,15 @@ uint8_t ymf278b::read_status()
|
|||||||
|
|
||||||
uint8_t ymf278b::read_data_pcm()
|
uint8_t ymf278b::read_data_pcm()
|
||||||
{
|
{
|
||||||
// write to FM
|
// read from PCM
|
||||||
if (bitfield(m_address, 9) != 0)
|
if (bitfield(m_address, 9) != 0)
|
||||||
return m_pcm.read(m_address & 0xff);
|
{
|
||||||
|
uint8_t result = m_pcm.read(m_address & 0xff);
|
||||||
|
if ((m_address & 0xff) == 0x02)
|
||||||
|
result |= 0x20;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,7 +46,6 @@ namespace ymfm
|
|||||||
void pcm_registers::reset()
|
void pcm_registers::reset()
|
||||||
{
|
{
|
||||||
std::fill_n(&m_regdata[0], REGISTERS, 0);
|
std::fill_n(&m_regdata[0], REGISTERS, 0);
|
||||||
m_regdata[0x02] = 0x20;
|
|
||||||
m_regdata[0xf8] = 0x1b;
|
m_regdata[0xf8] = 0x1b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user