mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 23:58:04 -04:00
sound fixes for Ferrari GP
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@247 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
e849512f15
commit
5f8c85be2a
4 changed files with 39 additions and 19 deletions
|
@ -117,7 +117,7 @@ PICO_INTERNAL void sound_reset(void)
|
|||
// to be called after changing sound rate or chips
|
||||
void sound_rerate(int preserve_state)
|
||||
{
|
||||
unsigned int state[28];
|
||||
void *state = NULL;
|
||||
int target_fps = Pico.m.pal ? 50 : 60;
|
||||
|
||||
// not all rates are supported in MCD mode due to mp3 decoder limitations
|
||||
|
@ -127,12 +127,16 @@ void sound_rerate(int preserve_state)
|
|||
}
|
||||
|
||||
if (preserve_state) {
|
||||
state = malloc(0x200);
|
||||
if (state == NULL) return;
|
||||
memcpy(state, YM2612GetRegs(), 0x200);
|
||||
if ((PicoMCD & 1) && Pico_mcd->m.audio_track)
|
||||
Pico_mcd->m.audio_offset = mp3_get_offset();
|
||||
}
|
||||
YM2612Init(Pico.m.pal ? OSC_PAL/7 : OSC_NTSC/7, PsndRate);
|
||||
if (preserve_state) {
|
||||
// feed it back it's own registers, just like after loading state
|
||||
memcpy(YM2612GetRegs(), state, 0x200);
|
||||
YM2612PicoStateLoad();
|
||||
if ((PicoMCD & 1) && Pico_mcd->m.audio_track)
|
||||
mp3_start_play(Pico_mcd->TOC.Tracks[Pico_mcd->m.audio_track].F, Pico_mcd->m.audio_offset);
|
||||
|
@ -142,6 +146,9 @@ void sound_rerate(int preserve_state)
|
|||
SN76496_init(Pico.m.pal ? OSC_PAL/15 : OSC_NTSC/15, PsndRate);
|
||||
if (preserve_state) memcpy(sn76496_regs, state, 28*4); // restore old state
|
||||
|
||||
if (state)
|
||||
free(state);
|
||||
|
||||
// calculate PsndLen
|
||||
PsndLen=PsndRate / target_fps;
|
||||
PsndLen_exc_add=((PsndRate - PsndLen*target_fps)<<16) / target_fps;
|
||||
|
|
|
@ -1637,8 +1637,7 @@ void YM2612Init_(int clock, int rate)
|
|||
ym2612_dacen = &ym2612.dacen;
|
||||
ym2612_dacout = &ym2612.dacout;
|
||||
|
||||
/* clear everything but the regs */
|
||||
memset(ym2612.CH, 0, sizeof(ym2612)-sizeof(ym2612.REGS)-4);
|
||||
memset(&ym2612, 0, sizeof(ym2612));
|
||||
init_tables();
|
||||
|
||||
ym2612.OPN.ST.clock = clock;
|
||||
|
@ -1654,8 +1653,11 @@ void YM2612ResetChip_(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
memset(ym2612.REGS, 0, sizeof(ym2612.REGS));
|
||||
|
||||
OPNSetPres( 6*24 );
|
||||
set_timers( 0x30 ); /* mode 0 , timer reset */
|
||||
ym2612.REGS[0x27] = 0x30;
|
||||
|
||||
ym2612.OPN.eg_timer = 0;
|
||||
ym2612.OPN.eg_cnt = 0;
|
||||
|
@ -1666,6 +1668,8 @@ void YM2612ResetChip_(void)
|
|||
{
|
||||
OPNWriteReg(i ,0xc0);
|
||||
OPNWriteReg(i|0x100,0xc0);
|
||||
ym2612.REGS[i ] = 0xc0;
|
||||
ym2612.REGS[i|0x100] = 0xc0;
|
||||
}
|
||||
for(i = 0xb2 ; i >= 0x30 ; i-- )
|
||||
{
|
||||
|
@ -1675,6 +1679,7 @@ void YM2612ResetChip_(void)
|
|||
for(i = 0x26 ; i >= 0x20 ; i-- ) OPNWriteReg(i,0);
|
||||
/* DAC mode clear */
|
||||
ym2612.dacen = 0;
|
||||
ym2612.addr_A1 = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1852,7 +1857,7 @@ int YM2612PicoTick_(int n)
|
|||
void YM2612PicoStateLoad_(void)
|
||||
{
|
||||
#ifndef EXTERNAL_YM2612
|
||||
int i, old_A1 = ym2612.addr_A1;
|
||||
int i, real_A1 = ym2612.addr_A1;
|
||||
|
||||
reset_channels( &ym2612.CH[0], 6 );
|
||||
|
||||
|
@ -1861,12 +1866,13 @@ void YM2612PicoStateLoad_(void)
|
|||
YM2612Write_(0, i);
|
||||
YM2612Write_(1, ym2612.REGS[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < 0x100; i++) {
|
||||
YM2612Write_(2, i);
|
||||
YM2612Write_(3, ym2612.REGS[i|0x100]);
|
||||
}
|
||||
|
||||
ym2612.addr_A1 = old_A1;
|
||||
ym2612.addr_A1 = real_A1;
|
||||
#else
|
||||
reset_channels( &ym2612.CH[0], 6 );
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue