DEADSOFTWARE

gl: remove bacanim flag from multitexture structure
[d2df-sdl.git] / src / game / g_animations.pas
index 1e9078e9320d52117e1b73aaf15371d3eaf7b22d..9c6dd4cb2aa53ab0a9086994dbf64ac00093d420 100644 (file)
@@ -70,12 +70,15 @@ interface
       back: Boolean; (* back animation normalization *)
     end;
 
+
   function g_Anim_GetTotalFrames (const a: TAnimInfo): LongWord;
   function g_Anim_GetTotalTime (const a: TAnimInfo): LongWord;
   function g_Anim_GetCountByTime (const a: TAnimInfo; time: LongWord): LongInt;
   procedure g_Anim_GetFrameByTime (const a: TAnimInfo; time: LongWord; out count, frame: LongInt);
   procedure g_Anim_GetState (const anim: TAnimInfo; time: LongWord; out state: TAnimState);
 
+  procedure g_Anim_GetFrameFromState (const s: TAnimState; backanim: Boolean; out frame: LongInt);
+
 implementation
 
   uses Math, utils, xstreams;
@@ -287,4 +290,17 @@ implementation
     state.mPlayed := count >= 1;
   end;
 
+  procedure g_Anim_GetFrameFromState (const s: TAnimState; backanim: Boolean; out frame: LongInt);
+    var total: LongInt;
+  begin
+    ASSERT(s.length > 0);
+    frame := s.CurrentFrame mod s.length;
+    if backanim then
+    begin
+      total := (s.length + 1) div 2;
+      if frame >= total then
+        frame := s.length - frame - 1;
+    end;
+  end;
+
 end.