1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
9 static void DrawFrame(int Delta);
13 static void CleanTempDir(char *TmpDir);
14 static void CountDown(long HalfSeconds, int bDisplayBar);
15 static void DrawFrame(int Delta);
16 static void DrawPauseLayer(long Layer);
17 static void FillFileList(char *Path);
18 static void FillLevelList(char *Path, int LevelIndex);
19 static void FocusTim_Timer();
20 static void Form_KeyDown(int KeyCode, int Shift);
21 static void Form_KeyUp(int KeyCode, int Shift);
22 static void Form_Paint();
23 static int GetFileNameToSave();
24 static long GetHwndFromTempFileName(char *TmpFile);
25 static char * GetMyTempFileName();
26 static void GetSettings();
27 static char * GetSpeedDescriptionFPS(currency FrameDelayUS);
28 static int GetSpeedIndex(long DelayUS);
29 static char * GetValidTempPath();
30 static long Get_LastOpenFilter();
31 static long Get_LastSaveFilter();
32 static int InitSpeeds();
33 static boolean InstanceStillRunning(char *TmpFile);
34 static void Let_LastOpenFilter(long NewVal);
35 static void Let_LastSaveFilter(long NewVal);
36 static void LoadKeyIndicators();
37 static void LoadMenus();
38 static void PanelTim_Timer();
39 static void ReStretch(float NewStretch);
40 static void RestoreFrame();
41 static boolean SaveAs();
42 static void SaveSettings();
43 static void SetScrollEdges();
44 static void UpdateDeltaT();
45 static void cmbFile_Click();
46 static void cmbFile_KeyDown(int KeyCode, int Shift);
47 static void cmbFile_KeyUp(int KeyCode, int Shift);
48 static void cmbLevel_Click();
49 static void cmbLevel_KeyUp(int KeyCode, int Shift);
50 static void cmblevel_KeyDown(int KeyCode, int Shift);
51 static void cmdPause_Click();
52 static void cmdPause_MouseUp(int Button, int Shift, float X, float Y);
53 static void cmdPlayAll_Click();
54 static void cmdPlayAll_MouseUp(int Button, int Shift, float X, float Y);
55 static void cmdPlayDemo_Click();
56 static void cmdPlayDemo_MouseUp(int Button, int Shift, float X, float Y);
57 static void cmdPlay_Click();
58 static void cmdPlay_MouseUp(int Button, int Shift, float X, float Y);
59 static void cmdRecordDemo_Click();
60 static void cmdRecordDemo_MouseUp(int Button, int Shift, float X, float Y);
61 static void cmdStop_Click();
62 static void cmdStop_MouseUp(int Button, int Shift, float X, float Y);
63 static void fpsTim_Timer();
64 static void menAbout_Click();
65 static void menAutoScroll_Click();
66 static void menBorder_Click();
67 static void menCopy_Click();
68 static void menEnOff_Click();
69 static void menEnOn_Click();
70 static void menExit_Click();
71 static void menFaster_Click();
72 static void menGravOff_Click();
73 static void menGravOn_Click();
74 static void menNewStd_Click();
75 static void menNew_Click();
76 static void menOpen_Click();
77 static void menOptions_Click();
78 static void menPanel_Click();
79 static void menPaste_Click();
80 static void menPause_Click();
81 static void menPlayAll_Click();
82 static void menPlayDemo_Click();
83 static void menPlay_Click();
84 static void menReRecordDemo_Click();
85 static void menRec_Click();
86 static void menRemSP_Click();
87 static void menRestoreBorder_Click();
88 static void menSaveAs_Click();
89 static void menSave_Click();
90 static void menSelectAll_Click();
91 static void menShowLInfo_Click();
92 static void menSlower_Click();
93 static void menSoundFX_Click();
94 static void menStretch_Click(int Index);
95 static void menToolTips_Click();
96 static void menTrim_Click();
97 static void menZonkOff_Click();
98 static void menZonkOn_Click();
99 static void picKeys_MouseUp(int Button, int Shift, float X, float Y);
100 static void picMenu_Click();
101 static void picPane_KeyDown(int KeyCode, int Shift);
102 static void picPane_KeyUp(int KeyCode, int Shift);
103 static void picPane_MouseDown(int Button, int Shift, float X, float Y);
104 static void picPane_MouseMove(int Button, int Shift, float X, float Y);
105 static void picPane_MouseUp(int Button, int Shift, float X, float Y);
106 static void picPane_Paint();
107 static void picViewPort_MouseUp(int Button, int Shift, float X, float Y);
108 static void picViewPort_Paint();
109 static void picViewPort_Resize();
113 void DrawField(int X, int Y);
114 void DrawFieldAnimated(int X, int Y);
115 void DrawFieldNoAnimated(int X, int Y);
118 // --- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
119 // --- Begin VB.Form MainForm
120 // --- AutoRedraw = -1 'True // True
121 // --- Caption = "MegaPlex"
122 // --- ClientHeight = 5850
123 // --- ClientLeft = 2580
124 // --- ClientTop = 2205
125 // --- ClientWidth = 9285
126 // --- Icon = "MainForm.frx":0000
127 // --- LinkTopic = "Form1"
128 // --- ScaleHeight = 390
129 // --- ScaleMode = 3 'Pixel // Pixel
130 // --- ScaleWidth = 619
131 // --- Begin VB.Timer fpsTim
132 // --- Enabled = 0 'False // False
133 // --- Interval = 200
137 // --- Begin VB.Timer FocusTim
142 // --- Begin MSComDlg.CommonDialog cmDlg
145 // --- _ExtentX = 847
146 // --- _ExtentY = 847
147 // --- _Version = 393216
148 // --- CancelError = -1 'True // True
150 // --- Begin VB.Timer PanelTim
151 // --- Enabled = 0 'False // False
156 // --- Begin VB.Frame Panel
162 // --- Begin VB.CommandButton cmdPlay
163 // --- DisabledPicture = "MainForm.frx":0442
164 // --- DownPicture = "MainForm.frx":058C
167 // --- Picture = "MainForm.frx":06D6
168 // --- Style = 1 'Graphical // Graphical
170 // --- TabStop = 0 'False // False
174 // --- Begin VB.CommandButton cmdStop
175 // --- DisabledPicture = "MainForm.frx":0820
176 // --- DownPicture = "MainForm.frx":096A
177 // --- Enabled = 0 'False // False
180 // --- Picture = "MainForm.frx":0AB4
181 // --- Style = 1 'Graphical // Graphical
183 // --- TabStop = 0 'False // False
187 // --- Begin VB.CommandButton cmdPlayDemo
188 // --- DisabledPicture = "MainForm.frx":0BFE
189 // --- DownPicture = "MainForm.frx":0D48
190 // --- Enabled = 0 'False // False
193 // --- Picture = "MainForm.frx":0E92
194 // --- Style = 1 'Graphical // Graphical
196 // --- TabStop = 0 'False // False
200 // --- Begin VB.CommandButton cmdPause
201 // --- DisabledPicture = "MainForm.frx":0FDC
202 // --- DownPicture = "MainForm.frx":1126
203 // --- Enabled = 0 'False // False
206 // --- Picture = "MainForm.frx":1270
207 // --- Style = 1 'Graphical // Graphical
209 // --- TabStop = 0 'False // False
213 // --- Begin VB.CommandButton cmdRecordDemo
214 // --- DisabledPicture = "MainForm.frx":13BA
215 // --- DownPicture = "MainForm.frx":1504
218 // --- Picture = "MainForm.frx":164E
219 // --- Style = 1 'Graphical // Graphical
221 // --- TabStop = 0 'False // False
225 // --- Begin VB.ComboBox cmbFile
226 // --- BackColor = &H00000000&
227 // --- BeginProperty Font
228 // --- Name = "Fixedsys"
232 // --- Underline = 0 'False // False
233 // --- Italic = 0 'False // False
234 // --- Strikethrough = 0 'False // False
236 // --- ForeColor = &H00FF8080&
239 // --- Sorted = -1 'True // True
240 // --- Style = 2 'Dropdown List // Dropdown List
245 // --- Begin VB.ComboBox cmbLevel
246 // --- BackColor = &H00000000&
247 // --- BeginProperty Font
248 // --- Name = "Fixedsys"
252 // --- Underline = 0 'False // False
253 // --- Italic = 0 'False // False
254 // --- Strikethrough = 0 'False // False
256 // --- ForeColor = &H00FF8080&
259 // --- Sorted = -1 'True // True
260 // --- Style = 2 'Dropdown List // Dropdown List
265 // --- Begin VB.PictureBox picKeys
266 // --- BackColor = &H00008080&
267 // --- BorderStyle = 0 'None // None
270 // --- ScaleHeight = 22
271 // --- ScaleMode = 3 'Pixel // Pixel
272 // --- ScaleWidth = 22
274 // --- TabStop = 0 'False // False
277 // --- Begin VB.Shape shpKey
278 // --- FillColor = &H00008000&
279 // --- FillStyle = 0 'Solid // Solid
283 // --- Shape = 5 'Rounded Square // Rounded Square
288 // --- Begin VB.CommandButton cmdPlayAll
289 // --- Caption = "Play All Demos"
290 // --- Enabled = 0 'False // False
294 // --- TabStop = 0 'False // False
296 // --- Visible = 0 'False // False
299 // --- Begin VB.Shape shpProgress
300 // --- BackColor = &H00800000&
301 // --- BackStyle = 1 'Opaque // Opaque
305 // --- Visible = 0 'False // False
308 // --- Begin VB.Label lblStatus
309 // --- Alignment = 2 'Center // Center
310 // --- BorderStyle = 1 'Fixed Single // Fixed Single
311 // --- Caption = "MegaPlex"
312 // --- BeginProperty Font
313 // --- Name = "Fixedsys"
317 // --- Underline = 0 'False // False
318 // --- Italic = 0 'False // False
319 // --- Strikethrough = 0 'False // False
327 // --- Begin VB.Image Image2
330 // --- Picture = "MainForm.frx":1BD8
334 // --- Begin VB.Image Image1
337 // --- Picture = "MainForm.frx":1D22
341 // --- Begin VB.Label lblFps
342 // --- Alignment = 2 'Center // Center
343 // --- BackColor = &H00000000&
344 // --- BorderStyle = 1 'Fixed Single // Fixed Single
345 // --- BeginProperty Font
346 // --- Name = "Fixedsys"
350 // --- Underline = 0 'False // False
351 // --- Italic = 0 'False // False
352 // --- Strikethrough = 0 'False // False
354 // --- ForeColor = &H0000C0C0&
361 // --- Begin VB.Label lblInfoCount
362 // --- Alignment = 2 'Center // Center
363 // --- BackColor = &H00000000&
364 // --- BorderStyle = 1 'Fixed Single // Fixed Single
365 // --- BeginProperty Font
366 // --- Name = "Fixedsys"
370 // --- Underline = 0 'False // False
371 // --- Italic = 0 'False // False
372 // --- Strikethrough = 0 'False // False
374 // --- ForeColor = &H00FF8080&
381 // --- Begin VB.Label lblRedDiskCount
382 // --- Alignment = 2 'Center // Center
383 // --- BackColor = &H00000000&
384 // --- BorderStyle = 1 'Fixed Single // Fixed Single
385 // --- BeginProperty Font
386 // --- Name = "Fixedsys"
390 // --- Underline = 0 'False // False
391 // --- Italic = 0 'False // False
392 // --- Strikethrough = 0 'False // False
394 // --- ForeColor = &H000000FF&
401 // --- Begin VB.Label lblFrameCount
402 // --- Alignment = 2 'Center // Center
403 // --- BorderStyle = 1 'Fixed Single // Fixed Single
405 // --- BeginProperty Font
406 // --- Name = "Fixedsys"
410 // --- Underline = 0 'False // False
411 // --- Italic = 0 'False // False
412 // --- Strikethrough = 0 'False // False
421 // --- Begin VB.PictureBox picViewPort
422 // --- BorderStyle = 0 'None // None
425 // --- ScaleHeight = 169
426 // --- ScaleMode = 3 'Pixel // Pixel
427 // --- ScaleWidth = 265
429 // --- TabStop = 0 'False // False
432 // --- Begin VB.PictureBox picPane
433 // --- AutoSize = -1 'True // True
434 // --- BackColor = &H00000000&
435 // --- BorderStyle = 0 'None // None
439 // --- ScaleHeight = 109
440 // --- ScaleMode = 3 'Pixel // Pixel
441 // --- ScaleWidth = 129
446 // --- Begin VB.PictureBox picFrame
449 // --- ScaleHeight = 57
450 // --- ScaleMode = 3 'Pixel // Pixel
451 // --- ScaleWidth = 81
453 // --- TabStop = 0 'False // False
458 // --- Begin VB.Menu menFile
459 // --- Caption = "&File"
460 // --- Begin VB.Menu menNewStd
461 // --- Caption = "New S&tandard Level"
463 // --- Begin VB.Menu menNew
464 // --- Caption = "&New Level"
466 // --- Begin VB.Menu menDash5
469 // --- Begin VB.Menu menOpen
470 // --- Caption = "&Open"
472 // --- Begin VB.Menu menSave
473 // --- Caption = "&Save"
476 // --- Begin VB.Menu menSaveAs
477 // --- Caption = "Save &As ..."
479 // --- Begin VB.Menu menDash4
482 // --- Begin VB.Menu menExit
483 // --- Caption = "E&xit"
487 // --- Begin VB.Menu menEditMain
488 // --- Caption = "&Edit"
489 // --- Begin VB.Menu menEdit
490 // --- Caption = "&Edit Level"
492 // --- Begin VB.Menu menDash3
495 // --- Begin VB.Menu menCopy
496 // --- Caption = "&Copy"
499 // --- Begin VB.Menu menPaste
500 // --- Caption = "&Paste"
503 // --- Begin VB.Menu menTrim
504 // --- Caption = "&Trim"
507 // --- Begin VB.Menu menDash8
511 // --- Begin VB.Menu menSelectAll
512 // --- Caption = "Select &All"
515 // --- Begin VB.Menu menDash6
518 // --- Begin VB.Menu menRestoreBorder
519 // --- Caption = "Restore &border"
522 // --- Begin VB.Menu menSp
523 // --- Caption = "Special Port"
524 // --- Begin VB.Menu menGravOn
525 // --- Caption = "&Gravity On"
527 // --- Begin VB.Menu menZonkOn
528 // --- Caption = "Freeze &Zonks On"
530 // --- Begin VB.Menu menEnOn
531 // --- Caption = "Freeze &Enemies On"
533 // --- Begin VB.Menu menDash7
536 // --- Begin VB.Menu menGravOff
537 // --- Caption = "Gravity &Off"
539 // --- Begin VB.Menu menZonkOff
540 // --- Caption = "Freeze Zon&ks Off"
542 // --- Begin VB.Menu menEnOff
543 // --- Caption = "Freeze E&nemies Off"
545 // --- Begin VB.Menu menDash10
548 // --- Begin VB.Menu menRemSP
549 // --- Caption = "&Remove (Make Normal Port)"
553 // --- Begin VB.Menu menView
554 // --- Caption = "&View"
555 // --- Begin VB.Menu menZoom
556 // --- Caption = "&Zoom"
557 // --- Begin VB.Menu menStretch
558 // --- Caption = "0.25 : 1"
562 // --- Begin VB.Menu menBorder
563 // --- Caption = "Show &Border"
564 // --- Checked = -1 'True // True
566 // --- Begin VB.Menu menPanel
567 // --- Caption = "Show &Panel"
568 // --- Checked = -1 'True // True
570 // --- Begin VB.Menu menAutoScroll
571 // --- Caption = "&Autoscroll"
572 // --- Checked = -1 'True // True
574 // --- Begin VB.Menu menDash9
577 // --- Begin VB.Menu menShowLInfo
578 // --- Caption = "Show Level &Info"
581 // --- Begin VB.Menu menSound
582 // --- Caption = "&Sound"
583 // --- Begin VB.Menu menSoundFX
584 // --- Caption = "&FX"
586 // --- Begin VB.Menu menMusic
587 // --- Caption = "&Music"
588 // --- Enabled = 0 'False // False
591 // --- Begin VB.Menu menSpeed
592 // --- Caption = "Speed"
593 // --- Begin VB.Menu menSpeedPlay
594 // --- Caption = "Game play"
596 // --- Begin VB.Menu menPlaySpeed
601 // --- Begin VB.Menu menSpeedDemo
602 // --- Caption = "Demo playback"
603 // --- Begin VB.Menu menDemoSpeed
608 // --- Begin VB.Menu menSpeedDash
611 // --- Begin VB.Menu menFaster
612 // --- Caption = "Faster (Pg Up)"
614 // --- Begin VB.Menu menSlower
615 // --- Caption = "Slower (Pg Down)"
618 // --- Begin VB.Menu menRun
619 // --- Caption = "&Play"
620 // --- Begin VB.Menu menPlay
621 // --- Caption = "P&lay Game (Space)"
623 // --- Begin VB.Menu menPause
624 // --- Caption = "&Pause (P)"
625 // --- Enabled = 0 'False // False
627 // --- Begin VB.Menu menStop
628 // --- Caption = "&Stop (Q)"
629 // --- Enabled = 0 'False // False
631 // --- Begin VB.Menu menDash0
634 // --- Begin VB.Menu menRec
635 // --- Caption = "&Record Demo (Ctrl+R)"
637 // --- Begin VB.Menu menPlayDemo
638 // --- Caption = "Play &Demo (Ctrl+Space)"
640 // --- Begin VB.Menu menPlayAll
641 // --- Caption = "Play &All Demos"
644 // --- Begin VB.Menu menOptionsMain
645 // --- Caption = "&Options"
646 // --- Begin VB.Menu menOptions
647 // --- Caption = "&Options ..."
650 // --- Begin VB.Menu menHelp
651 // --- Caption = "Help"
652 // --- Begin VB.Menu menToolTips
653 // --- Caption = "Show &ToolTips"
655 // --- Begin VB.Menu menDash1
658 // --- Begin VB.Menu menAbout
659 // --- Caption = "&About MegaPlex"
664 // static char *VB_Name = "MainForm";
665 // static boolean VB_GlobalNameSpace = False;
666 // static boolean VB_Creatable = False;
667 // static boolean VB_PredeclaredId = True;
668 // static boolean VB_Exposed = False;
670 // --- Option Explicit
671 // --- Option Compare Text
673 long SetParent(long hWndChild, long hWndNewParent);
674 long SetWindowLong(long hWnd, long nIndex, long dwNewLong);
675 long GetWindowLong(long hWnd, long nIndex);
676 long GetTempPath(long nBufferLength, char *lpBuffer);
677 long GetWindowText(long hWnd, char *lpString, long cch);
679 #define GWL_STYLE ((-16))
680 #define WS_CHILD (0x40000000)
681 #define WS_POPUP (0x80000000)
683 // [UNCOMMENTED] Dim StretchWidth2&
687 long OSX, OSY, MDX, MDY;
692 boolean Loaded, DemosAvailable;
694 #define nSpeedCount (17)
695 int SpeedsByDelayUS[nSpeedCount + 1];
696 #define DefaultSpeedIndex (12)
698 currency LastTick, LastFrame;
701 const char *AppTitle = "MegaPlex";
705 static char *GetSpeedDescriptionFPS(currency FrameDelayUS)
707 static char *GetSpeedDescriptionFPS;
711 if (FrameDelayUS == 0)
713 GetSpeedDescriptionFPS = "Fastest possible";
714 return GetSpeedDescriptionFPS;
717 if (FrameDelayUS < 0)
719 GetSpeedDescriptionFPS = "! display (even faster)";
720 return GetSpeedDescriptionFPS;
723 FPS = 1000000 / FrameDelayUS;
724 GetSpeedDescriptionFPS = CAT(INT_TO_STR(FPS), " fps");
726 GetSpeedDescriptionFPS = CAT(GetSpeedDescriptionFPS, "(Default)");
728 return GetSpeedDescriptionFPS;
731 static int InitSpeeds()
733 static int InitSpeeds;
735 SpeedsByDelayUS[1] = -1; // no display
736 SpeedsByDelayUS[2] = 0; // fastest possible
737 SpeedsByDelayUS[3] = 1000000 / 700; // 700 fps
738 SpeedsByDelayUS[4] = 1000000 / 500; // 500 fps
739 SpeedsByDelayUS[5] = 1000000 / 350; // 350 fps
740 SpeedsByDelayUS[6] = 1000000 / 250; // 250 fps
741 SpeedsByDelayUS[7] = 1000000 / 200; // etc.
742 SpeedsByDelayUS[8] = 1000000 / 150;
743 SpeedsByDelayUS[9] = 1000000 / 100;
744 SpeedsByDelayUS[10] = 1000000 / 70;
745 SpeedsByDelayUS[11] = 1000000 / 50;
746 SpeedsByDelayUS[12] = 1000000 / 35; // default
747 SpeedsByDelayUS[13] = 1000000 / 25;
748 SpeedsByDelayUS[14] = 1000000 / 20;
749 SpeedsByDelayUS[15] = 1000000 / 10;
750 SpeedsByDelayUS[16] = 1000000 / 5;
751 SpeedsByDelayUS[17] = 1000000 / 1;
756 static int GetSpeedIndex(long DelayUS)
758 static int GetSpeedIndex;
764 MinIdx = DefaultSpeedIndex;
766 for (i = 1; i <= nSpeedCount; i++)
768 Diff = Abs(DelayUS - SpeedsByDelayUS[i]);
776 GetSpeedIndex = MinIdx;
778 return GetSpeedIndex;
781 static long Get_LastOpenFilter()
783 static long LastOpenFilter;
787 LastOpenFilter = s.Read("LastOpenFilter", 1);
789 return LastOpenFilter;
792 static void Let_LastOpenFilter(long NewVal)
796 SettingsObject_Save("LastOpenFilter", NewVal);
799 static long Get_LastSaveFilter()
801 static long LastSaveFilter;
805 LastSaveFilter = s.Read("LastSaveFilter", 1);
807 return LastSaveFilter;
810 static void Let_LastSaveFilter(long NewVal)
814 SettingsObject_Save("LastSaveFilter", NewVal);
819 static void CountDown(long HalfSeconds, int bDisplayBar)
824 long LeftPos, TopPos, RightPos, MaxWidth; // , MaxHeight&
826 dT = HalfSeconds * 500;
828 LeftPos = cmbFile.left;
829 TopPos = cmbFile.top - shpProgress.Height - cmbFile.top / 8;
830 RightPos = lblFrameCount.left + lblFrameCount.Width;
831 MaxWidth = RightPos - LeftPos;
832 // MaxHeight = lblFrameCount.Top - TopPos + lblFrameCount.Height + 4
835 shpProgress.Move(LeftPos, TopPos, 0); // , MaxHeight
836 shpProgress.Visible = True;
839 for (i = 1; i <= 200; i++)
846 shpProgress.Width = MaxWidth * i / 100;
850 k = MaxWidth * (i - 100) / 100;
851 shpProgress.Move(k, TopPos, RightPos - k);
855 T.DelayMS(Delta, False);
858 shpProgress.Visible = False;
864 static char *GetValidTempPath()
866 static char *GetValidTempPath;
871 GetValidTempPath = "";
873 TP = String(nSize, Chr(32));
874 L = GetTempPath(nSize, TP);
877 // buffer was too small, retry with a properly sized buffer:
879 TP = String(nSize, Chr(32));
880 L = GetTempPath(nSize, TP);
883 TP = SlashLess(left(TP, L));
884 if ((0 == L) || (! IsDir(TP)))
886 // no valid temp path can be retrieved from the system --> create our own
887 TP = CAT(WithSlash(App.Path), "Temp");
891 // --- On Error Resume Next
893 if (! IS_NOTHING(&Err, sizeof(Err)))
895 MESSAGE_BOX("an error occured"); // MsgBox "cannot create directory for temporary files " & TP, vbCritical, "MegaPlex - Error";
896 return GetValidTempPath;
899 // --- On Error GoTo 0
905 GetValidTempPath = TP;
907 return GetValidTempPath;
910 static char *GetMyTempFileName()
912 static char *GetMyTempFileName;
916 (char *)T = Hex(hWnd);
922 GetMyTempFileName = CAT("tmp0x", CAT((char *)T, ".mpx"));
924 return GetMyTempFileName;
927 static long GetHwndFromTempFileName(char *TmpFile)
929 static long GetHwndFromTempFileName;
936 GetHwndFromTempFileName = 0;
937 FN = StripFileName(TmpFile);
941 return GetHwndFromTempFileName;
944 NumString = right(FN, L - LP);
946 NumString = left(NumString, 8);
948 NumString = CAT("&H", NumString);
949 GetHwndFromTempFileName = Val(NumString);
951 return GetHwndFromTempFileName;
954 static void CleanTempDir(char *TmpDir)
958 MFN = GetMyTempFileName();
959 MayKill(CAT(WithSlash(TmpDir), MFN));
960 FN = Dir(CAT(WithSlash(TmpDir), "tmp0x*.mpx"));
963 if (STRING_IS_LIKE(FN, "tmp0x*.mpx"))
965 if (! InstanceStillRunning(FN))
966 MayKill(CAT(WithSlash(TmpDir), FN));
969 FN = Dir_Without_Args();
973 static boolean InstanceStillRunning(char *TmpFile)
975 static boolean InstanceStillRunning;
977 long OtherHwnd, nSize, L;
980 InstanceStillRunning = False;
981 OtherHwnd = GetHwndFromTempFileName(TmpFile);
983 Cap = String(nSize, Chr(32));
984 L = GetWindowText(OtherHwnd, Cap, nSize);
985 if ((L == 0) || (nSize < L))
986 return InstanceStillRunning;
988 if (STRING_IS_LIKE(Cap, CAT(AppTitle, "*")))
989 InstanceStillRunning = True;
991 return InstanceStillRunning;
1013 if (! menBorder.Checked)
1019 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1021 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1023 DrawFieldNoAnimated(X, Y);
1027 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1029 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1031 DrawFieldAnimated(X, Y);
1038 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1040 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1050 static void cmbFile_Click()
1052 CurPath = CAT(StripDir(OrigPath), CAT("/", cmbFile.List(cmbFile.ListIndex)));
1054 FillLevelList(CurPath, LevelNumber);
1055 if (STRING_IS_LIKE(OrigPath, "*.mpx") || STRING_IS_LIKE(OrigPath, "*.sp"))
1057 menSave.Enabled = True;
1061 menSave.Enabled = False;
1065 static void cmbFile_KeyDown(int KeyCode, int Shift)
1067 picPane_KeyDown(KeyCode, Shift);
1070 static void cmbFile_KeyUp(int KeyCode, int Shift)
1072 picPane_KeyUp(KeyCode, Shift);
1075 static int GetFileNameToSave()
1077 static int GetFileNameToSave;
1081 (char *)T = StripFileName(OrigPath);
1082 if (STRING_IS_LIKE(T, "*.dat") || STRING_IS_LIKE(T, "*.d##"))
1084 T = "Level" & Format(LevelNumber, "#000");
1087 GetFileNameToSave = T;
1089 return GetFileNameToSave;
1092 static void cmbLevel_Click()
1103 // //////////////////////////////////////////////////////////////////
1108 Msg = "Save changes to " & GetFileNameToSave() & " ?";
1109 Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - close level");
1110 if (Res == vbCancel) // fallback
1114 // --- On Error Resume Next
1115 cmbLevel.ListIndex = LastIndex;
1116 // --- On Error GoTo 0
1119 Debug.Assert cmbLevel.ListIndex = LastIndex;
1126 // oldCurPath = CurPath
1127 if (FileExists(OrigPath) && menSave.Enabled)
1133 if (! SaveAs()) // fallback
1137 // --- On Error Resume Next
1138 cmbLevel.ListIndex = LastIndex;
1139 // --- On Error GoTo 0
1142 Debug.Assert cmbLevel.ListIndex = LastIndex;
1147 // CurPath = oldCurPath
1150 Let_ModifiedFlag(False);
1154 // //////////////////////////////////////////////////////////////////
1156 LevelNumber = cmbLevel.ListIndex + 1;
1160 Oldflag = NoDisplayFlag;
1161 NoDisplayFlag = False;
1162 subFetchAndInitLevel();
1163 if ((0 < SignatureDelay) && ! (WindowState == vbMinimized))
1165 Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")";
1166 if (DemoAvailable && bSignatureAvailable)
1167 Msg = Msg & vbNewLine & vbNewLine & gSignature;
1169 SignatureForm.Signature = Msg;
1170 SignatureForm.DelayMS = SignatureDelay;
1173 X = left + (Width - SignatureForm.Width) / 2;
1174 Y = top + (Height - SignatureForm.Height) / 2;
1175 SignatureForm.Move X, Y;
1176 SignatureForm.Show vbModeless, Me;
1180 lblStatus = "MegaPlex";
1181 lblFrameCount = GetTotalFramesOfDemo();
1188 NoDisplayFlag = Oldflag;
1189 LastIndex = cmbLevel.ListIndex;
1193 menPlayDemo.Enabled = DemoAvailable;
1194 cmdPlayDemo.Enabled = DemoAvailable;
1197 static void cmblevel_KeyDown(int KeyCode, int Shift)
1199 if (GameLoopRunning != 0)
1205 if (menPlay.Enabled == True)
1211 picPane_KeyDown(KeyCode, Shift);
1216 static void cmbLevel_KeyUp(int KeyCode, int Shift)
1218 picPane_KeyUp(KeyCode, Shift);
1221 static void cmdPause_Click()
1226 static void cmdPause_MouseUp(int Button, int Shift, float X, float Y)
1228 FocusTim.Enabled = True;
1231 static void cmdPlay_Click()
1233 if (menPlay.Enabled)
1237 static void cmdPlay_MouseUp(int Button, int Shift, float X, float Y)
1239 FocusTim.Enabled = True;
1242 static void cmdPlayAll_Click()
1247 static void cmdPlayAll_MouseUp(int Button, int Shift, float X, float Y)
1249 FocusTim.Enabled = True;
1252 static void cmdPlayDemo_Click()
1254 menPlayDemo_Click();
1257 static void cmdPlayDemo_MouseUp(int Button, int Shift, float X, float Y)
1259 FocusTim.Enabled = True;
1262 static void cmdRecordDemo_Click()
1268 static void cmdRecordDemo_MouseUp(int Button, int Shift, float X, float Y)
1270 FocusTim.Enabled = True;
1273 static void cmdStop_Click()
1275 if (menStop.Enabled)
1279 static void cmdStop_MouseUp(int Button, int Shift, float X, float Y)
1281 FocusTim.Enabled = True;
1284 static void FocusTim_Timer()
1286 FocusTim.Enabled = False;
1288 // --- On Error Resume Next
1292 static void Form_KeyDown(int KeyCode, int Shift)
1294 picPane_KeyDown(KeyCode, Shift);
1297 static void Form_KeyUp(int KeyCode, int Shift)
1299 picPane_KeyUp(KeyCode, Shift);
1302 static void Form_Load()
1316 // FMark = New MarkerObject; // (handle this later, if needed)
1323 TmpPath = GetValidTempPath();
1327 CleanTempDir(TmpPath);
1328 TmpPath = CAT(WithSlash(TmpPath), GetMyTempFileName());
1332 InitDirectX(hWnd, picPane.hWnd);
1334 // AllowRedDiskCheat = 1
1335 MpxBmp = CAT(App.Path, "/mpx.bmp");
1336 // // Set NormalSprites = New DDSpriteBuffer // (handle this later, if needed)
1337 // NormalSprites.CreateFromFile MPXBMP, 16, 16
1339 Field = REDIM_2D(sizeof(int), 0, 2 + 1 - 1, 0, 2 + 1 - 1);
1341 picViewPort.ScaleMode = vbPixels;
1348 LoadKeyIndicators();
1352 FillFileList(CurPath);
1353 if (s.Read("ShowSplash", True))
1355 // frmSplash.EnableTimer
1356 frmSplash.Show vbModal, Me;
1362 static void FillLevelList(char *Path, int LevelIndex)
1364 long FNum, LevLen, i, iMax;
1368 if (! FileExists(Path))
1371 if ((STRING_IS_LIKE(Path, "*.D??")) || (STRING_IS_LIKE(Path, "*.sp")))
1375 FNum = fopen(Path, "rb");
1378 FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo));
1379 cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i;
1380 if (STRING_IS_LIKE(Path, "*.D??"))
1382 while (!(EOF(FNum)))
1385 FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo));
1389 cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i;
1393 if (LevelIndex <= i && 0 < LevelIndex)
1398 cmbLevel.ListIndex = i;
1402 else if (STRING_IS_LIKE(Path, "*.mpx"))
1406 FNum = fopen(Path, "rb");
1411 for (i = 1; i <= LevelCount; i++)
1413 if (! MpxLoadLInfo(CInt(i)))
1416 cmbLevel.AddItem Format(i, "#000") & " " & LInfo.LevelTitle, i - 1;
1422 if (LevelIndex < i && 0 < LevelIndex)
1427 if (i < cmbLevel.ListCount)
1428 cmbLevel.ListIndex = i;
1435 static void FillFileList(char *Path)
1437 long FNum, LevLen, i;
1439 char *TFile, *TPath, *OFile;
1444 TPath = WithSlash(StripDir(Path));
1445 OFile = StripFileName(Path);
1446 TFile = Dir(TPath & "*.D??");
1449 if (FileLen(TPath & TFile) == 170496)
1451 cmbFile.AddItem TFile;
1457 TFile = Dir(TPath & "*.SP");
1460 nDemoCount = nDemoCount + 1;
1461 cmbFile.AddItem TFile;
1465 TFile = Dir(TPath & "*.mpx");
1468 nDemoCount = nDemoCount + 1;
1469 cmbFile.AddItem TFile;
1473 i = cmbFile.ListCount - 1;
1474 if (0 < cmbFile.ListCount)
1478 if ((cmbFile.List(i) Like OFile) || i == 0)
1485 cmbFile.ListIndex = i;
1488 DemosAvailable = (1 < nDemoCount);
1489 menPlayAll.Enabled = DemosAvailable;
1490 cmdPlayAll.Enabled = DemosAvailable;
1493 static void LoadMenus()
1498 menFaster.Enabled = False;
1499 menSlower.Enabled = False;
1501 for (i = 1; i <= nSpeedCount; i++)
1505 Load menPlaySpeed(i);
1506 Load menDemoSpeed(i);
1509 menPlaySpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]);
1510 menDemoSpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]);
1514 menStretch(1).Caption = Format(0.25, "#0.00") & ";
1516 if (Stretch == 0.25)
1517 menStretch(1).Checked = True;
1519 for (i = 2; i <= 20; i++)
1522 menStretch(i).Caption = Format(0.25 * i, "#0.00") & ";
1524 menStretch(i).Checked = ((i * 0.25) == Stretch);
1527 menSp.Enabled = False;
1531 // Function DisplayShift&()
1532 // Dim X&, Y&, A&, B&, iX&, iiX&, LD&
1535 // For A = 0 To picPane.ScaleWidth
1536 // For Y = DisplayMinY To DisplayMaxY
1537 // For X = DisplayMinX To DisplayMaxX
1538 // iX = StretchWidth * X + A
1539 // Sprite = Field(X, Y).SpritePos
1540 // If picPane.ScaleWidth < (iX + 1) Then
1541 // iX = iX - picPane.ScaleWidth
1543 // If picPane.ScaleWidth < (iX + 1 + BaseWidth) Then
1544 // iiX = iX - picPane.ScaleWidth
1545 // Sprites.BitBltSprite picPane.hdc, iiX, StretchWidth * Y, Sprite
1548 // Sprites.BitBltSprite picPane.hdc, iX, StretchWidth * Y, Sprite
1551 // DisplayShift = DisplayShift + 1
1556 static void Form_Paint()
1558 // Debug.Print "Form_Paint()"
1561 static void Form_Resize()
1566 if (WindowState == vbMinimized || ! Loaded)
1570 // NW = ScaleWidth - 2 * Space: If NW < 0 Then NW = 0
1571 // NH = ScaleHeight - 3 * Space - cmbLevel.Height: If NH < 0 Then NH = 0
1572 // picViewPort.Move Space, Space, NW, NH
1573 Tmp = (ShowPanel != 0 ? ScaleHeight - Panel.Height : ScaleHeight - Panel.Height);
1577 picViewPort.Move 0, 0, ScaleWidth, Tmp;
1578 // Tmp = 2 * Space + picViewPort.Height
1580 Panel.left = (ScaleWidth - Panel.Width) / 2;
1581 // 'cmdNormal.Top = 2 * Space + picViewPort.Height
1582 // cmbLevel.Top = Tmp
1583 // lblRedDiskCount.Top = Tmp
1584 // lblInfoCount.Top = Tmp
1585 // picKeys.Top = Tmp
1586 // lblFrameCount.Top = Tmp
1587 // cmdPlayAll.Top = Tmp
1592 static void DrawFrame(int Delta)
1594 int i, LX, tY, RX, BY;
1598 RX = FieldWidth - Delta;
1599 BY = FieldHeight - Delta;
1600 DrawSprite(LX, tY, posFrameCorner);
1601 DrawSprite(LX, BY, posFrameCorner);
1602 DrawSprite(RX, tY, posFrameCorner);
1603 DrawSprite(RX, BY, posFrameCorner);
1604 for (i = LX + 1; i <= RX - 1; i++)
1606 DrawSprite(i, tY, posFrameHorizontal);
1607 DrawSprite(i, BY, posFrameHorizontal);
1610 for (i = tY + 1; i <= BY - 1; i++)
1612 DrawSprite(LX, i, posFrameVertical);
1613 DrawSprite(RX, i, posFrameVertical);
1619 static void RestoreFrame()
1621 int i, LX, tY, RX, BY;
1625 RX = FieldWidth - 1;
1626 BY = FieldHeight - 1;
1627 for (i = LX; i <= RX; i++)
1633 for (i = tY + 1; i <= BY - 1; i++)
1640 static void Form_Unload(int Cancel)
1644 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Quit*"))
1649 if (menEdit.Checked)
1657 Msg = "Save changes to " & GetFileNameToSave() & " ?";
1658 Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - closing");
1659 if (Res == vbCancel)
1667 if (FileExists(OrigPath) && menSave.Enabled)
1678 if (FileExists(TmpPath) || ModifiedFlag)
1684 ReleaseDirectDraw();
1689 static void fpsTim_Timer()
1694 count5 = count5 + 1;
1697 TickDiff = T.TickDiffUS(LastTick);
1698 lblFps.Caption = CLng(Round((1000000 * (TimerVar - LastFrame)) / (TickDiff), 0));
1699 LastFrame = TimerVar;
1700 LastTick = T.TickNow();
1704 // If NoDisplayFlag Then lblFrameCount = TimerVar
1705 lblFrameCount = TimerVar;
1708 static void menAbout_Click()
1710 frmSplash.Show vbModal, Me;
1713 static void menAutoScroll_Click()
1716 menAutoScroll.Checked = ! menAutoScroll.Checked;
1717 AutoScrollFlag = menAutoScroll.Checked;
1721 static void menBorder_Click()
1723 if (menBorder.Checked)
1725 menBorder.Checked = False;
1727 DisplayMaxX = FieldWidth - 2;
1728 DisplayWidth = FieldWidth;
1730 DisplayMaxY = FieldHeight - 2;
1731 DisplayHeight = FieldHeight;
1732 if (Loaded && LevelLoaded)
1738 menBorder.Checked = True;
1740 DisplayMaxX = FieldWidth - 1;
1741 DisplayWidth = FieldWidth + 2;
1743 DisplayMaxY = FieldHeight - 1;
1744 DisplayHeight = FieldHeight + 2;
1745 if (Loaded && LevelLoaded)
1750 // DisplayLevel True
1753 void SetDisplayRegion()
1755 if (! menBorder.Checked)
1758 DisplayMaxX = FieldWidth - 2;
1759 DisplayWidth = FieldWidth;
1761 DisplayMaxY = FieldHeight - 2;
1762 DisplayHeight = FieldHeight;
1770 DisplayMaxX = FieldWidth - 1;
1771 DisplayWidth = FieldWidth + 2;
1773 DisplayMaxY = FieldHeight - 1;
1774 DisplayHeight = FieldHeight + 2;
1780 static void menCopy_Click()
1785 void menEdit_Click()
1789 if (menEdit.Checked)
1791 menEdit.Checked = False;
1798 FMark.ShowMarker False;
1799 picViewPort.MousePointer = 0;
1802 if (! STRING_IS_LIKE(CurPath, TmpPath))
1824 if (! STRING_IS_LIKE(CurPath, TmpPath))
1833 subFetchAndInitLevel();
1834 menEdit.Checked = True;
1837 // ScaleMode = vbTwips
1838 ToolBox.Move (Width - ToolBox.Width) / 2, Height - ToolBox.Height;
1839 // ScaleMode = vbPixels
1840 // L = GetWindowLong(ToolBox.hWnd, GWL_STYLE)
1841 // L = L And (Not WS_POPUP)
1842 // L = L Or WS_CHILD
1843 // SetWindowLong ToolBox.hWnd, GWL_STYLE, L
1844 // SetParent ToolBox.hWnd, hWnd
1845 ToolBox.Show vbModeless, Me;
1849 FMark.ShowMarker True;
1853 static void menEnOff_Click()
1855 menEnOn.Checked = False;
1856 menEnOff.Checked = True;
1861 static void menEnOn_Click()
1863 menEnOn.Checked = True;
1864 menEnOff.Checked = False;
1869 static void menExit_Click()
1874 static void menFaster_Click()
1880 Debug.Assert(False);
1884 if (DemoFlag != 0) // demoplayback
1886 i = GetSpeedIndex(DeltaTDemo);
1888 If i < 2 Then i = 2;
1889 menDemoSpeed_Click (i);
1893 i = GetSpeedIndex(DeltaTPlay);
1895 If i < 2 Then i = 2;
1896 menPlaySpeed_Click (i);
1900 static void menSlower_Click()
1906 Debug.Assert(False);
1910 if (DemoFlag != 0) // demoplayback
1912 i = GetSpeedIndex(DeltaTDemo);
1914 If nSpeedCount < i Then i = nSpeedCount;
1915 menDemoSpeed_Click (i);
1919 i = GetSpeedIndex(DeltaTPlay);
1921 If nSpeedCount < i Then i = nSpeedCount;
1922 menPlaySpeed_Click (i);
1926 void menPlaySpeed_Click(int Index)
1930 // If NoDisplayFlag And (GameLoopRunning <> 0) Then
1931 // NoDisplayFlag = False
1934 // NoDisplayFlag = False
1935 for (i = menPlaySpeed.LBound; i <= menPlaySpeed.UBound; i++)
1938 menPlaySpeed(i).Checked = (Index == i);
1942 BlockingSpeed = False;
1943 DeltaTPlay = SpeedsByDelayUS[Index];
1945 // If DeltaTPlay < 0 Then
1948 // NoDisplayFlag = True
1952 void menDemoSpeed_Click(int Index)
1956 // If NoDisplayFlag And (GameLoopRunning <> 0) Then
1957 // NoDisplayFlag = False
1960 NoDisplayFlag = False;
1961 for (i = menDemoSpeed.LBound; i <= menDemoSpeed.UBound; i++)
1964 menDemoSpeed(i).Checked = (Index == i);
1968 BlockingSpeed = False;
1969 DeltaTDemo = SpeedsByDelayUS[Index];
1971 // If DeltaTPlay < 0 Then
1974 // NoDisplayFlag = True
1978 static void UpdateDeltaT()
1983 DeltaT = (DemoFlag != 0 ? DeltaTDemo : DeltaTDemo);
1988 NoDisplayFlag = True;
1992 if (NoDisplayFlag && GameLoopRunning != 0)
1994 NoDisplayFlag = False;
1999 NoDisplayFlag = False;
2004 static void menGravOff_Click()
2006 menGravOn.Checked = False;
2007 menGravOff.Checked = True;
2012 static void menGravOn_Click()
2014 menGravOn.Checked = True;
2015 menGravOff.Checked = False;
2020 static void menNew_Click()
2022 NewForm.Show vbModal, Me;
2023 CreateLevel(FieldWidth, FieldHeight);
2027 static void menNewStd_Click()
2029 CreateLevel(60, 24);
2033 static void menOpen_Click()
2038 // cmDlg.DefaultExt = "sp"
2042 (prevent compiler warning here due to suspected use of trigraph)
2044 cmDlg.Filter = "All Levels (*.DAT;*.D??;*.sp;*.mpx)|*.DAT;*.D??;*.sp;*.mpx|MegaPlex Levels (*.mpx)|*.mpx" & "|Supaplex Level Sets (*.DAT;*.D??)|*.DAT;*.D??|SpeedFix Demos (*.sp)|*.sp";
2047 LFilt = LastOpenFilter;
2048 cmDlg.FilterIndex = (0 < LFilt & LFilt < 5 ? LFilt : LFilt);
2049 if (FileExists(CurPath))
2050 cmDlg.InitDir = WithSlash(StripDir(CurPath));
2052 cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames;
2055 // --- On Error GoTo menOpenEH
2057 // --- On Error GoTo 0
2059 LFilt = cmDlg.FilterIndex;
2060 LastOpenFilter = LFilt;
2061 CurPath = cmDlg.FileName;
2063 FillFileList (CurPath);
2068 static void menOptions_Click()
2072 oFrm.Show vbModal, Me;
2074 picViewPort_Resize();
2077 static void menPanel_Click()
2080 PanelVisible = ! menPanel.Checked;
2084 void Let_PanelVisible(boolean NewVal)
2088 if (HidePanel != NewVal)
2091 HidePanel = ! NewVal;
2092 PanelTim.Enabled = True;
2095 static void DrawPauseLayer(long Layer)
2097 DirectDrawPalette Pal;
2102 // For Y = 0 To bmpStage.Height Step BaseWidth
2103 // For X = 0 To bmpStage.Width Step BaseWidth
2104 // Pause.TransparentDraw bmpStageHDC, X, Y, Layer
2107 // With Stage.Surface
2108 // Set Pal = .GetPalette
2109 // for i=1 to pal.GetEntries(
2110 // Stage.Surface.SetPalette
2113 static void menPaste_Click()
2120 static void menPause_Click()
2125 PauseMode = (PauseMode != 0 ? 0 : 0);
2128 if (IS_NOTHING(&OldPic, sizeof(OldPic)))
2129 OldPic = cmdPause.Picture;
2131 cmdPause.Picture = cmdPause.DownPicture;
2132 OldText = lblStatus.Caption;
2133 lblStatus = "Paused ...";
2137 cmdPause.Picture = OldPic;
2138 lblStatus.Caption = OldText;
2142 static void menPlayAll_Click()
2146 char *LogPath, *OutStr, *ReRecPath, *SPPath;
2150 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play) All Demos")
2152 cmdPlayAll.Caption = "Quit All";
2153 menPlayAll.Caption = "Quit All";
2154 FocusTim.Enabled = True;
2157 iMax = cmbFile.ListCount - 1;
2158 LogPath = StripDir(CurPath) & "/Error.Log";
2159 if (Dir(LogPath) != "")
2162 for (i = iMin; i <= iMax; i++)
2164 cmbFile.ListIndex = i;
2165 // If CurPath Like "*.sp" Or CurPath Like "*.mpx" Then
2169 ReRecPath = SPPath & ".ReRec";
2170 menPlayDemo_Click();
2172 // bEqual = FilesEqual(ReRecPath, SPPath)
2173 // If bEqual Then MayKill ReRecPath
2175 OutStr = cmbFile.List(i) & " -> ";
2177 if (Val(lblFrameCount) != GetTotalFramesOfDemo())
2179 OutStr = OutStr & "Error in GetTotalFramesOfDemo()! ";
2180 Debug.Assert(False);
2184 if ((LevelStatus == 1) && bEqual)
2186 OutStr = OutStr & "Success";
2190 OutStr = OutStr & "All Demos (float)Canceled";
2194 if (LevelStatus != 1)
2196 OutStr = OutStr & "### Level Failed ### (TimerVar == " & TimerVar & ")";
2201 OutStr = OutStr & "### ReRecording is binary different ###";
2206 FNum = fopen(LogPath, "ab");
2207 Print #FNum, OutStr;
2214 cmdPlayAll.Caption = "Play All Demos";
2215 menPlayAll.Caption = "Play All Demos";
2216 SettingsObject Settings;
2218 MySignature = Settings.Read("MySignature", "");
2219 FirstDemoByte = 0x81;
2224 if (menStop.Enabled)
2229 static void menRemSP_Click()
2235 static void menRestoreBorder_Click()
2240 static void menSave_Click()
2245 if (STRING_IS_LIKE(CurPath, TmpPath))
2248 if (STRING_IS_LIKE(CurPath, "") || STRING_IS_LIKE(CurPath, "*.dat"))
2254 if (STRING_IS_LIKE(CurPath, "*.sp"))
2260 if (! FileExists(CurPath) || STRING_IS_LIKE(CurPath, "Untitled"))
2267 Let_ModifiedFlag(False);
2270 static void menSaveAs_Click()
2273 FillFileList (CurPath);
2276 static boolean SaveAs()
2278 static boolean SaveAs;
2285 // cmDlg.DefaultExt = "sp"
2286 cmDlg.Filter = "MegaPlex Level (*.mpx)|*.mpx|SpeedFix Demo (*.sp)|*.sp";
2287 cmDlg.FilterIndex = LastSaveFilter;
2288 // If OrigPath Like "*.sp" Then cmDlg.FilterIndex = 1 Else cmDlg.FilterIndex = 0
2289 if (FileExists(OrigPath))
2291 cmDlg.InitDir = WithSlash(StripDir(OrigPath));
2292 cmDlg.InitDir = s.Read("LastSaveDir", cmDlg.InitDir);
2293 cmDlg.FileName = StripExtensionlessFileName(GetFileNameToSave());
2296 cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames;
2299 // --- On Error GoTo SaveAsEH
2301 // --- On Error GoTo 0
2303 LastSaveFilter = cmDlg.FilterIndex;
2304 FN = cmDlg.FileName;
2305 SettingsObject_Save("LastSaveDir", WithSlash(StripDir(FN)));
2306 if (STRING_IS_LIKE(FN, "*.sp"))
2310 else if (STRING_IS_LIKE(FN, "*.mpx"))
2315 Let_ModifiedFlag(False);
2323 static void menSelectAll_Click()
2325 FMark.SetPoint1 0, 0;
2326 FMark.SetPoint2 FieldWidth - 1, FieldHeight - 1;
2329 static void menShowLInfo_Click()
2333 Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")";
2334 if (DemoAvailable && bSignatureAvailable)
2335 Msg = Msg & vbNewLine & vbNewLine & gSignature;
2337 SignatureForm.Signature = Msg;
2338 SignatureForm.DelayMS = 5000;
2341 X = left + (Width - SignatureForm.Width) / 2;
2342 Y = top + (Height - SignatureForm.Height) / 2;
2343 SignatureForm.Move X, Y;
2344 SignatureForm.Show vbModeless, Me;
2348 static void menSoundFX_Click()
2351 menSoundFX.Checked = ! menSoundFX.Checked;
2352 FXOnFlag = (menSoundFX.Checked ? -1 : -1);
2358 // static void menPlay_Click()
2359 void menPlay_Click()
2364 boolean OldEditFlag;
2366 // Trace "MainForm", "--> menPlay_Click()"
2373 SignatureForm.DelayMS = 1;
2374 menPlay.Enabled = False;
2375 menPause.Enabled = True;
2376 menStop.Enabled = True;
2377 cmdPlay.Enabled = False;
2378 cmdPause.Enabled = True;
2379 cmdStop.Enabled = True;
2380 cmdPlayDemo.Enabled = False;
2381 menPlayDemo.Enabled = False;
2382 cmdRecordDemo.Enabled = False;
2383 menRec.Enabled = False;
2384 menFaster.Enabled = True;
2385 menSlower.Enabled = True;
2386 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play*"))
2388 cmdPlayAll.Enabled = False;
2389 menPlayAll.Enabled = False;
2392 cmbFile.Enabled = False;
2393 cmbLevel.Enabled = False;
2394 OldEditFlag = EditFlag;
2398 menEditMain.Enabled = False;
2399 if (DemoFlag == 0 && RecordDemoFlag == 0)
2400 lblStatus = "Playing";
2407 LastTick = T.TickNow;
2411 fpsTim.Enabled = True;
2424 subFetchAndInitLevelB();
2425 // Trace "MainForm", "CountDown 1"
2426 CountDown(2, (0 == DemoFlag));
2427 // Trace "MainForm", "Call GoPlay"
2429 // Trace "MainForm", "GoPlay returned"
2433 if (LevelStatus == 1)
2435 lblStatus = "(float)Success";
2439 lblStatus = "Try (float)again";
2444 // Trace "MainForm", "CountDown 1"
2445 CountDown(1, False);
2453 // Trace "MainForm", "Call subFetchAndInitLevel"
2454 subFetchAndInitLevel();
2455 // Trace "MainForm", "subFetchAndInitLevel returned"
2460 menEditMain.Enabled = True;
2464 // Trace "MainForm", "<-- menPlay_Click()"
2472 static void menPlayDemo_Click()
2476 lblStatus = "Demo Playback";
2478 if (LevelStatus != 1)
2479 lblStatus = "Demo Failed";
2484 static void menRec_Click()
2486 Trace("MainForm", "--> menRec_Click()");
2495 lblStatus.ForeColor = vbRed;
2496 lblStatus = "Recording Demo";
2497 // DemoBuffer = New DemoBufferObject; // (handle this later, if needed)
2498 Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer)));
2499 Trace("MainForm", "Call menPlayClick");
2501 Trace("MainForm", "menPlayClick returned");
2503 lblStatus.ForeColor = vbButtonText;
2505 Let_ModifiedFlag(True);
2506 if (! STRING_IS_LIKE(CurPath, TmpPath))
2512 LInfo.DemoRandomSeed = RecDemoRandomSeed;
2513 Trace("MainForm", "Call SaveMPX(TmpPath)");
2515 Trace("MainForm", "Set DemoBuffer == Nothing");
2516 SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer));
2517 Trace("MainForm", "Call subFetchAndInitLevel");
2518 subFetchAndInitLevel();
2519 cmdPlayDemo.Enabled = DemoAvailable;
2520 Trace("MainForm", "<-- menRec_Click()");
2523 static void menReRecordDemo_Click()
2533 lblStatus.ForeColor = vbRed;
2534 lblStatus = "ReRecording Demo";
2535 // DemoBuffer = New DemoBufferObject; // (handle this later, if needed)
2536 Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer)));
2538 lblStatus.ForeColor = vbButtonText;
2540 Let_ModifiedFlag(True);
2541 if (! STRING_IS_LIKE(CurPath, TmpPath))
2547 LInfo.DemoRandomSeed = RecDemoRandomSeed;
2549 SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer));
2550 subFetchAndInitLevel();
2553 void menStop_Click()
2560 fpsTim.Enabled = False;
2562 lblFps.Caption = "";
2563 menRec.Enabled = True;
2564 menPlay.Enabled = True;
2565 menPause.Enabled = False;
2566 menStop.Enabled = False;
2567 cmdPlay.Enabled = True;
2568 cmdPause.Enabled = False;
2569 cmdStop.Enabled = False;
2570 cmdRecordDemo.Enabled = True;
2571 cmdPlayDemo.Enabled = DemoAvailable;
2572 cmdPlayAll.Enabled = DemosAvailable;
2573 menPlayDemo.Enabled = DemoAvailable;
2574 menPlayAll.Enabled = DemosAvailable;
2575 menFaster.Enabled = False;
2576 menSlower.Enabled = False;
2577 cmbFile.Enabled = True;
2578 cmbLevel.Enabled = True;
2581 static void menStretch_Click(int Index)
2583 ReStretch(0.25 * Index);
2584 // DisplayLevel True
2587 static void menToolTips_Click()
2590 menToolTips.Checked = ! menToolTips.Checked;
2591 if (menToolTips.Checked)
2593 cmdPlay.ToolTipText = "Play Game (Space)";
2594 cmdPause.ToolTipText = "Pause (P)";
2595 cmdStop.ToolTipText = "Stop (Q)";
2596 cmdPlayDemo.ToolTipText = "Play demo (Ctrl+Space)";
2597 cmdRecordDemo.ToolTipText = "Record demo (Ctrl+R)";
2598 lblInfoCount.ToolTipText = "Number of infotrons needed";
2599 lblRedDiskCount.ToolTipText = "Number of red disks";
2600 cmbLevel.ToolTipText = "List of all levels in the file";
2601 cmbFile.ToolTipText = "List of files in current directory";
2602 lblFps.ToolTipText = "Animation speed in fps";
2603 lblFrameCount.ToolTipText = "Game time in frames";
2607 cmdPlay.ToolTipText = "";
2608 cmdPause.ToolTipText = "";
2609 cmdStop.ToolTipText = "";
2610 cmdPlayDemo.ToolTipText = "";
2611 cmdRecordDemo.ToolTipText = "";
2612 lblInfoCount.ToolTipText = "";
2613 lblRedDiskCount.ToolTipText = "";
2614 cmbLevel.ToolTipText = "";
2615 cmbFile.ToolTipText = "";
2616 lblFps.ToolTipText = "";
2617 lblFrameCount.ToolTipText = "";
2623 static void menTrim_Click()
2628 OldOPath = OrigPath;
2630 Tmp.SpecialPortCount = 0; // hack: all special ports are deleted
2632 CreateLevel(FMark.Width, FMark.Height);
2634 OrigPath = OldOPath;
2636 menSelectAll_Click();
2638 picViewPort_Resize();
2641 static void menZonkOff_Click()
2643 menZonkOn.Checked = False;
2644 menZonkOff.Checked = True;
2649 static void menZonkOn_Click()
2651 menZonkOn.Checked = True;
2652 menZonkOff.Checked = False;
2657 static void PanelTim_Timer()
2662 if (PanelSeq < Panel.Height && -1 < PanelSeq)
2664 PanelSeq = (ShowPanel != 0 ? PanelSeq + 2 : PanelSeq + 2);
2665 Tmp = ScaleHeight - Tmp + PanelSeq;
2667 picViewPort.Height = Tmp;
2671 PanelTim.Enabled = False;
2672 PanelSeq = (PanelSeq < 0 ? 0 : 0);
2673 ShowPanel = (ShowPanel == 0 ? 1 : 1);
2674 menPanel.Checked = (ShowPanel != 0);
2678 static void picKeys_MouseUp(int Button, int Shift, float X, float Y)
2680 FocusTim.Enabled = True;
2683 static void picMenu_Click()
2687 static void picPane_KeyDown(int KeyCode, int Shift)
2689 if (KeyCode < 0 || 255 < KeyCode)
2692 KeyState[KeyCode] = True;
2696 if (MouseButton == 0 && EditFlag)
2697 picPane.MousePointer = 15;
2715 if (DemoFlag != 0 && 2 == Shift)
2724 bCapturePane = ! bCapturePane;
2729 static void picPane_KeyUp(int KeyCode, int Shift)
2731 if (KeyCode < 0 || 255 < KeyCode)
2734 KeyState[KeyCode] = False;
2738 if (menFaster.Enabled)
2744 if (menSlower.Enabled)
2750 if (2 == Shift) // ctrl+space
2752 if (menPlayDemo.Enabled)
2753 menPlayDemo_Click();
2758 if (menPlay.Enabled)
2765 if (menStop.Enabled)
2778 if (menPause.Enabled && (Shift == 0))
2784 if (MouseButton == 0 && EditFlag)
2785 picPane.MousePointer = 0;
2790 static void picPane_MouseDown(int Button, int Shift, float X, float Y)
2794 MouseButton = Button;
2795 OldEdMode = EditMode;
2798 if (Button == 2 && Shift != 2)
2800 EditMode = edSelect;
2818 picPane.MousePointer = 5; // size
2819 UserDragFlag = True;
2823 SetField(X, Y, ToolBox.ASpriteIndex);
2827 FMark.SetPoint1 EdGetX(X), EdGetY(Y);
2832 EditMode = OldEdMode;
2835 static void picPane_MouseMove(int Button, int Shift, float X, float Y)
2840 OldEdMode = EditMode;
2843 if (EditFlag && Button == 2 && Shift != 2)
2845 EditMode = edSelect;
2859 Oldflag = NoDisplayFlag;
2860 NoDisplayFlag = False;
2861 ScrollTo(OSX - X + MDX, OSY - Y + MDY);
2863 NoDisplayFlag = Oldflag;
2867 SetField(X, Y, ToolBox.ASpriteIndex);
2871 FMark.SetPoint2 EdGetX(X), EdGetY(Y);
2876 EditMode = OldEdMode;
2879 static void picPane_MouseUp(int Button, int Shift, float X, float Y)
2881 MouseButton = MouseButton ^ Button;
2882 picPane.MousePointer = 0;
2883 UserDragFlag = False;
2884 if (menEditMain.Enabled && Button == 2)
2886 if (MDX == X && MDY == Y)
2887 PopupMenu menEditMain;
2891 static void picPane_Paint()
2895 Oldflag = NoDisplayFlag;
2896 NoDisplayFlag = False;
2898 NoDisplayFlag = Oldflag;
2901 static void ReStretch(float NewStretch)
2903 long BW2, LW, LH, i;
2907 Stretch = NewStretch;
2912 SET_TO_NOTHING(&Stage, sizeof(Stage));
2913 SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites));
2914 menStretch(Stretch / 0.25).Checked = False;
2915 Stretch = NewStretch;
2916 menStretch(Stretch / 0.25).Checked = True;
2917 // StretchWidth = BaseWidth ' * NewStretch
2918 // StretchWidth2 = StretchWidth \ 2
2919 // TwoPixels = 2 '* Stretch
2920 // StretchLoad Sprites, imgMpx.Picture, 16, 16
2921 BW2 = StretchWidth / 2;
2922 LW = (FieldWidth + 2) * BaseWidth; // StretchWidth
2923 LH = (FieldHeight + 2) * BaseWidth; // StretchWidth
2924 // i = bmpStage.CreateAtSize(LW, LH)
2925 // Stage = New DDScrollBuffer; // (handle this later, if needed)
2926 i = Stage.CreateAtSize(LW, LH, picPane.hWnd);
2927 // Set StretchedSprites = NormalSprites.GetStretchCopy(Stretch)
2928 ReLoadStretchSprites();
2929 if (i == 0 || IS_NOTHING(&StretchedSprites, sizeof(StretchedSprites)))
2931 // menStretch(Stretch / 0.5).Enabled = False
2933 ReStretch(Stretch - 0.25);
2938 StretchedSprites.DestXOff = 1 * BaseWidth; // StretchWidth
2939 StretchedSprites.DestYOff = 1 * BaseWidth; // StretchWidth
2940 Stage.DestXOff = 1 * StretchWidth;
2941 Stage.DestYOff = 1 * StretchWidth;
2942 StretchedSprites.DestinationSurface = Stage.Surface;
2944 if (Loaded && LevelLoaded)
2947 picViewPort_Resize();
2951 subCalculateScreenScrollPos();
2952 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
2960 static void SetScrollEdges()
2962 ScrollMinX = (DisplayMinX - 0.5) * Stretch * BaseWidth;
2963 ScrollMinY = (DisplayMinY - 0.5) * Stretch * BaseWidth;
2964 ScrollMaxX = (DisplayMaxX + 1.5) * Stretch * BaseWidth - picPane.Width;
2965 ScrollMaxY = (DisplayMaxY + 1.5) * Stretch * BaseWidth - picPane.Height;
2970 void DrawField(int X, int Y)
2975 Tmp = LowByte(PlayField16[tsi]);
2979 if (Tmp == fiRAM || Tmp == fiHardWare)
2980 Tmp = DisPlayField[tsi];
2982 if (Tmp == fiBug || Tmp == 40)
2983 Tmp = DisPlayField[tsi];
2987 if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak)
2988 Tmp = DisPlayField[tsi];
2991 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
2994 void DrawFieldAnimated(int X, int Y)
2999 Tmp = LowByte(PlayField16[tsi]);
3003 subDrawAnimatedSnikSnaks(tsi);
3007 subDrawAnimatedElectrons(tsi);
3011 // If 40 < Tmp Then Tmp = 0
3012 // If Tmp = fiRAM Or Tmp = fiHardWare Then Tmp = DisPlayField(tsi)
3013 // If Tmp = fiBug Or Tmp = 40 Then Tmp = DisPlayField(tsi)
3015 // If fiOrangeDisk < Tmp And Tmp < fiSnikSnak Then Tmp = DisPlayField(tsi)
3017 // StretchedSprites.BltEx StretchWidth * X, StretchWidth * Y, Tmp
3022 void DrawFieldNoAnimated(int X, int Y)
3027 Tmp = LowByte(PlayField16[tsi]);
3031 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace);
3035 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace);
3042 if (Tmp == fiRAM || Tmp == fiHardWare)
3043 Tmp = DisPlayField[tsi];
3045 if (Tmp == fiBug || Tmp == 40)
3046 Tmp = DisPlayField[tsi];
3050 if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak)
3051 Tmp = DisPlayField[tsi];
3054 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
3059 void DrawSprite(int X, int Y, int SpritePos)
3061 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, SpritePos);
3066 void InvalidateRect(long XMin, long YMin, long XMax, long YMax)
3070 // For Y = YMin To YMax
3071 // For X = XMin To XMax
3072 // Field(X, Y).GraphicsValid = 0
3077 static void picViewPort_MouseUp(int Button, int Shift, float X, float Y)
3079 FocusTim.Enabled = True;
3082 static void picViewPort_Paint()
3084 // Debug.Print "picViewPort_Paint()"
3087 static void picViewPort_Resize()
3089 long bdX, bdY, PanelVisibility;
3094 bdX = picFrame.Width - picFrame.ScaleWidth;
3095 bdY = picFrame.Height - picFrame.ScaleHeight;
3096 dx = Min(picViewPort.ScaleWidth - bdX, (DisplayWidth - 1) * Stretch * BaseWidth);
3098 dY = Min(picViewPort.ScaleHeight - bdX, (DisplayHeight - 1) * Stretch * BaseWidth);
3100 B = s.Read("LimitToOriginalFieldSize", False);
3101 PanelVisibility = 24 * (Panel.Height - PanelSeq - (float)1) / Panel.Height;
3104 dx = Min(320 * Stretch, dx);
3105 dY = Min((200 - PanelVisibility) * Stretch, dY);
3108 X = Max((picViewPort.ScaleWidth - dx) / 2, 0);
3109 Y = Max((picViewPort.ScaleHeight - dY) / 2, 0);
3110 picPane.Move X, Y, dx, dY;
3111 picFrame.Move X - bdX / 2, Y - bdY / 2, dx + bdX, dY + bdY;
3113 ScrollTo(ScrollX, ScrollY);
3114 // SizeTim.Interval = 1
3118 // Private Sub SizeTim_Timer()
3120 // SizeTim.Interval = 0
3121 // wdX = Max(0, picViewPort.ScaleWidth - picPane.Width) * Screen.TwipsPerPixelX
3122 // wdY = Max(0, picViewPort.ScaleHeight - picPane.Height) * Screen.TwipsPerPixelY
3123 // If (0 < wdX) Or (0 < wdY) Then
3124 // Move Left, Top, Width - wdX, Height - wdY
3128 static void LoadKeyIndicators()
3132 picKeys.BackColor = vbButtonFace;
3133 for (i = 2; i <= 5; i++)
3138 for (i = 1; i <= 5; i++)
3140 shpKey(i).FillColor = vbButtonFace;
3141 shpKey(i).Visible = True;
3144 shpKey(1).Move 7, 0;
3145 shpKey(2).Move 0, 7;
3146 shpKey(3).Move 7, 14;
3147 shpKey(4).Move 14, 7;
3148 shpKey(5).Move 7, 7;
3151 void ShowKey(int KeyVar)
3153 boolean State[5 + 1];
3157 boolean LastState[5 + 1];
3169 State[KeyVar] = True;
3175 State[KeyVar - 4] = True;
3179 for (i = 1; i <= 5; i++)
3182 if (Tmp ^ LastState[i])
3184 Col = (i == 5 ? vbRed : vbRed);
3185 shpKey(i).FillColor = (Tmp ? Col : Col);
3192 static void GetSettings()
3202 APath = WithSlash(App.Path);
3203 CurPath = s.Read("LastPath", APath);
3205 // window width and height
3206 X = s.Read("Width", Width);
3207 Y = s.Read("Height", Height);
3208 if (X < 0 Then X == 0: If Y < 0)
3211 if (Screen.Width < X)
3214 if (Screen.Height < Y)
3219 // window position and state
3220 X = s.Read("Left", left);
3221 Y = s.Read("Top", top);
3222 if (X < 0 Then X == 0: If Y < 0)
3225 if (Screen.Width < (X + Width))
3226 X = Screen.Width - Width;
3228 if (Screen.Height < (Y + Height))
3229 Y = Screen.Height - Height;
3233 WindowState = s.Read("WinState", vbNormal);
3235 Flag = s.Read("ShowToolTips", True);
3237 menToolTips_Click();
3239 menBorder.Checked = ! CBool(s.Read("ShowBorder", False));
3240 Flag = CBool(s.Read("AutoScroll", True));
3243 AutoScrollFlag = False;
3244 menAutoScroll.Checked = False;
3247 Flag = CBool(s.Read("SoundFX", True));
3248 FXOnFlag = (Flag ? -1 : -1);
3249 menSoundFX.Checked = Flag;
3250 SignatureDelay = CLng(s.Read("SignatureDelay", 3000));
3251 AllowRedDiskCheat = CInt(s.Read("AllowRedDiskCheat", 1));
3252 AllowEatRightRedDiskBug = CInt(s.Read("AllowEatRightRedDiskBug", 1));
3253 MySignature = s.Read("MySignature", "");
3255 X = s.Read("FrameDelayPlay", 1000000 / 35);
3256 i = GetSpeedIndex(X);
3257 menPlaySpeed_Click(i);
3258 X = s.Read("FrameDelayDemo", 1000000 / 35);
3259 i = GetSpeedIndex(X);
3260 menDemoSpeed_Click(i);
3262 i = s.Read("Stretch", 4);
3263 if (i < menStretch.LBound || menStretch.UBound < i)
3266 menStretch_Click (i);
3270 static void SaveSettings()
3276 s.Save "LastPath", (ModifiedFlag ? OrigPath : OrigPath);
3277 if (WindowState != vbMinimized)
3279 s.Save "Width", Width;
3280 s.Save "Height", Height;
3281 s.Save "Left", left;
3283 s.Save "WinState", WindowState;
3286 s.Save "ShowToolTips", menToolTips.Checked;
3287 s.Save "ShowBorder", menBorder.Checked;
3288 s.Save "AutoScroll", menAutoScroll.Checked;
3289 s.Save "SoundFX", menSoundFX.Checked;
3290 s.Save "SignatureDelay", SignatureDelay;
3291 s.Save "AllowRedDiskCheat", AllowRedDiskCheat;
3292 s.Save "AllowEatRightRedDiskBug", AllowEatRightRedDiskBug;
3293 s.Save "MySignature", MySignature;
3295 s.Save "FrameDelayPlay", DeltaTPlay;
3296 s.Save "FrameDelayDemo", DeltaTDemo;
3298 for (i = menStretch.LBound; i <= menStretch.UBound; i++)
3300 if (menStretch(i).Checked)
3304 s.Save "Stretch", i;
3309 void ReLoadStretchSprites()
3312 BitMapObject NBMP, SBMP;
3315 // If Stretch = 1 Then
3316 MpxBmp = App.Path & "/Mpx.bmp";
3318 // MpxBmp = App.Path & "\Mpx" & Stretch & ".bmp"
3319 // tmpMpxBmp = App.Path & "\Mpx.bmp"
3320 // If FileExists(MpxBmp) And FileExists(tmpMpxBmp) Then
3321 // If FileDateTime(MpxBmp) < FileDateTime(tmpMpxBmp) Then
3325 // If Not FileExists(MpxBmp) Then
3326 // MousePointer = 11
3327 // // Set NBMP = New BitMapObject // (handle this later, if needed)
3328 // tmpMpxBmp = App.Path & "\Mpx.bmp"
3329 // If Not FileExists(tmpMpxBmp) Then
3330 // ReportError "ReLoadStretchSprites", "File not found: " & tmpMpxBmp
3331 // MESSAGE_BOX("an error occured"); // MsgBox "File not found: " & tmpMpxBmp, vbCritical, "MegaPlex - Error"
3334 // NBMP.CreateFromFile tmpMpxBmp
3335 // Set SBMP = NBMP.GetStretchCopy(Stretch)
3336 // SBMP.SaveToFile MpxBmp
3337 // Set NBMP = Nothing
3338 // Set SBMP = Nothing
3342 // StretchedSprites = New DDSpriteBuffer; // (handle this later, if needed)
3343 if (! StretchedSprites.CreateFromFile(MpxBmp, 16, 16))
3344 SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites));
3347 void SaveSnapshot(currency Number)
3351 Path = CAT(WithSlash(App.Path), "Capture");
3355 Path = Path & "\" & Format(Number, "00000000") & ".bmp";
3356 SavePicture CaptureWindow(picPane.hWnd, True, 0, 0, picPane.ScaleWidth, picPane.ScaleHeight), Path;