Skip to content

Commit

Permalink
Change S9xPlaySample to use pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
m45t3r committed Jun 6, 2020
1 parent a96f3f6 commit b55f23c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/apu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void S9xSetAPUDSP(uint8 byte, struct SAPU *apu, struct SIAPU *iapu)
// apu->DSP [APU_KON] |= mask;
apu->DSP[APU_KOFF] &= ~mask;
apu->DSP[APU_ENDX] &= ~mask;
S9xPlaySample(c);
S9xPlaySample(c, apu);
}
}
#ifdef DEBUGGER
Expand Down Expand Up @@ -482,7 +482,7 @@ void S9xSetAPUDSP(uint8 byte, struct SAPU *apu, struct SIAPU *iapu)
// apu->DSP [APU_KON] |= mask;
// apu->DSP [APU_KOFF] &= ~mask;
apu->DSP[APU_ENDX] &= ~mask;
S9xPlaySample(c);
S9xPlaySample(c, apu);
} else
KeyOn |= mask;
}
Expand Down
14 changes: 7 additions & 7 deletions src/soundux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1860,19 +1860,19 @@ bool8 S9xSetSoundMode(int channel, int mode)

void S9xSetSoundControl(int sound_switch) { so.sound_switch = sound_switch; }

void S9xPlaySample(int channel)
void S9xPlaySample(int channel, struct SAPU *apu)
{
Channel *ch = &SoundData.channels[channel];

ch->state = SOUND_SILENT;
ch->mode = MODE_NONE;
ch->xenvx = 0;

S9xFixEnvelope(channel, APU.DSP[APU_GAIN + (channel << 4)], APU.DSP[APU_ADSR1 + (channel << 4)],
APU.DSP[APU_ADSR2 + (channel << 4)]);
S9xFixEnvelope(channel, apu->DSP[APU_GAIN + (channel << 4)], apu->DSP[APU_ADSR1 + (channel << 4)],
apu->DSP[APU_ADSR2 + (channel << 4)]);

ch->sample_number = APU.DSP[APU_SRCN + channel * 0x10];
if (APU.DSP[APU_NON] & (1 << channel))
ch->sample_number = apu->DSP[APU_SRCN + channel * 0x10];
if (apu->DSP[APU_NON] & (1 << channel))
ch->type = SOUND_NOISE;
else
ch->type = SOUND_SAMPLE;
Expand Down Expand Up @@ -1943,6 +1943,6 @@ void S9xPlaySample(int channel)
break;
}

S9xFixEnvelope(channel, APU.DSP[APU_GAIN + (channel << 4)], APU.DSP[APU_ADSR1 + (channel << 4)],
APU.DSP[APU_ADSR2 + (channel << 4)]);
S9xFixEnvelope(channel, apu->DSP[APU_GAIN + (channel << 4)], apu->DSP[APU_ADSR1 + (channel << 4)],
apu->DSP[APU_ADSR2 + (channel << 4)]);
}
2 changes: 1 addition & 1 deletion src/soundux.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void S9xResetSound(bool8 full);
void S9xSetPlaybackRate(uint32 playback_rate);
bool8 S9xSetSoundMode(int channel, int mode);
void S9xSetSoundControl(int sound_switch);
void S9xPlaySample(int channel);
void S9xPlaySample(int channel, struct SAPU *);

void S9xFixEnvelope(int channel, uint8 gain, uint8 adsr1, uint8 adsr2);
bool8 S9xOpenSoundDevice(int mode, bool8 stereo, int buffer_size);
Expand Down

0 comments on commit b55f23c

Please sign in to comment.