/ source / blood / src / seq.h
seq.h
  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; // mostly translucent
 29      unsigned int transparent2   : 1; // less translucent
 30      unsigned int blockable      : 1; // blocking
 31      unsigned int hittable       : 1; // hitscan sensitive
 32      unsigned int xrepeat        : 8; //
 33      unsigned int yrepeat        : 8; //
 34      signed   int shade          : 8; //
 35      unsigned int pal            : 5; //
 36      unsigned int trigger        : 1; // callback trigger
 37      unsigned int smoke          : 1; // smoke view sprite
 38      unsigned int autoaim        : 1; // weapon auto-aim sensitive
 39      unsigned int pushable       : 1; // can be pushed down via action key
 40      unsigned int playSound      : 1; // play global sound + random(soundRange)
 41      unsigned int invisible      : 1; //
 42      unsigned int xflip          : 1; // 
 43      unsigned int yflip          : 1; //
 44      unsigned int tile2          : 4; // extends max tile number to 32767
 45  #ifdef NOONE_EXTENSIONS
 46      unsigned int soundRange     : 4; // random sound range relative to global SEQ sound
 47      unsigned int surfaceSound   : 1; // trigger surface sound when moving / touching
 48      unsigned int pal2           : 2; // extends max palookup number to 128
 49  #else
 50      unsigned int reserved       : 7;
 51  #endif
 52  };
 53  
 54  struct Seq {
 55      char signature[4];
 56      short version;
 57      short nFrames; // at6
 58      short ticksPerFrame;
 59      short nSoundID;
 60      int flags;
 61      SEQFRAME frames[];
 62      void Preload(void);
 63      void Precache(void);
 64  };
 65  
 66  struct ACTIVE
 67  {
 68      unsigned char type;
 69      unsigned short xindex;
 70  };
 71  
 72  struct SEQINST
 73  {
 74      DICTNODE *hSeq;
 75      Seq *pSequence;
 76      int nSeq;
 77      int nCallbackID;
 78      short timeCount;
 79      unsigned char frameIndex;
 80      char isPlaying;
 81      void Update(ACTIVE *pActive);
 82  };
 83  
 84  inline int seqGetTile(SEQFRAME* pFrame)
 85  {
 86      return pFrame->tile+(pFrame->tile2<<12);
 87  }
 88  
 89  inline int seqGetPal(SEQFRAME* pFrame)
 90  {
 91  #ifdef NOONE_EXTENSIONS
 92      return pFrame->pal+(pFrame->pal2<<5);
 93  #else
 94      return pFrame->pal;
 95  #endif
 96  }
 97  
 98  int seqRegisterClient(void(*pClient)(int, int));
 99  void seqPrecacheId(int id);
100  SEQINST* GetInstance(int nType, int nXIndex);
101  void UnlockInstance(SEQINST *pInst);
102  void seqSpawn(int nSeq, int nType, int nXIndex, int nCallbackID = -1);
103  void seqKill(int nType, int nXIndex);
104  void seqKillAll(void);
105  int seqGetStatus(int nType, int nXIndex);
106  int seqGetID(int nType, int nXIndex);
107  void seqProcess(int nTicks);