/* ============== ResetEdicts ============== */ void Level::ResetEdicts( void ) { int i; memset( g_entities, 0, game.maxentities * sizeof( g_entities[ 0 ] ) ); // Add all the edicts to the free list LL_Reset( &free_edicts, next, prev ); LL_Reset( &active_edicts, next, prev ); for( i = 0; i < game.maxentities; i++ ) { LL_Add( &free_edicts, &g_entities[ i ], next, prev ); } for( i = 0; i < game.maxclients; i++ ) { //char savedTeamName[ 16 ]; // set client fields on player ents g_entities[ i ].client = game.clients + i; //strcpy( savedTeamName, game.clients[i].pers.lastTeam ); G_InitClientPersistant (&game.clients[i]); //strcpy( game.clients[i].pers.lastTeam, savedTeamName ); } globals.num_entities = game.maxclients; }
int32_t MV_Shutdown(void) { if (!MV_Installed) return MV_Ok; MV_KillAllVoices(); MV_Installed = FALSE; // Stop the sound playback engine MV_StopPlayback(); // Shutdown the sound card SoundDriver_Shutdown(); // Free any voices we allocated #ifdef _3DS linearFree(MV_Voices); #else ALIGNED_FREE_AND_NULL(MV_Voices); #endif LL_Reset((VoiceNode*) &VoiceList, next, prev); LL_Reset((VoiceNode*) &VoicePool, next, prev); MV_MaxVoices = 1; // Release the descriptor from our mix buffer for (int buffer = 0; buffer < MV_NUMBEROFBUFFERS; buffer++) MV_MixBuffer[ buffer ] = NULL; MV_SetErrorCode(MV_NotInstalled); return MV_Ok; }
int WinMMDrv_MIDI_Init(midifuncs * funcs) { MMRESULT rv; if (midiInstalled) { WinMMDrv_MIDI_Shutdown(); } memset(funcs, 0, sizeof(midifuncs)); LL_Reset( (MidiBuffer*) &activeMidiBuffers, next, prev ); LL_Reset( (MidiBuffer*) &spareMidiBuffers, next, prev ); midiMutex = CreateMutex(0, FALSE, 0); if (!midiMutex) { ErrorCode = WinMMErr_MIDICreateMutex; return WinMMErr_Error; } rv = midiStreamOpen(&midiStream, &midiDeviceID, 1, (DWORD_PTR) 0, (DWORD_PTR) 0, CALLBACK_NULL); if (rv != MMSYSERR_NOERROR) { CloseHandle(midiMutex); midiMutex = 0; midi_error(rv, "WinMM MIDI_Init midiStreamOpen"); ErrorCode = WinMMErr_MIDIStreamOpen; return WinMMErr_Error; } funcs->NoteOff = Func_NoteOff; funcs->NoteOn = Func_NoteOn; funcs->PolyAftertouch = Func_PolyAftertouch; funcs->ControlChange = Func_ControlChange; funcs->ProgramChange = Func_ProgramChange; funcs->ChannelAftertouch = Func_ChannelAftertouch; funcs->PitchBend = Func_PitchBend; funcs->SysEx = Func_SysEx; midiInstalled = TRUE; return WinMMErr_Ok; }
int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numchannels, void *initdata) { if (MV_Installed) MV_Shutdown(); MV_SetErrorCode(MV_Ok); // MV_TotalMemory + 2: FIXME, see valgrind_errors.log int const totalmem = Voices * sizeof(VoiceNode) + MV_TOTALBUFFERSIZE + 2; #ifdef _3DS char *ptr = (char *) linearAlloc( totalmem); #else char *ptr = (char *) Xaligned_alloc(16, totalmem); #endif if (!ptr) { MV_SetErrorCode(MV_NoMem); return MV_Error; } Bmemset(ptr, 0, totalmem); MV_Voices = (VoiceNode *)ptr; ptr += Voices * sizeof(VoiceNode); // Set number of voices before calculating volume table MV_MaxVoices = Voices; LL_Reset((VoiceNode*) &VoiceList, next, prev); LL_Reset((VoiceNode*) &VoicePool, next, prev); for (int index = 0; index < Voices; index++) { LL_Add((VoiceNode*) &VoicePool, &MV_Voices[ index ], next, prev); } MV_SetReverseStereo(FALSE); ASS_SoundDriver = soundcard; // Initialize the sound card if (SoundDriver_Init(&MixRate, &numchannels, initdata) != MV_Ok) MV_SetErrorCode(MV_DriverError); if (MV_ErrorCode != MV_Ok) { ALIGNED_FREE_AND_NULL(MV_Voices); return MV_Error; } MV_Installed = TRUE; MV_CallBackFunc = NULL; MV_ReverbLevel = 0; MV_ReverbTable = NULL; // Set the sampling rate MV_MixRate = MixRate; // Set Mixer to play stereo digitized sound MV_SetMixMode(numchannels); MV_ReverbDelay = MV_BufferSize * 3; // Make sure we don't cross a physical page MV_MixBuffer[ MV_NumberOfBuffers ] = ptr; for (int buffer = 0; buffer < MV_NumberOfBuffers; buffer++) { MV_MixBuffer[ buffer ] = ptr; ptr += MV_BufferSize; } // Calculate pan table MV_CalcPanTable(); MV_SetVolume(MV_MAXTOTALVOLUME); // Start the playback engine if (MV_StartPlayback() != MV_Ok) { // Preserve error code while we shutdown. int status = MV_ErrorCode; MV_Shutdown(); MV_SetErrorCode(status); return MV_Error; } return MV_Ok; }