animlib.h
1 //------------------------------------------------------------------------- 2 /* 3 Copyright (C) 1996, 2003 - 3D Realms Entertainment 4 5 This file is part of Duke Nukem 3D version 1.5 - Atomic Edition 6 7 Duke Nukem 3D is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public License 9 as published by the Free Software Foundation; either version 2 10 of the License, or (at your option) any later version. 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 Original Source: 1996 - Todd Replogle 23 Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms 24 Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) 25 */ 26 //------------------------------------------------------------------------- 27 28 ///////////////////////////////////////////////////////////////////////////// 29 // 30 // ANIMLIB.H 31 // 32 ///////////////////////////////////////////////////////////////////////////// 33 34 #pragma once 35 36 #ifndef animlib_public_h_ 37 #define animlib_public_h_ 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 # pragma pack(push,1) 43 44 /* structure declarations for deluxe animate large page files, doesn't 45 need to be in the header because there are no exposed functions 46 that use any of this directly */ 47 48 typedef struct lpfileheaderstruct 49 { 50 uint32_t id; /* 4 uint8_tacter ID == "LPF " */ 51 uint16_t maxLps; /* max # largePages allowed. 256 FOR NOW. */ 52 uint16_t nLps; /* # largePages in this file. */ 53 uint32_t nRecords; /* # records in this file. 65534 is current limit + ring */ 54 uint16_t maxRecsPerLp; /* # records permitted in an lp. 256 FOR NOW. */ 55 uint16_t lpfTableOffset; /* Absolute Seek position of lpfTable. 1280 FOR NOW. */ 56 uint32_t contentType; /* 4 character ID == "ANIM" */ 57 uint16_t width; /* Width of screen in pixels. */ 58 uint16_t height; /* Height of screen in pixels. */ 59 uint8_t variant; /* 0==ANIM. */ 60 uint8_t version; /* 0==frame rate in 18/sec, 1= 70/sec */ 61 uint8_t hasLastDelta; /* 1==Last record is a delta from last-to-first frame. */ 62 uint8_t lastDeltaValid; /* 0==Ignore ring frame. */ 63 uint8_t pixelType; /* 0==256 color. */ 64 uint8_t CompressionType; /* 1==(RunSkipDump) Only one used FOR NOW. */ 65 uint8_t otherRecsPerFrm; /* 0 FOR NOW. */ 66 uint8_t bitmaptype; /* 1==320x200, 256-color. Only one implemented so far. */ 67 uint8_t recordTypes[32]; /* Not yet implemented. */ 68 uint32_t nFrames; /* Number of actual frames in the file, includes ring frame. */ 69 uint16_t framesPerSecond; /* Number of frames to play per second. */ 70 uint16_t pad2[29]; /* 58 bytes of filler to round up to 128 bytes total. */ 71 } 72 lpfileheader; /* (comments from original source) */ 73 74 // this is the format of a large page structure 75 typedef struct 76 { 77 uint16_t baseRecord; // Number of first record in this large page. 78 uint16_t nRecords; // Number of records in lp. 79 // bit 15 of "nRecords" == "has continuation from previous lp". 80 // bit 14 of "nRecords" == "final record continues on next lp". 81 uint16_t nBytes; // Total number of bytes of contents, excluding header. 82 } lp_descriptor; 83 84 #pragma pack(pop) 85 86 #define IMAGEBUFFERSIZE 0x10000 87 88 typedef struct 89 { 90 uint16_t framecount; // current frame of anim 91 lpfileheader * lpheader; // file header will be loaded into this structure 92 lp_descriptor * LpArray; // arrays of large page structs used to find frames 93 uint16_t curlpnum; // initialize to an invalid Large page number 94 lp_descriptor * curlp; // header of large page currently in memory 95 uint16_t * thepage; // buffer where current large page is loaded 96 uint8_t imagebuffer[IMAGEBUFFERSIZE]; // buffer where anim frame is decoded 97 uint8_t * buffer; 98 uint8_t pal[768]; 99 int32_t currentframe; 100 } anim_t; 101 102 //**************************************************************************** 103 // 104 // ANIM_LoadAnim () 105 // 106 // Setup internal anim data structure 107 // 108 //**************************************************************************** 109 110 int32_t ANIM_LoadAnim(uint8_t *buffer, int32_t length); 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_t ANIM_NumFrames(void); 131 132 //**************************************************************************** 133 // 134 // ANIM_DrawFrame () 135 // 136 // Draw the frame to a returned buffer 137 // 138 //**************************************************************************** 139 140 uint8_t * ANIM_DrawFrame(int32_t framenumber); 141 142 //**************************************************************************** 143 // 144 // ANIM_GetPalette () 145 // 146 // return the palette of the anim 147 //**************************************************************************** 148 149 uint8_t * ANIM_GetPalette(void); 150 151 #ifdef __cplusplus 152 } 153 #endif 154 #endif