From 2fbd7303d32fb68234cf006a4386e0e4f1c498e8 Mon Sep 17 00:00:00 2001 From: Steam Deck User Date: Mon, 13 Mar 2023 15:06:34 -0400 Subject: [PATCH] Fix 1000 Sound, remove old sound.cpp --- MakePHAT | 3 +- source/psp/main.cpp | 2 +- source/psp/sound.cpp | 157 ------------------------------------------- source/snd_dma.c | 2 +- 4 files changed, 3 insertions(+), 161 deletions(-) delete mode 100644 source/psp/sound.cpp diff --git a/MakePHAT b/MakePHAT index 5b6a629..0342fc9 100644 --- a/MakePHAT +++ b/MakePHAT @@ -13,7 +13,6 @@ PSP_FW_VERSION=660 MODE=-DKERNEL_MODE - ifeq ($(USE_GPROF),1) GPROF_LIBS = -lpspprof GPROF_FLAGS = -pg -DPROFILE @@ -28,7 +27,6 @@ COMMON_OBJS = \ source/psp/input.o \ source/psp/main.o \ source/psp/math.o \ - source/psp/sound.o \ source/psp/system.o \ source/psp/module.o \ source/psp/network.o \ @@ -64,6 +62,7 @@ COMMON_OBJS = \ source/pr_cmds.o \ source/pr_edict.o \ source/pr_exec.o \ + source/snd_sdl.o \ source/snd_dma.o \ source/snd_mem.o \ source/snd_mix.o \ diff --git a/source/psp/main.cpp b/source/psp/main.cpp index 6ff073c..71a8d77 100644 --- a/source/psp/main.cpp +++ b/source/psp/main.cpp @@ -89,7 +89,7 @@ namespace quake #else - static size_t heapSize = 9 * 1024 * 1024; + static size_t heapSize = 10 * 1024 * 1024; #endif // SLIM diff --git a/source/psp/sound.cpp b/source/psp/sound.cpp deleted file mode 100644 index 3318730..0000000 --- a/source/psp/sound.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* -Copyright (C) 1996-1997 Id Software, Inc. -Copyright (C) 2007 Peter Mackay and Chris Swindle. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include -#include - -extern "C" -{ -#include "../quakedef.h" -} - -namespace quake -{ - namespace sound - { - struct Sample - { - short left; - short right; - }; - - static const unsigned int channelCount = 2; - static const unsigned int inputBufferSize = 16384; - static const unsigned int inputFrequency = 11025; - static const unsigned int outputFrequency = 44100; - static const unsigned int inputSamplesPerOutputSample = outputFrequency / inputFrequency; - static Sample inputBuffer[inputBufferSize]; - static volatile unsigned int samplesRead; - - static inline void copySamples(const Sample* first, const Sample* last, Sample* destination) - { - // just assume inputSamplesPerOutputSample is 4. - for (const Sample* source = first; source != last; ++source) - { - const Sample sample = *source; - *destination++ = sample; - *destination++ = sample; - *destination++ = sample; - *destination++ = sample; - } - } - - static void fillOutputBuffer(void* buffer, unsigned int samplesToWrite, void* userData) - { - // Where are we writing to? - Sample* const destination = static_cast (buffer); - - // Where are we reading from? - const Sample* const firstSampleToRead = &inputBuffer[samplesRead]; - - // How many samples to read? - const unsigned int samplesToRead = samplesToWrite / inputSamplesPerOutputSample; - - // Going to wrap past the end of the input buffer? - const unsigned int samplesBeforeEndOfInput = inputBufferSize - samplesRead; - if (samplesToRead > samplesBeforeEndOfInput) - { - // Yes, so write the first chunk from the end of the input buffer. - copySamples( - firstSampleToRead, - firstSampleToRead + samplesBeforeEndOfInput, - &destination[0]); - - // Write the second chunk from the start of the input buffer. - const unsigned int samplesToReadFromBeginning = samplesToRead - samplesBeforeEndOfInput; - copySamples( - &inputBuffer[0], - &inputBuffer[samplesToReadFromBeginning], - &destination[samplesBeforeEndOfInput * inputSamplesPerOutputSample]); - } - else - { - // No wrapping, just copy. - copySamples( - firstSampleToRead, - firstSampleToRead + samplesToRead, - &destination[0]); - } - - // Update the read offset. - samplesRead = (samplesRead + samplesToRead) % inputBufferSize; - } - } -} - -using namespace quake; -using namespace quake::sound; - -qboolean SNDDMA_Init(void) -{ - // Set up Quake's audio. - shm = &sn; - shm->channels = channelCount; - shm->samplebits = 16; - shm->speed = inputFrequency; - shm->soundalive = qtrue; - shm->splitbuffer = qfalse; - shm->samples = inputBufferSize * channelCount; - shm->samplepos = 0; - shm->submission_chunk = 1; - shm->buffer = (unsigned char *) inputBuffer; - - // Initialise the audio system. This initialises it for the CD audio module - // too. - pspAudioInit(); - - // Set the channel callback. - // Sound effects use channel 0, CD audio uses channel 1. - pspAudioSetChannelCallback(0, fillOutputBuffer, 0); - - return qtrue; -} - -void SNDDMA_Shutdown(void) -{ - // Clear the mixing buffer so we don't get any noise during cleanup. - memset(inputBuffer, 0, sizeof(inputBuffer)); - - // Clear the channel callback. - pspAudioSetChannelCallback(0, 0, 0); - - // Stop the audio system? - pspAudioEndPre(); - - // Insert a false delay so the thread can be cleaned up. - sceKernelDelayThread(50 * 1000); - - // Shut down the audio system. - pspAudioEnd(); -} - -int SNDDMA_GetDMAPos(void) -{ - return samplesRead * channelCount; -} - -void SNDDMA_Submit(void) -{ -} diff --git a/source/snd_dma.c b/source/snd_dma.c index 4e9afb1..fc87811 100644 --- a/source/snd_dma.c +++ b/source/snd_dma.c @@ -189,7 +189,7 @@ void S_Init (void) Cvar_RegisterVariable(&snd_show); Cvar_RegisterVariable(&_snd_mixahead); - if (host_parms.memsize < 0x800000) + //if (host_parms.memsize < 0x800000) { Cvar_Set ("loadas8bit", "1"); Con_Printf ("loading all sounds as 8bit\n");