@@ -37,10 +37,13 @@ void FastAnim_Decompress(struct ModelAnim* ma, u_int* pCmd)
3737
3838 struct Mempack * ptrMempack = sdata -> PtrMempack ;
3939
40+ // TODO: Only Turn animation works
4041 if (ma -> name [0 ] != 't' )
4142 return ;
4243
43- printf ("Run Animation: %s\n" , ma -> name );
44+ printf ("Run Animation: %s\n" , ma -> name );
45+
46+ u_int pCmd_backup = pCmd ;
4447
4548 for (int i = 0 ; i < (ma -> numFrames & 0x7fff ); i ++ )
4649 {
@@ -56,6 +59,9 @@ void FastAnim_Decompress(struct ModelAnim* ma, u_int* pCmd)
5659 // may be compressed vertData, or uncompresed
5760 char * vertData = MODELFRAME_GETVERT (mf );
5861
62+ // reset
63+ pCmd = pCmd_backup ;
64+
5965 // pCmd[0] is number of commands
6066 pCmd ++ ;
6167
@@ -72,7 +78,7 @@ void FastAnim_Decompress(struct ModelAnim* ma, u_int* pCmd)
7278 unsigned int byte =
7379 (unsigned int )ptrMempack -> firstFreeByte ;
7480 byte += 3 ;
75- byte &= ~(4 );
81+ byte &= ~(3 );
7682 ptrMempack -> firstFreeByte = byte ;
7783
7884 // keep record
@@ -154,70 +160,4 @@ void FastAnim_Decompress(struct ModelAnim* ma, u_int* pCmd)
154160 mf -> vertexOffset = (unsigned int )addrArray [i ] - (unsigned int )mf ;
155161 }
156162}
157- #endif
158-
159- #if 0
160-
161- // temporary solution, plays animations
162- // at 30fps while rest of the game is 60fps
163- int frameIndex = FPS_HALF (curr -> animFrame );
164-
165- // Get first frame, then current frame
166- char * firstFrame = MODELANIM_GETFRAME (ma );
167- mf = & firstFrame [ma -> frameSize * frameIndex ];
168-
169- char * vertData = MODELFRAME_GETVERT (mf );
170-
171- Decompressed
172-
173- // Copy uncompressed vertices to scratchpad
174- CompVertex * ptrVerts = (CompVertex * )vertData ;
175-
176- stack [stackIndex ].X = ptrVerts [vertexIndex ].X ;
177- stack [stackIndex ].Y = ptrVerts [vertexIndex ].Y ;
178- stack [stackIndex ].Z = ptrVerts [vertexIndex ].Z ;
179-
180- Compressed
181-
182- //store temporal vertex packed uint
183- u_int temporal = ma -> ptrDeltaArray [vertexIndex ];
184-
185- //printf("temporal: %08x\n", temporal);
186-
187- //extract data from packed uint
188- //deltaArray bits: 0bXXXXXXXZZZZZZZZYYYYYYYYAAABBBCCC
189-
190- u_char XBits = (temporal >> 6 ) & 7 ;
191- u_char YBits = (temporal >> 3 ) & 7 ;
192- u_char ZBits = (temporal ) & 7 ;
193-
194- u_char bx = (temporal >> 0x19 ) << 1 ;
195- u_char by = (temporal << 7 ) >> 0x18 ;
196- u_char bz = (temporal << 0xf ) >> 0x18 ;
197-
198- // If reading a full 8 bits (7+1)
199- // reset accumulator, this is an
200- // uncompressed 1-byte number
201- if (XBits == 7 ) x_alu = 0 ;
202- if (YBits == 7 ) y_alu = 0 ;
203- if (ZBits == 7 ) z_alu = 0 ;
204-
205- // Read NumBits+1, where the first
206- // extra (+1) bit, determines negative
207-
208- // convert XZY frame data
209- int newX = GetSignedBits (vertData , XBits + 1 );
210- int newY = GetSignedBits (vertData , YBits + 1 );
211- int newZ = GetSignedBits (vertData , ZBits + 1 );
212-
213- //calculate decompressed coord value
214- x_alu = (x_alu + (int )newX + bx );
215- y_alu = (y_alu + (int )newY + by );
216- z_alu = (z_alu + (int )newZ + bz );
217-
218- //store values to stack index, axis swap is important
219- stack [stackIndex ].X = x_alu ;
220- stack [stackIndex ].Y = z_alu ;
221- stack [stackIndex ].Z = y_alu ;
222-
223163#endif
0 commit comments