Replace sound_func function pointer parameter and associate functions for hardcoded ANMs with equivalent animsounds arrays.

git-svn-id: https://svn.eduke32.com/eduke32@6285 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-25 11:24:34 +00:00
parent 5f8c99c3a1
commit d57234e668
11 changed files with 122 additions and 271 deletions

View file

@ -98,7 +98,6 @@ GAME_SRC = \
source/duke3d/src/game.cpp \
source/duke3d/src/actors.cpp \
source/duke3d/src/anim.cpp \
source/duke3d/src/animsounds.cpp \
source/duke3d/src/common.cpp \
source/duke3d/src/config.cpp \
source/duke3d/src/demo.cpp \

View file

@ -451,7 +451,6 @@ DUKE3D_GAME_OBJS = \
premap.cpp \
sector.cpp \
anim.cpp \
animsounds.cpp \
common.cpp \
config.cpp \
demo.cpp \

View file

@ -395,8 +395,6 @@
2038AE9A1A8F12590093B7B2 /* md4.h in Headers */ = {isa = PBXBuildFile; fileRef = 2038AE981A8F12590093B7B2 /* md4.h */; };
2038AE9C1A8F126C0093B7B2 /* md4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2038AE9B1A8F126C0093B7B2 /* md4.cpp */; };
2038AE9D1A8F126C0093B7B2 /* md4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2038AE9B1A8F126C0093B7B2 /* md4.cpp */; };
2038AEA01A8F12B60093B7B2 /* animsounds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2038AE9E1A8F12B60093B7B2 /* animsounds.cpp */; };
2038AEA11A8F12B60093B7B2 /* animsounds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2038AE9E1A8F12B60093B7B2 /* animsounds.cpp */; };
2038AEA31A8F137E0093B7B2 /* DUKE.RTS in Resources */ = {isa = PBXBuildFile; fileRef = 2038AEA21A8F137E0093B7B2 /* DUKE.RTS */; };
2044C9841E089F2500A8C543 /* palette.h in Headers */ = {isa = PBXBuildFile; fileRef = 2044C9831E089F2500A8C543 /* palette.h */; settings = {ATTRIBUTES = (Public, ); }; };
2044C9851E089F2500A8C543 /* palette.h in Headers */ = {isa = PBXBuildFile; fileRef = 2044C9831E089F2500A8C543 /* palette.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -795,8 +793,6 @@
2038AE951A8F122D0093B7B2 /* libdivide.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = libdivide.h; path = ../../source/build/include/libdivide.h; sourceTree = SOURCE_ROOT; };
2038AE981A8F12590093B7B2 /* md4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = md4.h; path = ../../source/build/include/md4.h; sourceTree = SOURCE_ROOT; };
2038AE9B1A8F126C0093B7B2 /* md4.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.c; name = md4.cpp; path = ../../source/build/src/md4.cpp; sourceTree = SOURCE_ROOT; };
2038AE9E1A8F12B60093B7B2 /* animsounds.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.c; name = animsounds.cpp; path = ../../source/duke3d/src/animsounds.cpp; sourceTree = SOURCE_ROOT; };
2038AE9F1A8F12B60093B7B2 /* animsounds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = animsounds.h; path = ../../source/duke3d/src/animsounds.h; sourceTree = SOURCE_ROOT; };
2038AEA21A8F137E0093B7B2 /* DUKE.RTS */ = {isa = PBXFileReference; lastKnownFileType = file; name = DUKE.RTS; path = ../../../DUKE.RTS; sourceTree = SOURCE_ROOT; };
2044C9831E089F2500A8C543 /* palette.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = palette.h; path = ../../source/build/include/palette.h; sourceTree = SOURCE_ROOT; };
2044C9891E08A66B00A8C543 /* palette.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.c; name = palette.cpp; path = ../../source/build/src/palette.cpp; sourceTree = SOURCE_ROOT; };
@ -1085,8 +1081,6 @@
0008E99F19F1AD9B0091588D /* actors.h */,
0008E9A019F1AD9B0091588D /* anim.cpp */,
0008E9A119F1AD9B0091588D /* anim.h */,
2038AE9E1A8F12B60093B7B2 /* animsounds.cpp */,
2038AE9F1A8F12B60093B7B2 /* animsounds.h */,
20F712531C6C1A07006B68D0 /* cheats.cpp */,
20F712541C6C1A07006B68D0 /* cheats.h */,
20E16CDF1C7022C300EE8446 /* cmdline.cpp */,
@ -1954,7 +1948,6 @@
0008E9EB19F1AD9B0091588D /* gamedef.cpp in Sources */,
20F7124D1C6C19E5006B68D0 /* screentext.cpp in Sources */,
0008EA0219F1AD9B0091588D /* soundsdyn.cpp in Sources */,
2038AEA01A8F12B60093B7B2 /* animsounds.cpp in Sources */,
0008E9EF19F1AD9B0091588D /* gamevars.cpp in Sources */,
0008E9EC19F1AD9B0091588D /* gameexec.cpp in Sources */,
20F712511C6C19F4006B68D0 /* sbar.cpp in Sources */,
@ -2129,7 +2122,6 @@
000C489D19F35601006E6B52 /* demo.cpp in Sources */,
20F712561C6C1A07006B68D0 /* cheats.cpp in Sources */,
000C48A719F35601006E6B52 /* menus.cpp in Sources */,
2038AEA11A8F12B60093B7B2 /* animsounds.cpp in Sources */,
000C48A919F35601006E6B52 /* net.cpp in Sources */,
000C48A819F35601006E6B52 /* namesdyn.cpp in Sources */,
000C48B219F35601006E6B52 /* sector.cpp in Sources */,

View file

@ -177,7 +177,6 @@
<ClInclude Include="..\..\source\duke3d\src\android.h" />
<ClInclude Include="..\..\source\duke3d\src\in_android.h" />
<ClInclude Include="..\..\source\duke3d\src\anim.h" />
<ClInclude Include="..\..\source\duke3d\src\animsounds.h" />
<ClInclude Include="..\..\source\duke3d\src\cheats.h" />
<ClInclude Include="..\..\source\duke3d\src\cmdline.h" />
<ClInclude Include="..\..\source\duke3d\src\common_game.h" />
@ -319,7 +318,6 @@
<ClCompile Include="..\..\source\duke3d\src\actors.cpp" />
<ClCompile Include="..\..\source\duke3d\src\in_android.cpp" />
<ClCompile Include="..\..\source\duke3d\src\anim.cpp" />
<ClCompile Include="..\..\source\duke3d\src\animsounds.cpp" />
<ClCompile Include="..\..\source\duke3d\src\astub.cpp" />
<ClCompile Include="..\..\source\duke3d\src\cheats.cpp" />
<ClCompile Include="..\..\source\duke3d\src\cmdline.cpp" />

View file

@ -438,9 +438,6 @@
<ClInclude Include="..\..\source\build\include\buildtypes.h">
<Filter>build\headers</Filter>
</ClInclude>
<ClInclude Include="..\..\source\duke3d\src\animsounds.h">
<Filter>eduke32\headers</Filter>
</ClInclude>
<ClInclude Include="..\..\platform\Android\Duke3d\jni\TouchControls\Button.h">
<Filter>touchcontrols\headers</Filter>
</ClInclude>
@ -854,9 +851,6 @@
<ClCompile Include="..\..\source\build\src\sdlayer12.cpp">
<Filter>build\source</Filter>
</ClCompile>
<ClCompile Include="..\..\source\duke3d\src\animsounds.cpp">
<Filter>eduke32\source</Filter>
</ClCompile>
<ClCompile Include="..\..\platform\Android\Duke3d\jni\TouchControls\Button.cpp">
<Filter>touchcontrols\source</Filter>
</ClCompile>

View file

@ -242,7 +242,6 @@ MACT_OBJS=$(MACT_OBJ)\file_lib.$o \
DUKE3D_OBJS=$(DUKE3D_OBJ)\game.$o \
$(DUKE3D_OBJ)\actors.$o \
$(DUKE3D_OBJ)\anim.$o \
$(DUKE3D_OBJ)\animsounds.$o \
$(DUKE3D_OBJ)\cheats.$o \
$(DUKE3D_OBJ)\sbar.$o \
$(DUKE3D_OBJ)\screentext.$o \

View file

@ -38,8 +38,7 @@ game_defs_dep=$(DUKE3D_SRC)/lunatic/_defs_game.lua
$(DUKE3D_OBJ)/game.$o: $(DUKE3D_SRC)/game.cpp $(game_defs_dep) $(MACT_INC)/scriplib.h $(duke3d_h) $(DUKE3D_SRC)/input.h $(DUKE3D_SRC)/osdfuncs.h $(DUKE3D_SRC)/osdcmds.h $(DUKE3D_SRC)/grpscan.h $(DUKE3D_SRC)/demo.h $(ENGINE_INC)/hightile.h
$(DUKE3D_OBJ)/actors.$o: $(DUKE3D_SRC)/actors.cpp $(duke3d_h)
$(DUKE3D_OBJ)/anim.$o: $(DUKE3D_SRC)/anim.cpp $(duke3d_h) $(DUKE3D_SRC)/input.h $(MACT_INC)/animlib.h $(ENGINE_INC)/animvpx.h $(DUKE3D_SRC)/animsounds.h
$(DUKE3D_OBJ)/animsounds.$o: $(DUKE3D_SRC)/animsounds.cpp $(DUKE3D_SRC)/animsounds.h
$(DUKE3D_OBJ)/anim.$o: $(DUKE3D_SRC)/anim.cpp $(duke3d_h) $(DUKE3D_SRC)/input.h $(MACT_INC)/animlib.h $(ENGINE_INC)/animvpx.h
$(DUKE3D_OBJ)/cheats.$o: $(DUKE3D_SRC)/cheats.cpp $(DUKE3D_SRC)/cheats.h
$(DUKE3D_OBJ)/cmdline.$o: $(DUKE3D_SRC)/cmdline.cpp $(DUKE3D_SRC)/cmdline.h
$(DUKE3D_OBJ)/demo.$o: $(DUKE3D_SRC)/demo.cpp $(duke3d_h) $(DUKE3D_SRC)/input.h

View file

@ -34,8 +34,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# include "animvpx.h"
#endif
#include "animsounds.h"
// animsound_t.sound
EDUKE32_STATIC_ASSERT(INT16_MAX >= MAXSOUNDS);
@ -75,39 +73,146 @@ dukeanim_t * Anim_Create(char const * fn)
return anim;
}
#ifdef DYNSOUNDREMAP_ENABLE
static int32_t const StopAllSounds = -1;
#else
# define StopAllSounds -1
#endif
void Anim_Init(void)
{
hash_init(&h_dukeanim);
struct defaultanmsound {
#ifdef DYNSOUNDREMAP_ENABLE
int32_t const & sound;
#else
int16_t sound;
#endif
uint8_t frame;
};
static defaultanmsound const cineov2[] =
{
{ WIND_AMBIENCE, 1 },
{ ENDSEQVOL2SND1, 26 },
{ ENDSEQVOL2SND2, 36 },
{ THUD, 54 },
{ ENDSEQVOL2SND3, 62 },
{ ENDSEQVOL2SND4, 75 },
{ ENDSEQVOL2SND5, 81 },
{ ENDSEQVOL2SND6, 115 },
{ ENDSEQVOL2SND7, 124 },
};
static defaultanmsound const cineov3[] =
{
{ WIND_REPEAT, 1 },
{ DUKE_GRUNT, 98 },
{ THUD, 82+20 },
{ SQUISHED, 82+20 },
{ ENDSEQVOL3SND3, 104+20 },
{ ENDSEQVOL3SND2, 114+20 },
{ PIPEBOMB_EXPLODE, 158 },
};
static defaultanmsound const logo[] =
{
{ FLY_BY, 1 },
{ PIPEBOMB_EXPLODE, 19 },
};
static defaultanmsound const vol42a[] =
{
{ INTRO4_B, 1 },
{ SHORT_CIRCUIT, 12 },
{ INTRO4_5, 18 },
{ SHORT_CIRCUIT, 34 },
};
static defaultanmsound const vol41a[] =
{
{ INTRO4_1, 1 },
{ INTRO4_3, 7 },
{ INTRO4_2, 12 },
{ INTRO4_4, 26 },
};
static defaultanmsound const vol43a[] =
{
{ INTRO4_6, 10 },
};
static defaultanmsound const vol4e1[] =
{
{ DUKE_UNDERWATER, 3 },
{ VOL4ENDSND1, 35 },
};
static defaultanmsound const vol4e2[] =
{
{ DUKE_UNDERWATER, 11 },
{ VOL4ENDSND1, 20 },
{ VOL4ENDSND2, 39 },
{ StopAllSounds, 50 },
};
static defaultanmsound const vol4e3[] =
{
{ BOSS4_DEADSPEECH, 1 },
{ VOL4ENDSND1, 40 },
{ DUKE_UNDERWATER, 40 },
{ BIGBANG, 50 },
};
struct defaultanm {
char const *fn;
void (*sound_func)(int32_t);
defaultanmsound const *sounds;
uint8_t numsounds;
uint8_t fdelay;
};
#define anmsnd(x) (x), ARRAY_SIZE(x)
static defaultanm const anms[] =
{
{ "logo.anm", logoanimsounds, 9 },
{ "3dr.anm", NULL, 10 },
{ "logo.anm", anmsnd(logo), 9 },
{ "3dr.anm", NULL, 0, 10 },
#ifndef EDUKE32_STANDALONE
{ "vol4e1.anm", endanimvol41, 10 },
{ "vol4e2.anm", endanimvol42, 14 },
{ "vol4e3.anm", endanimvol43, 10 },
{ "vol41a.anm", first4animsounds, 14 },
{ "vol42a.anm", intro4animsounds, 18 },
{ "vol43a.anm", intro42animsounds, 10 },
{ "duketeam.anm", NULL, 10 },
{ "radlogo.anm", NULL, 10 },
{ "cineov2.anm", endanimsounds, 18 },
{ "cineov3.anm", endanimsounds, 10 },
{ "vol4e1.anm", anmsnd(vol4e1), 10 },
{ "vol4e2.anm", anmsnd(vol4e2), 14 },
{ "vol4e3.anm", anmsnd(vol4e3), 10 },
{ "vol41a.anm", anmsnd(vol41a), 14 },
{ "vol42a.anm", anmsnd(vol42a), 18 },
{ "vol43a.anm", anmsnd(vol43a), 10 },
{ "duketeam.anm", NULL, 0, 10 },
{ "radlogo.anm", NULL, 0, 10 },
{ "cineov2.anm", anmsnd(cineov2), 18 },
{ "cineov3.anm", anmsnd(cineov3), 10 },
#endif
};
#undef anmsnd
for (defaultanm const & anm : anms)
{
dukeanim_t * anim = Anim_Create(anm.fn);
anim->framedelay = anm.fdelay;
anim->sound_func = anm.sound_func;
if (anm.numsounds)
{
anim->sounds = (animsound_t *)Xmalloc(anm.numsounds * sizeof(animsound_t));
size_t const numsounds = anm.numsounds;
for (size_t i = 0; i < numsounds; ++i)
{
defaultanmsound const & src = anm.sounds[i];
animsound_t & dst = anim->sounds[i];
dst.sound = src.sound;
dst.frame = src.frame;
}
anim->numsounds = numsounds;
}
}
}
@ -338,9 +443,6 @@ int32_t Anim_Play(const char *fn)
ototalclock += anim->framedelay;
if (!anim->numsounds && anim->sound_func)
anim->sound_func(i);
while (soundidx < anim->numsounds && anim->sounds[soundidx].frame == (uint16_t)i)
{
int16_t sound = anim->sounds[soundidx].sound;

View file

@ -31,7 +31,6 @@ typedef struct {
typedef struct
{
uint8_t* animbuf;
void (*sound_func)(int32_t);
animsound_t *sounds;
uint16_t numsounds;
uint8_t framedelay;

View file

@ -1,197 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2015 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "duke3d.h"
#include "animsounds.h"
void endanimsounds(int32_t fr)
{
switch (ud.volume_number)
{
case 0:
break;
case 1:
switch (fr)
{
case 1:
S_PlaySound(WIND_AMBIENCE);
break;
case 26:
S_PlaySound(ENDSEQVOL2SND1);
break;
case 36:
S_PlaySound(ENDSEQVOL2SND2);
break;
case 54:
S_PlaySound(THUD);
break;
case 62:
S_PlaySound(ENDSEQVOL2SND3);
break;
case 75:
S_PlaySound(ENDSEQVOL2SND4);
break;
case 81:
S_PlaySound(ENDSEQVOL2SND5);
break;
case 115:
S_PlaySound(ENDSEQVOL2SND6);
break;
case 124:
S_PlaySound(ENDSEQVOL2SND7);
break;
}
break;
case 2:
switch (fr)
{
case 1:
S_PlaySound(WIND_REPEAT);
break;
case 98:
S_PlaySound(DUKE_GRUNT);
break;
case 82+20:
S_PlaySound(THUD);
S_PlaySound(SQUISHED);
break;
case 104+20:
S_PlaySound(ENDSEQVOL3SND3);
break;
case 114+20:
S_PlaySound(ENDSEQVOL3SND2);
break;
case 158:
S_PlaySound(PIPEBOMB_EXPLODE);
break;
}
break;
}
}
void logoanimsounds(int32_t fr)
{
switch (fr)
{
case 1:
S_PlaySound(FLY_BY);
break;
case 19:
S_PlaySound(PIPEBOMB_EXPLODE);
break;
}
}
void intro4animsounds(int32_t fr)
{
switch (fr)
{
case 1:
S_PlaySound(INTRO4_B);
break;
case 12:
case 34:
S_PlaySound(SHORT_CIRCUIT);
break;
case 18:
S_PlaySound(INTRO4_5);
break;
}
}
void first4animsounds(int32_t fr)
{
switch (fr)
{
case 1:
S_PlaySound(INTRO4_1);
break;
case 12:
S_PlaySound(INTRO4_2);
break;
case 7:
S_PlaySound(INTRO4_3);
break;
case 26:
S_PlaySound(INTRO4_4);
break;
}
}
void intro42animsounds(int32_t fr)
{
switch (fr)
{
case 10:
S_PlaySound(INTRO4_6);
break;
}
}
void endanimvol41(int32_t fr)
{
switch (fr)
{
case 3:
S_PlaySound(DUKE_UNDERWATER);
break;
case 35:
S_PlaySound(VOL4ENDSND1);
break;
}
}
void endanimvol42(int32_t fr)
{
switch (fr)
{
case 11:
S_PlaySound(DUKE_UNDERWATER);
break;
case 20:
S_PlaySound(VOL4ENDSND1);
break;
case 39:
S_PlaySound(VOL4ENDSND2);
break;
case 50:
FX_StopAllSounds();
break;
}
}
void endanimvol43(int32_t fr)
{
switch (fr)
{
case 1:
S_PlaySound(BOSS4_DEADSPEECH);
break;
case 40:
S_PlaySound(VOL4ENDSND1);
S_PlaySound(DUKE_UNDERWATER);
break;
case 50:
S_PlaySound(BIGBANG);
break;
}
}

View file

@ -1,33 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2015 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#ifndef animsounds_h__
#define animsounds_h__
void endanimsounds(int32_t fr);
void logoanimsounds(int32_t fr);
void intro4animsounds(int32_t fr);
void endanimvol43(int32_t fr);
void endanimvol42(int32_t fr);
void endanimvol41(int32_t fr);
void intro42animsounds(int32_t fr);
void first4animsounds(int32_t fr);
#endif // animsounds_h__