mirror of
https://github.com/holub/mame
synced 2025-06-07 13:23:50 +03:00
fix up a couple in src/mame as well (nw)
This commit is contained in:
parent
272e686928
commit
f7ce343c49
@ -152,6 +152,9 @@ static const int ENVCNT[0x20]
|
||||
#define LEtoME16( x ) little_endianize_int16(x)
|
||||
#define MEtoLE16( x ) little_endianize_int16(x)
|
||||
|
||||
ALLOW_SAVE_TYPE(snes_sound_device::env_state_t32);
|
||||
|
||||
|
||||
|
||||
DEFINE_DEVICE_TYPE(SNES, snes_sound_device, "snes_sound", "SNES Custom DSP (SPC700)")
|
||||
|
||||
@ -348,7 +351,7 @@ void snes_sound_device::dsp_update( short *sound_ptr )
|
||||
unable to find any pattern. I doubt it will matter though, so
|
||||
we'll go ahead and do the full time for now. */
|
||||
vp->envcnt = CNT_INIT;
|
||||
vp->envstate = ATTACK;
|
||||
vp->envstate = env_state_t32::ATTACK;
|
||||
}
|
||||
|
||||
if (m_dsp_regs[0x4c] & m & ~m_dsp_regs[0x5c])
|
||||
@ -365,7 +368,7 @@ void snes_sound_device::dsp_update( short *sound_ptr )
|
||||
if (m_keys & m_dsp_regs[0x5c] & m)
|
||||
{
|
||||
/* Voice was keyed off */
|
||||
vp->envstate = RELEASE;
|
||||
vp->envstate = env_state_t32::RELEASE;
|
||||
vp->on_cnt = 0;
|
||||
|
||||
#ifdef DBG_KEY
|
||||
@ -747,7 +750,7 @@ int snes_sound_device::advance_envelope( int v )
|
||||
|
||||
envx = m_voice_state[v].envx;
|
||||
|
||||
if (m_voice_state[v].envstate == RELEASE)
|
||||
if (m_voice_state[v].envstate == env_state_t32::RELEASE)
|
||||
{
|
||||
/* Docs: "When in the state of "key off". the "click" sound is prevented
|
||||
by the addition of the fixed value 1/256" WTF??? Alright, I'm going
|
||||
@ -780,7 +783,7 @@ int snes_sound_device::advance_envelope( int v )
|
||||
{
|
||||
switch (m_voice_state[v].envstate)
|
||||
{
|
||||
case ATTACK:
|
||||
case env_state_t32::ATTACK:
|
||||
/* Docs are very confusing. "AR is multiplied by the fixed value
|
||||
1/64..." I believe it means to add 1/64th to ENVX once every
|
||||
time ATTACK is updated, and that's what I'm going to implement. */
|
||||
@ -808,7 +811,7 @@ int snes_sound_device::advance_envelope( int v )
|
||||
if (envx > 0x7ff)
|
||||
{
|
||||
envx = 0x7ff;
|
||||
m_voice_state[v].envstate = DECAY;
|
||||
m_voice_state[v].envstate = env_state_t32::DECAY;
|
||||
}
|
||||
|
||||
#ifdef DBG_ENV
|
||||
@ -818,7 +821,7 @@ int snes_sound_device::advance_envelope( int v )
|
||||
m_voice_state[v].envx = envx;
|
||||
break;
|
||||
|
||||
case DECAY:
|
||||
case env_state_t32::DECAY:
|
||||
/* Docs: "DR... [is multiplied] by the fixed value 1-1/256."
|
||||
Well, at least that makes some sense. Multiplying ENVX by
|
||||
255/256 every time DECAY is updated. */
|
||||
@ -832,7 +835,7 @@ int snes_sound_device::advance_envelope( int v )
|
||||
}
|
||||
|
||||
if (envx <= 0x100 * (SL(v) + 1))
|
||||
m_voice_state[v].envstate = SUSTAIN;
|
||||
m_voice_state[v].envstate = env_state_t32::SUSTAIN;
|
||||
|
||||
#ifdef DBG_ENV
|
||||
logerror("ENV voice %d: envx=%03X, state=DECAY\n", v, envx);
|
||||
@ -840,7 +843,7 @@ int snes_sound_device::advance_envelope( int v )
|
||||
|
||||
break;
|
||||
|
||||
case SUSTAIN:
|
||||
case env_state_t32::SUSTAIN:
|
||||
/* Docs: "SR [is multiplied] by the fixed value 1-1/256."
|
||||
Multiplying ENVX by 255/256 every time SUSTAIN is updated. */
|
||||
#ifdef DBG_ENV
|
||||
@ -864,7 +867,7 @@ int snes_sound_device::advance_envelope( int v )
|
||||
/* Note: no way out of this state except by explicit KEY OFF (or switch to GAIN). */
|
||||
break;
|
||||
|
||||
case RELEASE: /* Handled earlier to prevent GAIN mode from stopping KEY OFF events */
|
||||
case env_state_t32::RELEASE: /* Handled earlier to prevent GAIN mode from stopping KEY OFF events */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -14,20 +14,6 @@
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
||||
enum env_state_t32 /* ADSR state type */
|
||||
{
|
||||
ATTACK,
|
||||
DECAY,
|
||||
SUSTAIN,
|
||||
RELEASE
|
||||
};
|
||||
|
||||
ALLOW_SAVE_TYPE(env_state_t32);
|
||||
|
||||
/***************************************************************************
|
||||
DEVICE CONFIGURATION MACROS
|
||||
***************************************************************************/
|
||||
|
||||
class snes_sound_device : public device_t,
|
||||
public device_sound_interface
|
||||
{
|
||||
@ -54,6 +40,14 @@ protected:
|
||||
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
|
||||
|
||||
private:
|
||||
enum class env_state_t32 : u8
|
||||
{
|
||||
ATTACK,
|
||||
DECAY,
|
||||
SUSTAIN,
|
||||
RELEASE
|
||||
};
|
||||
|
||||
|
||||
static constexpr unsigned SNES_SPCRAM_SIZE = 0x10000;
|
||||
|
||||
|
@ -91,14 +91,13 @@ public:
|
||||
uint16_t m_videoram0[0x10000 / 2];
|
||||
uint16_t m_videoram2[0x10000 / 2];
|
||||
|
||||
enum picmode
|
||||
enum class picmode : u8
|
||||
{
|
||||
PIC_IDLE = 0,
|
||||
PIC_SET_READADDRESS = 1,
|
||||
PIC_SET_WRITEADDRESS = 2,
|
||||
PIC_SET_WRITELATCH = 3,
|
||||
PIC_SET_READLATCH = 4
|
||||
|
||||
IDLE = 0,
|
||||
SET_READADDRESS = 1,
|
||||
SET_WRITEADDRESS = 2,
|
||||
SET_WRITELATCH = 3,
|
||||
SET_READLATCH = 4
|
||||
};
|
||||
|
||||
picmode m_picmodex;
|
||||
@ -152,7 +151,7 @@ void ttchamp_state::machine_start()
|
||||
m_rom16 = (uint16_t*)memregion("maincpu")->base();
|
||||
m_rom8 = memregion("maincpu")->base();
|
||||
|
||||
m_picmodex = PIC_IDLE;
|
||||
m_picmodex = picmode::IDLE;
|
||||
|
||||
m_bakram = std::make_unique<uint8_t[]>(0x100);
|
||||
machine().device<nvram_device>("backram")->set_base(m_bakram.get(), 0x100);
|
||||
@ -281,10 +280,10 @@ WRITE16_MEMBER(ttchamp_state::paldat_w)
|
||||
READ16_MEMBER(ttchamp_state::pic_r)
|
||||
{
|
||||
// printf("%06x: read from PIC (%04x)\n", space.device().safe_pc(),mem_mask);
|
||||
if (m_picmodex == PIC_SET_READLATCH)
|
||||
if (m_picmodex == picmode::SET_READLATCH)
|
||||
{
|
||||
// printf("read data %02x from %02x\n", m_pic_latched, m_pic_readaddr);
|
||||
m_picmodex = PIC_IDLE;
|
||||
m_picmodex = picmode::IDLE;
|
||||
|
||||
return m_pic_latched << 8;
|
||||
|
||||
@ -296,26 +295,26 @@ READ16_MEMBER(ttchamp_state::pic_r)
|
||||
WRITE16_MEMBER(ttchamp_state::pic_w)
|
||||
{
|
||||
// printf("%06x: write to PIC %04x (%04x) (%d)\n", space.device().safe_pc(),data,mem_mask, m_picmodex);
|
||||
if (m_picmodex == PIC_IDLE)
|
||||
if (m_picmodex == picmode::IDLE)
|
||||
{
|
||||
if (data == 0x11)
|
||||
{
|
||||
m_picmodex = PIC_SET_READADDRESS;
|
||||
m_picmodex = picmode::SET_READADDRESS;
|
||||
// printf("state = SET_READADDRESS\n");
|
||||
}
|
||||
else if (data == 0x12)
|
||||
{
|
||||
m_picmodex = PIC_SET_WRITELATCH;
|
||||
m_picmodex = picmode::SET_WRITELATCH;
|
||||
// printf("latch write data.. \n" );
|
||||
}
|
||||
else if (data == 0x20)
|
||||
{
|
||||
m_picmodex = PIC_SET_WRITEADDRESS;
|
||||
// printf("state = PIC_SET_WRITEADDRESS\n");
|
||||
m_picmodex = picmode::SET_WRITEADDRESS;
|
||||
// printf("state = picmode::SET_WRITEADDRESS\n");
|
||||
}
|
||||
else if (data == 0x21) // write latched data
|
||||
{
|
||||
m_picmodex = PIC_IDLE;
|
||||
m_picmodex = picmode::IDLE;
|
||||
m_bakram[m_pic_writeaddr] = m_pic_writelatched;
|
||||
// printf("wrote %02x to %02x\n", m_pic_writelatched, m_pic_writeaddr);
|
||||
}
|
||||
@ -326,27 +325,27 @@ WRITE16_MEMBER(ttchamp_state::pic_w)
|
||||
m_pic_latched = m_bakram[m_pic_readaddr>>1];
|
||||
|
||||
// printf("latch read data %02x from %02x\n",m_pic_latched, m_pic_readaddr );
|
||||
m_picmodex = PIC_SET_READLATCH; // waiting to read...
|
||||
m_picmodex = picmode::SET_READLATCH; // waiting to read...
|
||||
}
|
||||
else
|
||||
{
|
||||
// printf("unknown\n");
|
||||
}
|
||||
}
|
||||
else if (m_picmodex == PIC_SET_READADDRESS)
|
||||
else if (m_picmodex == picmode::SET_READADDRESS)
|
||||
{
|
||||
m_pic_readaddr = data;
|
||||
m_picmodex = PIC_IDLE;
|
||||
m_picmodex = picmode::IDLE;
|
||||
}
|
||||
else if (m_picmodex == PIC_SET_WRITEADDRESS)
|
||||
else if (m_picmodex == picmode::SET_WRITEADDRESS)
|
||||
{
|
||||
m_pic_writeaddr = data;
|
||||
m_picmodex = PIC_IDLE;
|
||||
m_picmodex = picmode::IDLE;
|
||||
}
|
||||
else if (m_picmodex == PIC_SET_WRITELATCH)
|
||||
else if (m_picmodex == picmode::SET_WRITELATCH)
|
||||
{
|
||||
m_pic_writelatched = data;
|
||||
m_picmodex = PIC_IDLE;
|
||||
m_picmodex = picmode::IDLE;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user