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