mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-02-04 15:31:05 +00:00
Merge branch 'next' of https://git.magicalgirl.moe/STJr/SRB2 into banip-command
This commit is contained in:
commit
67a80ba311
43 changed files with 2038 additions and 177 deletions
|
@ -36,12 +36,15 @@ jobs:
|
|||
- v1-SRB2-APT
|
||||
- run:
|
||||
name: Install SDK
|
||||
command: apt-get -qq -y install git build-essential nasm libpng12-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 gettext ccache wget gcc-multilib upx
|
||||
command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng12-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
|
||||
- save_cache:
|
||||
key: v1-SRB2-APT
|
||||
paths:
|
||||
- /var/cache/apt/archives
|
||||
- checkout
|
||||
- run:
|
||||
name: Compile without network support
|
||||
command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1
|
||||
- run:
|
||||
name: Clean build
|
||||
command: make -C src LINUX=1 clean
|
||||
|
|
|
@ -15,6 +15,7 @@ matrix:
|
|||
- p7zip-full
|
||||
- gcc-4.4
|
||||
compiler: gcc-4.4
|
||||
env: GCC44=1
|
||||
#gcc-4.4 (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7
|
||||
- os: linux
|
||||
addons:
|
||||
|
@ -27,6 +28,7 @@ matrix:
|
|||
- p7zip-full
|
||||
- gcc-4.6
|
||||
compiler: gcc-4.6
|
||||
env: GCC46=1
|
||||
#gcc-4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4
|
||||
- os: linux
|
||||
addons:
|
||||
|
@ -39,9 +41,11 @@ matrix:
|
|||
- p7zip-full
|
||||
- gcc-4.7
|
||||
compiler: gcc-4.7
|
||||
env: GCC47=1
|
||||
#gcc-4.7
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: GCC48=1
|
||||
#gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
|
||||
- os: linux
|
||||
addons:
|
||||
|
@ -56,6 +60,7 @@ matrix:
|
|||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
env: GCC48=1
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
|
@ -70,7 +75,7 @@ matrix:
|
|||
- p7zip-full
|
||||
- gcc-7
|
||||
compiler: gcc-7
|
||||
env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough"
|
||||
env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough" GCC72=1
|
||||
#gcc-7 (Ubuntu 7.2.0-1ubuntu1~14.04) 7.2.0 20170802
|
||||
- os: linux
|
||||
addons:
|
||||
|
@ -85,7 +90,7 @@ matrix:
|
|||
- p7zip-full
|
||||
- gcc-8
|
||||
compiler: gcc-8
|
||||
env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow"
|
||||
env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow" GCC81=1
|
||||
#gcc-8 (Ubuntu 7.2.0-1ubuntu1~14.04) 8.1.0
|
||||
- os: linux
|
||||
compiler: clang
|
||||
|
|
|
@ -377,6 +377,12 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
|
|||
set(SRB2_HAVE_PNG ON)
|
||||
add_definitions(-DHAVE_PNG)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE)
|
||||
set(SRB2_PNG_SOURCES apng.c)
|
||||
set(SRB2_PNG_HEADERS apng.h)
|
||||
prepend_sources(SRB2_PNG_SOURCES)
|
||||
prepend_sources(SRB2_PNG_HEADERS)
|
||||
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS}
|
||||
${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS})
|
||||
else()
|
||||
message(WARNING "You have specified that PNG is available but it was not found. SRB2 may not compile correctly.")
|
||||
endif()
|
||||
|
|
|
@ -338,6 +338,8 @@ endif
|
|||
|
||||
LIBS+=$(PNG_LDFLAGS)
|
||||
CFLAGS+=$(PNG_CFLAGS)
|
||||
|
||||
OBJS+=$(OBJDIR)/apng.o
|
||||
endif
|
||||
|
||||
ifdef HAVE_LIBGME
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
# and other things
|
||||
#
|
||||
|
||||
ifdef GCC81
|
||||
GCC80=1
|
||||
endif
|
||||
|
||||
ifdef GCC80
|
||||
GCC72=1
|
||||
endif
|
||||
|
@ -116,6 +120,7 @@ WFLAGS+=-Wfloat-equal
|
|||
#WFLAGS+=-Wtraditional
|
||||
ifdef VCHELP
|
||||
WFLAGS+=-Wdeclaration-after-statement
|
||||
WFLAGS+=-Wno-error=declaration-after-statement
|
||||
endif
|
||||
WFLAGS+=-Wundef
|
||||
ifndef GCC295
|
||||
|
@ -189,12 +194,6 @@ ifdef GCC46
|
|||
WFLAGS+=-Wno-suggest-attribute=noreturn
|
||||
endif
|
||||
|
||||
ifndef MINGW
|
||||
ifdef GCC45
|
||||
WFLAGS+=-Wunsuffixed-float-constants
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef NOLDWARNING
|
||||
LDFLAGS+=-Wl,--as-needed
|
||||
endif
|
||||
|
@ -208,6 +207,9 @@ WFLAGS+=$(OLDWFLAGS)
|
|||
ifdef GCC43
|
||||
#WFLAGS+=-Wno-error=clobbered
|
||||
endif
|
||||
ifdef GCC44
|
||||
WFLAGS+=-Wno-error=array-bounds
|
||||
endif
|
||||
ifdef GCC46
|
||||
WFLAGS+=-Wno-error=suggest-attribute=noreturn
|
||||
endif
|
||||
|
|
|
@ -96,6 +96,37 @@ boolean I_SetSongSpeed(float speed)
|
|||
return false;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC SEEKING
|
||||
/// ------------------------
|
||||
|
||||
UINT32 I_GetSongLength(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongLoopPoint(UINT32 looppoint)
|
||||
{
|
||||
(void)looppoint;
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 I_GetSongLoopPoint(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongPosition(UINT32 position)
|
||||
{
|
||||
(void)position;
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 I_GetSongPosition(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC PLAYBACK
|
||||
/// ------------------------
|
||||
|
@ -140,3 +171,44 @@ void I_SetMusicVolume(INT32 volume)
|
|||
{
|
||||
(void)volume;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC FADING
|
||||
/// ------------------------
|
||||
|
||||
void I_SetInternalMusicVolume(UINT8 volume)
|
||||
{
|
||||
(void)volume;
|
||||
}
|
||||
|
||||
void I_StopFadingSong(void)
|
||||
{
|
||||
}
|
||||
|
||||
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void));
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)source_volume;
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeOutStopSong(UINT32 ms)
|
||||
{
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeInPlaySong(UINT32 ms, boolean looping)
|
||||
{
|
||||
(void)ms;
|
||||
(void)looping;
|
||||
return false;
|
||||
}
|
||||
|
|
289
src/apng.c
Normal file
289
src/apng.c
Normal file
|
@ -0,0 +1,289 @@
|
|||
/*
|
||||
Copyright 2019, James R.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "apng.h"
|
||||
|
||||
#define APNG_INFO_acTL 0x20000U
|
||||
|
||||
#define APNG_WROTE_acTL 0x10000U
|
||||
|
||||
struct apng_info_def
|
||||
{
|
||||
png_uint_32 mode;
|
||||
png_uint_32 valid;
|
||||
|
||||
png_uint_32 num_frames;
|
||||
png_uint_32 num_plays;
|
||||
|
||||
long start_acTL;/* acTL is written here */
|
||||
|
||||
png_flush_ptr output_flush_fn;
|
||||
apng_seek_ptr output_seek_fn;
|
||||
apng_tell_ptr output_tell_fn;
|
||||
|
||||
apng_set_acTL_ptr set_acTL_fn;
|
||||
};
|
||||
|
||||
/* PROTOS (FUCK COMPILER) */
|
||||
void apng_seek (png_structp, apng_const_infop, size_t);
|
||||
size_t apng_tell (png_structp, apng_const_infop);
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
void apng_flush (png_structp, apng_infop);
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
void apng_default_flush (png_structp);
|
||||
#endif/* PNG_STDIO_SUPPORTED */
|
||||
#endif/* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
void apng_default_seek (png_structp, size_t);
|
||||
size_t apng_default_tell (png_structp);
|
||||
#endif/* PNG_STDIO_SUPPORTED */
|
||||
void apng_write_IEND (png_structp);
|
||||
void apng_write_acTL (png_structp, png_uint_32, png_uint_32);
|
||||
#ifndef PNG_WRITE_APNG_SUPPORTED
|
||||
png_uint_32 apng_set_acTL_dummy (png_structp, png_infop,
|
||||
png_uint_32, png_uint_32);
|
||||
#endif/* PNG_WRITE_APNG_SUPPORTED */
|
||||
|
||||
apng_infop
|
||||
apng_create_info_struct (png_structp pngp)
|
||||
{
|
||||
apng_infop ainfop;
|
||||
(void)pngp;
|
||||
if (( ainfop = calloc(sizeof (apng_info),1) ))
|
||||
{
|
||||
apng_set_write_fn(pngp, ainfop, 0, 0, 0, 0, 0);
|
||||
apng_set_set_acTL_fn(pngp, ainfop, 0);
|
||||
}
|
||||
return ainfop;
|
||||
}
|
||||
|
||||
void
|
||||
apng_destroy_info_struct (png_structp pngp, apng_infopp ainfopp)
|
||||
{
|
||||
(void)pngp;
|
||||
if (!( pngp && ainfopp ))
|
||||
return;
|
||||
|
||||
free((*ainfopp));
|
||||
}
|
||||
|
||||
void
|
||||
apng_seek (png_structp pngp, apng_const_infop ainfop, size_t l)
|
||||
{
|
||||
(*(ainfop->output_seek_fn))(pngp, l);
|
||||
}
|
||||
|
||||
size_t
|
||||
apng_tell (png_structp pngp, apng_const_infop ainfop)
|
||||
{
|
||||
return (*(ainfop->output_tell_fn))(pngp);
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
void
|
||||
apng_flush (png_structp pngp, apng_infop ainfop)
|
||||
{
|
||||
if (ainfop->output_flush_fn)
|
||||
(*(ainfop->output_flush_fn))(pngp);
|
||||
}
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
void
|
||||
apng_default_flush (png_structp pngp)
|
||||
{
|
||||
if (!( pngp ))
|
||||
return;
|
||||
|
||||
fflush((png_FILE_p)png_get_io_ptr);
|
||||
}
|
||||
#endif/* PNG_STDIO_SUPPORTED */
|
||||
#endif/* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
void
|
||||
apng_default_seek (png_structp pngp, size_t l)
|
||||
{
|
||||
if (!( pngp ))
|
||||
return;
|
||||
|
||||
if (fseek((png_FILE_p)png_get_io_ptr(pngp), (long)l, SEEK_SET) == -1)
|
||||
png_error(pngp, "Seek Error");
|
||||
}
|
||||
|
||||
size_t
|
||||
apng_default_tell (png_structp pngp)
|
||||
{
|
||||
long l;
|
||||
|
||||
if (!( pngp ))
|
||||
{
|
||||
png_error(pngp, "Call to apng_default_tell with NULL pngp failed");
|
||||
}
|
||||
|
||||
if (( l = ftell((png_FILE_p)png_get_io_ptr(pngp)) ) == -1)
|
||||
png_error(pngp, "Tell Error");
|
||||
|
||||
return (size_t)l;
|
||||
}
|
||||
#endif/* PNG_STDIO_SUPPORTED */
|
||||
|
||||
void
|
||||
apng_set_write_fn (png_structp pngp, apng_infop ainfop, png_voidp iop,
|
||||
png_rw_ptr write_f, png_flush_ptr flush_f,
|
||||
apng_seek_ptr seek_f, apng_tell_ptr tell_f)
|
||||
{
|
||||
if (!( pngp && ainfop ))
|
||||
return;
|
||||
|
||||
png_set_write_fn(pngp, iop, write_f, flush_f);
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
if (!flush_f)
|
||||
ainfop->output_flush_fn = &apng_default_flush;
|
||||
else
|
||||
#endif/* PNG_STDIO_SUPPORTED */
|
||||
ainfop->output_flush_fn = flush_f;
|
||||
#endif/* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
if (!seek_f)
|
||||
ainfop->output_seek_fn = &apng_default_seek;
|
||||
else
|
||||
#endif/* PNG_STDIO_SUPPORTED */
|
||||
ainfop->output_seek_fn = seek_f;
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
if (!seek_f)
|
||||
ainfop->output_tell_fn = apng_default_tell;
|
||||
else
|
||||
#endif/* PNG_STDIO_SUPPORTED */
|
||||
ainfop->output_tell_fn = tell_f;
|
||||
}
|
||||
|
||||
void
|
||||
apng_write_IEND (png_structp pngp)
|
||||
{
|
||||
png_byte chunkc[] = "IEND";
|
||||
png_write_chunk(pngp, chunkc, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
apng_write_acTL (png_structp pngp, png_uint_32 frames, png_uint_32 plays)
|
||||
{
|
||||
png_byte chunkc[] = "acTL";
|
||||
png_byte buf[8];
|
||||
png_save_uint_32(buf, frames);
|
||||
png_save_uint_32(buf + 4, plays);
|
||||
png_write_chunk(pngp, chunkc, buf, 8);
|
||||
}
|
||||
|
||||
png_uint_32
|
||||
apng_set_acTL (png_structp pngp, png_infop infop, apng_infop ainfop,
|
||||
png_uint_32 frames, png_uint_32 plays)
|
||||
{
|
||||
(void)pngp;
|
||||
(void)infop;
|
||||
if (!( pngp && infop && ainfop ))
|
||||
return 0;
|
||||
|
||||
ainfop->num_frames = frames;
|
||||
ainfop->num_plays = plays;
|
||||
|
||||
ainfop->valid |= APNG_INFO_acTL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
apng_write_info_before_PLTE (png_structp pngp, png_infop infop,
|
||||
apng_infop ainfop)
|
||||
{
|
||||
if (!( pngp && infop && ainfop ))
|
||||
return;
|
||||
|
||||
png_write_info_before_PLTE(pngp, infop);
|
||||
|
||||
if (( ainfop->valid & APNG_INFO_acTL )&&!( ainfop->mode & APNG_WROTE_acTL ))
|
||||
{
|
||||
ainfop->start_acTL = apng_tell(pngp, ainfop);
|
||||
|
||||
apng_write_acTL(pngp, 0, 0);
|
||||
/* modified for runtime dynamic linking */
|
||||
(*(ainfop->set_acTL_fn))(pngp, infop, PNG_UINT_31_MAX, 0);
|
||||
|
||||
ainfop->mode |= APNG_WROTE_acTL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
apng_write_info (png_structp pngp, png_infop infop,
|
||||
apng_infop ainfop)
|
||||
{
|
||||
apng_write_info_before_PLTE(pngp, infop, ainfop);
|
||||
png_write_info(pngp, infop);
|
||||
}
|
||||
|
||||
void
|
||||
apng_write_end (png_structp pngp, png_infop infop, apng_infop ainfop)
|
||||
{
|
||||
(void)infop;
|
||||
apng_write_IEND(pngp);
|
||||
apng_seek(pngp, ainfop, ainfop->start_acTL);
|
||||
apng_write_acTL(pngp, ainfop->num_frames, ainfop->num_plays);
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
#ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED
|
||||
apng_flush(pngp, infop);
|
||||
#endif/* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
#endif/* PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED */
|
||||
}
|
||||
|
||||
#ifndef PNG_WRITE_APNG_SUPPORTED
|
||||
png_uint_32
|
||||
apng_set_acTL_dummy (png_structp pngp, png_infop infop,
|
||||
png_uint_32 frames, png_uint_32 plays)
|
||||
{
|
||||
(void)pngp;
|
||||
(void)infop;
|
||||
(void)frames;
|
||||
(void)plays;
|
||||
return 0;
|
||||
}
|
||||
#endif/* PNG_WRITE_APNG_SUPPORTED */
|
||||
|
||||
/* Dynamic runtime linking capable! (Hopefully.) */
|
||||
void
|
||||
apng_set_set_acTL_fn (png_structp pngp, apng_infop ainfop,
|
||||
apng_set_acTL_ptr set_acTL_f)
|
||||
{
|
||||
(void)pngp;
|
||||
if (!ainfop->set_acTL_fn)
|
||||
#ifndef PNG_WRITE_APNG_SUPPORTED
|
||||
ainfop->set_acTL_fn = &apng_set_acTL_dummy;
|
||||
#else
|
||||
ainfop->set_acTL_fn = &png_set_acTL;
|
||||
#endif/* PNG_WRITE_APNG_SUPPORTED */
|
||||
else
|
||||
ainfop->set_acTL_fn = set_acTL_f;
|
||||
}
|
82
src/apng.h
Normal file
82
src/apng.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
Copyright 2019, James R.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef APNG_H
|
||||
#define APNG_H
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#ifndef _WII
|
||||
#ifndef _LARGEFILE64_SOURCE
|
||||
#define _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _LFS64_LARGEFILE
|
||||
#define _LFS64_LARGEFILE
|
||||
#endif
|
||||
|
||||
#ifndef _FILE_OFFSET_BITS
|
||||
#define _FILE_OFFSET_BITS 0
|
||||
#endif
|
||||
|
||||
#include <png.h>
|
||||
|
||||
typedef struct apng_info_def apng_info;
|
||||
typedef apng_info * apng_infop;
|
||||
typedef const apng_info * apng_const_infop;
|
||||
typedef apng_info * * apng_infopp;
|
||||
|
||||
typedef void (*apng_seek_ptr)(png_structp, size_t);
|
||||
typedef size_t (*apng_tell_ptr)(png_structp);
|
||||
|
||||
typedef png_uint_32 (*apng_set_acTL_ptr)(png_structp, png_infop,
|
||||
png_uint_32, png_uint_32);
|
||||
|
||||
apng_infop apng_create_info_struct (png_structp png_ptr);
|
||||
|
||||
void apng_destroy_info_struct (png_structp png_ptr,
|
||||
apng_infopp info_ptr_ptr);
|
||||
|
||||
/* Call the following functions in place of the libpng counterparts. */
|
||||
|
||||
png_uint_32 apng_set_acTL (png_structp png_ptr, png_infop info_ptr,
|
||||
apng_infop ainfo_ptr,
|
||||
png_uint_32 num_frames, png_uint_32 num_plays);
|
||||
|
||||
void apng_write_info_before_PLTE (png_structp png_ptr, png_infop info_ptr,
|
||||
apng_infop ainfo_ptr);
|
||||
void apng_write_info (png_structp png_ptr, png_infop info_ptr,
|
||||
apng_infop ainfo_ptr);
|
||||
|
||||
void apng_write_end (png_structp png_ptr, png_infop info_ptr,
|
||||
apng_infop ainfo_ptr);
|
||||
|
||||
void apng_set_write_fn (png_structp png_ptr, apng_infop ainfo_ptr,
|
||||
png_voidp io_ptr,
|
||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn,
|
||||
apng_seek_ptr output_seek_fn, apng_tell_ptr output_tell_fn);
|
||||
|
||||
void apng_set_set_acTL_fn (png_structp png_ptr, apng_infop ainfo_ptr,
|
||||
apng_set_acTL_ptr set_acTL_fn);
|
||||
|
||||
#endif/* APNG_H */
|
|
@ -2415,6 +2415,8 @@ static void CL_RemovePlayer(INT32 playernum, INT32 reason)
|
|||
|
||||
#ifdef HAVE_BLUA
|
||||
LUAh_PlayerQuit(&players[playernum], reason); // Lua hook for player quitting
|
||||
#else
|
||||
(void)reason;
|
||||
#endif
|
||||
|
||||
// Reset player data
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define __D_NET__
|
||||
|
||||
// Max computers in a game
|
||||
#define MAXNETNODES 32
|
||||
#define MAXNETNODES (MAXPLAYERS+4)
|
||||
#define BROADCASTADDR MAXNETNODES
|
||||
#define MAXSPLITSCREENPLAYERS 2 // Max number of players on a single computer
|
||||
//#define NETSPLITSCREEN // Kart's splitscreen netgame feature
|
||||
|
|
|
@ -1196,6 +1196,13 @@ static void readlevelheader(MYFILE *f, INT32 num)
|
|||
#endif
|
||||
else if (fastcmp(word, "MUSICTRACK"))
|
||||
mapheaderinfo[num-1]->mustrack = ((UINT16)i - 1);
|
||||
else if (fastcmp(word, "MUSICPOS"))
|
||||
mapheaderinfo[num-1]->muspos = (UINT32)get_number(word2);
|
||||
else if (fastcmp(word, "MUSICINTERFADEOUT"))
|
||||
mapheaderinfo[num-1]->musinterfadeout = (UINT32)get_number(word2);
|
||||
else if (fastcmp(word, "MUSICINTER"))
|
||||
deh_strlcpy(mapheaderinfo[num-1]->musintername, word2,
|
||||
sizeof(mapheaderinfo[num-1]->musintername), va("Level header %d: intermission music", num));
|
||||
else if (fastcmp(word, "FORCECHARACTER"))
|
||||
{
|
||||
strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1);
|
||||
|
@ -1499,6 +1506,11 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum)
|
|||
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musswitchflags), UNDO_NONE);
|
||||
cutscenes[num]->scene[scenenum].musswitchflags = ((UINT16)i) & MUSIC_TRACKMASK;
|
||||
}
|
||||
else if (fastcmp(word, "MUSICPOS"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musswitchposition), UNDO_NONE);
|
||||
cutscenes[num]->scene[scenenum].musswitchposition = (UINT32)get_number(word2);
|
||||
}
|
||||
else if (fastcmp(word, "MUSICLOOP"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%u", cutscenes[num]->scene[scenenum].musicloop), UNDO_NONE);
|
||||
|
@ -7003,6 +7015,7 @@ struct {
|
|||
|
||||
// doomdef.h constants
|
||||
{"TICRATE",TICRATE},
|
||||
{"MUSICRATE",MUSICRATE},
|
||||
{"RING_DIST",RING_DIST},
|
||||
{"PUSHACCEL",PUSHACCEL},
|
||||
{"MODID",MODID}, // I don't know, I just thought it would be cool for a wad to potentially know what mod it was loaded into.
|
||||
|
@ -8314,6 +8327,9 @@ static inline int lib_getenum(lua_State *L)
|
|||
} else if (fastcmp(word,"mapmusflags")) {
|
||||
lua_pushinteger(L, mapmusflags);
|
||||
return 1;
|
||||
} else if (fastcmp(word,"mapmusposition")) {
|
||||
lua_pushinteger(L, mapmusposition);
|
||||
return 1;
|
||||
} else if (fastcmp(word,"server")) {
|
||||
if ((!multiplayer || !netgame) && !playeringame[serverplayer])
|
||||
return 0;
|
||||
|
|
|
@ -438,6 +438,37 @@ boolean I_SetSongSpeed(float speed)
|
|||
return false;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC SEEKING
|
||||
/// ------------------------
|
||||
|
||||
UINT32 I_GetSongLength(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongLoopPoint(UINT32 looppoint)
|
||||
{
|
||||
(void)looppoint;
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 I_GetSongLoopPoint(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongPosition(UINT32 position)
|
||||
{
|
||||
(void)position;
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 I_GetSongPosition(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC PLAYBACK
|
||||
/// ------------------------
|
||||
|
@ -545,3 +576,44 @@ int I_QrySongPlaying(int handle)
|
|||
return (midi_pos==-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC FADING
|
||||
/// ------------------------
|
||||
|
||||
void I_SetInternalMusicVolume(UINT8 volume)
|
||||
{
|
||||
(void)volume;
|
||||
}
|
||||
|
||||
void I_StopFadingSong(void)
|
||||
{
|
||||
}
|
||||
|
||||
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void));
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)source_volume;
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeOutStopSong(UINT32 ms)
|
||||
{
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeInPlaySong(UINT32 ms, boolean looping)
|
||||
{
|
||||
(void)ms;
|
||||
(void)looping;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -305,6 +305,8 @@ typedef enum
|
|||
#define NEWTICRATERATIO 1 // try 4 for 140 fps :)
|
||||
#define NEWTICRATE (TICRATE*NEWTICRATERATIO)
|
||||
|
||||
#define MUSICRATE 1000 // sound timing is calculated by milliseconds
|
||||
|
||||
#define RING_DIST 512*FRACUNIT // how close you need to be to a ring to attract it
|
||||
|
||||
#define PUSHACCEL (2*FRACUNIT) // Acceleration for MF2_SLIDEPUSH items.
|
||||
|
|
|
@ -33,8 +33,10 @@
|
|||
extern INT16 gamemap;
|
||||
extern char mapmusname[7];
|
||||
extern UINT16 mapmusflags;
|
||||
extern UINT32 mapmusposition;
|
||||
#define MUSIC_TRACKMASK 0x0FFF // ----************
|
||||
#define MUSIC_RELOADRESET 0x8000 // *---------------
|
||||
#define MUSIC_FORCERESET 0x4000 // -*--------------
|
||||
// Use other bits if necessary.
|
||||
|
||||
extern INT16 maptol;
|
||||
|
@ -145,6 +147,7 @@ typedef struct
|
|||
|
||||
char musswitch[7];
|
||||
UINT16 musswitchflags;
|
||||
UINT32 musswitchposition;
|
||||
|
||||
UINT8 fadecolor; // Color number for fade, 0 means don't do the first fade
|
||||
UINT8 fadeinid; // ID of the first fade, to a color -- ignored if fadecolor is 0
|
||||
|
@ -215,6 +218,7 @@ typedef struct
|
|||
INT16 nextlevel; ///< Map number of next level, or 1100-1102 to end.
|
||||
char musname[7]; ///< Music track to play. "" for no music.
|
||||
UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore.
|
||||
UINT32 muspos; ///< Music position to jump to.
|
||||
char forcecharacter[17]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable.
|
||||
UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave.
|
||||
INT16 skynum; ///< Sky number to use.
|
||||
|
@ -243,6 +247,10 @@ typedef struct
|
|||
UINT8 numGradedMares; ///< Internal. For grade support.
|
||||
nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful.
|
||||
|
||||
// Music stuff.
|
||||
UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds
|
||||
char musintername[7]; ///< Intermission screen music.
|
||||
|
||||
// Lua stuff.
|
||||
// (This is not ifdeffed so the map header structure can stay identical, just in case.)
|
||||
UINT8 numCustomOptions; ///< Internal. For Lua custom value support.
|
||||
|
|
|
@ -95,6 +95,37 @@ boolean I_SetSongSpeed(float speed)
|
|||
return false;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC SEEKING
|
||||
/// ------------------------
|
||||
|
||||
UINT32 I_GetSongLength(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongLoopPoint(UINT32 looppoint)
|
||||
{
|
||||
(void)looppoint;
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 I_GetSongLoopPoint(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongPosition(UINT32 position)
|
||||
{
|
||||
(void)position;
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 I_GetSongPosition(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC PLAYBACK
|
||||
/// ------------------------
|
||||
|
@ -142,4 +173,45 @@ boolean I_SetSongTrack(int track)
|
|||
{
|
||||
(void)track;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC FADING
|
||||
/// ------------------------
|
||||
|
||||
void I_SetInternalMusicVolume(UINT8 volume)
|
||||
{
|
||||
(void)volume;
|
||||
}
|
||||
|
||||
void I_StopFadingSong(void)
|
||||
{
|
||||
}
|
||||
|
||||
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void));
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)source_volume;
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeOutStopSong(UINT32 ms)
|
||||
{
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeInPlaySong(UINT32 ms, boolean looping)
|
||||
{
|
||||
(void)ms;
|
||||
(void)looping;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1728,9 +1728,10 @@ static void F_AdvanceToNextScene(void)
|
|||
picypos = cutscenes[cutnum]->scene[scenenum].ycoord[picnum];
|
||||
|
||||
if (cutscenes[cutnum]->scene[scenenum].musswitch[0])
|
||||
S_ChangeMusic(cutscenes[cutnum]->scene[scenenum].musswitch,
|
||||
S_ChangeMusicEx(cutscenes[cutnum]->scene[scenenum].musswitch,
|
||||
cutscenes[cutnum]->scene[scenenum].musswitchflags,
|
||||
cutscenes[cutnum]->scene[scenenum].musicloop);
|
||||
cutscenes[cutnum]->scene[scenenum].musicloop,
|
||||
cutscenes[cutnum]->scene[scenenum].musswitchposition, 0, 0);
|
||||
|
||||
// Fade to the next
|
||||
dofadenow = true;
|
||||
|
@ -1801,9 +1802,10 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset
|
|||
stoptimer = 0;
|
||||
|
||||
if (cutscenes[cutnum]->scene[0].musswitch[0])
|
||||
S_ChangeMusic(cutscenes[cutnum]->scene[0].musswitch,
|
||||
S_ChangeMusicEx(cutscenes[cutnum]->scene[0].musswitch,
|
||||
cutscenes[cutnum]->scene[0].musswitchflags,
|
||||
cutscenes[cutnum]->scene[0].musicloop);
|
||||
cutscenes[cutnum]->scene[0].musicloop,
|
||||
cutscenes[cutnum]->scene[scenenum].musswitchposition, 0, 0);
|
||||
else
|
||||
S_StopMusic();
|
||||
}
|
||||
|
|
10
src/g_game.c
10
src/g_game.c
|
@ -71,6 +71,7 @@ static void G_DoWorldDone(void);
|
|||
|
||||
char mapmusname[7]; // Music name
|
||||
UINT16 mapmusflags; // Track and reset bit
|
||||
UINT32 mapmusposition; // Position to jump to
|
||||
|
||||
INT16 gamemap = 1;
|
||||
INT16 maptol;
|
||||
|
@ -2268,9 +2269,14 @@ void G_PlayerReborn(INT32 player)
|
|||
{
|
||||
strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7);
|
||||
mapmusname[6] = 0;
|
||||
mapmusflags = mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK;
|
||||
mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK);
|
||||
mapmusposition = mapheaderinfo[gamemap-1]->muspos;
|
||||
}
|
||||
S_ChangeMusic(mapmusname, mapmusflags, true);
|
||||
|
||||
// This is in S_Start, but this was not here previously.
|
||||
// if (cv_resetmusic.value)
|
||||
// S_StopMusic();
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
|
||||
}
|
||||
|
||||
if (gametype == GT_COOP)
|
||||
|
|
|
@ -146,6 +146,18 @@ boolean I_SongPaused(void);
|
|||
|
||||
boolean I_SetSongSpeed(float speed);
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC SEEKING
|
||||
/// ------------------------
|
||||
|
||||
UINT32 I_GetSongLength(void);
|
||||
|
||||
boolean I_SetSongLoopPoint(UINT32 looppoint);
|
||||
UINT32 I_GetSongLoopPoint(void);
|
||||
|
||||
boolean I_SetSongPosition(UINT32 position);
|
||||
UINT32 I_GetSongPosition(void);
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC PLAYBACK
|
||||
/// ------------------------
|
||||
|
@ -216,6 +228,17 @@ void I_SetMusicVolume(UINT8 volume);
|
|||
|
||||
boolean I_SetSongTrack(INT32 track);
|
||||
|
||||
/// ------------------------
|
||||
/// MUSIC FADING
|
||||
/// ------------------------
|
||||
|
||||
void I_SetInternalMusicVolume(UINT8 volume);
|
||||
void I_StopFadingSong(void);
|
||||
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void));
|
||||
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void));
|
||||
boolean I_FadeOutStopSong(UINT32 ms);
|
||||
boolean I_FadeInPlaySong(UINT32 ms, boolean looping);
|
||||
|
||||
/// ------------------------
|
||||
// CD MUSIC I/O
|
||||
/// ------------------------
|
||||
|
|
|
@ -780,7 +780,8 @@ static int lib_pRestoreMusic(lua_State *L)
|
|||
NOHUD
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
P_RestoreMusic(player);
|
||||
if (P_IsLocalPlayer(player))
|
||||
P_RestoreMusic(player);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1820,7 +1821,7 @@ static int lib_sChangeMusic(lua_State *L)
|
|||
{
|
||||
#ifdef MUSICSLOT_COMPATIBILITY
|
||||
const char *music_name;
|
||||
UINT32 music_num;
|
||||
UINT32 music_num, position, prefadems, fadeinms;
|
||||
char music_compat_name[7];
|
||||
|
||||
boolean looping;
|
||||
|
@ -1848,7 +1849,6 @@ static int lib_sChangeMusic(lua_State *L)
|
|||
music_name = luaL_checkstring(L, 1);
|
||||
}
|
||||
|
||||
|
||||
looping = (boolean)lua_opttrueboolean(L, 2);
|
||||
|
||||
#else
|
||||
|
@ -1873,8 +1873,12 @@ static int lib_sChangeMusic(lua_State *L)
|
|||
#endif
|
||||
music_flags = (UINT16)luaL_optinteger(L, 4, 0);
|
||||
|
||||
position = (UINT32)luaL_optinteger(L, 5, 0);
|
||||
prefadems = (UINT32)luaL_optinteger(L, 6, 0);
|
||||
fadeinms = (UINT32)luaL_optinteger(L, 7, 0);
|
||||
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
S_ChangeMusic(music_name, music_flags, looping);
|
||||
S_ChangeMusicEx(music_name, music_flags, looping, position, prefadems, fadeinms);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1891,10 +1895,8 @@ static int lib_sSpeedMusic(lua_State *L)
|
|||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushboolean(L, S_SpeedMusic(speed));
|
||||
else
|
||||
lua_pushboolean(L, false);
|
||||
return 1;
|
||||
S_SpeedMusic(speed);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lib_sStopMusic(lua_State *L)
|
||||
|
@ -1912,6 +1914,110 @@ static int lib_sStopMusic(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lib_sSetInternalMusicVolume(lua_State *L)
|
||||
{
|
||||
UINT32 volume = (UINT32)luaL_checkinteger(L, 1);
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
{
|
||||
S_SetInternalMusicVolume(volume);
|
||||
lua_pushboolean(L, true);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sStopFadingMusic(lua_State *L)
|
||||
{
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
{
|
||||
S_StopFadingMusic();
|
||||
lua_pushboolean(L, true);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sFadeMusic(lua_State *L)
|
||||
{
|
||||
UINT32 target_volume = (UINT32)luaL_checkinteger(L, 1);
|
||||
UINT32 ms;
|
||||
INT32 source_volume;
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 3) && lua_isuserdata(L, 3))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
ms = (UINT32)luaL_checkinteger(L, 2);
|
||||
source_volume = -1;
|
||||
}
|
||||
else if (!lua_isnone(L, 4) && lua_isuserdata(L, 4))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 4, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
source_volume = (INT32)luaL_checkinteger(L, 2);
|
||||
ms = (UINT32)luaL_checkinteger(L, 3);
|
||||
}
|
||||
else if (luaL_optinteger(L, 3, INT32_MAX) == INT32_MAX)
|
||||
{
|
||||
ms = (UINT32)luaL_checkinteger(L, 2);
|
||||
source_volume = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
source_volume = (INT32)luaL_checkinteger(L, 2);
|
||||
ms = (UINT32)luaL_checkinteger(L, 3);
|
||||
}
|
||||
|
||||
NOHUD
|
||||
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
lua_pushboolean(L, S_FadeMusicFromVolume(target_volume, source_volume, ms));
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sFadeOutStopMusic(lua_State *L)
|
||||
{
|
||||
UINT32 ms = (UINT32)luaL_checkinteger(L, 1);
|
||||
player_t *player = NULL;
|
||||
NOHUD
|
||||
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
|
||||
{
|
||||
player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
}
|
||||
if (!player || P_IsLocalPlayer(player))
|
||||
{
|
||||
lua_pushboolean(L, S_FadeOutStopMusic(ms));
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_sOriginPlaying(lua_State *L)
|
||||
{
|
||||
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
|
@ -2264,6 +2370,10 @@ static luaL_Reg lib[] = {
|
|||
{"S_ChangeMusic",lib_sChangeMusic},
|
||||
{"S_SpeedMusic",lib_sSpeedMusic},
|
||||
{"S_StopMusic",lib_sStopMusic},
|
||||
{"S_SetInternalMusicVolume", lib_sSetInternalMusicVolume},
|
||||
{"S_StopFadingMusic",lib_sStopFadingMusic},
|
||||
{"S_FadeMusic",lib_sFadeMusic},
|
||||
{"S_FadeOutStopMusic",lib_sFadeOutStopMusic},
|
||||
{"S_OriginPlaying",lib_sOriginPlaying},
|
||||
{"S_IdPlaying",lib_sIdPlaying},
|
||||
{"S_SoundPlaying",lib_sSoundPlaying},
|
||||
|
|
|
@ -1468,6 +1468,12 @@ static int mapheaderinfo_get(lua_State *L)
|
|||
lua_pushstring(L, header->musname);
|
||||
else if (fastcmp(field,"mustrack"))
|
||||
lua_pushinteger(L, header->mustrack);
|
||||
else if (fastcmp(field,"muspos"))
|
||||
lua_pushinteger(L, header->muspos);
|
||||
else if (fastcmp(field,"musinterfadeout"))
|
||||
lua_pushinteger(L, header->musinterfadeout);
|
||||
else if (fastcmp(field,"musintername"))
|
||||
lua_pushstring(L, header->musintername);
|
||||
else if (fastcmp(field,"forcecharacter"))
|
||||
lua_pushstring(L, header->forcecharacter);
|
||||
else if (fastcmp(field,"weather"))
|
||||
|
|
123
src/m_misc.c
123
src/m_misc.c
|
@ -93,9 +93,8 @@ typedef off_t off64_t;
|
|||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#define USE_PNG // Only actually use PNG if write is supported.
|
||||
#if defined (PNG_WRITE_APNG_SUPPORTED) //|| !defined(PNG_STATIC)
|
||||
#if (PNG_LIBPNG_VER_MAJOR) == 1 && (PNG_LIBPNG_VER_MINOR <= 4) // Supposedly, the current APNG code can't work on newer versions as is
|
||||
#include "apng.h"
|
||||
#define USE_APNG
|
||||
#endif
|
||||
#endif
|
||||
// See hardware/hw_draw.c for a similar check to this one.
|
||||
#endif
|
||||
|
@ -794,13 +793,13 @@ static inline void M_PNGImage(png_structp png_ptr, png_infop png_info_ptr, PNG_C
|
|||
#ifdef USE_APNG
|
||||
static png_structp apng_ptr = NULL;
|
||||
static png_infop apng_info_ptr = NULL;
|
||||
static apng_infop apng_ainfo_ptr = NULL;
|
||||
static png_FILE_p apng_FILE = NULL;
|
||||
static png_uint_32 apng_frames = 0;
|
||||
static png_byte acTL_cn[5] = { 97, 99, 84, 76, '\0'};
|
||||
#ifdef PNG_STATIC // Win32 build have static libpng
|
||||
#define apng_set_acTL png_set_acTL
|
||||
#define apng_write_frame_head png_write_frame_head
|
||||
#define apng_write_frame_tail png_write_frame_tail
|
||||
#define aPNG_set_acTL png_set_acTL
|
||||
#define aPNG_write_frame_head png_write_frame_head
|
||||
#define aPNG_write_frame_tail png_write_frame_tail
|
||||
#else // outside libpng may not have apng support
|
||||
|
||||
#ifndef PNG_WRITE_APNG_SUPPORTED // libpng header may not have apng patch
|
||||
|
@ -837,20 +836,20 @@ static png_byte acTL_cn[5] = { 97, 99, 84, 76, '\0'};
|
|||
#endif
|
||||
|
||||
#endif
|
||||
typedef PNG_EXPORT(png_uint_32, (*P_png_set_acTL)) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays));
|
||||
typedef PNG_EXPORT (void, (*P_png_write_frame_head)) PNGARG((png_structp png_ptr,
|
||||
typedef png_uint_32 (*P_png_set_acTL) (png_structp png_ptr,
|
||||
png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays);
|
||||
typedef void (*P_png_write_frame_head) (png_structp png_ptr,
|
||||
png_infop info_ptr, png_bytepp row_pointers,
|
||||
png_uint_32 width, png_uint_32 height,
|
||||
png_uint_32 x_offset, png_uint_32 y_offset,
|
||||
png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
|
||||
png_byte blend_op));
|
||||
png_byte blend_op);
|
||||
|
||||
typedef PNG_EXPORT (void, (*P_png_write_frame_tail)) PNGARG((png_structp png_ptr,
|
||||
png_infop info_ptr));
|
||||
static P_png_set_acTL apng_set_acTL = NULL;
|
||||
static P_png_write_frame_head apng_write_frame_head = NULL;
|
||||
static P_png_write_frame_tail apng_write_frame_tail = NULL;
|
||||
typedef void (*P_png_write_frame_tail) (png_structp png_ptr,
|
||||
png_infop info_ptr);
|
||||
static P_png_set_acTL aPNG_set_acTL = NULL;
|
||||
static P_png_write_frame_head aPNG_write_frame_head = NULL;
|
||||
static P_png_write_frame_tail aPNG_write_frame_tail = NULL;
|
||||
#endif
|
||||
|
||||
static inline boolean M_PNGLib(void)
|
||||
|
@ -859,7 +858,7 @@ static inline boolean M_PNGLib(void)
|
|||
return true;
|
||||
#else
|
||||
static void *pnglib = NULL;
|
||||
if (apng_set_acTL && apng_write_frame_head && apng_write_frame_tail)
|
||||
if (aPNG_set_acTL && aPNG_write_frame_head && aPNG_write_frame_tail)
|
||||
return true;
|
||||
if (pnglib)
|
||||
return false;
|
||||
|
@ -879,16 +878,16 @@ static inline boolean M_PNGLib(void)
|
|||
if (!pnglib)
|
||||
return false;
|
||||
#ifdef HAVE_SDL
|
||||
apng_set_acTL = hwSym("png_set_acTL", pnglib);
|
||||
apng_write_frame_head = hwSym("png_write_frame_head", pnglib);
|
||||
apng_write_frame_tail = hwSym("png_write_frame_tail", pnglib);
|
||||
aPNG_set_acTL = hwSym("png_set_acTL", pnglib);
|
||||
aPNG_write_frame_head = hwSym("png_write_frame_head", pnglib);
|
||||
aPNG_write_frame_tail = hwSym("png_write_frame_tail", pnglib);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
apng_set_acTL = GetProcAddress("png_set_acTL", pnglib);
|
||||
apng_write_frame_head = GetProcAddress("png_write_frame_head", pnglib);
|
||||
apng_write_frame_tail = GetProcAddress("png_write_frame_tail", pnglib);
|
||||
aPNG_set_acTL = GetProcAddress("png_set_acTL", pnglib);
|
||||
aPNG_write_frame_head = GetProcAddress("png_write_frame_head", pnglib);
|
||||
aPNG_write_frame_tail = GetProcAddress("png_write_frame_tail", pnglib);
|
||||
#endif
|
||||
return (apng_set_acTL && apng_write_frame_head && apng_write_frame_tail);
|
||||
return (aPNG_set_acTL && aPNG_write_frame_head && aPNG_write_frame_tail);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -902,11 +901,6 @@ static void M_PNGFrame(png_structp png_ptr, png_infop png_info_ptr, png_bytep pn
|
|||
|
||||
apng_frames++;
|
||||
|
||||
#ifndef PNG_STATIC
|
||||
if (apng_set_acTL)
|
||||
#endif
|
||||
apng_set_acTL(apng_ptr, apng_info_ptr, apng_frames, 0);
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
row_pointers[y] = png_buf;
|
||||
|
@ -914,9 +908,9 @@ static void M_PNGFrame(png_structp png_ptr, png_infop png_info_ptr, png_bytep pn
|
|||
}
|
||||
|
||||
#ifndef PNG_STATIC
|
||||
if (apng_write_frame_head)
|
||||
if (aPNG_write_frame_head)
|
||||
#endif
|
||||
apng_write_frame_head(apng_ptr, apng_info_ptr, row_pointers,
|
||||
aPNG_write_frame_head(apng_ptr, apng_info_ptr, row_pointers,
|
||||
vid.width, /* width */
|
||||
height, /* height */
|
||||
0, /* x offset */
|
||||
|
@ -929,57 +923,21 @@ static void M_PNGFrame(png_structp png_ptr, png_infop png_info_ptr, png_bytep pn
|
|||
png_write_image(png_ptr, row_pointers);
|
||||
|
||||
#ifndef PNG_STATIC
|
||||
if (apng_write_frame_tail)
|
||||
if (aPNG_write_frame_tail)
|
||||
#endif
|
||||
apng_write_frame_tail(apng_ptr, apng_info_ptr);
|
||||
aPNG_write_frame_tail(apng_ptr, apng_info_ptr);
|
||||
|
||||
png_free(png_ptr, (png_voidp)row_pointers);
|
||||
}
|
||||
|
||||
static inline boolean M_PNGfind_acTL(void)
|
||||
static void M_PNGfix_acTL(png_structp png_ptr, png_infop png_info_ptr,
|
||||
apng_infop png_ainfo_ptr)
|
||||
{
|
||||
png_byte cn[8]; // 4 bytes for len then 4 byes for name
|
||||
long endpos = ftell(apng_FILE); // not the real end of file, just what of libpng wrote
|
||||
for (fseek(apng_FILE, 0, SEEK_SET); // let go to the start of the file
|
||||
ftell(apng_FILE)+12 < endpos; // let not go over the file bound
|
||||
fseek(apng_FILE, 1, SEEK_CUR) // we went 8 steps back and now we go 1 step forward
|
||||
)
|
||||
{
|
||||
if (fread(cn, sizeof(cn), 1, apng_FILE) != 1) // read 8 bytes
|
||||
return false; // failed to read data
|
||||
if (fseek(apng_FILE, -8, SEEK_CUR) != 0) //rewind 8 bytes
|
||||
return false; // failed to rewird
|
||||
if (!png_memcmp(cn+4, acTL_cn, 4)) //cmp for chuck header
|
||||
return true; // found it
|
||||
}
|
||||
return false; // acTL chuck not found
|
||||
}
|
||||
|
||||
static void M_PNGfix_acTL(png_structp png_ptr, png_infop png_info_ptr)
|
||||
{
|
||||
png_byte data[16];
|
||||
long oldpos;
|
||||
|
||||
#ifndef PNG_STATIC
|
||||
if (apng_set_acTL)
|
||||
#endif
|
||||
apng_set_acTL(png_ptr, png_info_ptr, apng_frames, 0);
|
||||
apng_set_acTL(png_ptr, png_info_ptr, png_ainfo_ptr, apng_frames, 0);
|
||||
|
||||
#ifndef NO_PNG_DEBUG
|
||||
png_debug(1, "in png_write_acTL\n");
|
||||
#endif
|
||||
|
||||
png_ptr->num_frames_to_write = apng_frames;
|
||||
|
||||
png_save_uint_32(data, apng_frames);
|
||||
png_save_uint_32(data + 4, 0);
|
||||
|
||||
oldpos = ftell(apng_FILE);
|
||||
|
||||
if (M_PNGfind_acTL())
|
||||
png_write_chunk(png_ptr, (png_bytep)acTL_cn, data, (png_size_t)8);
|
||||
|
||||
fseek(apng_FILE, oldpos, SEEK_SET);
|
||||
}
|
||||
|
||||
static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal)
|
||||
|
@ -1011,6 +969,16 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal)
|
|||
return false;
|
||||
}
|
||||
|
||||
apng_ainfo_ptr = apng_create_info_struct(apng_ptr);
|
||||
if (!apng_ainfo_ptr)
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "M_StartMovie: Error on allocate for apng\n");
|
||||
png_destroy_write_struct(&apng_ptr, &apng_info_ptr);
|
||||
fclose(apng_FILE);
|
||||
remove(filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
png_init_io(apng_ptr, apng_FILE);
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
|
@ -1028,12 +996,11 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal)
|
|||
|
||||
M_PNGText(apng_ptr, apng_info_ptr, true);
|
||||
|
||||
#ifndef PNG_STATIC
|
||||
if (apng_set_acTL)
|
||||
#endif
|
||||
apng_set_acTL(apng_ptr, apng_info_ptr, PNG_UINT_31_MAX, 0);
|
||||
apng_set_set_acTL_fn(apng_ptr, apng_ainfo_ptr, aPNG_set_acTL);
|
||||
|
||||
png_write_info(apng_ptr, apng_info_ptr);
|
||||
apng_set_acTL(apng_ptr, apng_info_ptr, apng_ainfo_ptr, PNG_UINT_31_MAX, 0);
|
||||
|
||||
apng_write_info(apng_ptr, apng_info_ptr, apng_ainfo_ptr);
|
||||
|
||||
apng_frames = 0;
|
||||
|
||||
|
@ -1236,8 +1203,8 @@ void M_StopMovie(void)
|
|||
|
||||
if (apng_frames)
|
||||
{
|
||||
M_PNGfix_acTL(apng_ptr, apng_info_ptr);
|
||||
png_write_end(apng_ptr, apng_info_ptr);
|
||||
M_PNGfix_acTL(apng_ptr, apng_info_ptr, apng_ainfo_ptr);
|
||||
apng_write_end(apng_ptr, apng_info_ptr, apng_ainfo_ptr);
|
||||
}
|
||||
|
||||
png_destroy_write_struct(&apng_ptr, &apng_info_ptr);
|
||||
|
|
|
@ -187,6 +187,12 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
|
|||
mapheaderinfo[num]->musname[6] = 0;
|
||||
DEH_WriteUndoline("MUSICTRACK", va("%d", mapheaderinfo[num]->mustrack), UNDO_NONE);
|
||||
mapheaderinfo[num]->mustrack = 0;
|
||||
DEH_WriteUndoline("MUSICPOS", va("%d", mapheaderinfo[num]->muspos), UNDO_NONE);
|
||||
mapheaderinfo[num]->muspos = 0;
|
||||
DEH_WriteUndoline("MUSICINTERFADEOUT", va("%d", mapheaderinfo[num]->musinterfadeout), UNDO_NONE);
|
||||
mapheaderinfo[num]->musinterfadeout = 0;
|
||||
DEH_WriteUndoline("MUSICINTER", mapheaderinfo[num]->musintername, UNDO_NONE);
|
||||
mapheaderinfo[num]->musintername[0] = '\0';
|
||||
DEH_WriteUndoline("FORCECHARACTER", va("%d", mapheaderinfo[num]->forcecharacter), UNDO_NONE);
|
||||
mapheaderinfo[num]->forcecharacter[0] = '\0';
|
||||
DEH_WriteUndoline("WEATHER", va("%d", mapheaderinfo[num]->weather), UNDO_NONE);
|
||||
|
@ -1527,19 +1533,33 @@ static void P_LoadRawSideDefs2(void *data)
|
|||
{
|
||||
M_Memcpy(process,msd->bottomtexture,8);
|
||||
process[8] = '\0';
|
||||
sd->bottomtexture = get_number(process)-1;
|
||||
sd->bottomtexture = get_number(process);
|
||||
}
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
process[8] = '\0';
|
||||
sd->text = Z_Malloc(7, PU_LEVEL, NULL);
|
||||
|
||||
// If they type in O_ or D_ and their music name, just shrug,
|
||||
// then copy the rest instead.
|
||||
if ((process[0] == 'O' || process[0] == 'D') && process[7])
|
||||
M_Memcpy(sd->text, process+2, 6);
|
||||
else // Assume it's a proper music name.
|
||||
M_Memcpy(sd->text, process, 6);
|
||||
sd->text[6] = 0;
|
||||
if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0')
|
||||
{
|
||||
M_Memcpy(process,msd->midtexture,8);
|
||||
process[8] = '\0';
|
||||
sd->midtexture = get_number(process);
|
||||
}
|
||||
|
||||
// always process if back sidedef, because we need that - symbol
|
||||
sd->text = Z_Malloc(7, PU_LEVEL, NULL);
|
||||
if (i == 1 || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0')
|
||||
{
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
process[8] = '\0';
|
||||
|
||||
// If they type in O_ or D_ and their music name, just shrug,
|
||||
// then copy the rest instead.
|
||||
if ((process[0] == 'O' || process[0] == 'D') && process[7])
|
||||
M_Memcpy(sd->text, process+2, 6);
|
||||
else // Assume it's a proper music name.
|
||||
M_Memcpy(sd->text, process, 6);
|
||||
sd->text[6] = 0;
|
||||
}
|
||||
else
|
||||
sd->text[0] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
66
src/p_spec.c
66
src/p_spec.c
|
@ -2408,16 +2408,68 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
|||
// console player only unless NOCLIMB is set
|
||||
if ((line->flags & ML_NOCLIMB) || (mo && mo->player && P_IsLocalPlayer(mo->player)))
|
||||
{
|
||||
UINT16 tracknum = (UINT16)sides[line->sidenum[0]].bottomtexture;
|
||||
boolean musicsame = (!sides[line->sidenum[0]].text[0] || !strnicmp(sides[line->sidenum[0]].text, S_MusicName(), 7));
|
||||
UINT16 tracknum = (UINT16)max(sides[line->sidenum[0]].bottomtexture, 0);
|
||||
INT32 position = (INT32)max(sides[line->sidenum[0]].midtexture, 0);
|
||||
UINT32 prefadems = (UINT32)max(sides[line->sidenum[0]].textureoffset >> FRACBITS, 0);
|
||||
UINT32 postfadems = (UINT32)max(sides[line->sidenum[0]].rowoffset >> FRACBITS, 0);
|
||||
UINT8 fadetarget = (UINT8)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].textureoffset >> FRACBITS : 0, 0);
|
||||
INT16 fadesource = (INT16)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].rowoffset >> FRACBITS : -1, -1);
|
||||
|
||||
strncpy(mapmusname, sides[line->sidenum[0]].text, 7);
|
||||
mapmusname[6] = 0;
|
||||
// Seek offset from current song position
|
||||
if (line->flags & ML_EFFECT1)
|
||||
{
|
||||
// adjust for loop point if subtracting
|
||||
if (position < 0 && S_GetMusicLength() &&
|
||||
S_GetMusicPosition() > S_GetMusicLoopPoint() &&
|
||||
S_GetMusicPosition() + position < S_GetMusicLoopPoint())
|
||||
position = max(S_GetMusicLength() - (S_GetMusicLoopPoint() - (S_GetMusicPosition() + position)), 0);
|
||||
else
|
||||
position = max(S_GetMusicPosition() + position, 0);
|
||||
}
|
||||
|
||||
mapmusflags = tracknum & MUSIC_TRACKMASK;
|
||||
if (!(line->flags & ML_BLOCKMONSTERS))
|
||||
mapmusflags |= MUSIC_RELOADRESET;
|
||||
// Fade current music to target volume (if music won't be changed)
|
||||
if ((line->flags & ML_EFFECT2) && fadetarget && musicsame)
|
||||
{
|
||||
// 0 fadesource means fade from current volume.
|
||||
// meaning that we can't specify volume 0 as the source volume -- this starts at 1.
|
||||
if (!fadesource)
|
||||
fadesource = -1;
|
||||
|
||||
S_ChangeMusic(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4));
|
||||
if (!postfadems)
|
||||
S_SetInternalMusicVolume(fadetarget);
|
||||
else
|
||||
S_FadeMusicFromVolume(fadetarget, fadesource, postfadems);
|
||||
|
||||
if (position)
|
||||
S_SetMusicPosition(position);
|
||||
}
|
||||
// Change the music and apply position/fade operations
|
||||
else
|
||||
{
|
||||
strncpy(mapmusname, sides[line->sidenum[0]].text, 7);
|
||||
mapmusname[6] = 0;
|
||||
|
||||
mapmusflags = tracknum & MUSIC_TRACKMASK;
|
||||
if (!(line->flags & ML_BLOCKMONSTERS))
|
||||
mapmusflags |= MUSIC_RELOADRESET;
|
||||
if (line->flags & ML_BOUNCY)
|
||||
mapmusflags |= MUSIC_FORCERESET;
|
||||
|
||||
mapmusposition = position;
|
||||
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position,
|
||||
!(line->flags & ML_EFFECT2) ? prefadems : 0,
|
||||
!(line->flags & ML_EFFECT2) ? postfadems : 0);
|
||||
|
||||
if ((line->flags & ML_EFFECT2) && fadetarget)
|
||||
{
|
||||
if (!postfadems)
|
||||
S_SetInternalMusicVolume(fadetarget);
|
||||
else
|
||||
S_FadeMusicFromVolume(fadetarget, fadesource, postfadems);
|
||||
}
|
||||
}
|
||||
|
||||
// Except, you can use the ML_BLOCKMONSTERS flag to change this behavior.
|
||||
// if (mapmusflags & MUSIC_RELOADRESET) then it will reset the music in G_PlayerReborn.
|
||||
|
|
|
@ -1124,13 +1124,13 @@ void P_RestoreMusic(player_t *player)
|
|||
if (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC)
|
||||
{
|
||||
S_SpeedMusic(1.4f);
|
||||
S_ChangeMusic(mapmusname, mapmusflags, true);
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
|
||||
}
|
||||
else
|
||||
S_ChangeMusicInternal("shoes", true);
|
||||
}
|
||||
else
|
||||
S_ChangeMusic(mapmusname, mapmusflags, true);
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
169
src/s_sound.c
169
src/s_sound.c
|
@ -38,6 +38,10 @@ extern INT32 msg_id;
|
|||
#include "p_local.h" // camera info
|
||||
#include "m_misc.h" // for tunes command
|
||||
|
||||
#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS)
|
||||
#include "lua_hook.h" // MusicChange hook
|
||||
#endif
|
||||
|
||||
#ifdef HW3SOUND
|
||||
// 3D Sound Interface
|
||||
#include "hardware/hw3sound.h"
|
||||
|
@ -1241,6 +1245,12 @@ static void *music_data;
|
|||
static UINT16 music_flags;
|
||||
static boolean music_looping;
|
||||
|
||||
static char queue_name[7];
|
||||
static UINT16 queue_flags;
|
||||
static boolean queue_looping;
|
||||
static UINT32 queue_position;
|
||||
static UINT32 queue_fadeinms;
|
||||
|
||||
/// ------------------------
|
||||
/// Music Status
|
||||
/// ------------------------
|
||||
|
@ -1275,6 +1285,11 @@ musictype_t S_MusicType(void)
|
|||
return I_SongType();
|
||||
}
|
||||
|
||||
const char *S_MusicName(void)
|
||||
{
|
||||
return music_name;
|
||||
}
|
||||
|
||||
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
|
||||
{
|
||||
if (!I_SongPlaying())
|
||||
|
@ -1305,6 +1320,35 @@ boolean S_SpeedMusic(float speed)
|
|||
return I_SetSongSpeed(speed);
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Music Seeking
|
||||
/// ------------------------
|
||||
|
||||
UINT32 S_GetMusicLength(void)
|
||||
{
|
||||
return I_GetSongLength();
|
||||
}
|
||||
|
||||
boolean S_SetMusicLoopPoint(UINT32 looppoint)
|
||||
{
|
||||
return I_SetSongLoopPoint(looppoint);
|
||||
}
|
||||
|
||||
UINT32 S_GetMusicLoopPoint(void)
|
||||
{
|
||||
return I_GetSongLoopPoint();
|
||||
}
|
||||
|
||||
boolean S_SetMusicPosition(UINT32 position)
|
||||
{
|
||||
return I_SetSongPosition(position);
|
||||
}
|
||||
|
||||
UINT32 S_GetMusicPosition(void)
|
||||
{
|
||||
return I_GetSongPosition();
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Music Playback
|
||||
/// ------------------------
|
||||
|
@ -1377,12 +1421,13 @@ static void S_UnloadMusic(void)
|
|||
music_looping = false;
|
||||
}
|
||||
|
||||
static boolean S_PlayMusic(boolean looping)
|
||||
static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
|
||||
{
|
||||
if (S_MusicDisabled())
|
||||
return false;
|
||||
|
||||
if (!I_PlaySong(looping))
|
||||
if ((!fadeinms && !I_PlaySong(looping)) ||
|
||||
(fadeinms && !I_FadeInPlaySong(fadeinms, looping)))
|
||||
{
|
||||
S_UnloadMusic();
|
||||
return false;
|
||||
|
@ -1392,8 +1437,30 @@ static boolean S_PlayMusic(boolean looping)
|
|||
return true;
|
||||
}
|
||||
|
||||
void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping)
|
||||
static void S_QueueMusic(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 fadeinms)
|
||||
{
|
||||
strncpy(queue_name, mmusic, 7);
|
||||
queue_flags = mflags;
|
||||
queue_looping = looping;
|
||||
queue_position = position;
|
||||
queue_fadeinms = fadeinms;
|
||||
}
|
||||
|
||||
static void S_ClearQueue(void)
|
||||
{
|
||||
queue_name[0] = queue_flags = queue_looping = queue_position = queue_fadeinms = 0;
|
||||
}
|
||||
|
||||
static void S_ChangeMusicToQueue(void)
|
||||
{
|
||||
S_ChangeMusicEx(queue_name, queue_flags, queue_looping, queue_position, 0, queue_fadeinms);
|
||||
S_ClearQueue();
|
||||
}
|
||||
|
||||
void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms)
|
||||
{
|
||||
char newmusic[7];
|
||||
|
||||
#if defined (DC) || defined (_WIN32_WCE) || defined (PSP) || defined(GP2X)
|
||||
S_ClearSfx();
|
||||
#endif
|
||||
|
@ -1401,33 +1468,66 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping)
|
|||
if (S_MusicDisabled())
|
||||
return;
|
||||
|
||||
// No Music (empty string)
|
||||
if (mmusic[0] == 0)
|
||||
{
|
||||
S_StopMusic();
|
||||
strncpy(newmusic, mmusic, 7);
|
||||
#if defined(HAVE_BLUA) && defined(HAVE_LUA_MUSICPLUS)
|
||||
if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms))
|
||||
return;
|
||||
#endif
|
||||
newmusic[6] = 0;
|
||||
|
||||
// No Music (empty string)
|
||||
if (newmusic[0] == 0)
|
||||
{
|
||||
if (prefadems)
|
||||
I_FadeSong(0, prefadems, &S_StopMusic);
|
||||
else
|
||||
S_StopMusic();
|
||||
return;
|
||||
}
|
||||
|
||||
if (strnicmp(music_name, mmusic, 6))
|
||||
if (prefadems && S_MusicPlaying()) // queue music change for after fade // allow even if the music is the same
|
||||
{
|
||||
S_StopMusic(); // shutdown old music
|
||||
CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music_name);
|
||||
S_QueueMusic(newmusic, mflags, looping, position, fadeinms);
|
||||
I_FadeSong(0, prefadems, S_ChangeMusicToQueue);
|
||||
return;
|
||||
}
|
||||
else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET))
|
||||
{
|
||||
CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic);
|
||||
|
||||
if (!S_LoadMusic(mmusic))
|
||||
S_StopMusic();
|
||||
|
||||
if (!S_LoadMusic(newmusic))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded!\n", mmusic);
|
||||
CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded!\n", newmusic);
|
||||
return;
|
||||
}
|
||||
|
||||
music_flags = mflags;
|
||||
music_looping = looping;
|
||||
|
||||
if (!S_PlayMusic(looping))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Music %.6s could not be played!\n", mmusic);
|
||||
if (!S_PlayMusic(looping, fadeinms))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Music %.6s could not be played!\n", newmusic);
|
||||
return;
|
||||
}
|
||||
|
||||
if (position)
|
||||
I_SetSongPosition(position);
|
||||
|
||||
I_SetSongTrack(mflags & MUSIC_TRACKMASK);
|
||||
}
|
||||
else if (fadeinms) // let fades happen with same music
|
||||
{
|
||||
I_SetSongPosition(position);
|
||||
I_FadeSong(100, fadeinms, NULL);
|
||||
}
|
||||
else // reset volume to 100 with same music
|
||||
{
|
||||
I_StopFadingSong();
|
||||
I_FadeSong(100, 500, NULL);
|
||||
}
|
||||
I_SetSongTrack(mflags & MUSIC_TRACKMASK);
|
||||
}
|
||||
|
||||
void S_StopMusic(void)
|
||||
|
@ -1502,6 +1602,32 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
|
|||
}
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Music Fading
|
||||
/// ------------------------
|
||||
|
||||
void S_SetInternalMusicVolume(INT32 volume)
|
||||
{
|
||||
I_SetInternalMusicVolume(min(max(volume, 0), 100));
|
||||
}
|
||||
|
||||
void S_StopFadingMusic(void)
|
||||
{
|
||||
I_StopFadingSong();
|
||||
}
|
||||
|
||||
boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 ms)
|
||||
{
|
||||
if (source_volume < 0)
|
||||
return I_FadeSong(target_volume, ms, NULL);
|
||||
else
|
||||
return I_FadeSongFromVolume(target_volume, source_volume, ms, NULL);
|
||||
}
|
||||
|
||||
boolean S_FadeOutStopMusic(UINT32 ms)
|
||||
{
|
||||
return I_FadeSong(0, ms, &S_StopMusic);
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Init & Others
|
||||
|
@ -1519,22 +1645,24 @@ void S_Start(void)
|
|||
strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7);
|
||||
mapmusname[6] = 0;
|
||||
mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK);
|
||||
mapmusposition = mapheaderinfo[gamemap-1]->muspos;
|
||||
}
|
||||
|
||||
if (cv_resetmusic.value)
|
||||
S_StopMusic();
|
||||
S_ChangeMusic(mapmusname, mapmusflags, true);
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
|
||||
}
|
||||
|
||||
static void Command_Tunes_f(void)
|
||||
{
|
||||
const char *tunearg;
|
||||
UINT16 tunenum, track = 0;
|
||||
UINT32 position = 0;
|
||||
const size_t argc = COM_Argc();
|
||||
|
||||
if (argc < 2) //tunes slot ...
|
||||
{
|
||||
CONS_Printf("tunes <name/num> [track] [speed] / <-show> / <-default> / <-none>:\n");
|
||||
CONS_Printf("tunes <name/num> [track] [speed] [position] / <-show> / <-default> / <-none>:\n");
|
||||
CONS_Printf(M_GetText("Play an arbitrary music lump. If a map number is used, 'MAP##M' is played.\n"));
|
||||
CONS_Printf(M_GetText("If the format supports multiple songs, you can specify which one to play.\n\n"));
|
||||
CONS_Printf(M_GetText("* With \"-show\", shows the currently playing tune and track.\n"));
|
||||
|
@ -1581,10 +1709,15 @@ static void Command_Tunes_f(void)
|
|||
snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum));
|
||||
else
|
||||
strncpy(mapmusname, tunearg, 7);
|
||||
|
||||
if (argc > 4)
|
||||
position = (UINT32)atoi(COM_Argv(4));
|
||||
|
||||
mapmusname[6] = 0;
|
||||
mapmusflags = (track & MUSIC_TRACKMASK);
|
||||
mapmusposition = position;
|
||||
|
||||
S_ChangeMusic(mapmusname, mapmusflags, true);
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
|
||||
|
||||
if (argc > 3)
|
||||
{
|
||||
|
|
|
@ -112,29 +112,49 @@ boolean S_MusicDisabled(void);
|
|||
boolean S_MusicPlaying(void);
|
||||
boolean S_MusicPaused(void);
|
||||
musictype_t S_MusicType(void);
|
||||
const char *S_MusicName(void);
|
||||
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping);
|
||||
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi);
|
||||
#define S_DigExists(a) S_MusicExists(a, false, true)
|
||||
#define S_MIDIExists(a) S_MusicExists(a, true, false)
|
||||
|
||||
|
||||
//
|
||||
// Music Properties
|
||||
// Music Effects
|
||||
//
|
||||
|
||||
// Set Speed of Music
|
||||
boolean S_SpeedMusic(float speed);
|
||||
|
||||
//
|
||||
// Music Routines
|
||||
// Music Seeking
|
||||
//
|
||||
|
||||
// Get Length of Music
|
||||
UINT32 S_GetMusicLength(void);
|
||||
|
||||
// Set LoopPoint of Music
|
||||
boolean S_SetMusicLoopPoint(UINT32 looppoint);
|
||||
|
||||
// Get LoopPoint of Music
|
||||
UINT32 S_GetMusicLoopPoint(void);
|
||||
|
||||
// Set Position of Music
|
||||
boolean S_SetMusicPosition(UINT32 position);
|
||||
|
||||
// Get Position of Music
|
||||
UINT32 S_GetMusicPosition(void);
|
||||
|
||||
//
|
||||
// Music Playback
|
||||
//
|
||||
|
||||
// Start music track, arbitrary, given its name, and set whether looping
|
||||
// note: music flags 12 bits for tracknum (gme, other formats with more than one track)
|
||||
// 13-15 aren't used yet
|
||||
// and the last bit we ignore (internal game flag for resetting music on reload)
|
||||
#define S_ChangeMusicInternal(a,b) S_ChangeMusic(a,0,b)
|
||||
void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping);
|
||||
void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms);
|
||||
#define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0)
|
||||
#define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0)
|
||||
|
||||
// Stops the music.
|
||||
void S_StopMusic(void);
|
||||
|
@ -143,6 +163,17 @@ void S_StopMusic(void);
|
|||
void S_PauseAudio(void);
|
||||
void S_ResumeAudio(void);
|
||||
|
||||
//
|
||||
// Music Fading
|
||||
//
|
||||
|
||||
void S_SetInternalMusicVolume(INT32 volume);
|
||||
void S_StopFadingMusic(void);
|
||||
boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 ms);
|
||||
#define S_FadeMusic(a, b) S_FadeMusicFromVolume(a, -1, b)
|
||||
#define S_FadeInChangeMusic(a,b,c,d) S_ChangeMusicEx(a,b,c,0,0,d)
|
||||
boolean S_FadeOutStopMusic(UINT32 ms);
|
||||
|
||||
//
|
||||
// Updates music & sounds
|
||||
//
|
||||
|
|
|
@ -70,6 +70,8 @@ if(${SDL2_FOUND})
|
|||
set(SRB2_SDL2_TOTAL_SOURCES
|
||||
${SRB2_CORE_SOURCES}
|
||||
${SRB2_CORE_HEADERS}
|
||||
${SRB2_PNG_SOURCES}
|
||||
${SRB2_PNG_HEADERS}
|
||||
${SRB2_CORE_RENDER_SOURCES}
|
||||
${SRB2_CORE_GAME_SOURCES}
|
||||
${SRB2_LUA_SOURCES}
|
||||
|
@ -80,7 +82,8 @@ if(${SDL2_FOUND})
|
|||
${SRB2_SDL2_HEADERS}
|
||||
)
|
||||
|
||||
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
|
||||
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS}
|
||||
${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS})
|
||||
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
|
||||
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
|
||||
source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES})
|
||||
|
|
|
@ -164,6 +164,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\am_map.h" />
|
||||
<ClInclude Include="..\apng.h" />
|
||||
<ClInclude Include="..\blua\lapi.h" />
|
||||
<ClInclude Include="..\blua\lauxlib.h" />
|
||||
<ClInclude Include="..\blua\lcode.h" />
|
||||
|
@ -316,6 +317,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\am_map.c" />
|
||||
<ClCompile Include="..\apng.c" />
|
||||
<ClCompile Include="..\blua\lapi.c" />
|
||||
<ClCompile Include="..\blua\lauxlib.c" />
|
||||
<ClCompile Include="..\blua\lbaselib.c" />
|
||||
|
|
|
@ -294,6 +294,9 @@
|
|||
<ClInclude Include="..\lua_script.h">
|
||||
<Filter>LUA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\apng.h">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\md5.h">
|
||||
<Filter>M_Misc</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -2834,6 +2834,50 @@
|
|||
RelativePath="..\m_argv.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\apng.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\apng.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\m_bbox.c"
|
||||
>
|
||||
|
|
|
@ -2045,8 +2045,8 @@ static void I_ShutdownTimer(void)
|
|||
//
|
||||
tic_t I_GetTime (void)
|
||||
{
|
||||
static Uint32 basetime = 0;
|
||||
Uint32 ticks = SDL_GetTicks();
|
||||
static Uint64 basetime = 0;
|
||||
Uint64 ticks = SDL_GetTicks();
|
||||
|
||||
if (!basetime)
|
||||
basetime = ticks;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
1E44AF0D0B67CDE900BAD059 /* m_fixed.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEFE0B67CDE900BAD059 /* m_fixed.c */; };
|
||||
1E44AF0F0B67CDE900BAD059 /* m_menu.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF000B67CDE900BAD059 /* m_menu.c */; };
|
||||
1E44AF110B67CDE900BAD059 /* m_misc.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF020B67CDE900BAD059 /* m_misc.c */; };
|
||||
1E44AF110B67CDE900BAD059 /* apng.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF020B67CDE900BAD059 /* apng.c */; };
|
||||
1E44AF130B67CDE900BAD059 /* m_random.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF040B67CDE900BAD059 /* m_random.c */; };
|
||||
1E44AF1A0B67CE2A00BAD059 /* info.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF180B67CE2A00BAD059 /* info.c */; };
|
||||
1E44AF1E0B67CE3600BAD059 /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF1C0B67CE3600BAD059 /* md5.c */; };
|
||||
|
@ -253,7 +254,9 @@
|
|||
1E44AF000B67CDE900BAD059 /* m_menu.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_menu.c; path = ../../m_menu.c; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF010B67CDE900BAD059 /* m_menu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_menu.h; path = ../../m_menu.h; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF020B67CDE900BAD059 /* m_misc.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_misc.c; path = ../../m_misc.c; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF020B67CDE900BAD059 /* apng.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = apng.c; path = ../../m_misc.c; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF030B67CDE900BAD059 /* m_misc.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_misc.h; path = ../../m_misc.h; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF020B67CDE900BAD059 /* apng.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = apng.h; path = ../../m_misc.c; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF040B67CDE900BAD059 /* m_random.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_random.c; path = ../../m_random.c; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF050B67CDE900BAD059 /* m_random.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_random.h; path = ../../m_random.h; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF060B67CDE900BAD059 /* m_swap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_swap.h; path = ../../m_swap.h; sourceTree = SOURCE_ROOT; };
|
||||
|
@ -679,6 +682,8 @@
|
|||
1E44AEFF0B67CDE900BAD059 /* m_fixed.h */,
|
||||
1E44AF020B67CDE900BAD059 /* m_misc.c */,
|
||||
1E44AF030B67CDE900BAD059 /* m_misc.h */,
|
||||
1E44AF020B67CDE900BAD059 /* apng.c */,
|
||||
1E44AF030B67CDE900BAD059 /* apng.h */,
|
||||
676BB51C0E0DE06100C95963 /* m_queue.c */,
|
||||
676BB51D0E0DE06100C95963 /* m_queue.h */,
|
||||
1E44AF040B67CDE900BAD059 /* m_random.c */,
|
||||
|
|
|
@ -75,15 +75,41 @@
|
|||
UINT8 sound_started = false;
|
||||
|
||||
static Mix_Music *music;
|
||||
static UINT8 music_volume, sfx_volume;
|
||||
static UINT8 music_volume, sfx_volume, internal_volume;
|
||||
static float loop_point;
|
||||
static float song_length; // length in seconds
|
||||
static boolean songpaused;
|
||||
static UINT32 music_bytes;
|
||||
static boolean is_looping;
|
||||
|
||||
// fading
|
||||
static boolean is_fading;
|
||||
static UINT8 fading_source;
|
||||
static UINT8 fading_target;
|
||||
static UINT32 fading_timer;
|
||||
static UINT32 fading_duration;
|
||||
static INT32 fading_id;
|
||||
static void (*fading_callback)(void);
|
||||
|
||||
#ifdef HAVE_LIBGME
|
||||
static Music_Emu *gme;
|
||||
static INT32 current_track;
|
||||
#endif
|
||||
|
||||
static void var_cleanup(void)
|
||||
{
|
||||
loop_point = song_length =\
|
||||
music_bytes = fading_source = fading_target =\
|
||||
fading_timer = fading_duration = 0;
|
||||
|
||||
songpaused = is_looping =\
|
||||
is_fading = false;
|
||||
|
||||
fading_callback = NULL;
|
||||
|
||||
internal_volume = 100;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Audio System
|
||||
/// ------------------------
|
||||
|
@ -111,6 +137,8 @@ void I_StartupSound(void)
|
|||
return;
|
||||
}
|
||||
|
||||
var_cleanup();
|
||||
|
||||
music = NULL;
|
||||
music_volume = sfx_volume = 0;
|
||||
|
||||
|
@ -336,6 +364,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
|
|||
len = (info->play_length * 441 / 10) << 2;
|
||||
mem = malloc(len);
|
||||
gme_play(emu, len >> 1, mem);
|
||||
gme_free_info(info);
|
||||
gme_delete(emu);
|
||||
|
||||
return Mix_QuickLoad_RAW((Uint8 *)mem, len);
|
||||
|
@ -408,6 +437,7 @@ void *I_GetSfx(sfxinfo_t *sfx)
|
|||
len = (info->play_length * 441 / 10) << 2;
|
||||
mem = malloc(len);
|
||||
gme_play(emu, len >> 1, mem);
|
||||
gme_free_info(info);
|
||||
gme_delete(emu);
|
||||
|
||||
return Mix_QuickLoad_RAW((Uint8 *)mem, len);
|
||||
|
@ -482,14 +512,102 @@ void I_SetSfxVolume(UINT8 volume)
|
|||
sfx_volume = volume;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Music Utilities
|
||||
/// ------------------------
|
||||
|
||||
static UINT32 get_real_volume(UINT8 volume)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (I_SongType() == MU_MID)
|
||||
// HACK: Until we stop using native MIDI,
|
||||
// disable volume changes
|
||||
return ((UINT32)31*128/31); // volume = 31
|
||||
else
|
||||
#endif
|
||||
// convert volume to mixer's 128 scale
|
||||
// then apply internal_volume as a percentage
|
||||
return ((UINT32)volume*128/31) * (UINT32)internal_volume / 100;
|
||||
}
|
||||
|
||||
static UINT32 get_adjusted_position(UINT32 position)
|
||||
{
|
||||
// all in milliseconds
|
||||
UINT32 length = I_GetSongLength();
|
||||
UINT32 looppoint = I_GetSongLoopPoint();
|
||||
if (length)
|
||||
return position >= length ? (position % (length-looppoint)) : position;
|
||||
else
|
||||
return position;
|
||||
}
|
||||
|
||||
static void do_fading_callback(void)
|
||||
{
|
||||
if (fading_callback)
|
||||
(*fading_callback)();
|
||||
fading_callback = NULL;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Music Hooks
|
||||
/// ------------------------
|
||||
|
||||
static void count_music_bytes(int chan, void *stream, int len, void *udata)
|
||||
{
|
||||
(void)chan;
|
||||
(void)stream;
|
||||
(void)udata;
|
||||
|
||||
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID)
|
||||
return;
|
||||
music_bytes += len;
|
||||
}
|
||||
|
||||
static void music_loop(void)
|
||||
{
|
||||
Mix_PlayMusic(music, 0);
|
||||
Mix_SetMusicPosition(loop_point);
|
||||
if (is_looping)
|
||||
{
|
||||
Mix_PlayMusic(music, 0);
|
||||
Mix_SetMusicPosition(loop_point);
|
||||
music_bytes = loop_point*44100.0L*4; //assume 44.1khz, 4-byte length (see I_GetSongPosition)
|
||||
}
|
||||
else
|
||||
I_StopSong();
|
||||
}
|
||||
|
||||
static UINT32 music_fade(UINT32 interval, void *param)
|
||||
{
|
||||
(void)param;
|
||||
|
||||
if (!is_fading ||
|
||||
internal_volume == fading_target ||
|
||||
fading_duration == 0)
|
||||
{
|
||||
I_StopFadingSong();
|
||||
do_fading_callback();
|
||||
return 0;
|
||||
}
|
||||
else if (songpaused) // don't decrement timer
|
||||
return interval;
|
||||
else if ((fading_timer -= 10) <= 0)
|
||||
{
|
||||
internal_volume = fading_target;
|
||||
Mix_VolumeMusic(get_real_volume(music_volume));
|
||||
I_StopFadingSong();
|
||||
do_fading_callback();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT8 delta = abs(fading_target - fading_source);
|
||||
fixed_t factor = FixedDiv(fading_duration - fading_timer, fading_duration);
|
||||
if (fading_target < fading_source)
|
||||
internal_volume = max(min(internal_volume, fading_source - FixedMul(delta, factor)), fading_target);
|
||||
else if (fading_target > fading_source)
|
||||
internal_volume = min(max(internal_volume, fading_source + FixedMul(delta, factor)), fading_target);
|
||||
Mix_VolumeMusic(get_real_volume(music_volume));
|
||||
return interval;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBGME
|
||||
|
@ -509,7 +627,7 @@ static void mix_gme(void *udata, Uint8 *stream, int len)
|
|||
|
||||
// apply volume to stream
|
||||
for (i = 0, p = (short *)stream; i < len/2; i++, p++)
|
||||
*p = ((INT32)*p) * music_volume*2 / 42;
|
||||
*p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 42;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -587,6 +705,194 @@ boolean I_SetSongSpeed(float speed)
|
|||
return false;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// MUSIC SEEKING
|
||||
/// ------------------------
|
||||
|
||||
UINT32 I_GetSongLength(void)
|
||||
{
|
||||
INT32 length;
|
||||
|
||||
#ifdef HAVE_LIBGME
|
||||
if (gme)
|
||||
{
|
||||
gme_info_t *info;
|
||||
gme_err_t gme_e = gme_track_info(gme, &info, current_track);
|
||||
|
||||
if (gme_e != NULL)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e);
|
||||
length = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// reconstruct info->play_length, from GME source
|
||||
// we only want intro + 1 loop, not 2
|
||||
length = info->length;
|
||||
if (length <= 0)
|
||||
{
|
||||
length = info->intro_length + info->loop_length; // intro + 1 loop
|
||||
if (length <= 0)
|
||||
length = 150 * 1000; // 2.5 minutes
|
||||
}
|
||||
}
|
||||
|
||||
gme_free_info(info);
|
||||
return max(length, 0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
// VERY IMPORTANT to set your LENGTHMS= in your song files, folks!
|
||||
// SDL mixer can't read music length itself.
|
||||
length = (UINT32)(song_length*1000);
|
||||
if (!length)
|
||||
CONS_Debug(DBG_DETAILED, "Getting music length: music is missing LENGTHMS= tag. Needed for seeking.\n");
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
boolean I_SetSongLoopPoint(UINT32 looppoint)
|
||||
{
|
||||
if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID || !is_looping)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
UINT32 length = I_GetSongLength();
|
||||
|
||||
if (length > 0)
|
||||
looppoint %= length;
|
||||
|
||||
loop_point = max((float)(looppoint / 1000.0L), 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
UINT32 I_GetSongLoopPoint(void)
|
||||
{
|
||||
#ifdef HAVE_LIBGME
|
||||
if (gme)
|
||||
{
|
||||
INT32 looppoint;
|
||||
gme_info_t *info;
|
||||
gme_err_t gme_e = gme_track_info(gme, &info, current_track);
|
||||
|
||||
if (gme_e != NULL)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e);
|
||||
looppoint = 0;
|
||||
}
|
||||
else
|
||||
looppoint = info->intro_length > 0 ? info->intro_length : 0;
|
||||
|
||||
gme_free_info(info);
|
||||
return max(looppoint, 0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID)
|
||||
return 0;
|
||||
else
|
||||
return (UINT32)(loop_point * 1000);
|
||||
}
|
||||
|
||||
boolean I_SetSongPosition(UINT32 position)
|
||||
{
|
||||
UINT32 length;
|
||||
#ifdef HAVE_LIBGME
|
||||
if (gme)
|
||||
{
|
||||
// this is unstable, so fail silently
|
||||
return true;
|
||||
// this isn't required technically, but GME thread-locks for a second
|
||||
// if you seek too high from the counter
|
||||
// length = I_GetSongLength();
|
||||
// if (length)
|
||||
// position = get_adjusted_position(position);
|
||||
|
||||
// SDL_LockAudio();
|
||||
// gme_err_t gme_e = gme_seek(gme, position);
|
||||
// SDL_UnlockAudio();
|
||||
|
||||
// if (gme_e != NULL)
|
||||
// {
|
||||
// CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e);
|
||||
// return false;
|
||||
// }
|
||||
// else
|
||||
// return true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (!music || I_SongType() == MU_MID)
|
||||
return false;
|
||||
else if (I_SongType() == MU_MOD)
|
||||
return Mix_SetMusicPosition(position); // Goes by channels
|
||||
else
|
||||
{
|
||||
// Because SDL mixer can't identify song length, if you have
|
||||
// a position input greater than the real length, then
|
||||
// music_bytes becomes inaccurate.
|
||||
|
||||
length = I_GetSongLength(); // get it in MS
|
||||
if (length)
|
||||
position = get_adjusted_position(position);
|
||||
|
||||
Mix_RewindMusic(); // needed for mp3
|
||||
if(Mix_SetMusicPosition((float)(position/1000.0L)) == 0)
|
||||
music_bytes = position/1000.0L*44100.0L*4; //assume 44.1khz, 4-byte length (see I_GetSongPosition)
|
||||
else
|
||||
// NOTE: This block fires on incorrect song format,
|
||||
// NOT if position input is greater than song length.
|
||||
music_bytes = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
UINT32 I_GetSongPosition(void)
|
||||
{
|
||||
#ifdef HAVE_LIBGME
|
||||
if (gme)
|
||||
{
|
||||
INT32 position = gme_tell(gme);
|
||||
|
||||
gme_info_t *info;
|
||||
gme_err_t gme_e = gme_track_info(gme, &info, current_track);
|
||||
|
||||
if (gme_e != NULL)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e);
|
||||
return position;
|
||||
}
|
||||
else
|
||||
{
|
||||
// adjust position, since GME's counter keeps going past loop
|
||||
if (info->length > 0)
|
||||
position %= info->length;
|
||||
else if (info->intro_length + info->loop_length > 0)
|
||||
position = position >= (info->intro_length + info->loop_length) ? (position % info->loop_length) : position;
|
||||
else
|
||||
position %= 150 * 1000; // 2.5 minutes
|
||||
}
|
||||
|
||||
gme_free_info(info);
|
||||
return max(position, 0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (!music || I_SongType() == MU_MID)
|
||||
return 0;
|
||||
else
|
||||
return music_bytes/44100.0L*1000.0L/4; //assume 44.1khz
|
||||
// 4 = byte length for 16-bit samples (AUDIO_S16SYS), stereo (2-channel)
|
||||
// This is hardcoded in I_StartupSound. Other formats for factor:
|
||||
// 8M: 1 | 8S: 2 | 16M: 2 | 16S: 4
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// Music Playback
|
||||
/// ------------------------
|
||||
|
@ -596,9 +902,21 @@ boolean I_LoadSong(char *data, size_t len)
|
|||
const char *key1 = "LOOP";
|
||||
const char *key2 = "POINT=";
|
||||
const char *key3 = "MS=";
|
||||
const char *key4 = "LENGTHMS=";
|
||||
const size_t key1len = strlen(key1);
|
||||
const size_t key2len = strlen(key2);
|
||||
const size_t key3len = strlen(key3);
|
||||
const size_t key4len = strlen(key4);
|
||||
|
||||
// for mp3 wide chars
|
||||
const char *key1w = "L\0O\0O\0P\0";
|
||||
const char *key2w = "P\0O\0I\0N\0T\0\0\0\xFF\xFE";
|
||||
const char *key3w = "M\0S\0\0\0\xFF\xFE";
|
||||
const char *key4w = "L\0E\0N\0G\0T\0H\0M\0S\0\0\0\xFF\xFE";
|
||||
const char *wterm = "\0\0";
|
||||
char wval[10];
|
||||
|
||||
size_t wstart, wp;
|
||||
char *p = data;
|
||||
SDL_RWops *rw;
|
||||
|
||||
|
@ -609,6 +927,9 @@ boolean I_LoadSong(char *data, size_t len)
|
|||
)
|
||||
I_UnloadSong();
|
||||
|
||||
// always do this whether or not a music already exists
|
||||
var_cleanup();
|
||||
|
||||
#ifdef HAVE_LIBGME
|
||||
if ((UINT8)data[0] == 0x1F
|
||||
&& (UINT8)data[1] == 0x8B)
|
||||
|
@ -718,30 +1039,88 @@ boolean I_LoadSong(char *data, size_t len)
|
|||
|
||||
// Find the OGG loop point.
|
||||
loop_point = 0.0f;
|
||||
song_length = 0.0f;
|
||||
|
||||
while ((UINT32)(p - data) < len)
|
||||
{
|
||||
if (strncmp(p++, key1, key1len))
|
||||
continue;
|
||||
p += key1len-1; // skip OOP (the L was skipped in strncmp)
|
||||
if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=?
|
||||
if (fpclassify(loop_point) == FP_ZERO && !strncmp(p, key1, key1len))
|
||||
{
|
||||
p += key2len; // skip POINT=
|
||||
loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count.
|
||||
// because SDL_Mixer is USELESS and can't even tell us
|
||||
// something simple like the frequency of the streaming music,
|
||||
// we are unfortunately forced to assume that ALL MUSIC is 44100hz.
|
||||
// This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly.
|
||||
p += key1len; // skip LOOP
|
||||
if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=?
|
||||
{
|
||||
p += key2len; // skip POINT=
|
||||
loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count.
|
||||
// because SDL_Mixer is USELESS and can't even tell us
|
||||
// something simple like the frequency of the streaming music,
|
||||
// we are unfortunately forced to assume that ALL MUSIC is 44100hz.
|
||||
// This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly.
|
||||
}
|
||||
else if (!strncmp(p, key3, key3len)) // is it LOOPMS=?
|
||||
{
|
||||
p += key3len; // skip MS=
|
||||
loop_point = (float)(atoi(p) / 1000.0L); // LOOPMS works by real time, as miliseconds.
|
||||
// Everything that uses LOOPMS will work perfectly with SDL_Mixer.
|
||||
}
|
||||
}
|
||||
else if (!strncmp(p, key3, key3len)) // is it LOOPMS=?
|
||||
else if (fpclassify(song_length) == FP_ZERO && !strncmp(p, key4, key4len)) // is it LENGTHMS=?
|
||||
{
|
||||
p += key3len; // skip MS=
|
||||
loop_point = (float)(atoi(p) / 1000.0L); // LOOPMS works by real time, as miliseconds.
|
||||
// Everything that uses LOOPMS will work perfectly with SDL_Mixer.
|
||||
p += key4len; // skip LENGTHMS
|
||||
song_length = (float)(atoi(p) / 1000.0L);
|
||||
}
|
||||
// below: search MP3 or other tags that use wide char encoding
|
||||
else if (fpclassify(loop_point) == FP_ZERO && !memcmp(p, key1w, key1len*2)) // LOOP wide char
|
||||
{
|
||||
p += key1len*2;
|
||||
if (!memcmp(p, key2w, (key2len+1)*2)) // POINT= wide char
|
||||
{
|
||||
p += (key2len+1)*2;
|
||||
wstart = (size_t)p;
|
||||
wp = 0;
|
||||
while (wp < 9 && memcmp(p, wterm, 2))
|
||||
{
|
||||
wval[wp] = *p;
|
||||
p += 2;
|
||||
wp = ((size_t)(p-wstart))/2;
|
||||
}
|
||||
wval[min(wp, 9)] = 0;
|
||||
loop_point = (float)((44.1L+atoi(wval) / 44100.0L));
|
||||
}
|
||||
else if (!memcmp(p, key3w, (key3len+1)*2)) // MS= wide char
|
||||
{
|
||||
p += (key3len+1)*2;
|
||||
wstart = (size_t)p;
|
||||
wp = 0;
|
||||
while (wp < 9 && memcmp(p, wterm, 2))
|
||||
{
|
||||
wval[wp] = *p;
|
||||
p += 2;
|
||||
wp = ((size_t)(p-wstart))/2;
|
||||
}
|
||||
wval[min(wp, 9)] = 0;
|
||||
loop_point = (float)(atoi(wval) / 1000.0L);
|
||||
}
|
||||
}
|
||||
else if (fpclassify(song_length) == FP_ZERO && !memcmp(p, key4w, (key4len+1)*2)) // LENGTHMS= wide char
|
||||
{
|
||||
p += (key4len+1)*2;
|
||||
wstart = (size_t)p;
|
||||
wp = 0;
|
||||
while (wp < 9 && memcmp(p, wterm, 2))
|
||||
{
|
||||
wval[wp] = *p;
|
||||
p += 2;
|
||||
wp = ((size_t)(p-wstart))/2;
|
||||
}
|
||||
wval[min(wp, 9)] = 0;
|
||||
song_length = (float)(atoi(wval) / 1000.0L);
|
||||
}
|
||||
// Neither?! Continue searching.
|
||||
}
|
||||
|
||||
if (fpclassify(loop_point) != FP_ZERO && fpclassify(song_length) != FP_ZERO && song_length > loop_point) // Got what we needed
|
||||
// the last case is a sanity check, in case the wide char searches were false matches.
|
||||
break;
|
||||
else // continue searching
|
||||
p++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -765,7 +1144,6 @@ void I_UnloadSong(void)
|
|||
|
||||
boolean I_PlaySong(boolean looping)
|
||||
{
|
||||
boolean lpz = fpclassify(loop_point) == FP_ZERO;
|
||||
#ifdef HAVE_LIBGME
|
||||
if (gme)
|
||||
{
|
||||
|
@ -779,21 +1157,37 @@ boolean I_PlaySong(boolean looping)
|
|||
if (!music)
|
||||
return false;
|
||||
|
||||
if (fpclassify(song_length) == FP_ZERO && (I_SongType() == MU_OGG || I_SongType() == MU_MP3 || I_SongType() == MU_FLAC))
|
||||
CONS_Debug(DBG_DETAILED, "This song is missing a LENGTHMS= tag! Required to make seeking work properly.\n");
|
||||
|
||||
if (Mix_PlayMusic(music, looping && lpz ? -1 : 0) == -1)
|
||||
if (I_SongType() != MU_MOD && I_SongType() != MU_MID && Mix_PlayMusic(music, 0) == -1)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
|
||||
return false;
|
||||
}
|
||||
else if ((I_SongType() == MU_MOD || I_SongType() == MU_MID) && Mix_PlayMusic(music, looping ? -1 : 0) == -1) // if MOD, loop forever
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError());
|
||||
return false;
|
||||
}
|
||||
Mix_VolumeMusic((UINT32)music_volume*128/31);
|
||||
|
||||
if (!lpz)
|
||||
Mix_HookMusicFinished(music_loop);
|
||||
is_looping = looping;
|
||||
|
||||
I_SetMusicVolume(music_volume);
|
||||
|
||||
if (I_SongType() != MU_MOD && I_SongType() != MU_MID)
|
||||
Mix_HookMusicFinished(music_loop); // don't bother counting if MOD
|
||||
|
||||
if(I_SongType() != MU_MOD && I_SongType() != MU_MID && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL))
|
||||
CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void I_StopSong(void)
|
||||
{
|
||||
I_StopFadingSong();
|
||||
|
||||
#ifdef HAVE_LIBGME
|
||||
if (gme)
|
||||
{
|
||||
|
@ -803,19 +1197,40 @@ void I_StopSong(void)
|
|||
#endif
|
||||
if (music)
|
||||
{
|
||||
Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes);
|
||||
Mix_HookMusicFinished(NULL);
|
||||
Mix_HaltMusic();
|
||||
}
|
||||
|
||||
var_cleanup();
|
||||
}
|
||||
|
||||
void I_PauseSong(void)
|
||||
{
|
||||
if(I_SongType() == MU_MID) // really, SDL Mixer? why can't you pause MIDI???
|
||||
return;
|
||||
|
||||
if(I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID)
|
||||
Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes);
|
||||
|
||||
Mix_PauseMusic();
|
||||
songpaused = true;
|
||||
}
|
||||
|
||||
void I_ResumeSong(void)
|
||||
{
|
||||
if (I_SongType() == MU_MID)
|
||||
return;
|
||||
|
||||
if (I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID)
|
||||
{
|
||||
while(Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes) != 0) { }
|
||||
// HACK: fixes issue of multiple effect callbacks being registered
|
||||
|
||||
if(music && I_SongType() != MU_MOD && I_SongType() != MU_MID && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL))
|
||||
CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError());
|
||||
}
|
||||
|
||||
Mix_ResumeMusic();
|
||||
songpaused = false;
|
||||
}
|
||||
|
@ -834,7 +1249,7 @@ void I_SetMusicVolume(UINT8 volume)
|
|||
#endif
|
||||
music_volume = volume;
|
||||
|
||||
Mix_VolumeMusic((UINT32)music_volume*128/31);
|
||||
Mix_VolumeMusic(get_real_volume(music_volume));
|
||||
}
|
||||
|
||||
boolean I_SetSongTrack(int track)
|
||||
|
@ -863,9 +1278,100 @@ boolean I_SetSongTrack(int track)
|
|||
SDL_UnlockAudio();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (I_SongType() == MU_MOD)
|
||||
return !Mix_SetMusicPosition(track);
|
||||
(void)track;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// MUSIC FADING
|
||||
/// ------------------------
|
||||
|
||||
void I_SetInternalMusicVolume(UINT8 volume)
|
||||
{
|
||||
internal_volume = volume;
|
||||
if (!I_SongPlaying())
|
||||
return;
|
||||
Mix_VolumeMusic(get_real_volume(music_volume));
|
||||
}
|
||||
|
||||
void I_StopFadingSong(void)
|
||||
{
|
||||
if (fading_id)
|
||||
SDL_RemoveTimer(fading_id);
|
||||
is_fading = false;
|
||||
fading_source = fading_target = fading_timer = fading_duration = fading_id = 0;
|
||||
}
|
||||
|
||||
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void))
|
||||
{
|
||||
INT16 volume_delta;
|
||||
|
||||
source_volume = min(source_volume, 100);
|
||||
volume_delta = (INT16)(target_volume - source_volume);
|
||||
|
||||
I_StopFadingSong();
|
||||
|
||||
if (!ms && volume_delta)
|
||||
{
|
||||
I_SetInternalMusicVolume(target_volume);
|
||||
if (callback)
|
||||
(*callback)();
|
||||
return true;
|
||||
|
||||
}
|
||||
else if (!volume_delta)
|
||||
{
|
||||
if (callback)
|
||||
(*callback)();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Round MS to nearest 10
|
||||
// If n - lower > higher - n, then round up
|
||||
ms = (ms - ((ms / 10) * 10) > (((ms / 10) * 10) + 10) - ms) ?
|
||||
(((ms / 10) * 10) + 10) // higher
|
||||
: ((ms / 10) * 10); // lower
|
||||
|
||||
if (!ms)
|
||||
I_SetInternalMusicVolume(target_volume);
|
||||
else if (source_volume != target_volume)
|
||||
{
|
||||
fading_id = SDL_AddTimer(10, music_fade, NULL);
|
||||
if (fading_id)
|
||||
{
|
||||
is_fading = true;
|
||||
fading_timer = fading_duration = ms;
|
||||
fading_source = source_volume;
|
||||
fading_target = target_volume;
|
||||
fading_callback = callback;
|
||||
|
||||
if (internal_volume != source_volume)
|
||||
I_SetInternalMusicVolume(source_volume);
|
||||
}
|
||||
}
|
||||
|
||||
return is_fading;
|
||||
}
|
||||
|
||||
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void))
|
||||
{
|
||||
return I_FadeSongFromVolume(target_volume, internal_volume, ms, callback);
|
||||
}
|
||||
|
||||
boolean I_FadeOutStopSong(UINT32 ms)
|
||||
{
|
||||
return I_FadeSongFromVolume(0, internal_volume, ms, &I_StopSong);
|
||||
}
|
||||
|
||||
boolean I_FadeInPlaySong(UINT32 ms, boolean looping)
|
||||
{
|
||||
if (I_PlaySong(looping))
|
||||
return I_FadeSongFromVolume(100, 0, ms, NULL);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1375,6 +1375,37 @@ boolean I_SetSongSpeed(float speed)
|
|||
return false;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC SEEKING
|
||||
/// ------------------------
|
||||
|
||||
UINT32 I_GetSongLength(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongLoopPoint(UINT32 looppoint)
|
||||
{
|
||||
(void)looppoint;
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 I_GetSongLoopPoint(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongPosition(UINT32 position)
|
||||
{
|
||||
(void)position;
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 I_GetSongPosition(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC PLAYBACK
|
||||
/// ------------------------
|
||||
|
@ -1443,6 +1474,47 @@ boolean I_SetSongTrack(int track)
|
|||
return false;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// MUSIC FADING
|
||||
/// ------------------------
|
||||
|
||||
void I_SetInternalMusicVolume(UINT8 volume)
|
||||
{
|
||||
(void)volume;
|
||||
}
|
||||
|
||||
void I_StopFadingSong(void)
|
||||
{
|
||||
}
|
||||
|
||||
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void))
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)source_volume;
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void))
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeOutStopSong(UINT32 ms)
|
||||
{
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeInPlaySong(UINT32 ms, boolean looping)
|
||||
{
|
||||
(void)ms;
|
||||
(void)looping;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC LOADING AND CLEANUP
|
||||
// \todo Split logic between loading and playing,
|
||||
|
|
|
@ -835,6 +835,16 @@
|
|||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\apng.c">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\m_misc.c">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -1293,6 +1303,7 @@
|
|||
<ClInclude Include="filter\interp.h" />
|
||||
<ClInclude Include="filter\lq2x.h" />
|
||||
<ClInclude Include="..\p5prof.h" />
|
||||
<ClInclude Include="..\apng.h" />
|
||||
<ClInclude Include="..\d_clisrv.h" />
|
||||
<ClInclude Include="..\d_event.h" />
|
||||
<ClInclude Include="..\d_main.h" />
|
||||
|
|
|
@ -2790,6 +2790,50 @@
|
|||
<Filter
|
||||
Name="M_Misc"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\apng.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\apng.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\m_argv.c"
|
||||
>
|
||||
|
|
|
@ -1365,6 +1365,20 @@
|
|||
path = ../../m_misc.h;
|
||||
refType = 2;
|
||||
};
|
||||
84177764085A10EB000C01D8 = {
|
||||
fileEncoding = 30;
|
||||
isa = PBXFileReference;
|
||||
name = apng.c;
|
||||
path = ../../apng.c;
|
||||
refType = 2;
|
||||
};
|
||||
84177765085A10EB000C01D8 = {
|
||||
fileEncoding = 30;
|
||||
isa = PBXFileReference;
|
||||
name = m_misc.h;
|
||||
path = ../../apng.h;
|
||||
refType = 2;
|
||||
};
|
||||
84177766085A10EB000C01D8 = {
|
||||
fileEncoding = 30;
|
||||
isa = PBXFileReference;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
1E44AF0D0B67CDE900BAD059 /* m_fixed.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEFE0B67CDE900BAD059 /* m_fixed.c */; };
|
||||
1E44AF0F0B67CDE900BAD059 /* m_menu.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF000B67CDE900BAD059 /* m_menu.c */; };
|
||||
1E44AF110B67CDE900BAD059 /* m_misc.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF020B67CDE900BAD059 /* m_misc.c */; };
|
||||
1E44AF110B67CDE900BAD059 /* apng.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF020B67CDE900BAD059 /* apng.c */; };
|
||||
1E44AF130B67CDE900BAD059 /* m_random.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF040B67CDE900BAD059 /* m_random.c */; };
|
||||
1E44AF1A0B67CE2A00BAD059 /* info.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF180B67CE2A00BAD059 /* info.c */; };
|
||||
1E44AF1E0B67CE3600BAD059 /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF1C0B67CE3600BAD059 /* md5.c */; };
|
||||
|
@ -254,6 +255,8 @@
|
|||
1E44AF010B67CDE900BAD059 /* m_menu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_menu.h; path = ../../m_menu.h; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF020B67CDE900BAD059 /* m_misc.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_misc.c; path = ../../m_misc.c; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF030B67CDE900BAD059 /* m_misc.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_misc.h; path = ../../m_misc.h; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF020B67CDE900BAD059 /* apng.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = apng.c; path = ../../m_misc.c; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF030B67CDE900BAD059 /* apng.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = apng.h; path = ../../m_misc.h; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF040B67CDE900BAD059 /* m_random.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_random.c; path = ../../m_random.c; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF050B67CDE900BAD059 /* m_random.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_random.h; path = ../../m_random.h; sourceTree = SOURCE_ROOT; };
|
||||
1E44AF060B67CDE900BAD059 /* m_swap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_swap.h; path = ../../m_swap.h; sourceTree = SOURCE_ROOT; };
|
||||
|
@ -679,6 +682,8 @@
|
|||
1E44AEFF0B67CDE900BAD059 /* m_fixed.h */,
|
||||
1E44AF020B67CDE900BAD059 /* m_misc.c */,
|
||||
1E44AF030B67CDE900BAD059 /* m_misc.h */,
|
||||
1E44AF020B67CDE900BAD059 /* apng.c */,
|
||||
1E44AF030B67CDE900BAD059 /* apng.h */,
|
||||
676BB51C0E0DE06100C95963 /* m_queue.c */,
|
||||
676BB51D0E0DE06100C95963 /* m_queue.h */,
|
||||
1E44AF040B67CDE900BAD059 /* m_random.c */,
|
||||
|
|
|
@ -185,6 +185,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
|
|||
static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum)
|
||||
{
|
||||
UINT16 posStart, posEnd;
|
||||
#ifdef HAVE_BLUA
|
||||
posStart = W_CheckNumForFolderStartPK3("Lua/", wadnum, 0);
|
||||
if (posStart != INT16_MAX)
|
||||
{
|
||||
|
@ -193,6 +194,7 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum)
|
|||
for (; posStart < posEnd; posStart++)
|
||||
LUA_LoadLump(wadnum, posStart);
|
||||
}
|
||||
#endif
|
||||
posStart = W_CheckNumForFolderStartPK3("SOC/", wadnum, 0);
|
||||
if (posStart != INT16_MAX)
|
||||
{
|
||||
|
@ -792,9 +794,11 @@ UINT16 W_InitFile(const char *filename)
|
|||
CONS_Printf(M_GetText("Loading SOC from %s\n"), wadfile->filename);
|
||||
DEH_LoadDehackedLumpPwad(numwadfiles - 1, 0);
|
||||
break;
|
||||
#ifdef HAVE_BLUA
|
||||
case RET_LUA:
|
||||
LUA_LoadLump(numwadfiles - 1, 0);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -182,6 +182,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\am_map.c" />
|
||||
<ClCompile Include="..\apng.c" />
|
||||
<ClCompile Include="..\blua\lapi.c" />
|
||||
<ClCompile Include="..\blua\lauxlib.c" />
|
||||
<ClCompile Include="..\blua\lbaselib.c" />
|
||||
|
@ -330,6 +331,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\am_map.h" />
|
||||
<ClInclude Include="..\apng.h" />
|
||||
<ClInclude Include="..\blua\lapi.h" />
|
||||
<ClInclude Include="..\blua\lauxlib.h" />
|
||||
<ClInclude Include="..\blua\lcode.h" />
|
||||
|
|
|
@ -2851,6 +2851,50 @@
|
|||
RelativePath="..\m_misc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\apng.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\apng.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\m_queue.c"
|
||||
>
|
||||
|
|
|
@ -815,6 +815,60 @@ void I_SetMusicVolume(UINT8 volume)
|
|||
FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0));
|
||||
}
|
||||
|
||||
UINT32 I_GetSongLength(void)
|
||||
{
|
||||
UINT32 length;
|
||||
if (I_SongType() == MU_MID)
|
||||
return 0;
|
||||
FMR_MUSIC(FMOD_Sound_GetLength(music_stream, &length, FMOD_TIMEUNIT_MS));
|
||||
return length;
|
||||
}
|
||||
|
||||
boolean I_SetSongLoopPoint(UINT32 looppoint)
|
||||
{
|
||||
(void)looppoint;
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT32 I_GetSongLoopPoint(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongPosition(UINT32 position)
|
||||
{
|
||||
FMOD_RESULT e;
|
||||
if(I_SongType() == MU_MID)
|
||||
// Dummy out; this works for some MIDI, but not others.
|
||||
// SDL does not support this for any MIDI.
|
||||
return false;
|
||||
e = FMOD_Channel_SetPosition(music_channel, position, FMOD_TIMEUNIT_MS);
|
||||
if (e == FMOD_OK)
|
||||
return true;
|
||||
else if (e == FMOD_ERR_UNSUPPORTED // Only music modules, numbnuts!
|
||||
|| e == FMOD_ERR_INVALID_POSITION) // Out-of-bounds!
|
||||
return false;
|
||||
else // Congrats, you horribly broke it somehow
|
||||
{
|
||||
FMR_MUSIC(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
UINT32 I_GetSongPosition(void)
|
||||
{
|
||||
FMOD_RESULT e;
|
||||
unsigned int fmposition = 0;
|
||||
if(I_SongType() == MU_MID)
|
||||
// Dummy out because unsupported, even though FMOD does this correctly.
|
||||
return 0;
|
||||
e = FMOD_Channel_GetPosition(music_channel, &fmposition, FMOD_TIMEUNIT_MS);
|
||||
if (e == FMOD_OK)
|
||||
return (UINT32)fmposition;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean I_SetSongTrack(INT32 track)
|
||||
{
|
||||
if (track != current_track) // If the track's already playing, then why bother?
|
||||
|
@ -859,3 +913,46 @@ boolean I_SetSongTrack(INT32 track)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
/// MUSIC FADING
|
||||
/// ------------------------
|
||||
|
||||
void I_SetInternalMusicVolume(UINT8 volume)
|
||||
{
|
||||
(void)volume;
|
||||
}
|
||||
|
||||
void I_StopFadingSong(void)
|
||||
{
|
||||
}
|
||||
|
||||
boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void))
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)source_volume;
|
||||
(void)ms;
|
||||
(void)callback;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void))
|
||||
{
|
||||
(void)target_volume;
|
||||
(void)ms;
|
||||
(void)callback;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeOutStopSong(UINT32 ms)
|
||||
{
|
||||
(void)ms;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean I_FadeInPlaySong(UINT32 ms, boolean looping)
|
||||
{
|
||||
(void)ms;
|
||||
(void)looping;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -696,7 +696,19 @@ void Y_Ticker(void)
|
|||
boolean anybonuses = false;
|
||||
|
||||
if (!intertic) // first time only
|
||||
S_ChangeMusicInternal("lclear", false); // don't loop it
|
||||
{
|
||||
if (mapheaderinfo[gamemap-1]->musinterfadeout
|
||||
#ifdef _WIN32
|
||||
// can't fade midi due to win32 volume hack
|
||||
&& S_MusicType() != MU_MID
|
||||
#endif
|
||||
)
|
||||
S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout);
|
||||
else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled))
|
||||
S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it
|
||||
else
|
||||
S_ChangeMusicInternal("lclear", false); // don't loop it
|
||||
}
|
||||
|
||||
if (intertic < TICRATE) // one second pause before tally begins
|
||||
return;
|
||||
|
@ -757,7 +769,17 @@ void Y_Ticker(void)
|
|||
|
||||
if (!intertic) // first time only
|
||||
{
|
||||
S_ChangeMusicInternal("lclear", false); // don't loop it
|
||||
if (mapheaderinfo[gamemap-1]->musinterfadeout
|
||||
#ifdef _WIN32
|
||||
// can't fade midi due to win32 volume hack
|
||||
&& S_MusicType() != MU_MID
|
||||
#endif
|
||||
)
|
||||
S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout);
|
||||
else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled))
|
||||
S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it
|
||||
else
|
||||
S_ChangeMusicInternal("lclear", false); // don't loop it
|
||||
tallydonetic = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue