mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
move more globals to PicoInterface
similar reasons as before
This commit is contained in:
parent
075672bf9f
commit
6311a3baf5
27 changed files with 244 additions and 247 deletions
|
@ -571,32 +571,32 @@ void pemu_sound_start(void)
|
|||
|
||||
samples_made = samples_done = 0;
|
||||
|
||||
if (PsndRate != PsndRate_old || (PicoIn.opt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
|
||||
if (PicoIn.sndRate != PsndRate_old || (PicoIn.opt&0x0b) != (PicoOpt_old&0x0b) || Pico.m.pal != pal_old) {
|
||||
PsndRerate(Pico.m.frame_count ? 1 : 0);
|
||||
}
|
||||
stereo=(PicoIn.opt&8)>>3;
|
||||
|
||||
samples_block = Pico.m.pal ? SOUND_BLOCK_SIZE_PAL : SOUND_BLOCK_SIZE_NTSC;
|
||||
if (PsndRate <= 22050) samples_block /= 2;
|
||||
if (PicoIn.sndRate <= 22050) samples_block /= 2;
|
||||
sndBuffer_endptr = &sndBuffer[samples_block*SOUND_BLOCK_COUNT];
|
||||
|
||||
lprintf("starting audio: %i, len: %i, stereo: %i, pal: %i, block samples: %i\n",
|
||||
PsndRate, PsndLen, stereo, Pico.m.pal, samples_block);
|
||||
PicoIn.sndRate, Pico.snd.len, stereo, Pico.m.pal, samples_block);
|
||||
|
||||
// while (sceAudioOutput2GetRestSample() > 0) psp_msleep(100);
|
||||
// sceAudio_5C37C0AE();
|
||||
ret = sceAudio_38553111(samples_block/2, PsndRate, 2); // seems to not need that stupid 64byte alignment
|
||||
ret = sceAudio_38553111(samples_block/2, PicoIn.sndRate, 2); // seems to not need that stupid 64byte alignment
|
||||
if (ret < 0) {
|
||||
lprintf("sceAudio_38553111() failed: %i\n", ret);
|
||||
emu_status_msg("sound init failed (%i), snd disabled", ret);
|
||||
currentConfig.EmuOpt &= ~EOPT_EN_SOUND;
|
||||
} else {
|
||||
PicoWriteSound = writeSound;
|
||||
PicoIn.writeSound = writeSound;
|
||||
memset32((int *)(void *)sndBuffer, 0, sizeof(sndBuffer)/4);
|
||||
snd_playptr = sndBuffer_endptr - samples_block;
|
||||
samples_made = samples_block; // send 1 empty block first..
|
||||
PsndOut = sndBuffer;
|
||||
PsndRate_old = PsndRate;
|
||||
PicoIn.sndOut = sndBuffer;
|
||||
PsndRate_old = PicoIn.sndRate;
|
||||
PicoOpt_old = PicoIn.opt;
|
||||
pal_old = Pico.m.pal;
|
||||
}
|
||||
|
@ -641,16 +641,16 @@ static void writeSound(int len)
|
|||
{
|
||||
int ret;
|
||||
|
||||
PsndOut += len / 2;
|
||||
/*if (PsndOut > sndBuffer_endptr) {
|
||||
memcpy32((int *)(void *)sndBuffer, (int *)endptr, (PsndOut - endptr + 1) / 2);
|
||||
PsndOut = &sndBuffer[PsndOut - endptr];
|
||||
PicoIn.sndOut += len / 2;
|
||||
/*if (PicoIn.sndOut > sndBuffer_endptr) {
|
||||
memcpy32((int *)(void *)sndBuffer, (int *)endptr, (PicoIn.sndOut - endptr + 1) / 2);
|
||||
PicoIn.sndOut = &sndBuffer[PicoIn.sndOut - endptr];
|
||||
lprintf("mov\n");
|
||||
}
|
||||
else*/
|
||||
if (PsndOut > sndBuffer_endptr) lprintf("snd oflow %i!\n", PsndOut - sndBuffer_endptr);
|
||||
if (PsndOut >= sndBuffer_endptr)
|
||||
PsndOut = sndBuffer;
|
||||
if (PicoIn.sndOut > sndBuffer_endptr) lprintf("snd oflow %i!\n", PicoIn.sndOut - sndBuffer_endptr);
|
||||
if (PicoIn.sndOut >= sndBuffer_endptr)
|
||||
PicoIn.sndOut = sndBuffer;
|
||||
|
||||
// signal the snd thread
|
||||
samples_made += len / 2;
|
||||
|
@ -873,7 +873,7 @@ void pemu_loop(void)
|
|||
}
|
||||
|
||||
// prepare sound stuff
|
||||
PsndOut = NULL;
|
||||
PicoIn.sndOut = NULL;
|
||||
if (currentConfig.EmuOpt & EOPT_EN_SOUND)
|
||||
{
|
||||
pemu_sound_start();
|
||||
|
@ -1021,9 +1021,9 @@ void pemu_loop(void)
|
|||
|
||||
if (PicoIn.AHW & PAHW_MCD) PicoCDBufferFree();
|
||||
|
||||
if (PsndOut != NULL) {
|
||||
if (PicoIn.sndOut != NULL) {
|
||||
pemu_sound_stop();
|
||||
PsndOut = NULL;
|
||||
PicoIn.sndOut = NULL;
|
||||
}
|
||||
|
||||
// save SRAM
|
||||
|
|
|
@ -1227,7 +1227,7 @@ static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *para
|
|||
break;
|
||||
case MA_OPT_SOUND_QUALITY:
|
||||
str = (PicoIn.opt&0x08)?"stereo":"mono";
|
||||
text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str);
|
||||
text_out16(x, y, "Sound Quality: %5iHz %s", PicoIn.sndRate, str);
|
||||
break;
|
||||
case MA_OPT_REGION:
|
||||
text_out16(x, y, "Region: %s", me_region_name(PicoIn.regionOverride, PicoIn.autoRgnOrder));
|
||||
|
@ -1353,7 +1353,7 @@ static int menu_loop_options(void)
|
|||
}
|
||||
break;
|
||||
case MA_OPT_SOUND_QUALITY:
|
||||
PsndRate = sndrate_prevnext(PsndRate, inp & PBTN_RIGHT);
|
||||
PicoIn.sndRate = sndrate_prevnext(PicoIn.sndRate, inp & PBTN_RIGHT);
|
||||
break;
|
||||
case MA_OPT_REGION:
|
||||
region_prevnext(inp & PBTN_RIGHT);
|
||||
|
|
|
@ -403,8 +403,8 @@ void mp3_update(int *buffer, int length, int stereo)
|
|||
if (mp3_handle < 0 || mp3_src_pos >= mp3_src_size) return;
|
||||
|
||||
length_mp3 = length;
|
||||
if (PsndRate == 22050) length_mp3 <<= 1; // mp3s are locked to 44100Hz stereo
|
||||
else if (PsndRate == 11025) length_mp3 <<= 2; // so make length 44100ish
|
||||
if (PicoIn.sndRate == 22050) length_mp3 <<= 1; // mp3s are locked to 44100Hz stereo
|
||||
else if (PicoIn.sndRate == 11025) length_mp3 <<= 2; // so make length 44100ish
|
||||
|
||||
/* do we have to wait? */
|
||||
if (mp3_job_started && mp3_samples_ready < length_mp3)
|
||||
|
@ -420,8 +420,8 @@ void mp3_update(int *buffer, int length, int stereo)
|
|||
{
|
||||
int shr = 0;
|
||||
void (*mix_samples)(int *dest_buf, short *mp3_buf, int count) = mix_16h_to_32;
|
||||
if (PsndRate == 22050) { mix_samples = mix_16h_to_32_s1; shr = 1; }
|
||||
else if (PsndRate == 11025) { mix_samples = mix_16h_to_32_s2; shr = 2; }
|
||||
if (PicoIn.sndRate == 22050) { mix_samples = mix_16h_to_32_s1; shr = 1; }
|
||||
else if (PicoIn.sndRate == 11025) { mix_samples = mix_16h_to_32_s2; shr = 2; }
|
||||
|
||||
if (1152 - mp3_buffer_offs >= length_mp3) {
|
||||
mix_samples(buffer, mp3_mix_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length<<1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue