1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 2010-2019 EDuke32 developers and contributors
4 Copyright (C) 2019 Nuke.YKT
5 
6 This file is part of NBlood.
7 
8 NBlood is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License version 2
10 as published by the Free Software Foundation.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 
16 See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 */
22 //-------------------------------------------------------------------------
23 #pragma once
24 #include "resource.h"
25 
26 struct SEQFRAME {
27     unsigned int tile : 12;
28     unsigned int transparent  : 1; // transparent
29     unsigned int transparent2 : 1; // transparent
30     unsigned int blockable : 1; // blockable
31     unsigned int hittable : 1; // hittable
32     unsigned int xrepeat : 8; // xrepeat
33     unsigned int yrepeat : 8; // yrepeat
34     signed int shade : 8; // shade
35     unsigned int pal : 5; // palette
36     unsigned int at5_5 : 1; //
37     unsigned int at5_6 : 1; //
38     unsigned int at5_7 : 1; //
39     unsigned int at6_0 : 1; //
40     unsigned int at6_1 : 1; //
41     unsigned int invisible : 1; // invisible
42     unsigned int at6_3 : 1; //
43     unsigned int at6_4 : 1; //
44     unsigned int tile2 : 4;
45     unsigned soundRange : 4; // (by NoOne) random sound range relative to global SEQ sound
46     unsigned surfaceSound : 1; // (by NoOne) trigger surface sound when moving / touching
47     unsigned reserved : 2;
48 };
49 
50 struct Seq {
51     char signature[4];
52     short version;
53     short nFrames; // at6
54     short ticksPerFrame;
55     short nSoundID;
56     int flags;
57     SEQFRAME frames[1];
58     void Preload(void);
59     void Precache(void);
60 };
61 
62 struct ACTIVE
63 {
64     unsigned char type;
65     unsigned short xindex;
66 };
67 
68 struct SEQINST
69 {
70     DICTNODE *hSeq;
71     Seq *pSequence;
72     int nSeq;
73     int nCallbackID;
74     short timeCount;
75     unsigned char frameIndex;
76     char isPlaying;
77     void Update(ACTIVE *pActive);
78 };
79 
seqGetTile(SEQFRAME * pFrame)80 inline int seqGetTile(SEQFRAME* pFrame)
81 {
82     return pFrame->tile+(pFrame->tile2<<12);
83 }
84 
85 int seqRegisterClient(void(*pClient)(int, int));
86 void seqPrecacheId(int id);
87 SEQINST* GetInstance(int nType, int nXIndex);
88 void UnlockInstance(SEQINST *pInst);
89 void seqSpawn(int nSeq, int nType, int nXIndex, int nCallbackID = -1);
90 void seqKill(int nType, int nXIndex);
91 void seqKillAll(void);
92 int seqGetStatus(int nType, int nXIndex);
93 int seqGetID(int nType, int nXIndex);
94 void seqProcess(int nTicks);