rnd-20090719-1-src
[rocksndiamonds.git] / src / game_sp / Globals.c
index abba579397c9aca0b4dc8e3d773ced7f3da46695..a51d7be0acecf1a6434b6d835ea90c392adacdb2 100644 (file)
@@ -7,7 +7,8 @@
 static void ReadDemo();
 void ReadLevel();
 
-static char *VB_Name = "modGlobals";
+// static char *VB_Name = "modGlobals";
+
 // --- Option Explicit
 // --- Option Compare Text
 // --- Option Base 0
@@ -300,6 +301,7 @@ void ReadLevel()
   // byte T;
 
   DemoAvailable = False;
+
   if (STRING_IS_LIKE(CurPath, "*.mpx"))
   {
     ReadMPX();
@@ -322,28 +324,52 @@ void ReadLevel()
   FieldWidth = 60;
   FieldHeight = 24;
   HeaderSize = 96;
+
   FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1;
   LevelMax = (FieldWidth * FieldHeight) - 1;
+
   PlayField8 = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
   DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
+
   // FNum = FreeFile();
 
   // --- On Error GoTo ReadLevelEH
+
+#if 1
+  CurPath = "/home/aeglos/projects/rocksndiamonds/levels/TEST_supaplex/supaplex/levels.dat";
+  LevelNumber = 1;
+#endif
+
+  printf("::: '%s', %d\n", CurPath, LevelNumber);
+
   FNum = fopen(CurPath, "rb");
+
   i = (LevelNumber - 1) * ((long)(FieldMax) + 1) + 1;
+#if 1
+  FILE_GET(FNum, i, PlayField8, FieldMax + 1);
+#else
   FILE_GET(FNum, i, &PlayField8, sizeof(PlayField8));
+#endif
   i = (LevelNumber) * ((long)(FieldMax) + 1) + 1 - HeaderSize;
   FILE_GET(FNum, i, &LInfo, sizeof(LInfo)); // store level info in an extra structure
+
   fclose(FNum);
+
   // --- On Error GoTo 0
 
   if (FieldMax < FileMax)
     DemoAvailable = True;
 
   ReadSignature();
+
   PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax);
+
   for (i = 0; i <= FieldMax; i++)
   {
+#if 0
+    printf("::: %d: %d\n", i, PlayField8[i]);
+#endif
+
     PlayField16[i] = PlayField8[i];
     DisPlayField[i] = PlayField8[i];
     PlayField8[i] = 0;
@@ -352,10 +378,14 @@ void ReadLevel()
   AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 *FieldWidth);
   AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 *FieldWidth);
   TerminalState = REDIM_1D(sizeof(byte), FieldWidth, LevelMax - FieldWidth);
+
   GravityFlag = LInfo.InitialGravity;
   FreezeZonks = LInfo.InitialFreezeZonks;
+
   subRandomize();
+
   LevelLoaded = True;
+
   return;
 
 #if 0
@@ -384,7 +414,11 @@ static void ReadDemo()
   // FNum = FreeFile();
   FNum = fopen(CurPath, "rb");
   i = (LevelNumber - 1) * ((long)(FieldMax) + 1) + 1;
+#if 1
+  FILE_GET(FNum, i, PlayField8, FileMax + 1);
+#else
   FILE_GET(FNum, i, &PlayField8, sizeof(PlayField8));
+#endif
   i = (LevelNumber) * ((long)(FieldMax) + 1) + 1 - HeaderSize;
   FILE_GET(FNum, i, &LInfo, sizeof(LInfo)); // store level info in an extra structure
   fclose(FNum);