ScummVM API documentation
px_anims.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_PX_ANIMS_H_
28 #define ICB_PX_ANIMS_H_
29 
30 #include "engines/icb/common/px_common.h"
31 
32 #include "common/endian.h"
33 
34 namespace ICB {
35 
36 #define PXANIM_SCHEMA 5
37 
38 #define PXANIM_TAG "Peas"
39 #define ORG_POS 0
40 #define ORG_STRING "ORG"
41 #define INT_POS 1
42 #define INT_STRING "INT"
43 #define OBJ_STRING "OBJ"
44 
45 #define ORG_TYPE 0
46 #define INT_TYPE 1
47 #define INT0_TYPE 2 // Forced export of INT marker on frame 0 of anim
48 
49 #define TRI_TYPE 3
50 #define OBJ_TYPE 4
51 
52 // PXmarker_PC : the PC version
53 typedef struct {
54  uint32 m_type;
55  float m_x, m_y, m_z;
56  float m_pan;
57 } PXmarker_PC;
58 
59 // PXmarker_PC : the PC version
61 public:
62  static uint32 GetType(PXmarker_PC *marker) { return FROM_LE_32(marker->m_type); }
63  static void GetPan(PXmarker_PC *marker, float *pan) { *pan = FROM_LE_32(marker->m_pan); }
64  static void GetXYZ(PXmarker_PC *marker, float *x, float *y, float *z);
65 };
66 
67 // PXframe_PC : the PC version //
68 typedef struct {
69  int16 left_foot_distance;
70  int16 right_foot_distance;
71  uint8 marker_qty;
72  uint8 leftFootStep;
73  uint8 rightFootStep;
74  uint8 pad3;
75  PXmarker_PC markers[1];
76 } PXframe_PC;
77 
78 // PXmarker_PSX : the PSX version
79 typedef struct {
80  uint8 m_type;
81  uint8 x8;
82  uint16 x7y9;
83  uint32 y6z15pan11;
84 } PXmarker_PSX;
85 
86 // PXmarker_PSX : the PSX version
88 public:
89  static uint8 GetType(PXmarker_PSX *marker) { return marker->m_type; }
90  static void GetPan(PXmarker_PSX *marker, float *pan);
91  static void GetXYZ(PXmarker_PSX *marker, float *x, float *y, float *z);
92 };
93 
94 inline void PXmarker_PSX_Object::GetPan(PXmarker_PSX *marker, float *pan) {
95  *pan = (float)(((FROM_LE_32(marker->y6z15pan11) & 0x7FF) << 1)) / 4096.0f;
96 }
97 
98 inline void PXmarker_PSX_Object::GetXYZ(PXmarker_PSX *marker, float *x, float *y, float *z) {
99  int32 ix, iy, iz;
100 
101  ix = ((marker->x8 << 7) | (FROM_LE_16(marker->x7y9) >> 9));
102  if (ix >= 16384)
103  ix = ix - 32768;
104 
105  iy = (((FROM_LE_16(marker->x7y9) & 0x1FF) << 6) | (FROM_LE_32(marker->y6z15pan11) >> 26));
106  if (iy >= 16384)
107  iy = iy - 32768;
108 
109  iz = ((FROM_LE_32(marker->y6z15pan11) >> 11) & 0x7FFF);
110  if (iz >= 16384)
111  iz = iz - 32768;
112 
113  *x = (float)ix;
114  *y = (float)iy;
115  *z = (float)iz;
116 }
117 
118 // PXframe_PSX : the PSX version //
119 typedef struct {
120  int16 left_foot_distance;
121  int16 right_foot_distance;
122  uint8 marker_qty;
123  uint8 leftFootStep;
124  uint8 rightFootStep;
125  uint8 pad3;
126  PXmarker_PSX markers[1];
127 } PXframe_PSX;
128 
129 // PXanim //
130 typedef struct {
131  char tag[4];
132  int32 schema;
133  uint8 frame_qty;
134  uint8 speed;
135  uint16 offsets[1];
136 } PXanim_PSX;
137 
138 typedef struct {
139  char tag[4];
140  int32 schema;
141  uint8 frame_qty;
142  uint8 speed;
143  uint16 offsets[1];
144 } PXanim_PC;
145 
146 inline void ConvertPXanim(PXanim_PSX *anim) {
147  // Support old schema type files
148  if (FROM_LE_32(anim->schema) == PXANIM_SCHEMA - 1) {
149  int32 nFrames = anim->frame_qty;
150  anim->frame_qty = (uint8)nFrames;
151  anim->speed = 1;
152  anim->schema = TO_LE_32(PXANIM_SCHEMA);
153  }
154 }
155 
156 inline void ConvertPXanim(PXanim_PC *anim) {
157  // Support old schema type files
158  if (FROM_LE_32(anim->schema) == PXANIM_SCHEMA - 1) {
159  int32 nFrames = anim->frame_qty;
160  anim->frame_qty = (uint8)nFrames;
161  anim->speed = 1;
162  anim->schema = TO_LE_32(PXANIM_SCHEMA);
163  }
164 }
165 
166 // The animation, frame, marker
167 typedef PXframe_PSX PXframe;
168 typedef PXmarker_PSX PXmarker;
169 
170 } // End of namespace ICB
171 
172 #endif // _library__PX_ANIMS_H_
Definition: px_anims.h:79
Definition: px_anims.h:60
Definition: px_anims.h:138
Definition: actor.h:32
Definition: px_anims.h:119
Definition: px_anims.h:68
Definition: px_anims.h:53
Definition: px_anims.h:87
Definition: px_anims.h:130