X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2FGlobals.c;h=f8d5277823f5640a3b0e957e9ec2a47670e95de0;hb=0d95c7df5f708c3f30e10cab3894082019f8cd6c;hp=abba579397c9aca0b4dc8e3d773ced7f3da46695;hpb=5ba7f2d9a3f07f342afdf215a3307d5487cb6d43;p=rocksndiamonds.git diff --git a/src/game_sp/Globals.c b/src/game_sp/Globals.c index abba5793..f8d52778 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 @@ -138,6 +139,7 @@ int FreezeZonks; // --- const int keySpaceRight = 8; // --- const int keySpace = 9; +#if 0 int *aniBug, *aniZonkRollRight, *aniZonkRollLeft; int *aniInfotronRollRight, *aniInfotronRollLeft; int *aniSnikSnak, *aniElectron, *aniExplosion; @@ -162,9 +164,37 @@ int *aniEatInfotronLeft, *aniEatInfotronRight; // --- const int aniPushLeft = 45; // --- const int aniPushRight = 44; // --- const int aniPushUpDown = 79; +#endif + +#if 1 +int aniBug[] = { 74, 75, 76, 77, 78, 77, 76, 77, 78, 77, 76, 75, 74, 25 }; +int aniZonkRollRight[] = { 198, 197, 196, 195, 194, 193, 192, 1, -1 }; +int aniZonkRollLeft[] = { 192, 193, 194, 195, 196, 197, 198, 1, -1 }; +int aniInfotronRollRight[] = { 206, 205, 204, 203, 202, 201, 200, 4 }; +int aniInfotronRollLeft[] = { 200, 201, 202, 203, 204, 205, 206, 4 }; +int aniSnikSnak[] = { 121, 122, 123, 124, 125, 126, 127, 120, 121 }; +int aniElectron[] = { 144, 145, 146, 147, 148, 149, 150, 151, 144 }; +int aniExplosion[] = { 3, 103, 104, 105, 106, 107, 108, 109, 0 }; +int aniTouchBase[] = { 80, 81, 82, 83, 84, 85, 86, 0, -1 }; +int aniTouchInfotron[] = { 87, 88, 89, 91, 92, 93, 0, -1 }; // Only seven frames!!!! +int aniTouchRedDisk[] = { 96, 97, 98, 99, 100, 101, 102, 0, -1 }; +int aniMurphyExit[] = { 46, 46, 46, 46, 47, 47, 47, 47, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 54, 0, 0, 0, 0, -1 }; +int aniMurphyEatLeft[] = { 176, 177, 178, 179, 180, 181, 182, 183, -1 }; +int aniMurphyEatRight[] = { 184, 185, 186, 187, 188, 189, 190, 191, -1 }; +int aniMurphyEatUpLeft[] = { 183, 182, 181, 180, 179, 178, 177, 176, -1 }; +int aniMurphyEatUpRight[] = { 191, 190, 189, 188, 187, 186, 185, 184, -1 }; + // aniMurphyEatRightRedDisk = { 184, 184, 185, 186, 187, 188, 189, 190, 191, -1) '9 frames! +int aniEatInfotronLeft[] = { 209, 211, 213, 215, 217, 219, 221, 223, -1 }; +int aniEatInfotronRight[] = { 224, 226, 228, 230, 232, 234, 236, 238, -1 }; +int aniSplitUpDown[] = { 3, 3, 3, 3, 3, 3, 3, 3, -1 }; +int aniYellowDisk[] = { 18, 18, 18, 18, 18, 18, 18, 18, -1 }; +int aniOrangeDisk[] = { 8, 8, 8, 8, 8, 8, 8, 8, -1 }; +int aniRedDisk[] = { 20, -1 }; +#endif void InitGlobals() { +#if 0 aniBug = Array(74, 75, 76, 77, 78, 77, 76, 77, 78, 77, 76, 75, 74, 25); aniZonkRollRight = Array(198, 197, 196, 195, 194, 193, 192, 1, -1); aniZonkRollLeft = Array(192, 193, 194, 195, 196, 197, 198, 1, -1); @@ -188,6 +218,8 @@ void InitGlobals() aniYellowDisk = Array(18, 18, 18, 18, 18, 18, 18, 18, -1); aniOrangeDisk = Array(8, 8, 8, 8, 8, 8, 8, 8, -1); aniRedDisk = Array(20, -1); +#endif + InitPseudoCompileFlags(); UserDragFlag = False; AutoScrollFlag = True; @@ -299,63 +331,122 @@ void ReadLevel() long i; // byte T; +#if 1 + // CurPath = "/home/aeglos/projects/rocksndiamonds/levels/TEST_supaplex/supaplex/levels.dat"; + CurPath = "/home/aeglos/projects/rocksndiamonds/supaplex_demo_JENS0001.sp"; + LevelNumber = 1; +#endif + DemoAvailable = False; + if (STRING_IS_LIKE(CurPath, "*.mpx")) { + printf("::: reading MPX file ...\n"); + ReadMPX(); return; } if (STRING_IS_LIKE(CurPath, "*.sp")) { + printf("::: reading SP file ...\n"); + ReadDemo(); return; } if (DemoFlag != 0) { + printf("::: reading demo file ...\n"); + ReadDemo(); return; } + printf("::: reading level file ...\n"); + FileMax = 0; 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 + + 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++) { - PlayField16[i] = PlayField8[i]; + PlayField16[i] = PlayField8[i]; DisPlayField[i] = PlayField8[i]; PlayField8[i] = 0; } - AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 *FieldWidth); - AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 *FieldWidth); +#if 0 + { + int x, y; + + for (x = 0; x < 60; x++) + printf("%02d.", x); + printf("\n"); + + for (x = 0; x < 60; x++) + printf("..."); + printf("\n"); + + for (y = 0; y < 24; y++) + { + for (x = 0; x < 60; x++) + { + printf("%02d.", PlayField16[y * 60 + x]); + } + + printf("\n"); + } + } +#endif + + 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 @@ -374,27 +465,42 @@ static void ReadDemo() FieldWidth = 60; FieldHeight = 24; HeaderSize = 96; + FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1; LevelMax = (FieldWidth * FieldHeight) - 1; // --- On Error GoTo ReadDemoEH + FileMax = FileLen(CurPath) - 1; + PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax + 1 - 1); DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); + // 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); + // --- On Error GoTo 0 if (FieldMax < FileMax) DemoAvailable = True; ReadSignature(); + PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax); + for (i = 0; i <= FieldMax; i++) { PlayField16[i] = PlayField8[i]; @@ -402,18 +508,28 @@ static void ReadDemo() PlayField8[i] = 0; } - AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 *FieldWidth); - AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 *FieldWidth); + AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 * FieldWidth); + AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 * FieldWidth); TerminalState = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); + DemoPointer = FieldMax + 1; DemoOffset = DemoPointer; DemoKeyRepeatCounter = 0; + // DemoFlag = 1 // DemoAvailable = True + GravityFlag = LInfo.InitialGravity; FreezeZonks = LInfo.InitialFreezeZonks; + +#if 1 + printf("::: Globals.c: ReadDemo(): %d / %d\n", GravityFlag, FreezeZonks); +#endif + RandomSeed = LInfo.DemoRandomSeed; + LevelLoaded = True; + return; #if 0