Compare commits

...
33 Commits
Author SHA1 Message Date
Gustaf Alhäll 89cecb88f5 Update license info 2025-12-06 19:45:35 +01:00
Gustaf Alhäll baf5c8d66b Fix music looping on digital 2025-12-06 19:45:32 +01:00
Gustaf Alhäll 72000c4546 Fix memory leak in AATree string trees 2025-12-06 19:45:29 +01:00
Gustaf Alhäll 82b774b2c3 Fix use-after-free when mobj is removed while still playing sounds 2025-12-06 19:45:27 +01:00
Gustaf Alhäll 3818b9ad1a Limit audio channels to 2 2025-12-05 00:22:09 +01:00
Alug ca8e811bd9 sdl_sound: attempt to fix sounds cutting off
i suck at explaining so just trust. :chonkbuncle:
Game sound handling has no idea which sound it is playing/checking, so a sound that ended frees its slot and it might get occupied again without the game knowing
so just encode the channel number into the sound so we can actually check
2025-12-04 17:52:38 +01:00
Alug 97ca034037 sdl_sound: handle explicit float conversions 2025-12-04 17:52:35 +01:00
Alug ac46f7ed00 add missing Fluidsynth ifdefs 2025-12-04 17:52:32 +01:00
Gustaf Alhäll 0afed59329 Fix MIDI music looping 2025-12-04 17:52:30 +01:00
Gustaf Alhäll ec3a1fee70 Tweak audio settings 2025-12-04 17:52:25 +01:00
Alug 5e8c0c3806 Add chorus and reverb settings to MIDI 2025-12-04 17:52:22 +01:00
Gustaf Alhäll 05ea898345 Fix Haiku build 2025-12-04 17:52:11 +01:00
Gustaf Alhäll 0c1fdc0be8 Fine-tune volume settings 2025-12-04 17:52:08 +01:00
Gustaf Alhäll 0e4c72e6f6 Implement MIDI seeking 2025-12-04 17:52:05 +01:00
Alug 29b83903ef delet the bird music resynching stuff
idk who even wants this, its pain, and even more pain to adapt
2025-12-04 17:52:03 +01:00
Alug 1cae09fa11 sdl_audio: use float M_PI for S_CURVE
meant for floats, prevents implicit double conversions
2025-12-04 17:51:59 +01:00
Alug 4a56819bc3 makefile: move openmpt stuff to before sdl stuff
seems to fix linking openmpt without mixer for some reason oh well
2025-12-01 16:49:11 +01:00
Alug 567a48aac3 sdl_sound: fix -Wmaybe-uninitialized warning 2025-12-01 16:49:08 +01:00
Alug d100401c5f this shouldnt be in sourcefile oops 2025-12-01 16:49:05 +01:00
Alug 6dee9fa561 add back "nearest" resampling from mixer
sdls own resampler uses linear interpolation, which sounds super muffled to me
some may like this, but i dont want to change how the game "sounds"
2025-12-01 16:49:01 +01:00
Alug 5bd7a09d9f force 44100khz sample rate
sounds better to me honestly
2025-12-01 16:48:56 +01:00
Alug 47477c2d03 make gme and tracker music slightly louder
prob needs some adjustment, but both were always quite quiet
2025-12-01 16:48:53 +01:00
Alug cd128a1084 lock audio stream in I_PlaySong
seems to fix weird crashes with gme
2025-12-01 16:48:49 +01:00
Alug 34f2afa3d9 add "audiobuffersize" handling
uses the SDL_AUDIO_DEVICE_SAMPLE_FRAMES hint
2025-12-01 16:48:46 +01:00
Alug 22f285edec disable sound precache for sdl sound 2025-12-01 16:48:43 +01:00
Alug 592abdef96 pitch is a float 2025-12-01 16:48:40 +01:00
Alug a27eee8e2f add few missing audiostream unlocks 2025-12-01 16:48:37 +01:00
Alug 904019d24b fix startup playing a super loud bit of music 2025-12-01 16:48:32 +01:00
Alug c6ca5a6f0f i_video: few type fixes for sdl3 2025-12-01 16:48:29 +01:00
Alug 2392f0484c remove hwr_shutdown call
honestly this didnt help with the issue i had, game should already release all the memory on quit anyways.
this just makes it take longer to quit
2025-12-01 16:48:26 +01:00
Alug 986a131a36 fix a few warnings 2025-12-01 16:48:23 +01:00
Alug e9685ef3e8 port srb2classics sdl audio system
still needs a little work reimplementing everything we got

from: https://codeberg.org/srb2classic/srb2classic/pulls/177
2025-12-01 16:48:18 +01:00
Alug 59f194cb9d fuckit SDL3 2025-12-01 16:48:15 +01:00
26 changed files with 2439 additions and 405 deletions

No files matched your search

+10 -6
View File
@@ -972,6 +972,14 @@ Public License instead of this License. But first, please read
Copyright (C) 1995-2018 Free Software Foundation, Inc. Copyright (C) 1995-2018 Free Software Foundation, Inc.
https://www.gnu.org/software/gettext/ https://www.gnu.org/software/gettext/
- FluidSynth
Copyright (C) 2000-2025 Peter Hanappe and others.
https://www.fluidsynth.org/
- libsndfile
Copyright (C) 1999-2016 Erik de Castro Lopo
https://libsndfile.github.io/libsndfile/
- mpg123 - mpg123
Copyright (c) 1995-2013 by Michael Hipp and others, Copyright (c) 1995-2013 by Michael Hipp and others,
free software under the terms of the LGPL v2.1 free software under the terms of the LGPL v2.1
@@ -1699,12 +1707,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zlib License zlib License
applies to: applies to:
- Simple DirectMedia Layer - Simple DirectMedia Layer
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
https://www.libsdl.org/hg.php https://libsdl.org/
- SDL_mixer: An audio mixer library based on the SDL library
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
https://www.libsdl.org/projects/SDL_mixer/
- zlib - zlib
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+41
View File
@@ -0,0 +1,41 @@
# Find FluidSynth
# Once done, this will define
#
# FLUIDSYNTH_FOUND - system has FluidSynth
# FLUIDSYNTH_INCLUDE_DIRS - FluidSynth include directories
# FLUIDSYNTH_LIBRARIES - link libraries
include(LibFindMacros)
libfind_pkg_check_modules(FLUIDSYNTH_PKGCONF FLUIDSYNTH)
# includes
find_path(FLUIDSYNTH_INCLUDE_DIR
NAMES fluidsynth.h
PATHS
${FLUIDSYNTH_PKGCONF_INCLUDE_DIRS}
)
# library
find_library(FLUIDSYNTH_LIBRARY
NAMES fluidsynth
PATHS
${FLUIDSYNTH_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
# set include dir variables
set(FLUIDSYNTH_PROCESS_INCLUDES FLUIDSYNTH_INCLUDE_DIR)
set(FLUIDSYNTH_PROCESS_LIBS FLUIDSYNTH_LIBRARY)
libfind_process(FLUIDSYNTH)
if(FLUIDSYNTH_FOUND AND NOT TARGET FluidSynth::libfluidsynth)
add_library(FluidSynth::libfluidsynth UNKNOWN IMPORTED)
set_target_properties(
FluidSynth::libfluidsynth
PROPERTIES
IMPORTED_LOCATION "${FLUIDSYNTH_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FLUIDSYNTH_INCLUDE_DIR}"
)
endif()
+1 -1
View File
@@ -8,6 +8,7 @@ passthru_opts+=\
HAVE_MINIUPNPC\ HAVE_MINIUPNPC\
HAVE_DISCORDRPC DEVELOP\ HAVE_DISCORDRPC DEVELOP\
NOHOLEPUNCH\ NOHOLEPUNCH\
NOOPENMPT\
# build with debugging information # build with debugging information
ifdef DEBUGMODE ifdef DEBUGMODE
@@ -91,7 +92,6 @@ endif
default_packages:=\ default_packages:=\
LIBGME/libgme/LIBGME\ LIBGME/libgme/LIBGME\
OPENMPT/libopenmpt/LIBOPENMPT\
ZLIB/zlib\ ZLIB/zlib\
$(foreach p,$(default_packages),\ $(foreach p,$(default_packages),\
+13 -9
View File
@@ -29,8 +29,19 @@ ifndef NOHW
sources+=sdl/ogl_sdl.c sources+=sdl/ogl_sdl.c
endif endif
ifndef NOOPENMPT
LIBOPENMPT_PKGCONFIG?=libopenmpt
$(eval $(call Use_pkg_config,LIBOPENMPT))
opts+=-DHAVE_OPENMPT
endif
NOMIXER=1
ifdef NOMIXER ifdef NOMIXER
sources+=sdl/dummy_sound.c #sources+=sdl/dummy_sound.c
sources+=sdl/sdl_sound.c
SNDFILE_PKGCONFIG?=sndfile
$(eval $(call Use_pkg_config,SNDFILE))
else else
opts+=-DHAVE_MIXER opts+=-DHAVE_MIXER
sources+=sdl/mixer_sound.c sources+=sdl/mixer_sound.c
@@ -45,15 +56,8 @@ opts+=-DHAVE_THREADS
sources+=sdl/i_threads.c sources+=sdl/i_threads.c
endif endif
ifdef SDL_PKGCONFIG SDL_PKGCONFIG?=sdl3
$(eval $(call Use_pkg_config,SDL)) $(eval $(call Use_pkg_config,SDL))
else
SDL_CONFIG?=$(call Prefix,sdl2-config)
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \
$(if $(STATIC),--static-libs,--libs))
$(eval $(call Propogate_flags,SDL))
endif
ifdef MINGW ifdef MINGW
ifndef NOSDLMAIN ifndef NOSDLMAIN
+3 -3
View File
@@ -79,14 +79,14 @@ $(eval $(call _set,LIBOPENMPT))
lib:=../libs/SDL2_mixer/$(mingw) lib:=../libs/SDL2_mixer/$(mingw)
ifdef SDL ifdef SDL
mixer_opts:=-I$(lib)/include/SDL2 mixer_opts:=-I$(lib)/include/SDL3
mixer_libs:=-L$(lib)/lib mixer_libs:=-L$(lib)/lib
lib:=../libs/SDL2/$(mingw) lib:=../libs/SDL2/$(mingw)
SDL_opts:=-I$(lib)/include/SDL2\ SDL_opts:=-I$(lib)/include/SDL3\
$(mixer_opts) -Dmain=SDL_main $(mixer_opts) -Dmain=SDL_main
SDL_libs:=-L$(lib)/lib $(mixer_libs)\ SDL_libs:=-L$(lib)/lib $(mixer_libs)\
-lmingw32 -lSDL2main -lSDL2 -mwindows -lmingw32 -lSDL3main -lSDL3 -mwindows
$(eval $(call _set,SDL)) $(eval $(call _set,SDL))
endif endif
+1 -1
View File
@@ -1264,7 +1264,7 @@ static void IdentifyVersion(void)
if (AddIWAD("extra3.kart", srb2waddir)) if (AddIWAD("extra3.kart", srb2waddir))
found_extra3_kart = true; found_extra3_kart = true;
#if !defined (HAVE_SDL) || defined (HAVE_MIXER) #if defined (HAVE_SDL)
#define MUSICTEST(str) \ #define MUSICTEST(str) \
musicpath = va(pandf, srb2waddir, str);\ musicpath = va(pandf, srb2waddir, str);\
handle = W_OpenWadFile(&musicpath, false); \ handle = W_OpenWadFile(&musicpath, false); \
+2 -1
View File
@@ -20,6 +20,7 @@
// but I can't stand that gibberish. D: // but I can't stand that gibberish. D:
#define SOUND_DUMMY 0 #define SOUND_DUMMY 0
#define SOUND_MIXER 1 #define SOUND_MIXER 1
#define SOUND_SDL 2
#ifndef SOUND #ifndef SOUND
#ifdef HAVE_SDL #ifdef HAVE_SDL
@@ -27,7 +28,7 @@
#ifdef HAVE_MIXER #ifdef HAVE_MIXER
#define SOUND SOUND_MIXER #define SOUND SOUND_MIXER
#else #else
#define SOUND SOUND_DUMMY #define SOUND SOUND_SDL
#endif #endif
#else #else
#define SOUND SOUND_DUMMY #define SOUND SOUND_DUMMY
+1 -1
View File
@@ -27,7 +27,7 @@ extern "C" {
#ifdef HAVE_SDL #ifdef HAVE_SDL
#define _MATH_DEFINES_DEFINED #define _MATH_DEFINES_DEFINED
#include "SDL_opengl.h" //Alam_GBC: Simple, yes? #include <SDL3/SDL_opengl.h> //Alam_GBC: Simple, yes?
#else #else
#include <GL/gl.h> #include <GL/gl.h>
-2
View File
@@ -158,8 +158,6 @@ UINT32 I_GetSongLoopPoint(void);
boolean I_SetSongPosition(UINT32 position); boolean I_SetSongPosition(UINT32 position);
UINT32 I_GetSongPosition(void); UINT32 I_GetSongPosition(void);
void I_UpdateSongLagThreshold (void);
/// ------------------------ /// ------------------------
// MUSIC PLAYBACK // MUSIC PLAYBACK
/// ------------------------ /// ------------------------
+6 -4
View File
@@ -49,17 +49,19 @@ aatree_t *M_AATreeAlloc(UINT32 flags)
return aatree; return aatree;
} }
static void M_AATreeFree_Node(aatree_node_t *node) static void M_AATreeFree_Node(aatree_node_t *node, bool is_string)
{ {
if (node->left) M_AATreeFree_Node(node->left); if (node->left) M_AATreeFree_Node(node->left, is_string);
if (node->right) M_AATreeFree_Node(node->right); if (node->right) M_AATreeFree_Node(node->right, is_string);
if (is_string)
Z_Free(node->value);
Z_Free(node); Z_Free(node);
} }
void M_AATreeFree(aatree_t *aatree) void M_AATreeFree(aatree_t *aatree)
{ {
if (aatree->root) if (aatree->root)
M_AATreeFree_Node(aatree->root); M_AATreeFree_Node(aatree->root, (aatree->flags & AATREE_STRING) == AATREE_STRING);
Z_Free(aatree); Z_Free(aatree);
} }
+2 -3
View File
@@ -88,8 +88,8 @@
#include "z_zone.h" #include "z_zone.h"
#include "mserv.h" #include "mserv.h"
#if defined(HAVE_SDL) #if defined (HAVE_SDL)
#include "SDL.h" #include <SDL3/SDL.h>
#if SDL_VERSION_ATLEAST(2,0,0) #if SDL_VERSION_ATLEAST(2,0,0)
#include "sdl/sdlmain.h" // JOYSTICK_HOTPLUG #include "sdl/sdlmain.h" // JOYSTICK_HOTPLUG
#endif #endif
@@ -504,7 +504,6 @@ static INT32 M_ShiftChar(INT32 ch)
// Pretty and consistent ^u^ // Pretty and consistent ^u^
// See also G_GetGametypeColor. // See also G_GetGametypeColor.
// //
static INT32 highlightflags, recommendedflags, warningflags; static INT32 highlightflags, recommendedflags, warningflags;
inline static void M_GetGametypeColor(void) inline static void M_GetGametypeColor(void)
+12 -7
View File
@@ -1153,6 +1153,13 @@ static menuitem_t OP_SoundAdvancedMenu[] =
{IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 35}, {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 35},
#endif #endif
#ifdef HAVE_FLUIDSYNTH
{IT_HEADER, NULL, "MIDI Settings", NULL, NULL, OPENMPT_MENUOFFSET},
{IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Sound Font File", NULL, &cv_midisoundfontpath, OPENMPT_MENUOFFSET+12},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Chorus", NULL, &cv_midichorus, OPENMPT_MENUOFFSET+40},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Reverb", NULL, &cv_midireverb, OPENMPT_MENUOFFSET+50},
#endif
{IT_HEADER, NULL, "Misc", NULL, 45}, {IT_HEADER, NULL, "Misc", NULL, 45},
{IT_STRING | IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 55}, {IT_STRING | IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 55},
@@ -1180,6 +1187,11 @@ static const char* OP_SoundAdvancedTooltips[] =
"Which Amiga should be used for .mod playback?", "Which Amiga should be used for .mod playback?",
#endif #endif
"How far should the four channels in .mod be panned?", "How far should the four channels in .mod be panned?",
#endif
#ifdef HAVE_FLUIDSYNTH
"Which MIDI soundfont to use",
"Controls the chorus of MIDI playback\n setting this too high might cause some instruments to be overexposed",
"Controls the reverb of MIDI playback\n setting this too high might cause notes to be drawn out",
#endif #endif
NULL, NULL,
"How many times is the same sound allowed to play at once?\nIf 0 theres no limit.", "How many times is the same sound allowed to play at once?\nIf 0 theres no limit.",
@@ -2180,9 +2192,6 @@ static menuitem_t OP_AdvancedBirdMenu[] =
{IT_STRING | IT_CVAR, NULL, "Fade Back from Grow", &cv_growmusicfade, 20}, {IT_STRING | IT_CVAR, NULL, "Fade Back from Grow", &cv_growmusicfade, 20},
{IT_STRING | IT_CVAR, NULL, "Fade Out Before Respawning", &cv_respawnfademusicout, 30}, {IT_STRING | IT_CVAR, NULL, "Fade Out Before Respawning", &cv_respawnfademusicout, 30},
{IT_STRING | IT_CVAR, NULL, "Fade Back In While Respawning", &cv_respawnfademusicback, 40}, {IT_STRING | IT_CVAR, NULL, "Fade Back In While Respawning", &cv_respawnfademusicback, 40},
{IT_STRING | IT_CVAR, NULL, "Resync Threshold", &cv_music_resync_threshold, 60},
{IT_STRING | IT_CVAR, NULL, "Resync Special Music Only", &cv_music_resync_powerups_only, 70},
}; };
static const char* OP_AdvancedBirdTooltips[] = static const char* OP_AdvancedBirdTooltips[] =
@@ -2192,8 +2201,6 @@ static const char* OP_AdvancedBirdTooltips[] =
"Fade in music after Grow.", "Fade in music after Grow.",
"Fade out music before respawning.", "Fade out music before respawning.",
"Fade in music while respawning.", "Fade in music while respawning.",
"Threshold for syncing music.",
"Only sync special music.",
}; };
enum enum
@@ -2203,8 +2210,6 @@ enum
fadegrow, fadegrow,
respawnfadeout, respawnfadeout,
respawnfadein, respawnfadein,
syncthreshold,
syncspecialonly,
}; };
menuitem_t OP_CustomCvarMenu[MAXMENUCCVARS]; menuitem_t OP_CustomCvarMenu[MAXMENUCCVARS];
+2
View File
@@ -812,6 +812,8 @@ static void P_LoadSectors(UINT8 *data)
ss->tag = SHORT(ms->tag); ss->tag = SHORT(ms->tag);
ss->flags |= SF_FLIPSPECIAL_FLOOR; ss->flags |= SF_FLIPSPECIAL_FLOOR;
ss->soundorg.thinker.function = (actionf_p1)P_MobjThinker;
} }
// set the sky flat num // set the sky flat num
+6 -1
View File
@@ -3986,7 +3986,12 @@ DoneSection2:
player->tossdelay = 3; player->tossdelay = 3;
} }
#if 0
// Event - Final Lap
// Still works for GME, but disabled for consistency
if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1))
S_SpeedMusic(1.2f);
#endif
if (player->laps >= (unsigned)cv_numlaps.value) if (player->laps >= (unsigned)cv_numlaps.value)
{ {
if (P_IsLocalPlayer(player)) if (P_IsLocalPlayer(player))
+19 -17
View File
@@ -58,7 +58,7 @@ static void AmigaType_OnChange(void);
#endif #endif
static CV_PossibleValue_t audbuffersize_cons_t[] = {{128, "128"}, {256, "256"}, {512, "512"}, {1024, "1024"}, {2048, "2048"}, {4096, "4096"}, {0, NULL}}; static CV_PossibleValue_t audbuffersize_cons_t[] = {{128, "128"}, {256, "256"}, {512, "512"}, {1024, "1024"}, {2048, "2048"}, {4096, "4096"}, {0, NULL}};
consvar_t cv_audbuffersize = {"audiobuffersize", "2048", CV_SAVE|CV_CALL, audbuffersize_cons_t, BufferSize_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_audbuffersize = {"audiobuffersize", "2048", CV_SAVE|CV_CALL|CV_NOINIT, audbuffersize_cons_t, BufferSize_OnChange, 0, NULL, NULL, 0, 0, NULL};
// stereo reverse // stereo reverse
consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -94,14 +94,6 @@ consvar_t cv_playsoundifunfocused = {"playsoundsifunfocused", "No", CV_SAVE, CV_
consvar_t cv_pausemusic = {"playmusicifpaused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_pausemusic = {"playmusicifpaused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
//bird music stuff //bird music stuff
static CV_PossibleValue_t music_resync_threshold_cons_t[] = {
{0, "MIN"},
{1000, "MAX"},
{0}
};
consvar_t cv_music_resync_threshold = {"music_resync_threshold", "0", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -281,6 +273,12 @@ void S_RegisterSoundStuff(void)
CV_RegisterVar(&cv_gamesounds); CV_RegisterVar(&cv_gamesounds);
CV_RegisterVar(&cv_gamedigimusic); CV_RegisterVar(&cv_gamedigimusic);
#ifdef HAVE_FLUIDSYNTH
CV_RegisterVar(&cv_midisoundfontpath);
CV_RegisterVar(&cv_midichorus);
CV_RegisterVar(&cv_midireverb);
#endif
CV_RegisterVar(&cv_samesoundlimit); CV_RegisterVar(&cv_samesoundlimit);
// bird music stuff // bird music stuff
@@ -288,9 +286,6 @@ void S_RegisterSoundStuff(void)
CV_RegisterVar(&cv_playsoundifunfocused); CV_RegisterVar(&cv_playsoundifunfocused);
CV_RegisterVar(&cv_pausemusic); CV_RegisterVar(&cv_pausemusic);
CV_RegisterVar(&cv_music_resync_threshold);
CV_RegisterVar(&cv_music_resync_powerups_only);
CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_invincmusicfade);
CV_RegisterVar(&cv_growmusicfade); CV_RegisterVar(&cv_growmusicfade);
@@ -362,6 +357,7 @@ boolean S_SoundDisabled(void)
int S_CacheSound(void) int S_CacheSound(void)
{ {
#if SOUND == SOUND_MIXER
if (sound_disabled) if (sound_disabled)
return SOUNDCACHE_OFF; return SOUNDCACHE_OFF;
@@ -369,6 +365,9 @@ int S_CacheSound(void)
return SOUNDCACHE_PRECACHE; return SOUNDCACHE_PRECACHE;
return cv_cachesound.value; return cv_cachesound.value;
#else
return SOUNDCACHE_OFF;
#endif
} }
// Stop all sounds, load level info, THEN start sounds. // Stop all sounds, load level info, THEN start sounds.
@@ -772,9 +771,14 @@ void S_UpdateSounds(void)
volume = c->volume; // 8 bits internal volume precision volume = c->volume; // 8 bits internal volume precision
sep = NORM_SEP; sep = NORM_SEP;
if (P_MobjWasRemoved(c->origin))
{
// origin was removed, stop the music
S_StopChannel(cnum);
}
// check non-local sounds for distance clipping // check non-local sounds for distance clipping
// or modify their params // or modify their params
if (c->origin) else
{ {
boolean itsUs = false; boolean itsUs = false;
@@ -1642,7 +1646,7 @@ UINT32 S_GetMusicPosition(void)
static lumpnum_t S_GetMusicLumpNum(const char *mname) static lumpnum_t S_GetMusicLumpNum(const char *mname)
{ {
if (S_MusicExists(mname, false, true)) // check non midis first if (S_MusicExists(mname, false, true)) // check non midis first
return W_GetNumForName(va("o_%s", mname)); return W_GetNumForName(va("O_%s", mname));
if (S_MusicExists(mname, true, false)) if (S_MusicExists(mname, true, false))
{ {
@@ -1650,7 +1654,7 @@ static lumpnum_t S_GetMusicLumpNum(const char *mname)
CONS_Alert(CONS_ERROR, "A MIDI music lump %.6s was found,\nbut SRB2Kart does not support MIDI output.\nWe apologise for the inconvenience.\n", mname); CONS_Alert(CONS_ERROR, "A MIDI music lump %.6s was found,\nbut SRB2Kart does not support MIDI output.\nWe apologise for the inconvenience.\n", mname);
return LUMPERROR; return LUMPERROR;
#else #else
return W_GetNumForName(va("d_%s", mname)); return W_GetNumForName(va("D_%s", mname));
#endif #endif
} }
@@ -1709,8 +1713,6 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
if (S_MusicDisabled()) if (S_MusicDisabled())
return false; return false;
I_UpdateSongLagThreshold();
if ((!fadeinms && !I_PlaySong(looping)) || if ((!fadeinms && !I_PlaySong(looping)) ||
(fadeinms && !I_FadeInPlaySong(fadeinms, looping))) (fadeinms && !I_FadeInPlaySong(fadeinms, looping)))
{ {
+6 -3
View File
@@ -54,10 +54,13 @@ extern consvar_t cv_amigatype;
#endif #endif
#endif #endif
//bird music stuff #ifdef HAVE_FLUIDSYNTH
extern consvar_t cv_music_resync_threshold; extern consvar_t cv_midisoundfontpath;
extern consvar_t cv_music_resync_powerups_only; extern consvar_t cv_midichorus;
extern consvar_t cv_midireverb;
#endif
//bird music stuff
extern consvar_t cv_invincmusicfade; extern consvar_t cv_invincmusicfade;
extern consvar_t cv_growmusicfade; extern consvar_t cv_growmusicfade;
+25 -24
View File
@@ -46,8 +46,8 @@
#include "SDL_image.h" #include "SDL_image.h"
#else #else
// SDLCALL terms removed from original SDL_image declarations // SDLCALL terms removed from original SDL_image declarations
int IMG_isXPM(SDL_RWops *src); int IMG_isXPM(SDL_IOStream *src);
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src); SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src);
SDL_Surface *IMG_ReadXPMFromArray(const char **xpm); SDL_Surface *IMG_ReadXPMFromArray(const char **xpm);
#define IMG_SetError SDL_SetError #define IMG_SetError SDL_SetError
#define IMG_GetError SDL_GetError #define IMG_GetError SDL_GetError
@@ -56,7 +56,7 @@ SDL_Surface *IMG_ReadXPMFromArray(const char **xpm);
#ifdef LOAD_XPM #ifdef LOAD_XPM
/* See if an image is contained in a data source */ /* See if an image is contained in a data source */
int IMG_isXPM(SDL_RWops *src) int IMG_isXPM(SDL_IOStream *src)
{ {
Sint64 start; Sint64 start;
int is_XPM; int is_XPM;
@@ -64,14 +64,14 @@ int IMG_isXPM(SDL_RWops *src)
if ( !src ) if ( !src )
return 0; return 0;
start = SDL_RWtell(src); start = SDL_TellIO(src);
is_XPM = 0; is_XPM = 0;
if ( SDL_RWread(src, magic, sizeof(magic), 1) ) { if ( SDL_ReadIO(src, magic, sizeof(magic)) ) {
if ( SDL_memcmp(magic, "/* XPM */", sizeof(magic)) == 0 ) { if ( SDL_memcmp(magic, "/* XPM */", sizeof(magic)) == 0 ) {
is_XPM = 1; is_XPM = 1;
} }
} }
SDL_RWseek(src, start, RW_SEEK_SET); SDL_SeekIO(src, start, SDL_IO_SEEK_SET);
return(is_XPM); return(is_XPM);
} }
@@ -933,7 +933,7 @@ static const char *error;
* If len > 0, it's assumed to be at least len chars (for efficiency). * If len > 0, it's assumed to be at least len chars (for efficiency).
* Return NULL and set error upon EOF or parse error. * Return NULL and set error upon EOF or parse error.
*/ */
static const char *get_next_line(const char ***lines, SDL_RWops *src, int len) static const char *get_next_line(const char ***lines, SDL_IOStream *src, int len)
{ {
char *linebufnew; char *linebufnew;
@@ -943,7 +943,7 @@ static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
char c; char c;
int n; int n;
do { do {
if (SDL_RWread(src, &c, 1, 1) <= 0) { if (SDL_ReadIO(src, &c, 1) <= 0) {
error = "Premature end of data"; error = "Premature end of data";
return NULL; return NULL;
} }
@@ -960,7 +960,7 @@ static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
} }
linebuf = linebufnew; linebuf = linebufnew;
} }
if (SDL_RWread(src, linebuf, len - 1, 1) <= 0) { if (SDL_ReadIO(src, linebuf, len - 1) <= 0) {
error = "Premature end of data"; error = "Premature end of data";
return NULL; return NULL;
} }
@@ -980,7 +980,7 @@ static const char *get_next_line(const char ***lines, SDL_RWops *src, int len)
} }
linebuf = linebufnew; linebuf = linebufnew;
} }
if (SDL_RWread(src, linebuf + n, 1, 1) <= 0) { if (SDL_ReadIO(src, linebuf + n, 1) <= 0) {
error = "Premature end of data"; error = "Premature end of data";
return NULL; return NULL;
} }
@@ -1005,7 +1005,7 @@ do { \
} while (0) } while (0)
/* read XPM from either array or RWops */ /* read XPM from either array or RWops */
static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src) static SDL_Surface *load_xpm(const char **xpm, SDL_IOStream *src)
{ {
Sint64 start = 0; Sint64 start = 0;
SDL_Surface *image = NULL; SDL_Surface *image = NULL;
@@ -1027,7 +1027,7 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
buflen = 0; buflen = 0;
if (src) if (src)
start = SDL_RWtell(src); start = SDL_TellIO(src);
if (xpm) if (xpm)
xpmlines = &xpm; xpmlines = &xpm;
@@ -1065,14 +1065,15 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
/* Create the new surface */ /* Create the new surface */
if (ncolors <= 256) { if (ncolors <= 256) {
indexed = 1; indexed = 1;
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8, image = SDL_CreateSurface(w, h,
0, 0, 0, 0); SDL_PIXELFORMAT_INDEX8);
im_colors = image->format->palette->colors; SDL_Palette *palette = SDL_CreateSurfacePalette(image);
image->format->palette->ncolors = ncolors; im_colors = palette->colors;
palette->ncolors = ncolors;
} else { } else {
indexed = 0; indexed = 0;
image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, image = SDL_CreateSurface(w, h,
0xff0000, 0x00ff00, 0x0000ff, 0); SDL_GetPixelFormatForMasks(32, 0xff0000, 0x00ff00, 0x0000ff, 0));
} }
if (!image) { if (!image) {
/* Hmm, some SDL error (out of memory?) */ /* Hmm, some SDL error (out of memory?) */
@@ -1128,7 +1129,7 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
add_colorhash(colors, nextkey, cpp, pixel); add_colorhash(colors, nextkey, cpp, pixel);
nextkey += cpp; nextkey += cpp;
if (rgb == 0xffffffff) if (rgb == 0xffffffff)
SDL_SetColorKey(image, SDL_TRUE, pixel); SDL_SetSurfaceColorKey(image, true, pixel);
break; break;
} }
} }
@@ -1164,9 +1165,9 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src)
done: done:
if (error) { if (error) {
if ( src ) if ( src )
SDL_RWseek(src, start, RW_SEEK_SET); SDL_SeekIO(src, start, SDL_IO_SEEK_SET);
if ( image ) { if ( image ) {
SDL_FreeSurface(image); SDL_DestroySurface(image);
image = NULL; image = NULL;
} }
IMG_SetError("%s", error); IMG_SetError("%s", error);
@@ -1180,7 +1181,7 @@ done:
} }
/* Load a XPM type image from an RWops datasource */ /* Load a XPM type image from an RWops datasource */
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src) SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src)
{ {
if ( !src ) { if ( !src ) {
/* The error message has been set in SDL_RWFromFile */ /* The error message has been set in SDL_RWFromFile */
@@ -1203,14 +1204,14 @@ SDL_Surface *IMG_ReadXPMFromArray(const char **xpm)
#else /* not LOAD_XPM */ #else /* not LOAD_XPM */
/* See if an image is contained in a data source */ /* See if an image is contained in a data source */
int IMG_isXPM(SDL_RWops *src) int IMG_isXPM(SDL_IOStream *src)
{ {
return(0); return(0);
} }
/* Load a XPM type image from an SDL datasource */ /* Load a XPM type image from an SDL datasource */
SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src) SDL_Surface *IMG_LoadXPM_RW(SDL_IOStream *src)
{ {
return(NULL); return(NULL);
} }
+2 -2
View File
@@ -27,10 +27,10 @@
#ifdef HAVE_SDL #ifdef HAVE_SDL
#include "SDL.h" #include <SDL3/SDL.h>
#ifndef NOLOADSO #ifndef NOLOADSO
#include "SDL_loadso.h" #include <SDL3/SDL_loadso.h>
#endif #endif
#define _CREATE_DLL_ // necessary for Unix AND Windows #define _CREATE_DLL_ // necessary for Unix AND Windows
+1 -1
View File
@@ -36,7 +36,7 @@
#ifdef HAVE_SDL #ifdef HAVE_SDL
#ifdef HAVE_TTF #ifdef HAVE_TTF
#include "SDL.h" #include <SDL3/SDL.h>
#include "i_ttf.h" #include "i_ttf.h"
#endif #endif
+52 -50
View File
@@ -67,13 +67,15 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#ifdef HAVE_SDL #ifdef HAVE_SDL
#define _MATH_DEFINES_DEFINED #define _MATH_DEFINES_DEFINED
#include "SDL.h" #include <SDL3/SDL.h>
#include <SDL3/SDL_joystick.h>
#include <SDL3/SDL_gamepad.h>
#ifdef HAVE_TTF #ifdef HAVE_TTF
#include "i_ttf.h" #include "i_ttf.h"
#endif #endif
#include "SDL_cpuinfo.h" #include <SDL3/SDL_cpuinfo.h>
#define HAVE_SDLCPUINFO #define HAVE_SDLCPUINFO
#if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (__HAIKU__)) #if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (__HAIKU__))
@@ -213,13 +215,13 @@ static char returnWadPath[256];
#include "../byteptr.h" #include "../byteptr.h"
#endif #endif
SDL_bool consolevent = SDL_FALSE; bool consolevent = false;
SDL_bool framebuffer = SDL_FALSE; bool framebuffer = false;
UINT8 keyboard_started = false; UINT8 keyboard_started = false;
#ifdef HAVE_TERMIOS #ifdef HAVE_TERMIOS
// TERMIOS console code from Quake3: thank you! // TERMIOS console code from Quake3: thank you!
SDL_bool stdin_active = SDL_TRUE; bool stdin_active = true;
typedef struct typedef struct
{ {
@@ -282,7 +284,7 @@ static void I_ShutdownConsole(void)
if (consolevent) if (consolevent)
{ {
I_OutputMsg("Shutdown tty console\n"); I_OutputMsg("Shutdown tty console\n");
consolevent = SDL_FALSE; consolevent = false;
tcsetattr(STDIN_FILENO, TCSADRAIN, &tty_tc); tcsetattr(STDIN_FILENO, TCSADRAIN, &tty_tc);
} }
} }
@@ -297,11 +299,11 @@ static void I_StartupConsole(void)
signal(SIGTTIN, SIG_IGN); signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN); signal(SIGTTOU, SIG_IGN);
consolevent = static_cast<SDL_bool>(!M_CheckParm("-noconsole")); consolevent = static_cast<bool>(!M_CheckParm("-noconsole"));
framebuffer = static_cast<SDL_bool>( M_CheckParm("-framebuffer")); framebuffer = static_cast<bool>( M_CheckParm("-framebuffer"));
if (framebuffer) if (framebuffer)
consolevent = SDL_FALSE; consolevent = false;
if (!consolevent) if (!consolevent)
return; return;
@@ -309,7 +311,7 @@ static void I_StartupConsole(void)
if (isatty(STDIN_FILENO)!=1) if (isatty(STDIN_FILENO)!=1)
{ {
I_OutputMsg("stdin is not a tty, tty console mode failed\n"); I_OutputMsg("stdin is not a tty, tty console mode failed\n");
consolevent = SDL_FALSE; consolevent = false;
return; return;
} }
@@ -511,7 +513,7 @@ static void I_StartupConsole(void)
if (gotConsole) if (gotConsole)
{ {
SetConsoleTitleA("SRB2Kart Console"); SetConsoleTitleA("SRB2Kart Console");
consolevent = SDL_TRUE; consolevent = true;
} }
//Let get the real console HANDLE, because Mingw's Bash is bad! //Let get the real console HANDLE, because Mingw's Bash is bad!
@@ -544,7 +546,7 @@ static inline void I_StartupConsole(void)
framebuffer = M_CheckParm("-framebuffer"); framebuffer = M_CheckParm("-framebuffer");
if (framebuffer) if (framebuffer)
consolevent = SDL_FALSE; consolevent = false;
} }
static inline void I_ShutdownConsole(void){} static inline void I_ShutdownConsole(void){}
#endif #endif
@@ -693,7 +695,7 @@ void I_OutputMsg(const char *fmt, ...)
// //
// I_GetKey // I_GetKey
// //
INT32 I_GetKey (void) INT32 I_GetKey(void)
{ {
// Warning: I_GetKey empties the event queue till next keypress // Warning: I_GetKey empties the event queue till next keypress
event_t *ev; event_t *ev;
@@ -723,7 +725,7 @@ static void JoyReset(SDLJoyInfo_t *JoySet)
{ {
if (JoySet->dev) if (JoySet->dev)
{ {
SDL_GameControllerClose(JoySet->dev); SDL_CloseGamepad(JoySet->dev);
} }
JoySet->dev = NULL; JoySet->dev = NULL;
@@ -765,15 +767,15 @@ void I_JoyScale4(void)
} }
// Cheat to get the device index for a joystick handle // Cheat to get the device index for a joystick handle
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev) INT32 I_GetJoystickDeviceIndex(SDL_Gamepad *dev)
{ {
SDL_Joystick *joystick = NULL; SDL_Joystick *joystick = NULL;
joystick = SDL_GameControllerGetJoystick(dev); joystick = SDL_GetGamepadJoystick(dev);
if (joystick) if (joystick)
{ {
return SDL_JoystickInstanceID(joystick); return SDL_GetJoystickID(joystick);
} }
return -1; return -1;
@@ -883,7 +885,7 @@ void I_ShutdownJoystick(UINT8 index)
*/ */
static int joy_open(int playerIndex, int joyIndex) static int joy_open(int playerIndex, int joyIndex)
{ {
SDL_GameController *newdev = NULL; SDL_Gamepad *newdev = NULL;
int num_joy = 0; int num_joy = 0;
if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0)
@@ -892,7 +894,7 @@ static int joy_open(int playerIndex, int joyIndex)
return -1; return -1;
} }
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0) if (SDL_WasInit(SDL_INIT_GAMEPAD) == 0)
{ {
CONS_Printf(M_GetText("Game Controller subsystem not started\n")); CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
return -1; return -1;
@@ -901,7 +903,7 @@ static int joy_open(int playerIndex, int joyIndex)
if (joyIndex <= 0) if (joyIndex <= 0)
return -1; return -1;
num_joy = SDL_NumJoysticks(); SDL_GetJoysticks(&num_joy);
if (num_joy == 0) if (num_joy == 0)
{ {
@@ -909,7 +911,7 @@ static int joy_open(int playerIndex, int joyIndex)
return -1; return -1;
} }
newdev = SDL_GameControllerOpen(joyIndex-1); newdev = SDL_OpenGamepad(joyIndex-1);
// Handle the edge case where the device <-> joystick index assignment can change due to hotplugging // Handle the edge case where the device <-> joystick index assignment can change due to hotplugging
// This indexing is SDL's responsibility and there's not much we can do about it. // This indexing is SDL's responsibility and there's not much we can do about it.
@@ -924,8 +926,8 @@ static int joy_open(int playerIndex, int joyIndex)
if (JoyInfo[playerIndex].dev) if (JoyInfo[playerIndex].dev)
{ {
if (JoyInfo[playerIndex].dev == newdev // same device, nothing to do if (JoyInfo[playerIndex].dev == newdev // same device, nothing to do
|| (newdev == NULL && SDL_GameControllerGetAttached(JoyInfo[playerIndex].dev))) // we failed, but already have a working device || (newdev == NULL && SDL_GamepadConnected(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
return SDL_CONTROLLER_AXIS_MAX; return SDL_GAMEPAD_AXIS_COUNT;
// Else, we're changing devices, so send neutral joy events // Else, we're changing devices, so send neutral joy events
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n"); CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
@@ -942,13 +944,13 @@ static int joy_open(int playerIndex, int joyIndex)
} }
else else
{ {
CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev)); CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GetGamepadName(JoyInfo[playerIndex].dev));
JoyInfo[playerIndex].axises = SDL_CONTROLLER_AXIS_MAX; JoyInfo[playerIndex].axises = SDL_GAMEPAD_AXIS_COUNT;
if (JoyInfo[playerIndex].axises > JOYAXISSET*2) if (JoyInfo[playerIndex].axises > JOYAXISSET*2)
JoyInfo[playerIndex].axises = JOYAXISSET*2; JoyInfo[playerIndex].axises = JOYAXISSET*2;
JoyInfo[playerIndex].buttons = SDL_CONTROLLER_BUTTON_MAX ; // dpad is 4 buttons JoyInfo[playerIndex].buttons = SDL_GAMEPAD_BUTTON_COUNT; // dpad is 4 buttons
if (JoyInfo[playerIndex].buttons > JOYBUTTONS) if (JoyInfo[playerIndex].buttons > JOYBUTTONS)
JoyInfo[playerIndex].buttons = JOYBUTTONS; JoyInfo[playerIndex].buttons = JOYBUTTONS;
@@ -968,7 +970,7 @@ static int joy_open(int playerIndex, int joyIndex)
void I_InitJoystick(UINT8 index) void I_InitJoystick(UINT8 index)
{ {
UINT8 i; UINT8 i;
SDL_GameController *newcontroller = NULL; SDL_Gamepad *newcontroller = NULL;
// not sure if this is the best place to put this // not sure if this is the best place to put this
SDL_SetHint(SDL_HINT_AUTO_UPDATE_SENSORS, "0"); SDL_SetHint(SDL_HINT_AUTO_UPDATE_SENSORS, "0");
@@ -986,15 +988,16 @@ void I_InitJoystick(UINT8 index)
{ {
CONS_Printf("I_InitJoystick()...\n"); CONS_Printf("I_InitJoystick()...\n");
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) if (!SDL_InitSubSystem(SDL_INIT_JOYSTICK))
{ {
CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError()); CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError());
return; return;
} }
} }
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
if (SDL_WasInit(SDL_INIT_GAMEPAD) == 0)
{ {
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1) if (!SDL_InitSubSystem(SDL_INIT_GAMEPAD))
{ {
CONS_Printf(M_GetText("Couldn't initialize gamepads: %s\n"), SDL_GetError()); CONS_Printf(M_GetText("Couldn't initialize gamepads: %s\n"), SDL_GetError());
return; return;
@@ -1007,7 +1010,7 @@ void I_InitJoystick(UINT8 index)
JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0; JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0;
if (cv_usejoystick[index].value) if (cv_usejoystick[index].value)
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1); newcontroller = SDL_OpenGamepad(cv_usejoystick[index].value-1);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
@@ -1047,7 +1050,7 @@ void I_InitJoystick(UINT8 index)
if (i == MAXSPLITSCREENPLAYERS) if (i == MAXSPLITSCREENPLAYERS)
{ {
// Joystick didn't end up being used // Joystick didn't end up being used
SDL_GameControllerClose(newcontroller); SDL_CloseGamepad(newcontroller);
} }
} }
@@ -1082,10 +1085,10 @@ static void I_ShutdownInput(void)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
I_ShutdownJoystick(i); I_ShutdownJoystick(i);
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == SDL_INIT_GAMECONTROLLER) if (SDL_WasInit(SDL_INIT_GAMEPAD) == SDL_INIT_GAMEPAD)
{ {
CONS_Printf("Shutting down gamecontroller system\n"); CONS_Printf("Shutting down gamecontroller system\n");
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); SDL_QuitSubSystem(SDL_INIT_GAMEPAD);
I_OutputMsg("I_Joystick: SDL's Game Controller system has been shutdown\n"); I_OutputMsg("I_Joystick: SDL's Game Controller system has been shutdown\n");
} }
@@ -1102,7 +1105,9 @@ INT32 I_NumJoys(void)
INT32 numjoy = 0; INT32 numjoy = 0;
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
numjoy = SDL_NumJoysticks(); {
SDL_GetJoysticks(&numjoy);
}
return numjoy; return numjoy;
} }
@@ -1117,7 +1122,7 @@ const char *I_GetJoyName(INT32 joyindex)
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
{ {
tempname = SDL_JoystickNameForIndex(joyindex); tempname = SDL_GetJoystickNameForID(joyindex);
if (tempname) if (tempname)
{ {
@@ -1137,14 +1142,14 @@ void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength,
(void)high_strength; (void)high_strength;
(void)duration; (void)duration;
#else #else
SDL_GameController *controller = JoyInfo[playernum].dev; SDL_Gamepad *controller = JoyInfo[playernum].dev;
if (controller == NULL) if (controller == NULL)
{ {
return; return;
} }
SDL_GameControllerRumble(controller, low_strength, high_strength, duration); SDL_RumbleGamepad(controller, low_strength, high_strength, duration);
#endif #endif
} }
@@ -1156,14 +1161,14 @@ void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 b
(void)green; (void)green;
(void)blue; (void)blue;
#else #else
SDL_GameController *controller = JoyInfo[playernum].dev; SDL_Gamepad *controller = JoyInfo[playernum].dev;
if (controller == NULL) if (controller == NULL)
{ {
return; return;
} }
SDL_GameControllerSetLED(controller, red, green, blue); SDL_SetGamepadLED(controller, red, green, blue);
#endif #endif
} }
@@ -1816,10 +1821,7 @@ static void I_Fork(void)
INT32 I_StartupSystem(void) INT32 I_StartupSystem(void)
{ {
SDL_version SDLcompiled; int SDLlinked = SDL_GetVersion();
SDL_version SDLlinked;
SDL_VERSION(&SDLcompiled)
SDL_GetVersion(&SDLlinked);
I_StartupConsole(); I_StartupConsole();
#ifdef NEWSIGNALHANDLER #ifdef NEWSIGNALHANDLER
// This is useful when debugging. It lets GDB attach to // This is useful when debugging. It lets GDB attach to
@@ -1835,15 +1837,15 @@ INT32 I_StartupSystem(void)
#endif #endif
I_RegisterSignals(); I_RegisterSignals();
I_OutputMsg("Compiled for SDL version: %d.%d.%d\n", I_OutputMsg("Compiled for SDL version: %d.%d.%d\n",
SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch); SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
I_OutputMsg("Linked with SDL version: %d.%d.%d\n", I_OutputMsg("Linked with SDL version: %d.%d.%d\n",
SDLlinked.major, SDLlinked.minor, SDLlinked.patch); SDL_VERSIONNUM_MAJOR(SDLlinked), SDL_VERSIONNUM_MINOR(SDLlinked), SDL_VERSIONNUM_MICRO(SDLlinked));
#if (SDL_VERSION_ATLEAST(2, 0, 18)) #if (SDL_VERSION_ATLEAST(2, 0, 18))
SDL_SetHint(SDL_HINT_APP_NAME, "SRB2Kart Saturn"); SDL_SetHint(SDL_HINT_APP_NAME, "SRB2Kart Saturn");
#endif #endif
if (SDL_Init(0) < 0) if (!SDL_Init(0))
I_Error("SRB2: SDL System Error: %s", SDL_GetError()); //Alam: Oh no.... I_Error("SRB2: SDL System Error: %s", SDL_GetError()); //Alam: Oh no....
#ifndef NOMUMBLE #ifndef NOMUMBLE
I_SetupMumble(); I_SetupMumble();
@@ -1856,12 +1858,12 @@ INT32 I_StartupSystem(void)
// //
FUNCNORETURN void ATTRNORETURN I_Quit(void) FUNCNORETURN void ATTRNORETURN I_Quit(void)
{ {
static SDL_bool quiting = SDL_FALSE; static bool quiting = false;
/* prevent recursive I_Quit() */ /* prevent recursive I_Quit() */
if (quiting) goto death; if (quiting) goto death;
SDL_ShowCursor(SDL_TRUE); SDL_ShowCursor();
quiting = SDL_FALSE; quiting = false;
I_ShutdownConsole(); I_ShutdownConsole();
M_SaveConfig(NULL); //save game config, cvars.. M_SaveConfig(NULL); //save game config, cvars..
D_SaveBan(); // save the ban list D_SaveBan(); // save the ban list
+25 -30
View File
@@ -12,7 +12,7 @@
#include "../doomdef.h" #include "../doomdef.h"
#include "../i_threads.h" #include "../i_threads.h"
#include <SDL.h> #include <SDL3/SDL.h>
typedef void * (*Create_fn)(void); typedef void * (*Create_fn)(void);
@@ -45,7 +45,7 @@ static I_mutex i_thread_pool_mutex;
static I_mutex i_mutex_pool_mutex; static I_mutex i_mutex_pool_mutex;
static I_mutex i_cond_pool_mutex; static I_mutex i_cond_pool_mutex;
static SDL_atomic_t i_threads_running = {1}; static SDL_AtomicInt i_threads_running = {1};
static Link static Link
Insert_link ( Insert_link (
@@ -103,13 +103,13 @@ Identity (
){ ){
void * id; void * id;
id = SDL_AtomicGetPtr(anchor); id = SDL_GetAtomicPointer(anchor);
if (! id) if (! id)
{ {
I_lock_mutex(&pool_mutex); I_lock_mutex(&pool_mutex);
{ {
id = SDL_AtomicGetPtr(anchor); id = SDL_GetAtomicPointer(anchor);
if (! id) if (! id)
{ {
@@ -120,7 +120,7 @@ Identity (
Insert_link(pool_anchor, New_link(id)); Insert_link(pool_anchor, New_link(id));
SDL_AtomicSetPtr(anchor, id); SDL_SetAtomicPointer(anchor, id);
} }
} }
I_unlock_mutex(pool_mutex); I_unlock_mutex(pool_mutex);
@@ -139,11 +139,11 @@ Worker (
(*th->entry)(th->userdata); (*th->entry)(th->userdata);
if (SDL_AtomicGet(&i_threads_running)) if (SDL_GetAtomicInt(&i_threads_running))
{ {
I_lock_mutex(&i_thread_pool_mutex); I_lock_mutex(&i_thread_pool_mutex);
{ {
if (SDL_AtomicGet(&i_threads_running)) if (SDL_GetAtomicInt(&i_threads_running))
{ {
SDL_DetachThread(th->thread); SDL_DetachThread(th->thread);
Free_link(&i_thread_pool, link); Free_link(&i_thread_pool, link);
@@ -176,7 +176,7 @@ I_spawn_thread (
{ {
link = Insert_link(&i_thread_pool, New_link(th)); link = Insert_link(&i_thread_pool, New_link(th));
if (SDL_AtomicGet(&i_threads_running)) if (SDL_GetAtomicInt(&i_threads_running))
{ {
th->thread = SDL_CreateThread( th->thread = SDL_CreateThread(
(SDL_ThreadFunction)Worker, (SDL_ThreadFunction)Worker,
@@ -194,7 +194,7 @@ I_spawn_thread (
int int
I_thread_is_stopped (void) I_thread_is_stopped (void)
{ {
return ( ! SDL_AtomicGet(&i_threads_running) ); return ( ! SDL_GetAtomicInt(&i_threads_running) );
} }
void void
@@ -220,13 +220,13 @@ I_stop_threads (void)
Link next; Link next;
Thread th; Thread th;
SDL_mutex * mutex; SDL_Mutex * mutex;
SDL_cond * cond; SDL_Condition * cond;
if (i_threads_running.value) if (i_threads_running.value)
{ {
/* rely on the good will of thread-san */ /* rely on the good will of thread-san */
SDL_AtomicSet(&i_threads_running, 0); SDL_SetAtomicInt(&i_threads_running, 0);
I_lock_mutex(&i_thread_pool_mutex); I_lock_mutex(&i_thread_pool_mutex);
{ {
@@ -267,7 +267,7 @@ I_stop_threads (void)
next = link->next; next = link->next;
cond = link->data; cond = link->data;
SDL_DestroyCond(cond); SDL_DestroyCondition(cond);
free(link); free(link);
} }
@@ -282,7 +282,7 @@ void
I_lock_mutex ( I_lock_mutex (
I_mutex * anchor I_mutex * anchor
){ ){
SDL_mutex * mutex; SDL_Mutex * mutex;
mutex = Identity( mutex = Identity(
&i_mutex_pool, &i_mutex_pool,
@@ -291,16 +291,14 @@ I_lock_mutex (
(Create_fn)SDL_CreateMutex (Create_fn)SDL_CreateMutex
); );
if (SDL_LockMutex(mutex) == -1) SDL_LockMutex(mutex);
abort();
} }
void void
I_unlock_mutex ( I_unlock_mutex (
I_mutex id I_mutex id
){ ){
if (SDL_UnlockMutex(id) == -1) SDL_UnlockMutex(id);
abort();
} }
void void
@@ -308,49 +306,46 @@ I_hold_cond (
I_cond * cond_anchor, I_cond * cond_anchor,
I_mutex mutex_id I_mutex mutex_id
){ ){
SDL_cond * cond; SDL_Condition * cond;
cond = Identity( cond = Identity(
&i_cond_pool, &i_cond_pool,
i_cond_pool_mutex, i_cond_pool_mutex,
cond_anchor, cond_anchor,
(Create_fn)SDL_CreateCond (Create_fn)SDL_CreateCondition
); );
if (SDL_CondWait(cond, mutex_id) == -1) SDL_WaitCondition(cond, mutex_id);
abort();
} }
void void
I_wake_one_cond ( I_wake_one_cond (
I_cond * anchor I_cond * anchor
){ ){
SDL_cond * cond; SDL_Condition * cond;
cond = Identity( cond = Identity(
&i_cond_pool, &i_cond_pool,
i_cond_pool_mutex, i_cond_pool_mutex,
anchor, anchor,
(Create_fn)SDL_CreateCond (Create_fn)SDL_CreateCondition
); );
if (SDL_CondSignal(cond) == -1) SDL_SignalCondition(cond);
abort();
} }
void void
I_wake_all_cond ( I_wake_all_cond (
I_cond * anchor I_cond * anchor
){ ){
SDL_cond * cond; SDL_Condition * cond;
cond = Identity( cond = Identity(
&i_cond_pool, &i_cond_pool,
i_cond_pool_mutex, i_cond_pool_mutex,
anchor, anchor,
(Create_fn)SDL_CreateCond (Create_fn)SDL_CreateCondition
); );
if (SDL_CondBroadcast(cond) == -1) SDL_BroadcastCondition(cond);
abort();
} }
+3 -3
View File
@@ -16,7 +16,7 @@
/// \file /// \file
/// \brief SDL_ttf interface code. Necessary for platforms with no framebuffer console systems. /// \brief SDL_ttf interface code. Necessary for platforms with no framebuffer console systems.
#if defined(HAVE_SDL) && defined(HAVE_TTF) #if defined (HAVE_SDL) && defined (HAVE_TTF)
#include "SDL.h" #include "SDL.h"
#include "SDL_ttf.h" #include "SDL_ttf.h"
#include "../doomdef.h" #include "../doomdef.h"
@@ -236,14 +236,14 @@ void I_StartupTTF(UINT32 fontpointsize, Uint32 initflags, Uint32 vidmodeflags)
// what's the point of trying to display an error? // what's the point of trying to display an error?
// SDL_ttf is not started, can't display anything to screen (presumably)... // SDL_ttf is not started, can't display anything to screen (presumably)...
if (SDL_InitSubSystem(initflags) < 0) if (!SDL_InitSubSystem(initflags))
I_Error("Couldn't initialize SDL: %s\n", SDL_GetError()); I_Error("Couldn't initialize SDL: %s\n", SDL_GetError());
TTFSurface = SDL_SetVideoMode(res.width, res.height, bitsperpixel, vidmodeflags); TTFSurface = SDL_SetVideoMode(res.width, res.height, bitsperpixel, vidmodeflags);
if (!TTFSurface) if (!TTFSurface)
I_Error("Couldn't set SDL Video resolution: %s\n", SDL_GetError()); I_Error("Couldn't set SDL Video resolution: %s\n", SDL_GetError());
if (TTF_Init() < 0) if (!TTF_Init())
I_Error("Couldn't start SDL_ttf: %s\n", TTF_GetError()); I_Error("Couldn't start SDL_ttf: %s\n", TTF_GetError());
// look for default font in many directories // look for default font in many directories
+235 -229
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -20,7 +20,7 @@
#ifdef HAVE_SDL #ifdef HAVE_SDL
#define _MATH_DEFINES_DEFINED #define _MATH_DEFINES_DEFINED
#include "SDL.h" #include <SDL3/SDL.h>
#include "sdlmain.h" #include "sdlmain.h"
@@ -96,7 +96,7 @@ boolean VID_LoadOGLAPI(void)
if (M_CheckParm("-OGLlib") && M_IsNextParm()) if (M_CheckParm("-OGLlib") && M_IsNextParm())
OGLLibname = M_GetNextParm(); OGLLibname = M_GetNextParm();
if (SDL_GL_LoadLibrary(OGLLibname) != 0) if (!SDL_GL_LoadLibrary(OGLLibname))
{ {
CONS_Alert(CONS_ERROR, "Could not load OpenGL Library: %s\n", SDL_GetError()); CONS_Alert(CONS_ERROR, "Could not load OpenGL Library: %s\n", SDL_GetError());
if (!M_CheckParm("-OGLlib")) if (!M_CheckParm("-OGLlib"))
+1962
View File
File diff suppressed because it is too large. Load diff
+7 -5
View File
@@ -23,14 +23,16 @@
extern "C" { extern "C" {
#endif #endif
extern SDL_bool consolevent; extern bool consolevent;
extern SDL_bool framebuffer; extern bool framebuffer;
#include "../m_fixed.h" #include "../m_fixed.h"
// SDL2 stub macro // SDL2 stub macro
#define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__) #define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
#include <SDL3/SDL_gamepad.h>
// So m_menu knows whether to store cv_usejoystick value or string // So m_menu knows whether to store cv_usejoystick value or string
#define JOYSTICK_HOTPLUG #define JOYSTICK_HOTPLUG
@@ -41,9 +43,9 @@ extern SDL_bool framebuffer;
typedef struct SDLJoyInfo_s typedef struct SDLJoyInfo_s
{ {
/// Controller handle /// Controller handle
SDL_GameController *dev; SDL_Gamepad *dev;
/// Controller index /// Controller index
INT32 id; SDL_JoystickID id;
/// number of old joystick /// number of old joystick
int oldjoy; int oldjoy;
/// number of axies /// number of axies
@@ -71,7 +73,7 @@ extern SDLJoyInfo_t JoyInfo[4]; //MAXSPLITSCREENPLAYERS
void I_ShutdownJoystick(UINT8 index); void I_ShutdownJoystick(UINT8 index);
// Cheat to get the device index for a game controller handle // Cheat to get the device index for a game controller handle
INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev); INT32 I_GetJoystickDeviceIndex(SDL_Gamepad *dev);
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination // Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
void I_UpdateJoystickDeviceIndex(UINT8 player); void I_UpdateJoystickDeviceIndex(UINT8 player);