Open source remastering of the Freespace 2 engine
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
12 #ifndef __PACKUNPACK_H__
13 #define __PACKUNPACK_H__
15 #include "globalincs/pstypes.h"
17 struct CFILE;
19 #define ANI_STREAM_CACHE_SIZE 4096
21 #define PACKER_CODE 0xEE
27 #define STD_RLE_CODE 0x80
29 typedef struct key_frame {
30  int frame_num; // which frame number this key frame is
31  int offset; // offset from the start of data block
32 } key_frame;
34 #define ANF_MEM_MAPPED (1<<0) // animation is memory-mapped file
35 #define ANF_STREAMED (1<<1)
36 #define ANF_XPARENT (1<<2) // animation has transparency
37 #define ANF_ALL_KEYFRAMES (1<<3) // all the frames are keyframes (this is necessary if we want to play the file backwards)
39 typedef struct anim {
43  int width;
44  int height;
46  int instance_count; // number of instances that are currently playing
47  int ref_count; // number of times this anim has been loaded
48  float time; // playback time in seconds
49  int num_keys;
51  ubyte palette[768];
53  ubyte *data; // points to compressed data
55  int version;
56  int fps;
57  ubyte xparent_r; // red component for the transparent color in source image
58  ubyte xparent_g; // green component for the transparent color in source image
59  ubyte xparent_b; // blue component for the transparent color in source image
60  int flags;
62  int file_offset; // file offset to start of frame data
65 } anim;
67 // the direction to play the anim (forwards or backwards)
71 typedef struct anim_instance {
73  int x,y; // coordinates anim is played at (top left corner of anim)
74  int base_w, base_h; // coordinate scale this anim is played in.
75  vec3d *world_pos; // world (x,y,z) position of explosion
76  float radius; // radius of image, needed for scaling
77  int frame_num; // current frame, or last frame if between frames (first frame is 0)
78  int last_frame_num;// last frame rendered
79  anim *parent; // pointer to anim structure, which holds compressed data
80  ubyte *data; // pointer to next frame's compressed data
81  ubyte *frame; // uncompressed frame
82  float time_elapsed; // how long the anim has played for (in seconds)
83  int start_at; // frame anim playing should start
84  int stop_at; // frame anim playing should stop
85  int framerate_independent; // animation should play back in same amount of time, regardless
86  int skip_frames; // should anim skip frames during framerate independent playback
87  int looped; // should anim keep playing over and over...
88  int stop_now; // flag to indicate time to stop the animation
89  int last_bitmap; // id of last bitmap that was rendered out from animation
90  int screen_id; // 0 means all screens should render, otherwise screen specific
91  void *aa_color; // anti-aliased bitmap color
92  int xlate_pal;
93  int direction; // playing forwards or backwards ?
94  int ping_pong; // should be played ping-pong style
95  int paused; // pause the anim
96  int file_offset; // current offset into frame (like data, put offset into file)
97  int loop_count; // starts at 0, and is incremented each time it loops
100 int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_type);
101 int pack_frame(ubyte *frame, ubyte *frame2, ubyte *save, long size, long max, int compress_type);
103 ubyte *unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp);
104 int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp);
106 void anim_init();
107 anim_instance *init_anim_instance(anim *ptr, int bpp);
110 ubyte *anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap, int bpp);
111 void anim_set_palette(anim *a);
115 #endif /* __PACKUNPACK_H__ */
int height
Definition: packunpack.h:44
ubyte * unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp)
Unpack frame.
Definition: packunpack.cpp:669
int last_frame_num
Definition: packunpack.h:78
int framerate_independent
Definition: packunpack.h:85
int instance_count
Definition: packunpack.h:46
int offset
Definition: packunpack.h:31
void free_anim_instance(anim_instance *inst)
Definition: packunpack.cpp:68
anim_instance * next
Definition: packunpack.h:72
CFILE * cfile_ptr
Definition: packunpack.h:54
anim * next
Definition: packunpack.h:40
int num_keys
Definition: packunpack.h:49
ubyte * frame
Definition: packunpack.h:81
struct anim_instance anim_instance
Definition: pstypes.h:88
int anim_get_next_frame(anim_instance *inst)
Definition: packunpack.cpp:81
int total_frames
Definition: packunpack.h:45
void * aa_color
Definition: packunpack.h:91
ubyte xparent_g
Definition: packunpack.h:58
Definition: cfile.h:28
ubyte * anim_get_next_raw_buffer(anim_instance *inst, int xlate_pal, int aabitmap, int bpp)
Definition: packunpack.cpp:127
int flags
Definition: packunpack.h:60
struct anim anim
ubyte palette_translation[256]
Definition: packunpack.h:52
GLsizeiptr size
Definition: Glext.h:5496
void anim_check_for_palette_change(anim_instance *inst)
Definition: packunpack.cpp:21
int pack_frame(ubyte *frame, ubyte *frame2, ubyte *save, long size, long max, int compress_type)
Pack frame.
Definition: packunpack.cpp:326
int cache_file_offset
Definition: packunpack.h:63
key_frame * keys
Definition: packunpack.h:50
ubyte xparent_r
Definition: packunpack.h:57
ubyte packer_code
Definition: packunpack.h:42
unsigned int uint
Definition: pstypes.h:64
ubyte * data
Definition: packunpack.h:80
GLboolean GLboolean GLboolean GLboolean a
Definition: Glext.h:5781
ubyte xparent_b
Definition: packunpack.h:59
int width
Definition: packunpack.h:43
int frame_num
Definition: packunpack.h:30
struct key_frame key_frame
unsigned char ubyte
Definition: pstypes.h:62
int ref_count
Definition: packunpack.h:47
int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal_translate, int aabitmap, int bpp)
Unpack frame from file.
Definition: packunpack.cpp:858
GLuint const GLchar * name
Definition: Glext.h:5608
void anim_set_palette(anim *a)
Set animation palette.
float radius
Definition: packunpack.h:76
#define MAX_PATH_LEN
Definition: pstypes.h:325
int fps
Definition: packunpack.h:56
anim_instance * init_anim_instance(anim *ptr, int bpp)
Definition: packunpack.cpp:28
float time
Definition: packunpack.h:48
float time_elapsed
Definition: packunpack.h:82
int file_offset
Definition: packunpack.h:62
ubyte * data
Definition: packunpack.h:53
uint screen_sig
Definition: packunpack.h:61
int pack_key_frame(ubyte *frame, ubyte *save, long size, long max, int compress_type)
Pack key frame.
Definition: packunpack.cpp:175
void anim_init()
Initialise animation.
Definition: animplay.cpp:45
int version
Definition: packunpack.h:55
anim_instance * prev
Definition: packunpack.h:72
ubyte * cache
Definition: packunpack.h:64
vec3d * world_pos
Definition: packunpack.h:75
anim * parent
Definition: packunpack.h:79
ubyte palette[768]
Definition: packunpack.h:51