mirror of
https://github.com/holub/mame
synced 2025-06-17 09:49:31 +03:00
twinspri: Fix missing samples by masking the ADPCM-A end address properly.
This commit is contained in:
parent
3bc9169926
commit
e1bd766620
@ -4,11 +4,21 @@
|
|||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "ymadpcm.h"
|
#include "ymadpcm.h"
|
||||||
|
|
||||||
#define VERBOSE 1
|
//#define VERBOSE 1
|
||||||
#define LOG_OUTPUT_FUNC osd_printf_verbose
|
#define LOG_OUTPUT_FUNC osd_printf_verbose
|
||||||
#include "logmacro.h"
|
#include "logmacro.h"
|
||||||
|
|
||||||
|
|
||||||
|
//*********************************************************
|
||||||
|
// DEBUGGING
|
||||||
|
//*********************************************************
|
||||||
|
|
||||||
|
// set this to only play certain channels: bits 0-5 are ADPCM-A
|
||||||
|
// channels and bit 0x80 is the ADPCM-B channel
|
||||||
|
constexpr u8 global_chanmask = 0xff;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//*********************************************************
|
//*********************************************************
|
||||||
// MACROS
|
// MACROS
|
||||||
//*********************************************************
|
//*********************************************************
|
||||||
@ -117,6 +127,9 @@ void ymadpcm_a_channel::keyonoff(bool on)
|
|||||||
m_curbyte = 0;
|
m_curbyte = 0;
|
||||||
m_accumulator = 0;
|
m_accumulator = 0;
|
||||||
m_step_index = 0;
|
m_step_index = 0;
|
||||||
|
|
||||||
|
// don't log masked channels
|
||||||
|
if (((global_chanmask >> m_choffs) & 1) != 0)
|
||||||
LOG("KeyOn ADPCM-A%d: pan=%d%d start=%04X end=%04X level=%02X\n",
|
LOG("KeyOn ADPCM-A%d: pan=%d%d start=%04X end=%04X level=%02X\n",
|
||||||
m_choffs,
|
m_choffs,
|
||||||
m_regs.ch_pan_left(m_choffs),
|
m_regs.ch_pan_left(m_choffs),
|
||||||
@ -141,8 +154,11 @@ bool ymadpcm_a_channel::clock()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop when we hit the end address
|
// stop when we hit the end address; apparently only low 20 bits are used for
|
||||||
if ((m_curaddress >> m_address_shift) >= m_regs.ch_end(m_choffs))
|
// comparison on the YM2610: this affects sample playback in some games, for
|
||||||
|
// example twinspri character select screen music will skip some samples if
|
||||||
|
// this is not correct
|
||||||
|
if (((m_curaddress ^ (m_regs.ch_end(m_choffs) << m_address_shift)) & 0xfffff) == 0)
|
||||||
{
|
{
|
||||||
m_playing = m_accumulator = 0;
|
m_playing = m_accumulator = 0;
|
||||||
return true;
|
return true;
|
||||||
@ -292,6 +308,9 @@ u32 ymadpcm_a_engine::clock(u32 chanmask)
|
|||||||
|
|
||||||
void ymadpcm_a_engine::output(s32 outputs[2], u32 chanmask)
|
void ymadpcm_a_engine::output(s32 outputs[2], u32 chanmask)
|
||||||
{
|
{
|
||||||
|
// mask out some channels for debug purposes
|
||||||
|
chanmask &= global_chanmask;
|
||||||
|
|
||||||
// compute the output of each channel
|
// compute the output of each channel
|
||||||
for (int chnum = 0; chnum < std::size(m_channel); chnum++)
|
for (int chnum = 0; chnum < std::size(m_channel); chnum++)
|
||||||
if (BIT(chanmask, chnum))
|
if (BIT(chanmask, chnum))
|
||||||
@ -494,6 +513,10 @@ void ymadpcm_b_channel::clock()
|
|||||||
|
|
||||||
void ymadpcm_b_channel::output(s32 outputs[2], u32 rshift) const
|
void ymadpcm_b_channel::output(s32 outputs[2], u32 rshift) const
|
||||||
{
|
{
|
||||||
|
// mask out some channels for debug purposes
|
||||||
|
if ((global_chanmask & 0x80) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// do a linear interpolation between samples
|
// do a linear interpolation between samples
|
||||||
s32 result = (m_prev_accum * s32((m_position ^ 0xffff) + 1) + m_accumulator * s32(m_position)) >> 16;
|
s32 result = (m_prev_accum * s32((m_position ^ 0xffff) + 1) + m_accumulator * s32(m_position)) >> 16;
|
||||||
|
|
||||||
@ -557,6 +580,9 @@ void ymadpcm_b_channel::write(u32 regnum, u8 value)
|
|||||||
if (m_regs.execute())
|
if (m_regs.execute())
|
||||||
{
|
{
|
||||||
load_start();
|
load_start();
|
||||||
|
|
||||||
|
// don't log masked channels
|
||||||
|
if ((global_chanmask & 0x80) != 0)
|
||||||
LOG("KeyOn ADPCM-B: rep=%d spk=%d pan=%d%d dac=%d 8b=%d rom=%d ext=%d rec=%d start=%04X end=%04X pre=%04X dn=%04X lvl=%02X lim=%04X\n",
|
LOG("KeyOn ADPCM-B: rep=%d spk=%d pan=%d%d dac=%d 8b=%d rom=%d ext=%d rec=%d start=%04X end=%04X pre=%04X dn=%04X lvl=%02X lim=%04X\n",
|
||||||
m_regs.repeat(),
|
m_regs.repeat(),
|
||||||
m_regs.speaker(),
|
m_regs.speaker(),
|
||||||
|
@ -8,6 +8,15 @@
|
|||||||
#define LOG_OUTPUT_FUNC osd_printf_verbose
|
#define LOG_OUTPUT_FUNC osd_printf_verbose
|
||||||
#include "logmacro.h"
|
#include "logmacro.h"
|
||||||
|
|
||||||
|
|
||||||
|
//*********************************************************
|
||||||
|
// DEBUGGING
|
||||||
|
//*********************************************************
|
||||||
|
|
||||||
|
// set this mask to only play certain channels
|
||||||
|
constexpr u32 global_chanmask = 0xffffffff;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// ONE FM CORE TO RULE THEM ALL
|
// ONE FM CORE TO RULE THEM ALL
|
||||||
//
|
//
|
||||||
@ -1012,6 +1021,10 @@ void ymopm_registers::log_keyon(u32 choffs, u32 opoffs)
|
|||||||
u32 chnum = choffs;
|
u32 chnum = choffs;
|
||||||
u32 opnum = opoffs;
|
u32 opnum = opoffs;
|
||||||
|
|
||||||
|
// don't log masked channels
|
||||||
|
if (((global_chanmask >> chnum) & 1) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
LOG("%d.%02d freq=%04X dt2=%d dt=%d fb=%d alg=%X mul=%X tl=%02X ksr=%d adsr=%02X/%02X/%02X/%X sl=%X out=%c%c",
|
LOG("%d.%02d freq=%04X dt2=%d dt=%d fb=%d alg=%X mul=%X tl=%02X ksr=%d adsr=%02X/%02X/%02X/%X sl=%X out=%c%c",
|
||||||
chnum, opnum,
|
chnum, opnum,
|
||||||
ch_block_freq(choffs),
|
ch_block_freq(choffs),
|
||||||
@ -3009,6 +3022,9 @@ u32 ymfm_engine_base<RegisterType>::clock(u32 chanmask)
|
|||||||
template<class RegisterType>
|
template<class RegisterType>
|
||||||
void ymfm_engine_base<RegisterType>::output(s32 outputs[RegisterType::OUTPUTS], u32 rshift, s32 clipmax, u32 chanmask) const
|
void ymfm_engine_base<RegisterType>::output(s32 outputs[RegisterType::OUTPUTS], u32 rshift, s32 clipmax, u32 chanmask) const
|
||||||
{
|
{
|
||||||
|
// mask out some channels for debug purposes
|
||||||
|
chanmask &= global_chanmask;
|
||||||
|
|
||||||
// mask out inactive channels
|
// mask out inactive channels
|
||||||
chanmask &= m_active_channels;
|
chanmask &= m_active_channels;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user