From 4b529914aef6f833bcd131d04238f0cac4940268 Mon Sep 17 00:00:00 2001 From: Nikolay Ambartsumov Date: Sat, 24 Oct 2020 05:29:22 +0300 Subject: [PATCH] Raise SNDSEQ limit to 4096 sequences # Conflicts: # src/maploader/polyobjects.cpp --- src/po_man.cpp | 3 ++- src/sound/s_sndseq.cpp | 33 ++++++++++++++++++--------------- src/sound/s_sndseq.h | 2 ++ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/po_man.cpp b/src/po_man.cpp index 2a2f6ec69..42e17d2d1 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -45,6 +45,7 @@ #include "g_levellocals.h" #include "actorinlines.h" #include "v_text.h" +#include "s_sndseq.h" // MACROS ------------------------------------------------------------------ @@ -1561,7 +1562,7 @@ static void SpawnPolyobj (int index, int tag, int type) po->bHurtOnTouch = (type == SMT_PolySpawnHurt); po->tag = tag; po->seqType = sd->linedef->args[2]; - if (po->seqType < 0 || po->seqType > 63) + if (po->seqType < 0 || po->seqType > (MAX_SNDSEQS - 1)) { po->seqType = 0; } diff --git a/src/sound/s_sndseq.cpp b/src/sound/s_sndseq.cpp index fc7538f03..8dde0d5d8 100644 --- a/src/sound/s_sndseq.cpp +++ b/src/sound/s_sndseq.cpp @@ -50,10 +50,13 @@ #define GetData(a) (int32_t(a) >> 8 ) #define GetFloatData(a) float((int32_t(a) >> 8 )/65536.f) #define MakeCommand(a,b) ((a) | ((b) << 8)) -#define HexenPlatSeq(a) (a) -#define HexenDoorSeq(a) ((a) | 0x40) -#define HexenEnvSeq(a) ((a) | 0x80) -#define HexenLastSeq (0xff) +#define HexenPlatSeqStart (0) +#define HexenDoorSeqStart (MAX_SNDSEQS) +#define HexenEnvSeqStart (MAX_SNDSEQS << 1) +#define HexenPlatSeq(a) ((a) | (HexenPlatSeqStart)) +#define HexenDoorSeq(a) ((a) | (HexenDoorSeqStart)) +#define HexenEnvSeq(a) ((a) | (HexenEnvSeqStart)) +#define HexenLastSeq ((MAX_SNDSEQS << 2) - 1) // TYPES ------------------------------------------------------------------- @@ -108,7 +111,7 @@ typedef enum struct hexenseq_t { ENamedName Name; - uint8_t Seqs[4]; + uint16_t Seqs[4]; }; class DSeqActorNode : public DSeqNode @@ -285,7 +288,7 @@ static const hexenseq_t HexenSequences[] = { { NAME_None, {0} } }; -static int SeqTrans[64*3]; +static int SeqTrans[MAX_SNDSEQS*3]; static FRandom pr_sndseq ("SndSeq"); @@ -498,7 +501,7 @@ static void AssignTranslations (FScanner &sc, int seq, seqtype_t type) { if (IsNum(sc.String)) { - SeqTrans[(atoi(sc.String) & 63) + type * 64] = seq; + SeqTrans[(atoi(sc.String) & (MAX_SNDSEQS - 1)) + type * MAX_SNDSEQS] = seq; } } sc.UnGet(); @@ -528,16 +531,16 @@ static void AssignHexenTranslations (void) { int trans; - if (HexenSequences[i].Seqs[j] & 0x40) + if (HexenSequences[i].Seqs[j] & HexenDoorSeqStart) { - trans = 64 * SEQ_DOOR; + trans = MAX_SNDSEQS * SEQ_DOOR; } - else if (HexenSequences[i].Seqs[j] & 0x80) - trans = 64 * SEQ_ENVIRONMENT; + else if (HexenSequences[i].Seqs[j] & HexenEnvSeqStart) + trans = MAX_SNDSEQS * SEQ_ENVIRONMENT; else - trans = 64 * SEQ_PLATFORM; + trans = MAX_SNDSEQS * SEQ_PLATFORM; - SeqTrans[trans + (HexenSequences[i].Seqs[j] & 0x3f)] = seq; + SeqTrans[trans + (HexenSequences[i].Seqs[j] & (MAX_SNDSEQS - 1))] = seq; } } } @@ -866,9 +869,9 @@ static bool TwiddleSeqNum (int &sequence, seqtype_t type) { // [GrafZahl] Needs some range checking: // Sector_ChangeSound doesn't do it so this makes invalid sequences play nothing. - if (sequence >= 0 && sequence < 64) + if (sequence >= 0 && sequence < MAX_SNDSEQS) { - sequence = SeqTrans[sequence + type * 64]; + sequence = SeqTrans[sequence + type * MAX_SNDSEQS]; } else { diff --git a/src/sound/s_sndseq.h b/src/sound/s_sndseq.h index 0e3024dde..003cbcda0 100644 --- a/src/sound/s_sndseq.h +++ b/src/sound/s_sndseq.h @@ -5,6 +5,8 @@ #include "dobject.h" #include "s_sound.h" +#define MAX_SNDSEQS (4096) + enum { // Sound channel aliases for sound sequences.