X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2FGlobals.c;h=a51d7be0acecf1a6434b6d835ea90c392adacdb2;hb=e63e92923fa0196ba7d538d4c8f5a16994e3bee8;hp=abba579397c9aca0b4dc8e3d773ced7f3da46695;hpb=5ba7f2d9a3f07f342afdf215a3307d5487cb6d43;p=rocksndiamonds.git diff --git a/src/game_sp/Globals.c b/src/game_sp/Globals.c index abba5793..a51d7be0 100644 --- a/src/game_sp/Globals.c +++ b/src/game_sp/Globals.c @@ -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);