1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
7 static void ReadDemo();
10 // static char *VB_Name = "modGlobals";
12 // --- Option Explicit
13 // --- Option Compare Text
16 // --- const long StretchWidth = 16;
17 // --- const long StretchWidth2 = StretchWidth / 2;
18 // --- const long BaseWidth = 16;
19 // --- const int TwoPixels = 2;
44 boolean DemoRecordFix;
52 char *CurPath, *OrigPath, *TmpPath;
58 int FieldWidth; // = 60
59 int FieldHeight; // = 24
60 int HeaderSize; // = 96
61 int FieldMax, LevelMax;
67 // Public DisplayMin%, DisplayMax%, DisplayWidth%, DisplayHeight%
69 int TimerVar, RandomSeed;
70 currency DeltaT; // Interval between two frames (in ms)
71 long DeltaTPlay, DeltaTDemo;
72 boolean BlockingSpeed;
74 // --- const int posFrameCorner = 55;
75 // --- const int posFrameVertical = 110;
76 // --- const int posFrameHorizontal = 111;
80 // constants for Fixed Fields:
81 // --- const int fiSpace = 0; // &H00 space(28 = wall space ...)
82 // --- const int fiZonk = 1; // &H01 zonk
83 // --- const int fiBase = 2; // &H02 base
84 // --- const int fiMurphy = 3; // &H03 Murphy
85 // --- const int fiInfotron = 4; // &H04 infotron
86 // --- const int fiRAM = 5; // &H05 small RAM chip
87 // --- const int fiHardWare = 6; // &H06 hardware (square, standard pyramid shape)
88 // --- const int fiExit = 7; // &H07 exit
89 // --- const int fiOrangeDisk = 8; // &H08 brown/orange utility disk
90 // --- const int fiPortRight = 9; // &H09 port 1 left to right
91 // --- const int fiPortDown = 10; // &H0A port 1 up to down
92 // --- const int fiPortLeft = 11; // &H0B port 1 right to left
93 // --- const int fiPortUp = 12; // &H0C port 1 down to up
94 // --- const int fiSpPortRight = 13; // &H0D port 2 left to right (gravity change)
95 // --- const int fiSpPortDown = 14; // &H0E port 2 up to down (gravity change)
96 // --- const int fiSpPortLeft = 15; // &H0F port 2 right to left (gravity change)
97 // --- const int fiSpPortUp = 16; // &H10 port 2 down to up (gravity change)
98 // --- const int fiSnikSnak = 17; // &H11 snik snak
99 // --- const int fiYellowDisk = 18; // &H12 yellow utility disk
100 // --- const int fiTerminal = 19; // &H13 terminal
101 // --- const int fiRedDisk = 20; // &H14 red utility disk
102 // --- const int fiPortUpAndDown = 21; // &H15 vertical port
103 // --- const int fiPortLeftAndRight = 22; // &H16 horizontal port
104 // --- const int fiPortAllDirections = 23; // &H17 horizontal + vertical port
105 // --- const int fiElectron = 24; // &H18 electron
106 // --- const int fiBug = 25; // &H19 bug
107 // --- const int fiRAMLeft = 26; // &H1A horizontal RAM chip, left (pin 1)
108 // --- const int fiRAMRight = 27; // &H1B horizontal RAM chip, right
109 // --- const int fiHWFirst = 28; // &H1C hardware (radial blue circular cap + coloured shapes)
111 // Public Const fiHW1% = 29 ' 29 = 1D hardware (green signal lamp)
112 // Public Const fiHW2% = 30 ' 30 = 1E hardware (blue signal lamp)
113 // Public Const fiHW3% = 31 ' 31 = 1F hardware (red signal lamp)
114 // Public Const fiHW4% = 32 ' 32 = 20 hardware (yellow/black diagonal stripes)
115 // Public Const fiHW5% = 33 ' 33 = 21 hardware (yellow resistor + blue + red shapes)
116 // Public Const fiHW6% = 34 ' 34 = 22 hardware (horizontal red capacitor + smd shape)
117 // Public Const fiHW7% = 35 ' 35 = 23 hardware (red + yellow + blue horizontal resistors)
118 // Public Const fiHW8% = 36 ' 36 = 24 hardware (3 red vertical resistors)
119 // --- const int fiHWLast = 37; // 37 = 25 hardware (3 yellow horizontal resistors)
120 // --- const int fiRAMTop = 38; // 38 = 26 vertical RAM chip, top (pin 1)
121 // --- const int fiRAMBottom = 39; // 39 = 27 vertical RAM chip, bottom
123 // Specials to experiment with ...
124 // --- const int fiWallSpace = 40; // 40 = 28 invisible wall (can explode, zonks don't roll off)
125 // --- const int fiHWTrash1 = 41; // 41 = 29 hardware trash
126 // --- const int fiHWTrash2 = 42; // 42 = 2A hardware trash
127 // --- const int fiHWMurphy = 43; // 43 = 2B hardware inverted Murphy ... (maybe nice for use?)
129 // --- const int fiExplosion = 0x1F;
131 // --- const int keyNone = 0;
132 // --- const int keyUp = 1;
133 // --- const int keyLeft = 2;
134 // --- const int keyDown = 3;
135 // --- const int keyRight = 4;
136 // --- const int keySpaceUp = 5;
137 // --- const int keySpaceLeft = 6;
138 // --- const int keySpaceDown = 7;
139 // --- const int keySpaceRight = 8;
140 // --- const int keySpace = 9;
143 int *aniBug, *aniZonkRollRight, *aniZonkRollLeft;
144 int *aniInfotronRollRight, *aniInfotronRollLeft;
145 int *aniSnikSnak, *aniElectron, *aniExplosion;
146 int *aniTouchBase, *aniTouchInfotron, *aniTouchRedDisk;
147 // --- const int aniExplosionInfo = 111;
148 // --- const int aniSnikSnakUp = 159;
149 // --- const int aniSnikSnakDown = 167;
150 // --- const int aniSnikSnakLeft = 239;
151 // --- const int aniSnikSnakRight = 247;
152 // --- const int aniMurphyYawn = 56;
153 // --- const int aniMurphySleepLeft = 71;
154 // --- const int aniMurphySleepRight = 68;
155 int *aniMurphyExit; // , aniMurphyFaceLeft%, aniMurphyFaceRight%
156 int *aniMurphyEatLeft, *aniMurphyEatRight; // , aniMurphyEatRightRedDisk
157 int *aniMurphyEatUpLeft, *aniMurphyEatUpRight, *aniSplitUpDown;
158 int *aniYellowDisk, *aniOrangeDisk, *aniRedDisk;
159 // --- const int aniMurphyTouchUp = 46;
160 // --- const int aniMurphyTouchLeft = 95;
161 // --- const int aniMurphyTouchDown = 47;
162 // --- const int aniMurphyTouchRight = 94;
163 int *aniEatInfotronLeft, *aniEatInfotronRight;
164 // --- const int aniPushLeft = 45;
165 // --- const int aniPushRight = 44;
166 // --- const int aniPushUpDown = 79;
170 int aniBug[] = { 74, 75, 76, 77, 78, 77, 76, 77, 78, 77, 76, 75, 74, 25 };
171 int aniZonkRollRight[] = { 198, 197, 196, 195, 194, 193, 192, 1, -1 };
172 int aniZonkRollLeft[] = { 192, 193, 194, 195, 196, 197, 198, 1, -1 };
173 int aniInfotronRollRight[] = { 206, 205, 204, 203, 202, 201, 200, 4 };
174 int aniInfotronRollLeft[] = { 200, 201, 202, 203, 204, 205, 206, 4 };
175 int aniSnikSnak[] = { 121, 122, 123, 124, 125, 126, 127, 120, 121 };
176 int aniElectron[] = { 144, 145, 146, 147, 148, 149, 150, 151, 144 };
177 int aniExplosion[] = { 3, 103, 104, 105, 106, 107, 108, 109, 0 };
178 int aniTouchBase[] = { 80, 81, 82, 83, 84, 85, 86, 0, -1 };
179 int aniTouchInfotron[] = { 87, 88, 89, 91, 92, 93, 0, -1 }; // Only seven frames!!!!
180 int aniTouchRedDisk[] = { 96, 97, 98, 99, 100, 101, 102, 0, -1 };
181 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 };
182 int aniMurphyEatLeft[] = { 176, 177, 178, 179, 180, 181, 182, 183, -1 };
183 int aniMurphyEatRight[] = { 184, 185, 186, 187, 188, 189, 190, 191, -1 };
184 int aniMurphyEatUpLeft[] = { 183, 182, 181, 180, 179, 178, 177, 176, -1 };
185 int aniMurphyEatUpRight[] = { 191, 190, 189, 188, 187, 186, 185, 184, -1 };
186 // aniMurphyEatRightRedDisk = { 184, 184, 185, 186, 187, 188, 189, 190, 191, -1) '9 frames!
187 int aniEatInfotronLeft[] = { 209, 211, 213, 215, 217, 219, 221, 223, -1 };
188 int aniEatInfotronRight[] = { 224, 226, 228, 230, 232, 234, 236, 238, -1 };
189 int aniSplitUpDown[] = { 3, 3, 3, 3, 3, 3, 3, 3, -1 };
190 int aniYellowDisk[] = { 18, 18, 18, 18, 18, 18, 18, 18, -1 };
191 int aniOrangeDisk[] = { 8, 8, 8, 8, 8, 8, 8, 8, -1 };
192 int aniRedDisk[] = { 20, -1 };
198 aniBug = Array(74, 75, 76, 77, 78, 77, 76, 77, 78, 77, 76, 75, 74, 25);
199 aniZonkRollRight = Array(198, 197, 196, 195, 194, 193, 192, 1, -1);
200 aniZonkRollLeft = Array(192, 193, 194, 195, 196, 197, 198, 1, -1);
201 aniInfotronRollRight = Array(206, 205, 204, 203, 202, 201, 200, 4);
202 aniInfotronRollLeft = Array(200, 201, 202, 203, 204, 205, 206, 4);
203 aniSnikSnak = Array(121, 122, 123, 124, 125, 126, 127, 120, 121);
204 aniElectron = Array(144, 145, 146, 147, 148, 149, 150, 151, 144);
205 aniExplosion = Array(3, 103, 104, 105, 106, 107, 108, 109, 0);
206 aniTouchBase = Array(80, 81, 82, 83, 84, 85, 86, 0, -1);
207 aniTouchInfotron = Array(87, 88, 89, 91, 92, 93, 0, -1); // Only seven frames!!!!
208 aniTouchRedDisk = Array(96, 97, 98, 99, 100, 101, 102, 0, -1);
209 aniMurphyExit = Array(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);
210 aniMurphyEatLeft = Array(176, 177, 178, 179, 180, 181, 182, 183, -1);
211 aniMurphyEatRight = Array(184, 185, 186, 187, 188, 189, 190, 191, -1);
212 aniMurphyEatUpLeft = Array(183, 182, 181, 180, 179, 178, 177, 176, -1);
213 aniMurphyEatUpRight = Array(191, 190, 189, 188, 187, 186, 185, 184, -1);
214 // aniMurphyEatRightRedDisk = Array(184, 184, 185, 186, 187, 188, 189, 190, 191, -1) '9 frames!
215 aniEatInfotronLeft = Array(209, 211, 213, 215, 217, 219, 221, 223, -1);
216 aniEatInfotronRight = Array(224, 226, 228, 230, 232, 234, 236, 238, -1);
217 aniSplitUpDown = Array(3, 3, 3, 3, 3, 3, 3, 3, -1);
218 aniYellowDisk = Array(18, 18, 18, 18, 18, 18, 18, 18, -1);
219 aniOrangeDisk = Array(8, 8, 8, 8, 8, 8, 8, 8, -1);
220 aniRedDisk = Array(20, -1);
223 InitPseudoCompileFlags();
224 UserDragFlag = False;
225 AutoScrollFlag = True;
227 BlockingSpeed = False;
232 FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1;
233 LevelMax = (FieldWidth * FieldHeight) - 1;
234 Let_ModifiedFlag(False);
237 bSignatureAvailable = False;
238 FirstDemoByte = 0x81;
240 InitErrorReporting();
243 void InitPseudoCompileFlags()
245 Cracked = 1; // If protection Then crack it
246 Level_Arg = 1; // :number is cmd line option
247 // Level_Arg = 0 ' Remove Level cmd line option
248 EGA_Arg = 1; // EGA is command line option
249 Record_Fix = 1; // Assemble with fixed Demo rec
250 SpeedKeys = 0; // Remove Speed Keys fix
251 Level_Fix = 1; // Assemble with Level Fix
252 Dead_Code = 0; // Remove dead code
253 Redundant = 0; // Remove redundant code
254 Alignments = 1; // Assemble with alignments
255 Ctrl_Alt_Fix = 1; // Assemble with Ctrl/Alt fix
256 Protection = 0; // Remove protection code,do HP
257 // EP added by EP for version 5.
258 EP_ENHANCE = 1; // Some more nice things (EP)
259 EP_DEMO = 1; // Use .SP files for demos (EP)
260 // Including record demo!
261 EP_DEBUG = 0; // little cmdline debugging
262 EXTRASPEED = 1; // '@' option, superfast!
263 TIMINGFIX = 1; // "Fixed" the timing problem..
264 // Inactive If DemoRecordFix Then1
265 SafeRecord = 1; // skip debug keys in recording
266 Norm_Time = 1; // force automatic speed test,
267 // save result and then do as
268 // requested from cmd line.
269 EP_OLD8 = 1; // call old int8 from current.
270 SAVEGAME = 1; // Allow saving to SUPAPLEX.SAV
271 HP_DEMO = 1; // Use fixed demo routines 5.5
272 ScreenFix = 1; // No menu-write to gamy field
273 DemoRecordFix = 1; // Demo record timing fix on
274 DebugSwitch = 1; // Allow Ctrl/Alt-ScrollLock
275 Ver62 = 1; // Version 6.2 stuff
276 Ver62test = 0; // Version 6.2 test stuff
277 Ver63 = 1; // Version 6.3 stuff
278 Ver64 = 1; // Version 6.4 stuff
282 int GetSI(int X, int Y)
286 GetSI = Y * FieldWidth + X;
295 GetX = si % FieldWidth;
304 GetY = si / FieldWidth;
309 int GetStretchX(int si)
313 GetStretchX = StretchWidth * (si % FieldWidth);
318 int GetStretchY(int si)
322 GetStretchY = StretchWidth * (si / FieldWidth);
334 DemoAvailable = False;
336 if (STRING_IS_LIKE(CurPath, "*.mpx"))
342 if (STRING_IS_LIKE(CurPath, "*.sp"))
359 FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1;
360 LevelMax = (FieldWidth * FieldHeight) - 1;
362 PlayField8 = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
363 DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
365 // FNum = FreeFile();
367 // --- On Error GoTo ReadLevelEH
370 CurPath = "/home/aeglos/projects/rocksndiamonds/levels/TEST_supaplex/supaplex/levels.dat";
374 printf("::: '%s', %d\n", CurPath, LevelNumber);
376 FNum = fopen(CurPath, "rb");
378 i = (LevelNumber - 1) * ((long)(FieldMax) + 1) + 1;
380 FILE_GET(FNum, i, PlayField8, FieldMax + 1);
382 FILE_GET(FNum, i, &PlayField8, sizeof(PlayField8));
384 i = (LevelNumber) * ((long)(FieldMax) + 1) + 1 - HeaderSize;
385 FILE_GET(FNum, i, &LInfo, sizeof(LInfo)); // store level info in an extra structure
389 // --- On Error GoTo 0
391 if (FieldMax < FileMax)
392 DemoAvailable = True;
396 PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax);
398 for (i = 0; i <= FieldMax; i++)
401 printf("::: %d: %d\n", i, PlayField8[i]);
404 PlayField16[i] = PlayField8[i];
405 DisPlayField[i] = PlayField8[i];
409 AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 *FieldWidth);
410 AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 *FieldWidth);
411 TerminalState = REDIM_1D(sizeof(byte), FieldWidth, LevelMax - FieldWidth);
413 GravityFlag = LInfo.InitialGravity;
414 FreezeZonks = LInfo.InitialFreezeZonks;
428 static void ReadDemo()
438 FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1;
439 LevelMax = (FieldWidth * FieldHeight) - 1;
441 // --- On Error GoTo ReadDemoEH
442 FileMax = FileLen(CurPath) - 1;
443 PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax + 1 - 1);
444 DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
445 // FNum = FreeFile();
446 FNum = fopen(CurPath, "rb");
447 i = (LevelNumber - 1) * ((long)(FieldMax) + 1) + 1;
449 FILE_GET(FNum, i, PlayField8, FileMax + 1);
451 FILE_GET(FNum, i, &PlayField8, sizeof(PlayField8));
453 i = (LevelNumber) * ((long)(FieldMax) + 1) + 1 - HeaderSize;
454 FILE_GET(FNum, i, &LInfo, sizeof(LInfo)); // store level info in an extra structure
456 // --- On Error GoTo 0
458 if (FieldMax < FileMax)
459 DemoAvailable = True;
462 PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax);
463 for (i = 0; i <= FieldMax; i++)
465 PlayField16[i] = PlayField8[i];
466 DisPlayField[i] = PlayField8[i];
470 AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 *FieldWidth);
471 AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 *FieldWidth);
472 TerminalState = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
473 DemoPointer = FieldMax + 1;
474 DemoOffset = DemoPointer;
475 DemoKeyRepeatCounter = 0;
477 // DemoAvailable = True
478 GravityFlag = LInfo.InitialGravity;
479 FreezeZonks = LInfo.InitialFreezeZonks;
480 RandomSeed = LInfo.DemoRandomSeed;