1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 1996, 2003 - 3D Realms Entertainment
4 Copyright (C) 2017-2019 Nuke.YKT
5 
6 This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
7 
8 Duke Nukem 3D is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 See the GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 
23 Original Source: 1996 - Todd Replogle
24 Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
25 */
26 //-------------------------------------------------------------------------
27 
28 /////////////////////////////////////////////////////////////////////////////
29 //
30 //      ANIMLIB.H
31 //
32 /////////////////////////////////////////////////////////////////////////////
33 
34 #ifndef _animlib_public_
35 #define _animlib_public_
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 
41 // structure declarations for deluxe animate large page files */
42 
43 typedef struct
44    {
45    uint32 id;                 // 4 character ID == "LPF " */
46    uint16 maxLps;                  // max # largePages allowed. 256 FOR NOW.   */
47    uint16 nLps;            // # largePages in this file. */
48    uint32 nRecords;        // # records in this file.  65534 is current limit plus */
49                         // one for last-to-first delta for looping the animation */
50    uint16 maxRecsPerLp; // # records permitted in an lp. 256 FOR NOW.   */
51    uint16 lpfTableOffset; // Absolute Seek position of lpfTable.  1280 FOR NOW.
52                                          // The lpf Table is an array of 256 large page structures
53                                          // that is used to facilitate finding records in an anim
54                                          // file without having to seek through all of the Large
55                                          // Pages to find which one a specific record lives in. */
56    uint32 contentType;  // 4 character ID == "ANIM" */
57    uint16 width;                   // Width of screen in pixels. */
58    uint16 height;                  // Height of screen in pixels. */
59    byte variant;              // 0==ANIM. */
60    byte version;              // 0==frame rate is multiple of 18 cycles/sec.
61                                         // 1==frame rate is multiple of 70 cycles/sec.  */
62    byte hasLastDelta;   // 1==Last record is a delta from last-to-first frame. */
63    byte lastDeltaValid; // 0==The last-to-first delta (if present) hasn't been
64                                   // updated to match the current first&last frames,    so it
65                                   // should be ignored. */
66    byte pixelType;         //   /* 0==256 color. */
67    byte CompressionType;//      /* 1==(RunSkipDump) Only one used FOR NOW. */
68    byte otherRecsPerFrm;//      /* 0 FOR NOW. */
69    byte bitmaptype;     //   /* 1==320x200, 256-color.  Only one implemented so far. */
70    byte recordTypes[32];//      /* Not yet implemented. */
71    uint32 nFrames;         //   /* In case future version adds other records at end of
72                                 //      file, we still know how many actual frames.
73                                   //    NOTE: DOES include last-to-first delta when present. */
74    uint16 framesPerSecond;      // Number of frames to play per second. */
75    uint16 pad2[29];           // 58 bytes of filler to round up to 128 bytes total. */
76    } lpfileheader;
77 
78 // this is the format of a large page structure
79 typedef struct
80    {
81    uint16 baseRecord;   // Number of first record in this large page.
82    uint16 nRecords;        // Number of records in lp.
83                                                       // bit 15 of "nRecords" == "has continuation from previous lp".
84                                               // bit 14 of "nRecords" == "final record continues on next lp".
85    uint16 nBytes;                  // Total number of bytes of contents, excluding header.
86    } lp_descriptor;
87 
88 typedef struct
89    {
90    uint16 framecount;          // current frame of anim
91    lpfileheader lpheader;           // file header will be loaded into this structure
92    lp_descriptor LpArray[256]; // arrays of large page structs used to find frames
93    uint16 curlpnum;               // initialize to an invalid Large page number
94    lp_descriptor curlp;        // header of large page currently in memory
95    uint16 thepage[0x8000];     // buffer where current large page is loaded
96    byte imagebuffer[0x10000]; // buffer where anim frame is decoded
97    byte * buffer;
98    byte pal[768];
99    int32  currentframe;
100   } anim_t;
101 
102 //****************************************************************************
103 //
104 //      ANIM_LoadAnim ()
105 //
106 // Setup internal anim data structure
107 //
108 //****************************************************************************
109 
110 void ANIM_LoadAnim (char * buffer);
111 
112 //****************************************************************************
113 //
114 //      ANIM_FreeAnim ()
115 //
116 // Free up internal anim data structure
117 //
118 //****************************************************************************
119 
120 void ANIM_FreeAnim ( void );
121 
122 //****************************************************************************
123 //
124 //      ANIM_NumFrames ()
125 //
126 // returns the number of frames in the current anim
127 //
128 //****************************************************************************
129 
130 int32 ANIM_NumFrames ( void );
131 
132 //****************************************************************************
133 //
134 //      ANIM_DrawFrame ()
135 //
136 // Draw the frame to a returned buffer
137 //
138 //****************************************************************************
139 
140 byte * ANIM_DrawFrame (int32 framenumber);
141 
142 //****************************************************************************
143 //
144 //      ANIM_GetPalette ()
145 //
146 // return the palette of the anim
147 //****************************************************************************
148 
149 byte * ANIM_GetPalette ( void );
150 
151 extern anim_t * anim;
152 
153 #ifdef __cplusplus
154 };
155 #endif
156 #endif
157