rnd-20090623-1-src
[rocksndiamonds.git] / src / game_sp / Demo.c
1 // ----------------------------------------------------------------------------
2 // Demo.c
3 // ----------------------------------------------------------------------------
4
5 #include "Demo.h"
6
7 static char *VB_Name = "modDemo";
8 // --- Option Explicit
9 //
10 // Public Function subCloseDemoRecordingFile()
11 //
12 // End Function
13 int RecDemoRandomSeed;
14 byte FirstDemoByte;
15 char *MySignature;
16
17 void subGetNextDemoKey()
18 {
19   int ax;
20
21   if (0 < DemoKeyRepeatCounter)
22   {
23     DemoKeyRepeatCounter = DemoKeyRepeatCounter - 1;
24   }
25   else
26   {
27     DemoOffset = DemoOffset + 1;
28     if (DemoOffset <= FileMax)
29     {
30       ax = PlayField8[DemoOffset];
31       if (ax == 0xFF)
32       {
33         demo_stopped = 1;
34         ExitToMenuFlag = 1;
35       }
36       else
37       {
38         DemoKeyCode = ax & 0xF;
39         DemoKeyRepeatCounter = (ax & 0xF0) / 0x10;
40       }
41
42     }
43     else
44     {
45       ExitToMenuFlag = 1;
46     }
47   }
48 }
49
50 currency GetTotalFramesOfDemo()
51 {
52   currency GetTotalFramesOfDemo;
53
54   long i;
55   currency nFrames;
56   byte db;
57
58   GetTotalFramesOfDemo = 0;
59   if (! DemoAvailable)
60     return GetTotalFramesOfDemo;
61
62   nFrames = 1;
63   i = DemoPointer + 1;
64
65   // --- On Error GoTo GetTotalFramesOfDemoEH
66   db = PlayField8[i];
67   while (db != 0xFF)
68   {
69     nFrames = nFrames + (db & 0xF0) / 0x10 + 1;
70     i = i + 1;
71     db = PlayField8[i];
72   }
73
74   GetTotalFramesOfDemo = nFrames;
75   return GetTotalFramesOfDemo;
76
77 GetTotalFramesOfDemoEH:
78   // ReportError "GetTotalFramesOfDemo()", "invalid data detected in file " & OrigPath
79   GetTotalFramesOfDemo = 0;
80   DemoAvailable = False;
81
82   return GetTotalFramesOfDemo;
83 }