- [FIX] el só para durant el debug [però new BUG: al tornar està desincronitzat]

- [FIX] si el canal està desactivat, no fer el envelope sweep
- [FIX] Se miraba el bit incorrecte per a determinar si el envelope sweep anava amunt o avall
This commit is contained in:
2025-01-29 17:43:28 +01:00
parent 1c0f243d04
commit 8fc576cda2
4 changed files with 21 additions and 8 deletions

18
APU.cpp
View File

@@ -79,11 +79,21 @@ namespace APU
}
}
void init()
void silence()
{
SDL_PauseAudioDevice(sdlAudioDevice, 1);
}
void resume()
{
SDL_PauseAudioDevice(sdlAudioDevice, 0);
}
void init()
{
SDL_AudioSpec audioSpec{11025, AUDIO_U8, 1, 0, AUDIO_BUFFER_SIZE>>2, 0, 0, &audioCallback, NULL};
sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0);
SDL_PauseAudioDevice(sdlAudioDevice, 0);
resume();
//samples_time=SDL_GetTicks();
}
@@ -183,11 +193,11 @@ namespace APU
DIVAPU_envelope_sweep++;
if (DIVAPU_envelope_sweep==8) {
DIVAPU_envelope_sweep=0;
if ( NR12&0x7 ) { // If sweep pace != 0, envelope sweep is enabled
if ( CH1.enabled && (NR12&0x7) ) { // If sweep pace != 0, envelope sweep is enabled
CH1.envelope_sweep_timer++;
if ( CH1.envelope_sweep_timer == (NR12&0x07) ) { // if timer == envelope sweep, increase or decrease volume
CH1.envelope_sweep_timer=0;
if (NR12&0x80) { // bit set increases, reset decreases
if (NR12&0x8) { // bit set increases, reset decreases
if (CH1.volume<0x0f) CH1.volume++;
} else {
if (CH1.volume>0) CH1.volume--;