From: Holger Schemel Date: Fri, 24 Jul 2009 12:18:00 +0000 (+0200) Subject: rnd-20090724-1-src X-Git-Tag: 3.3.0.0^2~86 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=bc739f556617ab3e83f1beb7e0a446b9d074b8ee rnd-20090724-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 208d098e..c194c8e9 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2009-07-22 12:30" +#define COMPILE_DATE_STRING "2009-07-24 14:16" diff --git a/src/game_sp/Globals.c b/src/game_sp/Globals.c index 36034f5b..67491f73 100644 --- a/src/game_sp/Globals.c +++ b/src/game_sp/Globals.c @@ -331,26 +331,40 @@ 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; @@ -366,11 +380,6 @@ void ReadLevel() // --- 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"); @@ -381,6 +390,7 @@ void ReadLevel() #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 @@ -426,8 +436,8 @@ void ReadLevel() } #endif - 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), FieldWidth, LevelMax - FieldWidth); GravityFlag = LInfo.InitialGravity; @@ -455,31 +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]; @@ -487,18 +508,24 @@ 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; + RandomSeed = LInfo.DemoRandomSeed; + LevelLoaded = True; + return; #if 0 diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index 5c3b85fd..b04fda82 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -2523,20 +2523,28 @@ void menPlay_Click() } -#if 0 - -static void menPlayDemo_Click() +// static void menPlayDemo_Click() +void menPlayDemo_Click() { DemoFlag = 1; RecordDemoFlag = 0; + +#if 0 lblStatus = "Demo Playback"; +#endif + menPlay_Click(); + +#if 0 if (LevelStatus != 1) lblStatus = "Demo Failed"; +#endif DemoFlag = 0; } +#if 0 + static void menRec_Click() { Trace("MainForm", "--> menRec_Click()"); diff --git a/src/game_sp/MainForm.h b/src/game_sp/MainForm.h index ae913f8e..9846ce2c 100644 --- a/src/game_sp/MainForm.h +++ b/src/game_sp/MainForm.h @@ -28,6 +28,7 @@ extern void menEdit_Click(); extern void menPlaySpeed_Click(int Index); extern void menStop_Click(); extern void menPlay_Click(); +extern void menPlayDemo_Click(); extern void Form_Load(); #endif /* MAINFORM_H */ diff --git a/src/game_sp/MainGameLoop.c b/src/game_sp/MainGameLoop.c index b4a91d00..398bc80f 100644 --- a/src/game_sp/MainGameLoop.c +++ b/src/game_sp/MainGameLoop.c @@ -35,12 +35,16 @@ int subMainGameLoop() if (DemoFlag != 0) { + printf("::: playing demo ...\n"); + // EP set level success byte: demo, not game WasDemoFlag = 1; EP_GameDemoVar0DAA = 0; // demo } else // loc_g_1836: { + printf("::: playing game ...\n"); + // EP set level success byte: game, not demo WasDemoFlag = 0; EP_GameDemoVar0DAA = 1; // game @@ -249,8 +253,13 @@ int subCalculateScreenScrollPos() Ay = MainForm.picPane.Height / 2; } +#if 1 + ScreenScrollXPos = Stretch * (MurphyScreenXPos + 16) - ax; + ScreenScrollYPos = Stretch * (MurphyScreenYPos + 16) - Ay; +#else ScreenScrollXPos = Stretch * (MurphyScreenXPos + 8) - ax; ScreenScrollYPos = Stretch * (MurphyScreenYPos + 8) - Ay; +#endif #if 0 printf("::: MainGameLoop.c: subCalculateScreenScrollPos(): %d, %d [%d, %d] -> %d, %d\n", diff --git a/src/game_sp/main.c b/src/game_sp/main.c index 235d4334..ce409eb4 100644 --- a/src/game_sp/main.c +++ b/src/game_sp/main.c @@ -5,7 +5,11 @@ void InitGameEngine_SP() { +#if 0 menPlay_Click(); +#else + menPlayDemo_Click(); +#endif } void BlitScreenToBitmap_SP(Bitmap *target_bitmap) diff --git a/src/game_sp/vb_lib.c b/src/game_sp/vb_lib.c index d32a62f8..fa1ef2c6 100644 --- a/src/game_sp/vb_lib.c +++ b/src/game_sp/vb_lib.c @@ -9,6 +9,8 @@ #include "main_sp.h" +#include + /* helper functions for constructs not supported by C */ void *REDIM_1D(int a, int b, int c) @@ -55,7 +57,16 @@ char *INT_TO_STR(int a) boolean STRING_IS_LIKE(char *a, char *b) { - return 0; + if (*b == '*') // something like "*.sp" + { + return (strSuffix(a, &b[1])); + } + else + { + // more sophisticated patterns currently not supported + + return 0; + } } @@ -154,7 +165,16 @@ char *Hex(int a) int FileLen(char *a) { - return 0; + struct stat buffer; + + if (stat(a, &buffer) == 0) + { + return buffer.st_size; + } + else + { + return 0; + } } long GetTickCount()