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;
142 int *aniBug, *aniZonkRollRight, *aniZonkRollLeft;
143 int *aniInfotronRollRight, *aniInfotronRollLeft;
144 int *aniSnikSnak, *aniElectron, *aniExplosion;
145 int *aniTouchBase, *aniTouchInfotron, *aniTouchRedDisk;
146 // --- const int aniExplosionInfo = 111;
147 // --- const int aniSnikSnakUp = 159;
148 // --- const int aniSnikSnakDown = 167;
149 // --- const int aniSnikSnakLeft = 239;
150 // --- const int aniSnikSnakRight = 247;
151 // --- const int aniMurphyYawn = 56;
152 // --- const int aniMurphySleepLeft = 71;
153 // --- const int aniMurphySleepRight = 68;
154 int *aniMurphyExit; // , aniMurphyFaceLeft%, aniMurphyFaceRight%
155 int *aniMurphyEatLeft, *aniMurphyEatRight; // , aniMurphyEatRightRedDisk
156 int *aniMurphyEatUpLeft, *aniMurphyEatUpRight, *aniSplitUpDown;
157 int *aniYellowDisk, *aniOrangeDisk, *aniRedDisk;
158 // --- const int aniMurphyTouchUp = 46;
159 // --- const int aniMurphyTouchLeft = 95;
160 // --- const int aniMurphyTouchDown = 47;
161 // --- const int aniMurphyTouchRight = 94;
162 int *aniEatInfotronLeft, *aniEatInfotronRight;
163 // --- const int aniPushLeft = 45;
164 // --- const int aniPushRight = 44;
165 // --- const int aniPushUpDown = 79;
169 aniBug = Array(74, 75, 76, 77, 78, 77, 76, 77, 78, 77, 76, 75, 74, 25);
170 aniZonkRollRight = Array(198, 197, 196, 195, 194, 193, 192, 1, -1);
171 aniZonkRollLeft = Array(192, 193, 194, 195, 196, 197, 198, 1, -1);
172 aniInfotronRollRight = Array(206, 205, 204, 203, 202, 201, 200, 4);
173 aniInfotronRollLeft = Array(200, 201, 202, 203, 204, 205, 206, 4);
174 aniSnikSnak = Array(121, 122, 123, 124, 125, 126, 127, 120, 121);
175 aniElectron = Array(144, 145, 146, 147, 148, 149, 150, 151, 144);
176 aniExplosion = Array(3, 103, 104, 105, 106, 107, 108, 109, 0);
177 aniTouchBase = Array(80, 81, 82, 83, 84, 85, 86, 0, -1);
178 aniTouchInfotron = Array(87, 88, 89, 91, 92, 93, 0, -1); // Only seven frames!!!!
179 aniTouchRedDisk = Array(96, 97, 98, 99, 100, 101, 102, 0, -1);
180 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);
181 aniMurphyEatLeft = Array(176, 177, 178, 179, 180, 181, 182, 183, -1);
182 aniMurphyEatRight = Array(184, 185, 186, 187, 188, 189, 190, 191, -1);
183 aniMurphyEatUpLeft = Array(183, 182, 181, 180, 179, 178, 177, 176, -1);
184 aniMurphyEatUpRight = Array(191, 190, 189, 188, 187, 186, 185, 184, -1);
185 // aniMurphyEatRightRedDisk = Array(184, 184, 185, 186, 187, 188, 189, 190, 191, -1) '9 frames!
186 aniEatInfotronLeft = Array(209, 211, 213, 215, 217, 219, 221, 223, -1);
187 aniEatInfotronRight = Array(224, 226, 228, 230, 232, 234, 236, 238, -1);
188 aniSplitUpDown = Array(3, 3, 3, 3, 3, 3, 3, 3, -1);
189 aniYellowDisk = Array(18, 18, 18, 18, 18, 18, 18, 18, -1);
190 aniOrangeDisk = Array(8, 8, 8, 8, 8, 8, 8, 8, -1);
191 aniRedDisk = Array(20, -1);
192 InitPseudoCompileFlags();
193 UserDragFlag = False;
194 AutoScrollFlag = True;
196 BlockingSpeed = False;
201 FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1;
202 LevelMax = (FieldWidth * FieldHeight) - 1;
203 Let_ModifiedFlag(False);
206 bSignatureAvailable = False;
207 FirstDemoByte = 0x81;
209 InitErrorReporting();
212 void InitPseudoCompileFlags()
214 Cracked = 1; // If protection Then crack it
215 Level_Arg = 1; // :number is cmd line option
216 // Level_Arg = 0 ' Remove Level cmd line option
217 EGA_Arg = 1; // EGA is command line option
218 Record_Fix = 1; // Assemble with fixed Demo rec
219 SpeedKeys = 0; // Remove Speed Keys fix
220 Level_Fix = 1; // Assemble with Level Fix
221 Dead_Code = 0; // Remove dead code
222 Redundant = 0; // Remove redundant code
223 Alignments = 1; // Assemble with alignments
224 Ctrl_Alt_Fix = 1; // Assemble with Ctrl/Alt fix
225 Protection = 0; // Remove protection code,do HP
226 // EP added by EP for version 5.
227 EP_ENHANCE = 1; // Some more nice things (EP)
228 EP_DEMO = 1; // Use .SP files for demos (EP)
229 // Including record demo!
230 EP_DEBUG = 0; // little cmdline debugging
231 EXTRASPEED = 1; // '@' option, superfast!
232 TIMINGFIX = 1; // "Fixed" the timing problem..
233 // Inactive If DemoRecordFix Then1
234 SafeRecord = 1; // skip debug keys in recording
235 Norm_Time = 1; // force automatic speed test,
236 // save result and then do as
237 // requested from cmd line.
238 EP_OLD8 = 1; // call old int8 from current.
239 SAVEGAME = 1; // Allow saving to SUPAPLEX.SAV
240 HP_DEMO = 1; // Use fixed demo routines 5.5
241 ScreenFix = 1; // No menu-write to gamy field
242 DemoRecordFix = 1; // Demo record timing fix on
243 DebugSwitch = 1; // Allow Ctrl/Alt-ScrollLock
244 Ver62 = 1; // Version 6.2 stuff
245 Ver62test = 0; // Version 6.2 test stuff
246 Ver63 = 1; // Version 6.3 stuff
247 Ver64 = 1; // Version 6.4 stuff
251 int GetSI(int X, int Y)
255 GetSI = Y * FieldWidth + X;
264 GetX = si % FieldWidth;
273 GetY = si / FieldWidth;
278 int GetStretchX(int si)
282 GetStretchX = StretchWidth * (si % FieldWidth);
287 int GetStretchY(int si)
291 GetStretchY = StretchWidth * (si / FieldWidth);
303 DemoAvailable = False;
305 if (STRING_IS_LIKE(CurPath, "*.mpx"))
311 if (STRING_IS_LIKE(CurPath, "*.sp"))
328 FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1;
329 LevelMax = (FieldWidth * FieldHeight) - 1;
331 PlayField8 = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
332 DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
334 // FNum = FreeFile();
336 // --- On Error GoTo ReadLevelEH
339 CurPath = "/home/aeglos/projects/rocksndiamonds/levels/TEST_supaplex/supaplex/levels.dat";
343 printf("::: '%s', %d\n", CurPath, LevelNumber);
345 FNum = fopen(CurPath, "rb");
347 i = (LevelNumber - 1) * ((long)(FieldMax) + 1) + 1;
349 FILE_GET(FNum, i, PlayField8, FieldMax + 1);
351 FILE_GET(FNum, i, &PlayField8, sizeof(PlayField8));
353 i = (LevelNumber) * ((long)(FieldMax) + 1) + 1 - HeaderSize;
354 FILE_GET(FNum, i, &LInfo, sizeof(LInfo)); // store level info in an extra structure
358 // --- On Error GoTo 0
360 if (FieldMax < FileMax)
361 DemoAvailable = True;
365 PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax);
367 for (i = 0; i <= FieldMax; i++)
370 printf("::: %d: %d\n", i, PlayField8[i]);
373 PlayField16[i] = PlayField8[i];
374 DisPlayField[i] = PlayField8[i];
378 AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 *FieldWidth);
379 AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 *FieldWidth);
380 TerminalState = REDIM_1D(sizeof(byte), FieldWidth, LevelMax - FieldWidth);
382 GravityFlag = LInfo.InitialGravity;
383 FreezeZonks = LInfo.InitialFreezeZonks;
397 static void ReadDemo()
407 FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1;
408 LevelMax = (FieldWidth * FieldHeight) - 1;
410 // --- On Error GoTo ReadDemoEH
411 FileMax = FileLen(CurPath) - 1;
412 PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax + 1 - 1);
413 DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
414 // FNum = FreeFile();
415 FNum = fopen(CurPath, "rb");
416 i = (LevelNumber - 1) * ((long)(FieldMax) + 1) + 1;
418 FILE_GET(FNum, i, PlayField8, FileMax + 1);
420 FILE_GET(FNum, i, &PlayField8, sizeof(PlayField8));
422 i = (LevelNumber) * ((long)(FieldMax) + 1) + 1 - HeaderSize;
423 FILE_GET(FNum, i, &LInfo, sizeof(LInfo)); // store level info in an extra structure
425 // --- On Error GoTo 0
427 if (FieldMax < FileMax)
428 DemoAvailable = True;
431 PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax);
432 for (i = 0; i <= FieldMax; i++)
434 PlayField16[i] = PlayField8[i];
435 DisPlayField[i] = PlayField8[i];
439 AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 *FieldWidth);
440 AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 *FieldWidth);
441 TerminalState = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1);
442 DemoPointer = FieldMax + 1;
443 DemoOffset = DemoPointer;
444 DemoKeyRepeatCounter = 0;
446 // DemoAvailable = True
447 GravityFlag = LInfo.InitialGravity;
448 FreezeZonks = LInfo.InitialFreezeZonks;
449 RandomSeed = LInfo.DemoRandomSeed;