From: Holger Schemel Date: Fri, 25 Sep 2009 18:55:35 +0000 (+0200) Subject: rnd-20090925-1-src X-Git-Tag: 3.3.0.0^2~80 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=026c569fc47fbe95d8cb131442a4e04610f27f05;p=rocksndiamonds.git rnd-20090925-1-src * fixed bug when reading Supaplex single level files (preventing loader from seeking to level position like in Supaplex level package files) --- diff --git a/ChangeLog b/ChangeLog index de1e04b4..1e307c07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-09-23 + * fixed bug when reading Supaplex single level files (preventing loader + from seeking to level position like in Supaplex level package files) + 2009-08-01 * first classic Supaplex level running and solved by solution/demo tape diff --git a/src/conftime.h b/src/conftime.h index b0b6875e..847d17c6 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2009-09-19 02:10" +#define COMPILE_DATE_STRING "2009-09-25 20:53" diff --git a/src/files.c b/src/files.c index 239b85ec..863ac203 100644 --- a/src/files.c +++ b/src/files.c @@ -4013,7 +4013,8 @@ static void LoadLevelFromFileInfo_SP(struct LevelInfo *level, } /* position file stream to the requested level inside the level package */ - if (fseek(file, nr * SP_LEVEL_SIZE, SEEK_SET) != 0) + if (level_file_info->packed && + fseek(file, nr * SP_LEVEL_SIZE, SEEK_SET) != 0) { level->no_valid_file = TRUE; diff --git a/src/game_sp/BugsTerminals.c b/src/game_sp/BugsTerminals.c index 4847b92e..4bb27c03 100644 --- a/src/game_sp/BugsTerminals.c +++ b/src/game_sp/BugsTerminals.c @@ -94,7 +94,11 @@ int subAnimateTerminals(int si) int subAnimateTerminals; // int bl, ax, al, X, Y; +#if 1 + short bl, al, X, Y; +#else int bl, al, X, Y; +#endif if (LowByte(PlayField16[si]) != fiTerminal) return subAnimateTerminals; @@ -159,6 +163,10 @@ int subRandomize() } #endif +#if 1 + printf("::: BugsTerminals.c: ========== subRandomize()\n"); +#endif + return subRandomize; } // subRandomize @@ -178,7 +186,12 @@ int subGetRandomNumber() if (0x8000 == (RandomSeed & 0x8000)) RSeed = RSeed | 0x8000; +#if 0 + /* !!! TEST !!! */ + Tmp = 0xFFFF & (((0x5E5 * RSeed) & 0xFFFF) + 0x31); +#else Tmp = 0xFFFF & (((0x5E5 * RandomSeed) & 0xFFFF) + 0x31); +#endif RandomSeed = 0x7FFF & Tmp; if ((Tmp & 0x8000) != 0) RandomSeed = RandomSeed | 0x8000; @@ -192,6 +205,10 @@ int subGetRandomNumber() // Mov randomseed, ax // shr ax,1 +#if 0 + printf("::: BugsTerminals.c: ---------- subGetRandomNumber(): %d\n", + subGetRandomNumber); +#endif + return subGetRandomNumber; } // subGetRandomNumber - diff --git a/src/game_sp/Globals.c b/src/game_sp/Globals.c index 8bd2e450..9dbe3138 100644 --- a/src/game_sp/Globals.c +++ b/src/game_sp/Globals.c @@ -66,7 +66,12 @@ byte *DisPlayField; // Public DisplayMin%, DisplayMax%, DisplayWidth%, DisplayHeight% -int TimerVar, RandomSeed; +int TimerVar; +#if 1 +short RandomSeed; +#else +int RandomSeed; +#endif currency DeltaT; // Interval between two frames (in ms) long DeltaTPlay, DeltaTDemo; boolean BlockingSpeed; @@ -342,7 +347,15 @@ void ReadLevel() CurPath = "/home/aeglos/projects/rocksndiamonds/supaplex_demo_JENS0001.sp"; LevelNumber = 1; #else + +#if 0 + // sprintf(CurPathTEST, "/home/aeglos/projects/rocksndiamonds/levels/TEST_supaplex/test_solutions/%03d.sp", level_nr); + + sprintf(CurPathTEST, "/home/aeglos/projects/Level_Stuff/SUPAPLEX/SUPAPLEX_LEVELS/Set77/77S%03d.SP", level_nr); +#else sprintf(CurPathTEST, "/home/aeglos/projects/Level_Stuff/SUPAPLEX/SUPAPLEX_LEVELS/solve00/JENS%04d.SP", level_nr); +#endif + CurPath = CurPathTEST; LevelNumber = level_nr; #endif @@ -546,24 +559,40 @@ static void ReadDemo() printf("::: Globals.c: ReadDemo(): %d / %d\n", GravityFlag, FreezeZonks); #endif - RandomSeed = LInfo.DemoRandomSeed; + + +#if 0 + /* !!! TESTING BIG / LITTLE ENDIAN STUFF !!! */ + LInfo.DemoRandomSeed = + LowByte(LInfo.DemoRandomSeed) << 8 | + HighByte(LInfo.DemoRandomSeed); + for (i = 0; i < 10; i++) + LInfo.SpecialPort[i].PortLocation = + LowByte(LInfo.SpecialPort[i].PortLocation) << 8 | + HighByte(LInfo.SpecialPort[i].PortLocation); + + printf("::: swapping file bytes for DemoRandomSeed etc.\n"); +#else + printf("::: keeping file bytes in (maybe wrong) 'native' order.\n"); +#endif #if 1 + printf("::: LInfo.DemoRandomSeed == %d\n", LInfo.DemoRandomSeed); +#endif + + RandomSeed = LInfo.DemoRandomSeed; + +#if 0 + printf("::: SpeedByte == %d\n", LInfo.SpeedByte); + printf("::: CheckSumByte == %d\n", LInfo.CheckSumByte); printf("::: RandomSeed == %d\n", RandomSeed); -#if 1 +#if 0 { int i; for (i = 0; i < 10; i++) printf("::: TEST random number: %d\n", subGetRandomNumber()); - - int buffer, value = -3; - - MovHighByte(&buffer, value); - value = SgnHighByte(buffer); - - printf("::: TEST: 0x%08x / %d\n", value, value); } #endif diff --git a/src/game_sp/Globals.h b/src/game_sp/Globals.h index f705fd53..7a618ed9 100644 --- a/src/game_sp/Globals.h +++ b/src/game_sp/Globals.h @@ -175,7 +175,8 @@ extern int FieldWidth; extern int FreezeZonks; extern int HeaderSize; extern int LevelNumber; -extern int TimerVar, RandomSeed; +extern int TimerVar; +extern short RandomSeed; extern long DeltaTPlay, DeltaTDemo; extern long FileMax; extern long SignatureDelay; diff --git a/src/game_sp/Murphy.c b/src/game_sp/Murphy.c index a646978b..bfe6854a 100644 --- a/src/game_sp/Murphy.c +++ b/src/game_sp/Murphy.c @@ -932,7 +932,7 @@ loc_g_6756: return subAnimateMurphy; #if 1 - printf("::: Murphy.c: !!!!!!!!!! GAME SOLVED !!!!!!!!!!\n"); + printf("::: Murphy.c: !!!!!!!!!! LEVEL %d SOLVED !!!!!!!!!!\n", LevelNumber); #endif subSoundFXExit(); @@ -2328,6 +2328,28 @@ int subSpPortTest(int si) int i, cx, bx; +#if 1 + cx = LInfo.SpecialPortCount; // number of special ports + + for (i = 0; i < cx; i++) + { + bx = HighByte(LInfo.SpecialPort[i].PortLocation); + MovHighByte(&bx, LowByte(LInfo.SpecialPort[i].PortLocation)); + + if (bx / 2 == si) + { + GravityFlag = LInfo.SpecialPort[i].Gravity; + FreezeZonks = LInfo.SpecialPort[i].FreezeZonks; + SnikSnaksElectronsFrozen = LInfo.SpecialPort[i].FreezeEnemies; + + // RandomTime = RandomTime Xor RandomSeed 'is RandomTime used at all? no! + + break; + } + } + +#else + cx = LInfo.SpecialPortCount; // number of special ports for (i = 1; i <= cx; i++) { @@ -2342,9 +2364,9 @@ int subSpPortTest(int si) // RandomTime = RandomTime Xor RandomSeed 'is RandomTime used at all? no! i = cx + 1; } - } } +#endif return subSpPortTest; } // subSpPortTest diff --git a/src/game_sp/modAnimations.h b/src/game_sp/modAnimations.h index 13e6db66..38325dc0 100644 --- a/src/game_sp/modAnimations.h +++ b/src/game_sp/modAnimations.h @@ -15,7 +15,11 @@ #ifndef HAS_SpecialPortType typedef struct { +#if 1 + short PortLocation; // = 2*(x+(y*60)) +#else int PortLocation; // = 2*(x+(y*60)) +#endif byte Gravity; // 1 = turn on, anything else (0) = turn off byte FreezeZonks; // 2 = turn on, anything else (0) = turn off (1=off!) byte FreezeEnemies; // 1 = turn on, anything else (0) = turn off @@ -38,10 +42,14 @@ typedef struct // amount of Infotrons in the level, and use the low byte of that number. // (A multiple of 256 Infotrons will then result in 0-to-eat, etc.!) byte SpecialPortCount; // Maximum 10 allowed! - SpecialPortType SpecialPort[10 + 1]; + SpecialPortType SpecialPort[10]; byte SpeedByte; // = Speed XOR Highbyte(RandomSeed) byte CheckSumByte; // = CheckSum XOR SpeedByte +#if 1 + short DemoRandomSeed; +#else int DemoRandomSeed; +#endif } LevelInfoType; #define HAS_LevelInfoType #endif