1 /* ResidualVM - A 3D game interpreter
2 *
3 * ResidualVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the AUTHORS
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
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (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, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 *
26 */
27
28 #ifndef ICB_RAP_API_HH
29 #define ICB_RAP_API_HH
30
31 #include "engines/icb/gfx/psx_pcdefines.h"
32
33 namespace ICB {
34
35 #define RAP_API_SCHEMA 10
36
37 #define RAP_API_ID "RAP"
38
39 // A bone-bone link
40 // tx, ty, tz : is translation
41 // parent : is the the parent bone ID
42 // = nBones means no linkage
43 typedef struct BoneLink {
44 int16 tx, ty, tz;
45 uint16 parent;
46 } BoneLink;
47
48 // A simple vertex description
49 typedef struct Vertex {
50 int16 vx, vy, vz;
51 uint16 vertId;
52 } Vertex;
53
54 // A vertex-bone link
55 typedef struct VertexLink {
56 int16 vx, vy, vz; // the position in bone co-ordinate frame
57 int16 primId; // bone id - -ve number means no bone just "local" frame
58 uint32 vertId; // vertex id
59 } VertexLink;
60
61 // A weighted vertex-bone link
62 typedef struct WeightedVertexLink {
63 VertexLink link;
64 uint32 weight; // % weight (fixed-point int scaled to weightScale)
65 } WeightedVertexLink;
66
67 // Each polygon is 6 32-bit WORDS
68 // Bit 31 ----> Bit 0
69 //
70 // 8-bits | 8-bits | 16-bits
71 // --------------------------
72 // u0 | v0 | cba
73 // u1 | v1 | tsb
74 // u2 | v2 | pad
75 // --------------------------
76 // n0 | v0
77 // n1 | v1
78 // n2 | v2
79 //
80 // u0, v0 = u,v of vertex 0 : 0-255
81 // u1, v1 = u,v of vertex 1 : 0-255
82 // u2, v2 = u,v of vertex 2 : 0-255
83 // cba = weird PSX flag, giving the VRAM x,y of the CLUT to use
84 // tsb = weird PSX flag, giving the VRAM texture page to use
85 // pad = padding !
86 //
87 // n0, v0 = index into the the normal and vertex pool for normal/vertex 0
88 // n1, v1 = index into the the normal and vertex pool for normal/vertex 1
89 // n2, v2 = index into the the normal and vertex pool for normal/vertex 2
90 //
91 // The .rap file format
92 //
93 // Notice, how poor ANSI C/C++ is at its representation
94 //
95
96 typedef struct rap_API {
97 char id[4];
98 uint32 schema;
99 uint32 platform;
100 uint32 worldScaleShift;
101 uint32 weightScaleShift;
102 uint32 bothScaleShift;
103 uint32 nNone;
104 uint32 nSingle;
105 uint32 nMultiple;
106 uint32 nFUS3;
107 uint32 nGUS3;
108 uint32 nFTS3;
109 uint32 nGTS3;
110 uint32 nFUL3;
111 uint32 nGUL3;
112 uint32 nFTL3;
113 uint32 nGTL3;
114 uint16 nTRI3;
115 uint16 nFrames;
116 uint32 nAnimTypes;
117 uint32 animPolySize; // in bytes
118 uint16 nBones;
119 int8 jawBone; // -1 - means not there
120 int8 neckBone; // - 1 - means not there
121 uint32 singleLinkOffset; // in bytes
122 uint32 multiLinkOffset; // in bytes
123 uint32 FUS3offset; // in bytes
124 uint32 GUS3offset; // in bytes
125 uint32 FTS3offset; // in bytes
126 uint32 GTS3offset; // in bytes
127 uint32 FUL3offset; // in bytes
128 uint32 GUL3offset; // in bytes
129 uint32 FTL3offset; // in bytes
130 uint32 GTL3offset; // in bytes
131 uint16 TRI3offset; // in bytes
132 uint16 animPolyOffset; // in bytes
133 uint32 normalOffset; // in bytes
134 uint32 boneOffset; // in bytes
135 Vertex noneLinkData[1]; // Vertex noLinkData[nNone];
136
GetNoneLinkPtrrap_API137 Vertex *GetNoneLinkPtr() { return noneLinkData; }
138
GetSingleLinkPtrrap_API139 VertexLink *GetSingleLinkPtr() { return (VertexLink *)(id + singleLinkOffset); }
140
GetMultiLinkPtrrap_API141 WeightedVertexLink *GetMultiLinkPtr() { return (WeightedVertexLink *)(id + multiLinkOffset); }
142
GetFUS3Ptrrap_API143 uint32 *GetFUS3Ptr() { return (uint32 *)(id + FUS3offset); }
GetGUS3Ptrrap_API144 uint32 *GetGUS3Ptr() { return (uint32 *)(id + GUS3offset); }
GetFTS3Ptrrap_API145 uint32 *GetFTS3Ptr() { return (uint32 *)(id + FTS3offset); }
GetGTS3Ptrrap_API146 uint32 *GetGTS3Ptr() { return (uint32 *)(id + GTS3offset); }
GetFUL3Ptrrap_API147 uint32 *GetFUL3Ptr() { return (uint32 *)(id + FUL3offset); }
GetGUL3Ptrrap_API148 uint32 *GetGUL3Ptr() { return (uint32 *)(id + GUL3offset); }
GetFTL3Ptrrap_API149 uint32 *GetFTL3Ptr() { return (uint32 *)(id + FTL3offset); }
GetGTL3Ptrrap_API150 uint32 *GetGTL3Ptr() { return (uint32 *)(id + GTL3offset); }
GetTRI3Ptrrap_API151 uint32 *GetTRI3Ptr() { return (uint32 *)(id + TRI3offset); }
GetNormalPtrrap_API152 uint32 *GetNormalPtr() { return (uint32 *)(id + normalOffset); }
GetBonePtrrap_API153 BoneLink *GetBonePtr() { return (BoneLink *)(id + boneOffset); }
GetBoneHashPtrrap_API154 uint32 *GetBoneHashPtr() {
155 BoneLink *bPtr = GetBonePtr();
156 return (uint32 *)(bPtr + nBones);
157 }
158
GetAnimPolyPtrrap_API159 uint32 *GetAnimPolyPtr() { return (uint32 *)(id + animPolyOffset); }
GetAnimPolyFramerap_API160 uint32 *GetAnimPolyFrame(int32 frame) { return (uint32 *)(id + animPolyOffset + nAnimTypes * 2 * sizeof(uint32) + frame * animPolySize); }
161
162 } rap_API;
163
ConvertRAP(rap_API * rap)164 inline void ConvertRAP(rap_API *rap) {
165 // Do we need to do any conversion ?
166 if (rap->schema == RAP_API_SCHEMA)
167 return;
168
169 // You can't so a schema check will fail !
170 return;
171 }
172
173 } // End of namespace ICB
174
175 #endif // #ifndef RAP_API_HH
176