From d25455736af2d9826272745d075d08ae58fa3ccd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 12 Feb 2016 01:21:29 +0100 Subject: [PATCH 1/7] - store floating point parameters for DECORATE properties as doubles. --- src/thingdef/thingdef.h | 9 ++++++--- src/thingdef/thingdef_parse.cpp | 2 +- src/thingdef/thingdef_properties.cpp | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index d8c13174a..aa6a54445 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -258,7 +258,7 @@ enum EDefinitionType union FPropParam { int i; - float f; + double d; const char *s; FxExpression *exp; }; @@ -317,10 +317,13 @@ int MatchString (const char *in, const char **strings); int var = params[(no)+1].i; #define PROP_FLOAT_PARM(var, no) \ - float var = params[(no)+1].f; + float var = float(params[(no)+1].d); + +#define PROP_DOUBLE_PARM(var, no) \ + double var = params[(no)+1].d; #define PROP_FIXED_PARM(var, no) \ - fixed_t var = fixed_t(params[(no)+1].f * FRACUNIT); + fixed_t var = FLOAT2FIXED(params[(no)+1].d); #define PROP_COLOR_PARM(var, no) \ int var = params[(no)+1].i== 0? params[(no)+2].i : V_GetColor(NULL, params[(no)+2].s); diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index 2cd271ad5..93a139850 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -825,7 +825,7 @@ static bool ParsePropertyParams(FScanner &sc, FPropertyInfo *prop, AActor *defau case 'F': sc.MustGetFloat(); - conv.f = float(sc.Float); + conv.d = sc.Float; break; case 'Z': // an optional string. Does not allow any numerical value. diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 57de3684f..2d69c0eb8 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -2174,7 +2174,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(powerup, color, C_f, Inventory) } if (PROP_PARM_COUNT > 2) { - PROP_FLOAT_PARM(falpha, 2); + PROP_DOUBLE_PARM(falpha, 2); alpha=int(falpha*255); } else alpha = 255/3; @@ -2718,17 +2718,17 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cfs, PlayerPawn) } else if (PROP_PARM_COUNT < 4) { - PROP_FLOAT_PARM(a, 2); + PROP_DOUBLE_PARM(a, 2); - color.a = BYTE(255 * clamp(a, 0.f, 1.f)); + color.a = BYTE(255 * clamp(a, 0.f, 1.f)); defaults->DamageFade = color; } else { - PROP_FLOAT_PARM(a, 2); + PROP_DOUBLE_PARM(a, 2); PROP_STRING_PARM(type, 3); - color.a = BYTE(255 * clamp(a, 0.f, 1.f)); + color.a = BYTE(255 * clamp(a, 0.f, 1.f)); assert(info->IsKindOf(RUNTIME_CLASS(PClassPlayerPawn))); static_cast(info)->PainFlashes.Insert(type, color); } From e6328c84320e8e41edd8fb568d46c96fedff18db Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 12 Feb 2016 02:02:48 +0100 Subject: [PATCH 2/7] - enable fast floating point math in the subprojects that can benefit from it: dumb, gme and gdtoa. --- dumb/CMakeLists.txt | 4 ++++ game-music-emu/CMakeLists.txt | 5 +++++ gdtoa/CMakeLists.txt | 2 +- src/g_hexen/a_flechette.cpp | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dumb/CMakeLists.txt b/dumb/CMakeLists.txt index 97a72b42c..c8fa34bf7 100644 --- a/dumb/CMakeLists.txt +++ b/dumb/CMakeLists.txt @@ -14,6 +14,10 @@ if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE ) endif(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.5") endif() +if( MSVC ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:fast" ) +endif() + CHECK_FUNCTION_EXISTS( itoa ITOA_EXISTS ) if( NOT ITOA_EXISTS ) add_definitions( -DNEED_ITOA=1 ) diff --git a/game-music-emu/CMakeLists.txt b/game-music-emu/CMakeLists.txt index 27b065f42..f1d467bcc 100644 --- a/game-music-emu/CMakeLists.txt +++ b/game-music-emu/CMakeLists.txt @@ -29,6 +29,11 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) endif() endif() +if( MSVC ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:fast" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast" ) +endif() + # Default emulators to build (all of them! ;) if (NOT DEFINED USE_GME_AY) diff --git a/gdtoa/CMakeLists.txt b/gdtoa/CMakeLists.txt index e0a6bab29..94ab9a691 100644 --- a/gdtoa/CMakeLists.txt +++ b/gdtoa/CMakeLists.txt @@ -5,7 +5,7 @@ set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG" ) # Disable warnings for << operator precedence (4554) and # unreferenced labels (4102) from VC if( MSVC ) - set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4554 /wd4102" ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4554 /wd4102 /fp:fast" ) endif() if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index f26a6b41a..7c8afb4cf 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -332,7 +332,7 @@ int APoisonCloud::DoSpecialDamage (AActor *victim, int damage, FName damagetype) int damage = 15 + (pr_poisoncloudd()&15); if (mate) { - damage = (int)((float)damage * level.teamdamage); + damage = (int)((double)damage * level.teamdamage); } // Handle passive damage modifiers (e.g. PowerProtection) if (victim->Inventory != NULL) From b818624f5835b4823d77bf735c82406f22cb509c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 12 Feb 2016 12:51:09 +0100 Subject: [PATCH 3/7] - enabled fast math for all known non-playsim files in the CMake project. --- src/CMakeLists.txt | 195 ++++++++++++++++++++++++--------------------- 1 file changed, 105 insertions(+), 90 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8e43bcf3..47351a1f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,14 @@ if( CMAKE_SIZEOF_VOID_P MATCHES "8" ) set( X64 64 ) endif() +if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + set ( FASTMATH "-ffast-math" ) +else() + if ( MSVC ) + set ( FASTMATH "/fp:fast" ) + endif() +endif() + # You can either use "make install" on the FMOD distribution to put it # in standard system locations, or you can unpack the FMOD distribution # in the root of the zdoom tree. e.g.: @@ -101,8 +109,6 @@ if( WIN32 ) "C:/Program Files (x86)/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" # This next one is for Randy. "E:/Software/Dev/FMOD/${WIN_TYPE}/api" - # .. and this one for Graf Zahl - "D:/portable/FMOD SoundSystem 4.26/FMOD Programmers API WIN32/api" ) set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) @@ -858,6 +864,95 @@ set( NOT_COMPILED_SOURCE_FILES asm_x86_64/tmap3.s ) +set( FASTMATH_SOURCES + nodebuild.cpp + nodebuild_classify_nosse2.cpp + nodebuild_events.cpp + nodebuild_extract.cpp + nodebuild_gl.cpp + nodebuild_utility.cpp + r_swrenderer.cpp + r_3dfloors.cpp + r_bsp.cpp + r_draw.cpp + r_drawt.cpp + r_main.cpp + r_plane.cpp + r_segs.cpp + r_sky.cpp + r_things.cpp + s_advsound.cpp + s_environment.cpp + s_playlist.cpp + s_sndseq.cpp + s_sound.cpp + GuillotineBinPack.cpp + SkylineBinPack.cpp + intermission/intermission.cpp + intermission/intermission_parse.cpp + menu/colorpickermenu.cpp + menu/joystickmenu.cpp + menu/listmenu.cpp + menu/loadsavemenu.cpp + menu/menu.cpp + menu/menudef.cpp + menu/menuinput.cpp + menu/messagebox.cpp + menu/optionmenu.cpp + menu/playerdisplay.cpp + menu/playermenu.cpp + menu/readthis.cpp + menu/videomenu.cpp + oplsynth/fmopl.cpp + oplsynth/mlopl.cpp + oplsynth/mlopl_io.cpp + oplsynth/music_opldumper_mididevice.cpp + oplsynth/music_opl_mididevice.cpp + oplsynth/opl_mus_player.cpp + oplsynth/dosbox/opl.cpp + oplsynth/OPL3.cpp + oplsynth/nukedopl3.cpp + sound/fmodsound.cpp + sound/i_music.cpp + sound/i_sound.cpp + sound/mpg123_decoder.cpp + sound/music_cd.cpp + sound/music_dumb.cpp + sound/music_gme.cpp + sound/music_mus_midiout.cpp + sound/music_smf_midiout.cpp + sound/music_hmi_midiout.cpp + sound/music_xmi_midiout.cpp + sound/music_midistream.cpp + sound/music_midi_base.cpp + sound/music_midi_timidity.cpp + sound/music_mus_opl.cpp + sound/music_stream.cpp + sound/music_fluidsynth_mididevice.cpp + sound/music_softsynth_mididevice.cpp + sound/music_timidity_mididevice.cpp + sound/music_wildmidi_mididevice.cpp + sound/music_win_mididevice.cpp + sound/oalsound.cpp + sound/sndfile_decoder.cpp + sound/music_pseudo_mididevice.cpp + timidity/common.cpp + timidity/instrum.cpp + timidity/instrum_dls.cpp + timidity/instrum_font.cpp + timidity/instrum_sf2.cpp + timidity/mix.cpp + timidity/playmidi.cpp + timidity/resample.cpp + timidity/timidity.cpp + wildmidi/file_io.cpp + wildmidi/gus_pat.cpp + wildmidi/reverb.cpp + wildmidi/wildmidi_lib.cpp + wildmidi/wm_error.cpp + r_data/colormaps.cpp + r_data/r_translate.cpp +) add_executable( zdoom WIN32 MACOSX_BUNDLE ${HEADER_FILES} ${NOT_COMPILED_SOURCE_FILES} @@ -865,6 +960,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE ${ASM_SOURCES} ${SYSTEM_SOURCES} ${X86_SOURCES} + ${FASTMATH_SOURCES} x86.cpp actorptrselect.cpp am_map.cpp @@ -930,12 +1026,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE memarena.cpp md5.cpp name.cpp - nodebuild.cpp - nodebuild_classify_nosse2.cpp - nodebuild_events.cpp - nodebuild_extract.cpp - nodebuild_gl.cpp - nodebuild_utility.cpp pathexpander.cpp p_3dfloors.cpp p_3dmidtex.cpp @@ -979,23 +1069,8 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE p_xlat.cpp parsecontext.cpp po_man.cpp - portal.cpp - r_swrenderer.cpp + portal.cpp r_utility.cpp - r_3dfloors.cpp - r_bsp.cpp - r_draw.cpp - r_drawt.cpp - r_main.cpp - r_plane.cpp - r_segs.cpp - r_sky.cpp - r_things.cpp - s_advsound.cpp - s_environment.cpp - s_playlist.cpp - s_sndseq.cpp - s_sound.cpp sc_man.cpp st_stuff.cpp statistics.cpp @@ -1017,8 +1092,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE wi_stuff.cpp zstrformat.cpp zstring.cpp - GuillotineBinPack.cpp - SkylineBinPack.cpp g_doom/a_doommisc.cpp g_heretic/a_hereticmisc.cpp g_hexen/a_hexenmisc.cpp @@ -1062,30 +1135,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE g_shared/sbar_mugshot.cpp g_shared/shared_hud.cpp g_shared/shared_sbar.cpp - intermission/intermission.cpp - intermission/intermission_parse.cpp - menu/colorpickermenu.cpp - menu/joystickmenu.cpp - menu/listmenu.cpp - menu/loadsavemenu.cpp - menu/menu.cpp - menu/menudef.cpp - menu/menuinput.cpp - menu/messagebox.cpp - menu/optionmenu.cpp - menu/playerdisplay.cpp - menu/playermenu.cpp - menu/readthis.cpp - menu/videomenu.cpp - oplsynth/fmopl.cpp - oplsynth/mlopl.cpp - oplsynth/mlopl_io.cpp - oplsynth/music_opldumper_mididevice.cpp - oplsynth/music_opl_mididevice.cpp - oplsynth/opl_mus_player.cpp - oplsynth/dosbox/opl.cpp - oplsynth/OPL3.cpp - oplsynth/nukedopl3.cpp resourcefiles/ancientzip.cpp resourcefiles/file_7z.cpp resourcefiles/file_grp.cpp @@ -1097,30 +1146,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE resourcefiles/file_directory.cpp resourcefiles/resourcefile.cpp sfmt/SFMT.cpp - sound/fmodsound.cpp - sound/i_music.cpp - sound/i_sound.cpp - sound/mpg123_decoder.cpp - sound/music_cd.cpp - sound/music_dumb.cpp - sound/music_gme.cpp - sound/music_mus_midiout.cpp - sound/music_smf_midiout.cpp - sound/music_hmi_midiout.cpp - sound/music_xmi_midiout.cpp - sound/music_midistream.cpp - sound/music_midi_base.cpp - sound/music_midi_timidity.cpp - sound/music_mus_opl.cpp - sound/music_stream.cpp - sound/music_fluidsynth_mididevice.cpp - sound/music_softsynth_mididevice.cpp - sound/music_timidity_mididevice.cpp - sound/music_wildmidi_mididevice.cpp - sound/music_win_mididevice.cpp - sound/oalsound.cpp - sound/sndfile_decoder.cpp - sound/music_pseudo_mididevice.cpp textures/animations.cpp textures/anim_switches.cpp textures/automaptexture.cpp @@ -1150,20 +1175,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE thingdef/thingdef_parse.cpp thingdef/thingdef_properties.cpp thingdef/thingdef_states.cpp - timidity/common.cpp - timidity/instrum.cpp - timidity/instrum_dls.cpp - timidity/instrum_font.cpp - timidity/instrum_sf2.cpp - timidity/mix.cpp - timidity/playmidi.cpp - timidity/resample.cpp - timidity/timidity.cpp - wildmidi/file_io.cpp - wildmidi/gus_pat.cpp - wildmidi/reverb.cpp - wildmidi/wildmidi_lib.cpp - wildmidi/wm_error.cpp xlat/parse_xlat.cpp fragglescript/t_fspic.cpp fragglescript/t_func.cpp @@ -1175,12 +1186,10 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE fragglescript/t_spec.cpp fragglescript/t_variable.cpp fragglescript/t_cmd.cpp - r_data/colormaps.cpp r_data/sprites.cpp r_data/voxels.cpp r_data/renderstyle.cpp r_data/r_interpolate.cpp - r_data/r_translate.cpp zscript/ast.cpp zscript/vmbuilder.cpp zscript/vmdisasm.cpp @@ -1192,9 +1201,14 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE zzautozend.cpp ) +set_source_files_properties( ${FASTMATH_SOURCES} PROPERTIES COMPILE_FLAGS ${FASTMATH} ) set_source_files_properties( xlat/parse_xlat.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c" ) set_source_files_properties( sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" ) set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE ) +if ( WIN32 ) + set_source_files_properties( win32/fb_d3d9.cpp win32/fb_d3d9_wipe.cpp PROPERTIES COMPILE_FLAGS ${FASTMATH} ) +endif() + if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS") # [BL] Solaris requires these to be explicitly linked. @@ -1214,6 +1228,7 @@ include_directories( . textures thingdef timidity + wildmidi xlat zscript ../gdtoa From f7e27032dc7693f2737f618b49d2d6efce043535 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 12 Feb 2016 18:55:18 +0100 Subject: [PATCH 4/7] - fixed: The default vertical spread for the BFG tracers was set to 32*FRACUNIT instead of 32*ANGLE_1. --- src/g_doom/a_doomweaps.cpp | 2 +- src/vectors.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index cacffd6ca..73fda96b3 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -636,7 +636,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) PARAM_INT_OPT (damagecnt) { damagecnt = 15; } PARAM_ANGLE_OPT (angle) { angle = ANGLE_90; } PARAM_FIXED_OPT (distance) { distance = 16*64*FRACUNIT; } - PARAM_ANGLE_OPT (vrange) { vrange = 32*FRACUNIT; } + PARAM_ANGLE_OPT (vrange) { vrange = 32*ANGLE_1; } PARAM_INT_OPT (defdamage) { defdamage = 0; } int i; diff --git a/src/vectors.h b/src/vectors.h index c1bcf74b9..466e8cd4e 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -1230,6 +1230,6 @@ typedef TVector2 FVector2; typedef TVector3 FVector3; typedef TRotator FRotator; typedef TMatrix3x3 FMatrix3x3; -typedef TAngle FAngle; +//typedef TAngle FAngle; #endif From 01bed0527539c3d1cc97061aef19667ae41e0c1d Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 12 Feb 2016 16:27:47 -0600 Subject: [PATCH 5/7] Do not use fast math for the node builder - The node builder generates data used by the playsim, so should be as consistant as we can manage across compilers and architectures. --- src/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 47351a1f7..6b5f66a3e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -865,12 +865,6 @@ set( NOT_COMPILED_SOURCE_FILES ) set( FASTMATH_SOURCES - nodebuild.cpp - nodebuild_classify_nosse2.cpp - nodebuild_events.cpp - nodebuild_extract.cpp - nodebuild_gl.cpp - nodebuild_utility.cpp r_swrenderer.cpp r_3dfloors.cpp r_bsp.cpp @@ -1026,6 +1020,12 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE memarena.cpp md5.cpp name.cpp + nodebuild.cpp + nodebuild_classify_nosse2.cpp + nodebuild_events.cpp + nodebuild_extract.cpp + nodebuild_gl.cpp + nodebuild_utility.cpp pathexpander.cpp p_3dfloors.cpp p_3dmidtex.cpp From ce8b2974a3f93ec66995442329765084306b53f2 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 13 Feb 2016 11:09:37 +0200 Subject: [PATCH 6/7] Handle inability of OpenAL implementation to return number of available sources OpenAL specification doesn't require alcGetIntegerv() to return meaningful values for ALC_MONO_SOURCES and ALC_MONO_SOURCES. At least Apple's OpenAL implementation returns zeroes, although it can generate reasonable number of sources. --- src/sound/oalsound.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 1eec34c1b..736893de7 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -781,7 +781,20 @@ OpenALSoundRenderer::OpenALSoundRenderer() alcGetIntegerv(Device, ALC_MONO_SOURCES, 1, &numMono); alcGetIntegerv(Device, ALC_STEREO_SOURCES, 1, &numStereo); - Sources.Resize(MIN(MAX(*snd_channels, 2), numMono+numStereo)); + // OpenAL specification doesn't require alcGetIntegerv() to return + // meaningful values for ALC_MONO_SOURCES and ALC_MONO_SOURCES. + // At least Apple's OpenAL implementation returns zeroes, + // although it can generate reasonable number of sources. + + const int numChannels = MAX(*snd_channels, 2); + int numSources = numMono + numStereo; + + if (0 == numSources) + { + numSources = numChannels; + } + + Sources.Resize(MIN(numChannels, numSources)); for(size_t i = 0;i < Sources.Size();i++) { alGenSources(1, &Sources[i]); From 340faef1ecd9a5cf99ad2ea07a1b0c7e34007941 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 13 Feb 2016 13:37:28 +0100 Subject: [PATCH 7/7] - fixed a few 64-bit warnings. --- game-music-emu/gme/Fir_Resampler.cpp | 2 +- src/sound/mpg123_decoder.cpp | 4 ++-- src/sound/oalsound.cpp | 4 ++-- src/sound/sndfile_decoder.cpp | 2 +- src/thingdef/thingdef_data.cpp | 4 ++-- src/win32/st_start.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/game-music-emu/gme/Fir_Resampler.cpp b/game-music-emu/gme/Fir_Resampler.cpp index fa426c78c..7f0deeca3 100644 --- a/game-music-emu/gme/Fir_Resampler.cpp +++ b/game-music-emu/gme/Fir_Resampler.cpp @@ -156,7 +156,7 @@ int Fir_Resampler_::input_needed( blargg_long output_count ) const output_count -= 2; } - long input_extra = input_count - (write_pos - &buf [(width_ - 1) * stereo]); + long input_extra = (long)(input_count - (write_pos - &buf [(width_ - 1) * stereo])); if ( input_extra < 0 ) input_extra = 0; return input_extra; diff --git a/src/sound/mpg123_decoder.cpp b/src/sound/mpg123_decoder.cpp index 5b33100a5..0f0afa299 100644 --- a/src/sound/mpg123_decoder.cpp +++ b/src/sound/mpg123_decoder.cpp @@ -38,7 +38,7 @@ off_t MPG123Decoder::file_lseek(void *handle, off_t offset, int whence) ssize_t MPG123Decoder::file_read(void *handle, void *buffer, size_t bytes) { FileReader *reader = reinterpret_cast(handle)->Reader; - return reader->Read(buffer, bytes); + return (ssize_t)reader->Read(buffer, (long)bytes); } @@ -183,7 +183,7 @@ bool MPG123Decoder::seek(size_t ms_offset) if(mpg123_getformat(MPG123, &srate, &channels, &enc) == MPG123_OK) { size_t smp_offset = (size_t)((double)ms_offset / 1000. * srate); - if(mpg123_seek(MPG123, smp_offset, SEEK_SET) >= 0) + if(mpg123_seek(MPG123, (off_t)smp_offset, SEEK_SET) >= 0) { Done = false; return true; diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 1eec34c1b..768e7b7ba 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -617,7 +617,7 @@ public: SampleRate = srate; Looping = loop; - Data.Resize((size_t)(0.2 * SampleRate) * FrameSize); + Data.Resize((SampleRate / 5) * FrameSize); return true; } @@ -782,7 +782,7 @@ OpenALSoundRenderer::OpenALSoundRenderer() alcGetIntegerv(Device, ALC_STEREO_SOURCES, 1, &numStereo); Sources.Resize(MIN(MAX(*snd_channels, 2), numMono+numStereo)); - for(size_t i = 0;i < Sources.Size();i++) + for(unsigned i = 0;i < Sources.Size();i++) { alGenSources(1, &Sources[i]); if(getALError() != AL_NO_ERROR) diff --git a/src/sound/sndfile_decoder.cpp b/src/sound/sndfile_decoder.cpp index 52376a6c7..382b22ab6 100644 --- a/src/sound/sndfile_decoder.cpp +++ b/src/sound/sndfile_decoder.cpp @@ -126,7 +126,7 @@ TArray SndFileDecoder::readAll() output.Resize((unsigned)(SndInfo.frames * framesize)); size_t got = read(&output[0], output.Size()); - output.Resize(got); + output.Resize((unsigned)got); return output; } diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 82fe3a739..c972493d0 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -54,8 +54,8 @@ static TArray AFTable; //========================================================================== // [RH] Keep GCC quiet by not using offsetof on Actor types. -#define DEFINE_FLAG(prefix, name, type, variable) { prefix##_##name, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable) } -#define DEFINE_FLAG2(symbol, name, type, variable) { symbol, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable) } +#define DEFINE_FLAG(prefix, name, type, variable) { (unsigned int)prefix##_##name, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable) } +#define DEFINE_FLAG2(symbol, name, type, variable) { (unsigned int)symbol, #name, (int)(size_t)&((type*)1)->variable - 1, sizeof(((type *)0)->variable) } #define DEFINE_DEPRECATED_FLAG(name) { DEPF_##name, #name, -1, 0 } #define DEFINE_DUMMY_FLAG(name) { DEPF_UNUSED, #name, -1, 0 } diff --git a/src/win32/st_start.cpp b/src/win32/st_start.cpp index 69e00f586..b172b282f 100644 --- a/src/win32/st_start.cpp +++ b/src/win32/st_start.cpp @@ -1584,7 +1584,7 @@ void ST_Util_DrawChar (BITMAPINFO *screen, const BYTE *font, int x, int y, BYTE const BYTE fg = attrib & 0x0F; const BYTE fg_left = fg << 4; const BYTE bg = bg_left >> 4; - const BYTE color_array[4] = { bg_left | bg, attrib & 0x7F, fg_left | bg, fg_left | fg }; + const BYTE color_array[4] = { (BYTE)(bg_left | bg), (BYTE)(attrib & 0x7F), (BYTE)(fg_left | bg), (BYTE)(fg_left | fg) }; const BYTE *src = font + 1 + charnum * font[0]; int pitch = screen->bmiHeader.biWidth >> 1; BYTE *dest = ST_Util_BitsForBitmap(screen) + x*4 + y * font[0] * pitch;