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)
827 long LeftPos, TopPos, RightPos, MaxWidth; // , MaxHeight&
829 dT = HalfSeconds * 500;
831 LeftPos = cmbFile.left;
832 TopPos = cmbFile.top - shpProgress.Height - cmbFile.top / 8;
833 RightPos = lblFrameCount.left + lblFrameCount.Width;
834 MaxWidth = RightPos - LeftPos;
835 // MaxHeight = lblFrameCount.Top - TopPos + lblFrameCount.Height + 4
838 shpProgress.Move(LeftPos, TopPos, 0); // , MaxHeight
839 shpProgress.Visible = True;
842 for (i = 1; i <= 200; i++)
849 shpProgress.Width = MaxWidth * i / 100;
853 k = MaxWidth * (i - 100) / 100;
854 shpProgress.Move(k, TopPos, RightPos - k);
858 T.DelayMS(Delta, False);
861 shpProgress.Visible = False;
870 static char *GetValidTempPath()
872 static char *GetValidTempPath;
877 GetValidTempPath = "";
879 TP = String(nSize, Chr(32));
880 L = GetTempPath(nSize, TP);
883 // buffer was too small, retry with a properly sized buffer:
885 TP = String(nSize, Chr(32));
886 L = GetTempPath(nSize, TP);
889 TP = SlashLess(left(TP, L));
890 if ((0 == L) || (! IsDir(TP)))
892 // no valid temp path can be retrieved from the system --> create our own
893 TP = CAT(WithSlash(App.Path), "Temp");
897 // --- On Error Resume Next
899 if (! IS_NOTHING(&Err, sizeof(Err)))
901 MESSAGE_BOX("an error occured"); // MsgBox "cannot create directory for temporary files " & TP, vbCritical, "MegaPlex - Error";
902 return GetValidTempPath;
905 // --- On Error GoTo 0
911 GetValidTempPath = TP;
913 return GetValidTempPath;
916 static char *GetMyTempFileName()
918 static char *GetMyTempFileName;
922 (char *)T = Hex(hWnd);
928 GetMyTempFileName = CAT("tmp0x", CAT((char *)T, ".mpx"));
930 return GetMyTempFileName;
933 static long GetHwndFromTempFileName(char *TmpFile)
935 static long GetHwndFromTempFileName;
942 GetHwndFromTempFileName = 0;
943 FN = StripFileName(TmpFile);
947 return GetHwndFromTempFileName;
950 NumString = right(FN, L - LP);
952 NumString = left(NumString, 8);
954 NumString = CAT("&H", NumString);
955 GetHwndFromTempFileName = Val(NumString);
957 return GetHwndFromTempFileName;
960 static void CleanTempDir(char *TmpDir)
964 MFN = GetMyTempFileName();
965 MayKill(CAT(WithSlash(TmpDir), MFN));
966 FN = Dir(CAT(WithSlash(TmpDir), "tmp0x*.mpx"));
969 if (STRING_IS_LIKE(FN, "tmp0x*.mpx"))
971 if (! InstanceStillRunning(FN))
972 MayKill(CAT(WithSlash(TmpDir), FN));
975 FN = Dir_Without_Args();
979 static boolean InstanceStillRunning(char *TmpFile)
981 static boolean InstanceStillRunning;
983 long OtherHwnd, nSize, L;
986 InstanceStillRunning = False;
987 OtherHwnd = GetHwndFromTempFileName(TmpFile);
989 Cap = String(nSize, Chr(32));
990 L = GetWindowText(OtherHwnd, Cap, nSize);
991 if ((L == 0) || (nSize < L))
992 return InstanceStillRunning;
994 if (STRING_IS_LIKE(Cap, CAT(AppTitle, "*")))
995 InstanceStillRunning = True;
997 return InstanceStillRunning;
1019 if (! menBorder.Checked)
1025 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1027 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1029 DrawFieldNoAnimated(X, Y);
1033 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1035 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1037 DrawFieldAnimated(X, Y);
1044 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1046 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1056 static void cmbFile_Click()
1058 CurPath = CAT(StripDir(OrigPath), CAT("/", cmbFile.List(cmbFile.ListIndex)));
1060 FillLevelList(CurPath, LevelNumber);
1061 if (STRING_IS_LIKE(OrigPath, "*.mpx") || STRING_IS_LIKE(OrigPath, "*.sp"))
1063 menSave.Enabled = True;
1067 menSave.Enabled = False;
1071 static void cmbFile_KeyDown(int KeyCode, int Shift)
1073 picPane_KeyDown(KeyCode, Shift);
1076 static void cmbFile_KeyUp(int KeyCode, int Shift)
1078 picPane_KeyUp(KeyCode, Shift);
1081 static int GetFileNameToSave()
1083 static int GetFileNameToSave;
1087 (char *)T = StripFileName(OrigPath);
1088 if (STRING_IS_LIKE(T, "*.dat") || STRING_IS_LIKE(T, "*.d##"))
1090 T = "Level" & Format(LevelNumber, "#000");
1093 GetFileNameToSave = T;
1095 return GetFileNameToSave;
1098 static void cmbLevel_Click()
1109 // //////////////////////////////////////////////////////////////////
1114 Msg = "Save changes to " & GetFileNameToSave() & " ?";
1115 Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - close level");
1116 if (Res == vbCancel) // fallback
1120 // --- On Error Resume Next
1121 cmbLevel.ListIndex = LastIndex;
1122 // --- On Error GoTo 0
1125 Debug.Assert cmbLevel.ListIndex = LastIndex;
1132 // oldCurPath = CurPath
1133 if (FileExists(OrigPath) && menSave.Enabled)
1139 if (! SaveAs()) // fallback
1143 // --- On Error Resume Next
1144 cmbLevel.ListIndex = LastIndex;
1145 // --- On Error GoTo 0
1148 Debug.Assert cmbLevel.ListIndex = LastIndex;
1153 // CurPath = oldCurPath
1156 Let_ModifiedFlag(False);
1160 // //////////////////////////////////////////////////////////////////
1162 LevelNumber = cmbLevel.ListIndex + 1;
1166 Oldflag = NoDisplayFlag;
1167 NoDisplayFlag = False;
1168 subFetchAndInitLevel();
1169 if ((0 < SignatureDelay) && ! (WindowState == vbMinimized))
1171 Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")";
1172 if (DemoAvailable && bSignatureAvailable)
1173 Msg = Msg & vbNewLine & vbNewLine & gSignature;
1175 SignatureForm.Signature = Msg;
1176 SignatureForm.DelayMS = SignatureDelay;
1179 X = left + (Width - SignatureForm.Width) / 2;
1180 Y = top + (Height - SignatureForm.Height) / 2;
1181 SignatureForm.Move X, Y;
1182 SignatureForm.Show vbModeless, Me;
1186 lblStatus = "MegaPlex";
1187 lblFrameCount = GetTotalFramesOfDemo();
1194 NoDisplayFlag = Oldflag;
1195 LastIndex = cmbLevel.ListIndex;
1199 menPlayDemo.Enabled = DemoAvailable;
1200 cmdPlayDemo.Enabled = DemoAvailable;
1203 static void cmblevel_KeyDown(int KeyCode, int Shift)
1205 if (GameLoopRunning != 0)
1211 if (menPlay.Enabled == True)
1217 picPane_KeyDown(KeyCode, Shift);
1222 static void cmbLevel_KeyUp(int KeyCode, int Shift)
1224 picPane_KeyUp(KeyCode, Shift);
1227 static void cmdPause_Click()
1232 static void cmdPause_MouseUp(int Button, int Shift, float X, float Y)
1234 FocusTim.Enabled = True;
1237 static void cmdPlay_Click()
1239 if (menPlay.Enabled)
1243 static void cmdPlay_MouseUp(int Button, int Shift, float X, float Y)
1245 FocusTim.Enabled = True;
1248 static void cmdPlayAll_Click()
1253 static void cmdPlayAll_MouseUp(int Button, int Shift, float X, float Y)
1255 FocusTim.Enabled = True;
1258 static void cmdPlayDemo_Click()
1260 menPlayDemo_Click();
1263 static void cmdPlayDemo_MouseUp(int Button, int Shift, float X, float Y)
1265 FocusTim.Enabled = True;
1268 static void cmdRecordDemo_Click()
1274 static void cmdRecordDemo_MouseUp(int Button, int Shift, float X, float Y)
1276 FocusTim.Enabled = True;
1279 static void cmdStop_Click()
1281 if (menStop.Enabled)
1285 static void cmdStop_MouseUp(int Button, int Shift, float X, float Y)
1287 FocusTim.Enabled = True;
1290 static void FocusTim_Timer()
1292 FocusTim.Enabled = False;
1294 // --- On Error Resume Next
1298 static void Form_KeyDown(int KeyCode, int Shift)
1300 picPane_KeyDown(KeyCode, Shift);
1303 static void Form_KeyUp(int KeyCode, int Shift)
1305 picPane_KeyUp(KeyCode, Shift);
1308 static void Form_Load()
1322 // FMark = New MarkerObject; // (handle this later, if needed)
1329 TmpPath = GetValidTempPath();
1333 CleanTempDir(TmpPath);
1334 TmpPath = CAT(WithSlash(TmpPath), GetMyTempFileName());
1338 InitDirectX(hWnd, picPane.hWnd);
1340 // AllowRedDiskCheat = 1
1341 MpxBmp = CAT(App.Path, "/mpx.bmp");
1342 // // Set NormalSprites = New DDSpriteBuffer // (handle this later, if needed)
1343 // NormalSprites.CreateFromFile MPXBMP, 16, 16
1345 Field = REDIM_2D(sizeof(int), 0, 2 + 1 - 1, 0, 2 + 1 - 1);
1347 picViewPort.ScaleMode = vbPixels;
1354 LoadKeyIndicators();
1358 FillFileList(CurPath);
1359 if (s.Read("ShowSplash", True))
1361 // frmSplash.EnableTimer
1362 frmSplash.Show vbModal, Me;
1368 static void FillLevelList(char *Path, int LevelIndex)
1370 long FNum, LevLen, i, iMax;
1374 if (! FileExists(Path))
1377 if ((STRING_IS_LIKE(Path, "*.D??")) || (STRING_IS_LIKE(Path, "*.sp")))
1381 FNum = fopen(Path, "rb");
1384 FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo));
1385 cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i;
1386 if (STRING_IS_LIKE(Path, "*.D??"))
1388 while (!(EOF(FNum)))
1391 FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo));
1395 cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i;
1399 if (LevelIndex <= i && 0 < LevelIndex)
1404 cmbLevel.ListIndex = i;
1408 else if (STRING_IS_LIKE(Path, "*.mpx"))
1412 FNum = fopen(Path, "rb");
1417 for (i = 1; i <= LevelCount; i++)
1419 if (! MpxLoadLInfo(CInt(i)))
1422 cmbLevel.AddItem Format(i, "#000") & " " & LInfo.LevelTitle, i - 1;
1428 if (LevelIndex < i && 0 < LevelIndex)
1433 if (i < cmbLevel.ListCount)
1434 cmbLevel.ListIndex = i;
1441 static void FillFileList(char *Path)
1443 long FNum, LevLen, i;
1445 char *TFile, *TPath, *OFile;
1450 TPath = WithSlash(StripDir(Path));
1451 OFile = StripFileName(Path);
1452 TFile = Dir(TPath & "*.D??");
1455 if (FileLen(TPath & TFile) == 170496)
1457 cmbFile.AddItem TFile;
1463 TFile = Dir(TPath & "*.SP");
1466 nDemoCount = nDemoCount + 1;
1467 cmbFile.AddItem TFile;
1471 TFile = Dir(TPath & "*.mpx");
1474 nDemoCount = nDemoCount + 1;
1475 cmbFile.AddItem TFile;
1479 i = cmbFile.ListCount - 1;
1480 if (0 < cmbFile.ListCount)
1484 if ((cmbFile.List(i) Like OFile) || i == 0)
1491 cmbFile.ListIndex = i;
1494 DemosAvailable = (1 < nDemoCount);
1495 menPlayAll.Enabled = DemosAvailable;
1496 cmdPlayAll.Enabled = DemosAvailable;
1499 static void LoadMenus()
1504 menFaster.Enabled = False;
1505 menSlower.Enabled = False;
1507 for (i = 1; i <= nSpeedCount; i++)
1511 Load menPlaySpeed(i);
1512 Load menDemoSpeed(i);
1515 menPlaySpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]);
1516 menDemoSpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]);
1520 menStretch(1).Caption = Format(0.25, "#0.00") & ";
1522 if (Stretch == 0.25)
1523 menStretch(1).Checked = True;
1525 for (i = 2; i <= 20; i++)
1528 menStretch(i).Caption = Format(0.25 * i, "#0.00") & ";
1530 menStretch(i).Checked = ((i * 0.25) == Stretch);
1533 menSp.Enabled = False;
1537 // Function DisplayShift&()
1538 // Dim X&, Y&, A&, B&, iX&, iiX&, LD&
1541 // For A = 0 To picPane.ScaleWidth
1542 // For Y = DisplayMinY To DisplayMaxY
1543 // For X = DisplayMinX To DisplayMaxX
1544 // iX = StretchWidth * X + A
1545 // Sprite = Field(X, Y).SpritePos
1546 // If picPane.ScaleWidth < (iX + 1) Then
1547 // iX = iX - picPane.ScaleWidth
1549 // If picPane.ScaleWidth < (iX + 1 + BaseWidth) Then
1550 // iiX = iX - picPane.ScaleWidth
1551 // Sprites.BitBltSprite picPane.hdc, iiX, StretchWidth * Y, Sprite
1554 // Sprites.BitBltSprite picPane.hdc, iX, StretchWidth * Y, Sprite
1557 // DisplayShift = DisplayShift + 1
1562 static void Form_Paint()
1564 // Debug.Print "Form_Paint()"
1567 static void Form_Resize()
1572 if (WindowState == vbMinimized || ! Loaded)
1576 // NW = ScaleWidth - 2 * Space: If NW < 0 Then NW = 0
1577 // NH = ScaleHeight - 3 * Space - cmbLevel.Height: If NH < 0 Then NH = 0
1578 // picViewPort.Move Space, Space, NW, NH
1579 Tmp = (ShowPanel != 0 ? ScaleHeight - Panel.Height : ScaleHeight - Panel.Height);
1583 picViewPort.Move 0, 0, ScaleWidth, Tmp;
1584 // Tmp = 2 * Space + picViewPort.Height
1586 Panel.left = (ScaleWidth - Panel.Width) / 2;
1587 // 'cmdNormal.Top = 2 * Space + picViewPort.Height
1588 // cmbLevel.Top = Tmp
1589 // lblRedDiskCount.Top = Tmp
1590 // lblInfoCount.Top = Tmp
1591 // picKeys.Top = Tmp
1592 // lblFrameCount.Top = Tmp
1593 // cmdPlayAll.Top = Tmp
1598 static void DrawFrame(int Delta)
1600 int i, LX, tY, RX, BY;
1604 RX = FieldWidth - Delta;
1605 BY = FieldHeight - Delta;
1606 DrawSprite(LX, tY, posFrameCorner);
1607 DrawSprite(LX, BY, posFrameCorner);
1608 DrawSprite(RX, tY, posFrameCorner);
1609 DrawSprite(RX, BY, posFrameCorner);
1610 for (i = LX + 1; i <= RX - 1; i++)
1612 DrawSprite(i, tY, posFrameHorizontal);
1613 DrawSprite(i, BY, posFrameHorizontal);
1616 for (i = tY + 1; i <= BY - 1; i++)
1618 DrawSprite(LX, i, posFrameVertical);
1619 DrawSprite(RX, i, posFrameVertical);
1625 static void RestoreFrame()
1627 int i, LX, tY, RX, BY;
1631 RX = FieldWidth - 1;
1632 BY = FieldHeight - 1;
1633 for (i = LX; i <= RX; i++)
1639 for (i = tY + 1; i <= BY - 1; i++)
1646 static void Form_Unload(int Cancel)
1650 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Quit*"))
1655 if (menEdit.Checked)
1663 Msg = "Save changes to " & GetFileNameToSave() & " ?";
1664 Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - closing");
1665 if (Res == vbCancel)
1673 if (FileExists(OrigPath) && menSave.Enabled)
1684 if (FileExists(TmpPath) || ModifiedFlag)
1690 ReleaseDirectDraw();
1695 static void fpsTim_Timer()
1700 count5 = count5 + 1;
1703 TickDiff = T.TickDiffUS(LastTick);
1704 lblFps.Caption = CLng(Round((1000000 * (TimerVar - LastFrame)) / (TickDiff), 0));
1705 LastFrame = TimerVar;
1706 LastTick = T.TickNow();
1710 // If NoDisplayFlag Then lblFrameCount = TimerVar
1711 lblFrameCount = TimerVar;
1714 static void menAbout_Click()
1716 frmSplash.Show vbModal, Me;
1719 static void menAutoScroll_Click()
1722 menAutoScroll.Checked = ! menAutoScroll.Checked;
1723 AutoScrollFlag = menAutoScroll.Checked;
1727 static void menBorder_Click()
1729 if (menBorder.Checked)
1731 menBorder.Checked = False;
1733 DisplayMaxX = FieldWidth - 2;
1734 DisplayWidth = FieldWidth;
1736 DisplayMaxY = FieldHeight - 2;
1737 DisplayHeight = FieldHeight;
1738 if (Loaded && LevelLoaded)
1744 menBorder.Checked = True;
1746 DisplayMaxX = FieldWidth - 1;
1747 DisplayWidth = FieldWidth + 2;
1749 DisplayMaxY = FieldHeight - 1;
1750 DisplayHeight = FieldHeight + 2;
1751 if (Loaded && LevelLoaded)
1756 // DisplayLevel True
1759 void SetDisplayRegion()
1761 if (! menBorder.Checked)
1764 DisplayMaxX = FieldWidth - 2;
1765 DisplayWidth = FieldWidth;
1767 DisplayMaxY = FieldHeight - 2;
1768 DisplayHeight = FieldHeight;
1776 DisplayMaxX = FieldWidth - 1;
1777 DisplayWidth = FieldWidth + 2;
1779 DisplayMaxY = FieldHeight - 1;
1780 DisplayHeight = FieldHeight + 2;
1786 static void menCopy_Click()
1791 void menEdit_Click()
1795 if (menEdit.Checked)
1797 menEdit.Checked = False;
1804 FMark.ShowMarker False;
1805 picViewPort.MousePointer = 0;
1808 if (! STRING_IS_LIKE(CurPath, TmpPath))
1830 if (! STRING_IS_LIKE(CurPath, TmpPath))
1839 subFetchAndInitLevel();
1840 menEdit.Checked = True;
1843 // ScaleMode = vbTwips
1844 ToolBox.Move (Width - ToolBox.Width) / 2, Height - ToolBox.Height;
1845 // ScaleMode = vbPixels
1846 // L = GetWindowLong(ToolBox.hWnd, GWL_STYLE)
1847 // L = L And (Not WS_POPUP)
1848 // L = L Or WS_CHILD
1849 // SetWindowLong ToolBox.hWnd, GWL_STYLE, L
1850 // SetParent ToolBox.hWnd, hWnd
1851 ToolBox.Show vbModeless, Me;
1855 FMark.ShowMarker True;
1859 static void menEnOff_Click()
1861 menEnOn.Checked = False;
1862 menEnOff.Checked = True;
1867 static void menEnOn_Click()
1869 menEnOn.Checked = True;
1870 menEnOff.Checked = False;
1875 static void menExit_Click()
1880 static void menFaster_Click()
1886 Debug.Assert(False);
1890 if (DemoFlag != 0) // demoplayback
1892 i = GetSpeedIndex(DeltaTDemo);
1894 If i < 2 Then i = 2;
1895 menDemoSpeed_Click (i);
1899 i = GetSpeedIndex(DeltaTPlay);
1901 If i < 2 Then i = 2;
1902 menPlaySpeed_Click (i);
1906 static void menSlower_Click()
1912 Debug.Assert(False);
1916 if (DemoFlag != 0) // demoplayback
1918 i = GetSpeedIndex(DeltaTDemo);
1920 If nSpeedCount < i Then i = nSpeedCount;
1921 menDemoSpeed_Click (i);
1925 i = GetSpeedIndex(DeltaTPlay);
1927 If nSpeedCount < i Then i = nSpeedCount;
1928 menPlaySpeed_Click (i);
1932 void menPlaySpeed_Click(int Index)
1936 // If NoDisplayFlag And (GameLoopRunning <> 0) Then
1937 // NoDisplayFlag = False
1940 // NoDisplayFlag = False
1941 for (i = menPlaySpeed.LBound; i <= menPlaySpeed.UBound; i++)
1944 menPlaySpeed(i).Checked = (Index == i);
1948 BlockingSpeed = False;
1949 DeltaTPlay = SpeedsByDelayUS[Index];
1951 // If DeltaTPlay < 0 Then
1954 // NoDisplayFlag = True
1958 void menDemoSpeed_Click(int Index)
1962 // If NoDisplayFlag And (GameLoopRunning <> 0) Then
1963 // NoDisplayFlag = False
1966 NoDisplayFlag = False;
1967 for (i = menDemoSpeed.LBound; i <= menDemoSpeed.UBound; i++)
1970 menDemoSpeed(i).Checked = (Index == i);
1974 BlockingSpeed = False;
1975 DeltaTDemo = SpeedsByDelayUS[Index];
1977 // If DeltaTPlay < 0 Then
1980 // NoDisplayFlag = True
1984 static void UpdateDeltaT()
1989 DeltaT = (DemoFlag != 0 ? DeltaTDemo : DeltaTDemo);
1994 NoDisplayFlag = True;
1998 if (NoDisplayFlag && GameLoopRunning != 0)
2000 NoDisplayFlag = False;
2005 NoDisplayFlag = False;
2010 static void menGravOff_Click()
2012 menGravOn.Checked = False;
2013 menGravOff.Checked = True;
2018 static void menGravOn_Click()
2020 menGravOn.Checked = True;
2021 menGravOff.Checked = False;
2026 static void menNew_Click()
2028 NewForm.Show vbModal, Me;
2029 CreateLevel(FieldWidth, FieldHeight);
2033 static void menNewStd_Click()
2035 CreateLevel(60, 24);
2039 static void menOpen_Click()
2044 // cmDlg.DefaultExt = "sp"
2048 (prevent compiler warning here due to suspected use of trigraph)
2050 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";
2053 LFilt = LastOpenFilter;
2054 cmDlg.FilterIndex = (0 < LFilt & LFilt < 5 ? LFilt : LFilt);
2055 if (FileExists(CurPath))
2056 cmDlg.InitDir = WithSlash(StripDir(CurPath));
2058 cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames;
2061 // --- On Error GoTo menOpenEH
2063 // --- On Error GoTo 0
2065 LFilt = cmDlg.FilterIndex;
2066 LastOpenFilter = LFilt;
2067 CurPath = cmDlg.FileName;
2069 FillFileList (CurPath);
2074 static void menOptions_Click()
2078 oFrm.Show vbModal, Me;
2080 picViewPort_Resize();
2083 static void menPanel_Click()
2086 PanelVisible = ! menPanel.Checked;
2090 void Let_PanelVisible(boolean NewVal)
2094 if (HidePanel != NewVal)
2097 HidePanel = ! NewVal;
2098 PanelTim.Enabled = True;
2101 static void DrawPauseLayer(long Layer)
2103 DirectDrawPalette Pal;
2108 // For Y = 0 To bmpStage.Height Step BaseWidth
2109 // For X = 0 To bmpStage.Width Step BaseWidth
2110 // Pause.TransparentDraw bmpStageHDC, X, Y, Layer
2113 // With Stage.Surface
2114 // Set Pal = .GetPalette
2115 // for i=1 to pal.GetEntries(
2116 // Stage.Surface.SetPalette
2119 static void menPaste_Click()
2126 static void menPause_Click()
2131 PauseMode = (PauseMode != 0 ? 0 : 0);
2134 if (IS_NOTHING(&OldPic, sizeof(OldPic)))
2135 OldPic = cmdPause.Picture;
2137 cmdPause.Picture = cmdPause.DownPicture;
2138 OldText = lblStatus.Caption;
2139 lblStatus = "Paused ...";
2143 cmdPause.Picture = OldPic;
2144 lblStatus.Caption = OldText;
2148 static void menPlayAll_Click()
2152 char *LogPath, *OutStr, *ReRecPath, *SPPath;
2156 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play) All Demos")
2158 cmdPlayAll.Caption = "Quit All";
2159 menPlayAll.Caption = "Quit All";
2160 FocusTim.Enabled = True;
2163 iMax = cmbFile.ListCount - 1;
2164 LogPath = StripDir(CurPath) & "/Error.Log";
2165 if (Dir(LogPath) != "")
2168 for (i = iMin; i <= iMax; i++)
2170 cmbFile.ListIndex = i;
2171 // If CurPath Like "*.sp" Or CurPath Like "*.mpx" Then
2175 ReRecPath = SPPath & ".ReRec";
2176 menPlayDemo_Click();
2178 // bEqual = FilesEqual(ReRecPath, SPPath)
2179 // If bEqual Then MayKill ReRecPath
2181 OutStr = cmbFile.List(i) & " -> ";
2183 if (Val(lblFrameCount) != GetTotalFramesOfDemo())
2185 OutStr = OutStr & "Error in GetTotalFramesOfDemo()! ";
2186 Debug.Assert(False);
2190 if ((LevelStatus == 1) && bEqual)
2192 OutStr = OutStr & "Success";
2196 OutStr = OutStr & "All Demos (float)Canceled";
2200 if (LevelStatus != 1)
2202 OutStr = OutStr & "### Level Failed ### (TimerVar == " & TimerVar & ")";
2207 OutStr = OutStr & "### ReRecording is binary different ###";
2212 FNum = fopen(LogPath, "ab");
2213 Print #FNum, OutStr;
2220 cmdPlayAll.Caption = "Play All Demos";
2221 menPlayAll.Caption = "Play All Demos";
2222 SettingsObject Settings;
2224 MySignature = Settings.Read("MySignature", "");
2225 FirstDemoByte = 0x81;
2230 if (menStop.Enabled)
2235 static void menRemSP_Click()
2241 static void menRestoreBorder_Click()
2246 static void menSave_Click()
2251 if (STRING_IS_LIKE(CurPath, TmpPath))
2254 if (STRING_IS_LIKE(CurPath, "") || STRING_IS_LIKE(CurPath, "*.dat"))
2260 if (STRING_IS_LIKE(CurPath, "*.sp"))
2266 if (! FileExists(CurPath) || STRING_IS_LIKE(CurPath, "Untitled"))
2273 Let_ModifiedFlag(False);
2276 static void menSaveAs_Click()
2279 FillFileList (CurPath);
2282 static boolean SaveAs()
2284 static boolean SaveAs;
2291 // cmDlg.DefaultExt = "sp"
2292 cmDlg.Filter = "MegaPlex Level (*.mpx)|*.mpx|SpeedFix Demo (*.sp)|*.sp";
2293 cmDlg.FilterIndex = LastSaveFilter;
2294 // If OrigPath Like "*.sp" Then cmDlg.FilterIndex = 1 Else cmDlg.FilterIndex = 0
2295 if (FileExists(OrigPath))
2297 cmDlg.InitDir = WithSlash(StripDir(OrigPath));
2298 cmDlg.InitDir = s.Read("LastSaveDir", cmDlg.InitDir);
2299 cmDlg.FileName = StripExtensionlessFileName(GetFileNameToSave());
2302 cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames;
2305 // --- On Error GoTo SaveAsEH
2307 // --- On Error GoTo 0
2309 LastSaveFilter = cmDlg.FilterIndex;
2310 FN = cmDlg.FileName;
2311 SettingsObject_Save("LastSaveDir", WithSlash(StripDir(FN)));
2312 if (STRING_IS_LIKE(FN, "*.sp"))
2316 else if (STRING_IS_LIKE(FN, "*.mpx"))
2321 Let_ModifiedFlag(False);
2329 static void menSelectAll_Click()
2331 FMark.SetPoint1 0, 0;
2332 FMark.SetPoint2 FieldWidth - 1, FieldHeight - 1;
2335 static void menShowLInfo_Click()
2339 Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")";
2340 if (DemoAvailable && bSignatureAvailable)
2341 Msg = Msg & vbNewLine & vbNewLine & gSignature;
2343 SignatureForm.Signature = Msg;
2344 SignatureForm.DelayMS = 5000;
2347 X = left + (Width - SignatureForm.Width) / 2;
2348 Y = top + (Height - SignatureForm.Height) / 2;
2349 SignatureForm.Move X, Y;
2350 SignatureForm.Show vbModeless, Me;
2354 static void menSoundFX_Click()
2357 menSoundFX.Checked = ! menSoundFX.Checked;
2358 FXOnFlag = (menSoundFX.Checked ? -1 : -1);
2364 // static void menPlay_Click()
2365 void menPlay_Click()
2370 boolean OldEditFlag;
2372 // Trace "MainForm", "--> menPlay_Click()"
2379 SignatureForm.DelayMS = 1;
2380 menPlay.Enabled = False;
2381 menPause.Enabled = True;
2382 menStop.Enabled = True;
2383 cmdPlay.Enabled = False;
2384 cmdPause.Enabled = True;
2385 cmdStop.Enabled = True;
2386 cmdPlayDemo.Enabled = False;
2387 menPlayDemo.Enabled = False;
2388 cmdRecordDemo.Enabled = False;
2389 menRec.Enabled = False;
2390 menFaster.Enabled = True;
2391 menSlower.Enabled = True;
2392 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play*"))
2394 cmdPlayAll.Enabled = False;
2395 menPlayAll.Enabled = False;
2398 cmbFile.Enabled = False;
2399 cmbLevel.Enabled = False;
2400 OldEditFlag = EditFlag;
2404 menEditMain.Enabled = False;
2405 if (DemoFlag == 0 && RecordDemoFlag == 0)
2406 lblStatus = "Playing";
2414 LastTick = T.TickNow();
2419 fpsTim.Enabled = True;
2432 subFetchAndInitLevelB();
2434 // Trace "MainForm", "CountDown 1"
2435 CountDown(2, (0 == DemoFlag));
2436 // Trace "MainForm", "Call GoPlay"
2440 // Trace "MainForm", "GoPlay returned"
2444 if (LevelStatus == 1)
2446 lblStatus = "(float)Success";
2450 lblStatus = "Try (float)again";
2455 // Trace "MainForm", "CountDown 1"
2456 CountDown(1, False);
2464 // Trace "MainForm", "Call subFetchAndInitLevel"
2466 subFetchAndInitLevel();
2468 // Trace "MainForm", "subFetchAndInitLevel returned"
2474 menEditMain.Enabled = True;
2478 // Trace "MainForm", "<-- menPlay_Click()"
2486 static void menPlayDemo_Click()
2490 lblStatus = "Demo Playback";
2492 if (LevelStatus != 1)
2493 lblStatus = "Demo Failed";
2498 static void menRec_Click()
2500 Trace("MainForm", "--> menRec_Click()");
2509 lblStatus.ForeColor = vbRed;
2510 lblStatus = "Recording Demo";
2511 // DemoBuffer = New DemoBufferObject; // (handle this later, if needed)
2512 Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer)));
2513 Trace("MainForm", "Call menPlayClick");
2515 Trace("MainForm", "menPlayClick returned");
2517 lblStatus.ForeColor = vbButtonText;
2519 Let_ModifiedFlag(True);
2520 if (! STRING_IS_LIKE(CurPath, TmpPath))
2526 LInfo.DemoRandomSeed = RecDemoRandomSeed;
2527 Trace("MainForm", "Call SaveMPX(TmpPath)");
2529 Trace("MainForm", "Set DemoBuffer == Nothing");
2530 SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer));
2531 Trace("MainForm", "Call subFetchAndInitLevel");
2532 subFetchAndInitLevel();
2533 cmdPlayDemo.Enabled = DemoAvailable;
2534 Trace("MainForm", "<-- menRec_Click()");
2537 static void menReRecordDemo_Click()
2547 lblStatus.ForeColor = vbRed;
2548 lblStatus = "ReRecording Demo";
2549 // DemoBuffer = New DemoBufferObject; // (handle this later, if needed)
2550 Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer)));
2552 lblStatus.ForeColor = vbButtonText;
2554 Let_ModifiedFlag(True);
2555 if (! STRING_IS_LIKE(CurPath, TmpPath))
2561 LInfo.DemoRandomSeed = RecDemoRandomSeed;
2563 SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer));
2564 subFetchAndInitLevel();
2567 void menStop_Click()
2574 fpsTim.Enabled = False;
2576 lblFps.Caption = "";
2577 menRec.Enabled = True;
2578 menPlay.Enabled = True;
2579 menPause.Enabled = False;
2580 menStop.Enabled = False;
2581 cmdPlay.Enabled = True;
2582 cmdPause.Enabled = False;
2583 cmdStop.Enabled = False;
2584 cmdRecordDemo.Enabled = True;
2585 cmdPlayDemo.Enabled = DemoAvailable;
2586 cmdPlayAll.Enabled = DemosAvailable;
2587 menPlayDemo.Enabled = DemoAvailable;
2588 menPlayAll.Enabled = DemosAvailable;
2589 menFaster.Enabled = False;
2590 menSlower.Enabled = False;
2591 cmbFile.Enabled = True;
2592 cmbLevel.Enabled = True;
2595 static void menStretch_Click(int Index)
2597 ReStretch(0.25 * Index);
2598 // DisplayLevel True
2601 static void menToolTips_Click()
2604 menToolTips.Checked = ! menToolTips.Checked;
2605 if (menToolTips.Checked)
2607 cmdPlay.ToolTipText = "Play Game (Space)";
2608 cmdPause.ToolTipText = "Pause (P)";
2609 cmdStop.ToolTipText = "Stop (Q)";
2610 cmdPlayDemo.ToolTipText = "Play demo (Ctrl+Space)";
2611 cmdRecordDemo.ToolTipText = "Record demo (Ctrl+R)";
2612 lblInfoCount.ToolTipText = "Number of infotrons needed";
2613 lblRedDiskCount.ToolTipText = "Number of red disks";
2614 cmbLevel.ToolTipText = "List of all levels in the file";
2615 cmbFile.ToolTipText = "List of files in current directory";
2616 lblFps.ToolTipText = "Animation speed in fps";
2617 lblFrameCount.ToolTipText = "Game time in frames";
2621 cmdPlay.ToolTipText = "";
2622 cmdPause.ToolTipText = "";
2623 cmdStop.ToolTipText = "";
2624 cmdPlayDemo.ToolTipText = "";
2625 cmdRecordDemo.ToolTipText = "";
2626 lblInfoCount.ToolTipText = "";
2627 lblRedDiskCount.ToolTipText = "";
2628 cmbLevel.ToolTipText = "";
2629 cmbFile.ToolTipText = "";
2630 lblFps.ToolTipText = "";
2631 lblFrameCount.ToolTipText = "";
2637 static void menTrim_Click()
2642 OldOPath = OrigPath;
2644 Tmp.SpecialPortCount = 0; // hack: all special ports are deleted
2646 CreateLevel(FMark.Width, FMark.Height);
2648 OrigPath = OldOPath;
2650 menSelectAll_Click();
2652 picViewPort_Resize();
2655 static void menZonkOff_Click()
2657 menZonkOn.Checked = False;
2658 menZonkOff.Checked = True;
2663 static void menZonkOn_Click()
2665 menZonkOn.Checked = True;
2666 menZonkOff.Checked = False;
2671 static void PanelTim_Timer()
2676 if (PanelSeq < Panel.Height && -1 < PanelSeq)
2678 PanelSeq = (ShowPanel != 0 ? PanelSeq + 2 : PanelSeq + 2);
2679 Tmp = ScaleHeight - Tmp + PanelSeq;
2681 picViewPort.Height = Tmp;
2685 PanelTim.Enabled = False;
2686 PanelSeq = (PanelSeq < 0 ? 0 : 0);
2687 ShowPanel = (ShowPanel == 0 ? 1 : 1);
2688 menPanel.Checked = (ShowPanel != 0);
2692 static void picKeys_MouseUp(int Button, int Shift, float X, float Y)
2694 FocusTim.Enabled = True;
2697 static void picMenu_Click()
2701 static void picPane_KeyDown(int KeyCode, int Shift)
2703 if (KeyCode < 0 || 255 < KeyCode)
2706 KeyState[KeyCode] = True;
2710 if (MouseButton == 0 && EditFlag)
2711 picPane.MousePointer = 15;
2729 if (DemoFlag != 0 && 2 == Shift)
2738 bCapturePane = ! bCapturePane;
2743 static void picPane_KeyUp(int KeyCode, int Shift)
2745 if (KeyCode < 0 || 255 < KeyCode)
2748 KeyState[KeyCode] = False;
2752 if (menFaster.Enabled)
2758 if (menSlower.Enabled)
2764 if (2 == Shift) // ctrl+space
2766 if (menPlayDemo.Enabled)
2767 menPlayDemo_Click();
2772 if (menPlay.Enabled)
2779 if (menStop.Enabled)
2792 if (menPause.Enabled && (Shift == 0))
2798 if (MouseButton == 0 && EditFlag)
2799 picPane.MousePointer = 0;
2804 static void picPane_MouseDown(int Button, int Shift, float X, float Y)
2808 MouseButton = Button;
2809 OldEdMode = EditMode;
2812 if (Button == 2 && Shift != 2)
2814 EditMode = edSelect;
2832 picPane.MousePointer = 5; // size
2833 UserDragFlag = True;
2837 SetField(X, Y, ToolBox.ASpriteIndex);
2841 FMark.SetPoint1 EdGetX(X), EdGetY(Y);
2846 EditMode = OldEdMode;
2849 static void picPane_MouseMove(int Button, int Shift, float X, float Y)
2854 OldEdMode = EditMode;
2857 if (EditFlag && Button == 2 && Shift != 2)
2859 EditMode = edSelect;
2873 Oldflag = NoDisplayFlag;
2874 NoDisplayFlag = False;
2875 ScrollTo(OSX - X + MDX, OSY - Y + MDY);
2877 NoDisplayFlag = Oldflag;
2881 SetField(X, Y, ToolBox.ASpriteIndex);
2885 FMark.SetPoint2 EdGetX(X), EdGetY(Y);
2890 EditMode = OldEdMode;
2893 static void picPane_MouseUp(int Button, int Shift, float X, float Y)
2895 MouseButton = MouseButton ^ Button;
2896 picPane.MousePointer = 0;
2897 UserDragFlag = False;
2898 if (menEditMain.Enabled && Button == 2)
2900 if (MDX == X && MDY == Y)
2901 PopupMenu menEditMain;
2905 static void picPane_Paint()
2909 Oldflag = NoDisplayFlag;
2910 NoDisplayFlag = False;
2912 NoDisplayFlag = Oldflag;
2915 static void ReStretch(float NewStretch)
2917 long BW2, LW, LH, i;
2921 Stretch = NewStretch;
2926 SET_TO_NOTHING(&Stage, sizeof(Stage));
2927 SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites));
2928 menStretch(Stretch / 0.25).Checked = False;
2929 Stretch = NewStretch;
2930 menStretch(Stretch / 0.25).Checked = True;
2931 // StretchWidth = BaseWidth ' * NewStretch
2932 // StretchWidth2 = StretchWidth \ 2
2933 // TwoPixels = 2 '* Stretch
2934 // StretchLoad Sprites, imgMpx.Picture, 16, 16
2935 BW2 = StretchWidth / 2;
2936 LW = (FieldWidth + 2) * BaseWidth; // StretchWidth
2937 LH = (FieldHeight + 2) * BaseWidth; // StretchWidth
2938 // i = bmpStage.CreateAtSize(LW, LH)
2939 // Stage = New DDScrollBuffer; // (handle this later, if needed)
2940 i = Stage.CreateAtSize(LW, LH, picPane.hWnd);
2941 // Set StretchedSprites = NormalSprites.GetStretchCopy(Stretch)
2942 ReLoadStretchSprites();
2943 if (i == 0 || IS_NOTHING(&StretchedSprites, sizeof(StretchedSprites)))
2945 // menStretch(Stretch / 0.5).Enabled = False
2947 ReStretch(Stretch - 0.25);
2952 StretchedSprites.DestXOff = 1 * BaseWidth; // StretchWidth
2953 StretchedSprites.DestYOff = 1 * BaseWidth; // StretchWidth
2954 Stage.DestXOff = 1 * StretchWidth;
2955 Stage.DestYOff = 1 * StretchWidth;
2956 StretchedSprites.DestinationSurface = Stage.Surface;
2958 if (Loaded && LevelLoaded)
2961 picViewPort_Resize();
2965 subCalculateScreenScrollPos();
2966 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
2974 static void SetScrollEdges()
2976 ScrollMinX = (DisplayMinX - 0.5) * Stretch * BaseWidth;
2977 ScrollMinY = (DisplayMinY - 0.5) * Stretch * BaseWidth;
2978 ScrollMaxX = (DisplayMaxX + 1.5) * Stretch * BaseWidth - picPane.Width;
2979 ScrollMaxY = (DisplayMaxY + 1.5) * Stretch * BaseWidth - picPane.Height;
2984 void DrawField(int X, int Y)
2989 Tmp = LowByte(PlayField16[tsi]);
2993 if (Tmp == fiRAM || Tmp == fiHardWare)
2994 Tmp = DisPlayField[tsi];
2996 if (Tmp == fiBug || Tmp == 40)
2997 Tmp = DisPlayField[tsi];
3001 if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak)
3002 Tmp = DisPlayField[tsi];
3005 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
3008 void DrawFieldAnimated(int X, int Y)
3013 Tmp = LowByte(PlayField16[tsi]);
3017 subDrawAnimatedSnikSnaks(tsi);
3021 subDrawAnimatedElectrons(tsi);
3025 // If 40 < Tmp Then Tmp = 0
3026 // If Tmp = fiRAM Or Tmp = fiHardWare Then Tmp = DisPlayField(tsi)
3027 // If Tmp = fiBug Or Tmp = 40 Then Tmp = DisPlayField(tsi)
3029 // If fiOrangeDisk < Tmp And Tmp < fiSnikSnak Then Tmp = DisPlayField(tsi)
3031 // StretchedSprites.BltEx StretchWidth * X, StretchWidth * Y, Tmp
3036 void DrawFieldNoAnimated(int X, int Y)
3041 Tmp = LowByte(PlayField16[tsi]);
3045 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace);
3049 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace);
3056 if (Tmp == fiRAM || Tmp == fiHardWare)
3057 Tmp = DisPlayField[tsi];
3059 if (Tmp == fiBug || Tmp == 40)
3060 Tmp = DisPlayField[tsi];
3064 if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak)
3065 Tmp = DisPlayField[tsi];
3068 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
3073 void DrawSprite(int X, int Y, int SpritePos)
3075 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, SpritePos);
3080 void InvalidateRect(long XMin, long YMin, long XMax, long YMax)
3084 // For Y = YMin To YMax
3085 // For X = XMin To XMax
3086 // Field(X, Y).GraphicsValid = 0
3091 static void picViewPort_MouseUp(int Button, int Shift, float X, float Y)
3093 FocusTim.Enabled = True;
3096 static void picViewPort_Paint()
3098 // Debug.Print "picViewPort_Paint()"
3101 static void picViewPort_Resize()
3103 long bdX, bdY, PanelVisibility;
3108 bdX = picFrame.Width - picFrame.ScaleWidth;
3109 bdY = picFrame.Height - picFrame.ScaleHeight;
3110 dx = Min(picViewPort.ScaleWidth - bdX, (DisplayWidth - 1) * Stretch * BaseWidth);
3112 dY = Min(picViewPort.ScaleHeight - bdX, (DisplayHeight - 1) * Stretch * BaseWidth);
3114 B = s.Read("LimitToOriginalFieldSize", False);
3115 PanelVisibility = 24 * (Panel.Height - PanelSeq - (float)1) / Panel.Height;
3118 dx = Min(320 * Stretch, dx);
3119 dY = Min((200 - PanelVisibility) * Stretch, dY);
3122 X = Max((picViewPort.ScaleWidth - dx) / 2, 0);
3123 Y = Max((picViewPort.ScaleHeight - dY) / 2, 0);
3124 picPane.Move X, Y, dx, dY;
3125 picFrame.Move X - bdX / 2, Y - bdY / 2, dx + bdX, dY + bdY;
3127 ScrollTo(ScrollX, ScrollY);
3128 // SizeTim.Interval = 1
3132 // Private Sub SizeTim_Timer()
3134 // SizeTim.Interval = 0
3135 // wdX = Max(0, picViewPort.ScaleWidth - picPane.Width) * Screen.TwipsPerPixelX
3136 // wdY = Max(0, picViewPort.ScaleHeight - picPane.Height) * Screen.TwipsPerPixelY
3137 // If (0 < wdX) Or (0 < wdY) Then
3138 // Move Left, Top, Width - wdX, Height - wdY
3142 static void LoadKeyIndicators()
3146 picKeys.BackColor = vbButtonFace;
3147 for (i = 2; i <= 5; i++)
3152 for (i = 1; i <= 5; i++)
3154 shpKey(i).FillColor = vbButtonFace;
3155 shpKey(i).Visible = True;
3158 shpKey(1).Move 7, 0;
3159 shpKey(2).Move 0, 7;
3160 shpKey(3).Move 7, 14;
3161 shpKey(4).Move 14, 7;
3162 shpKey(5).Move 7, 7;
3165 void ShowKey(int KeyVar)
3167 boolean State[5 + 1];
3171 boolean LastState[5 + 1];
3183 State[KeyVar] = True;
3189 State[KeyVar - 4] = True;
3193 for (i = 1; i <= 5; i++)
3196 if (Tmp ^ LastState[i])
3198 Col = (i == 5 ? vbRed : vbRed);
3199 shpKey(i).FillColor = (Tmp ? Col : Col);
3206 static void GetSettings()
3216 APath = WithSlash(App.Path);
3217 CurPath = s.Read("LastPath", APath);
3219 // window width and height
3220 X = s.Read("Width", Width);
3221 Y = s.Read("Height", Height);
3222 if (X < 0 Then X == 0: If Y < 0)
3225 if (Screen.Width < X)
3228 if (Screen.Height < Y)
3233 // window position and state
3234 X = s.Read("Left", left);
3235 Y = s.Read("Top", top);
3236 if (X < 0 Then X == 0: If Y < 0)
3239 if (Screen.Width < (X + Width))
3240 X = Screen.Width - Width;
3242 if (Screen.Height < (Y + Height))
3243 Y = Screen.Height - Height;
3247 WindowState = s.Read("WinState", vbNormal);
3249 Flag = s.Read("ShowToolTips", True);
3251 menToolTips_Click();
3253 menBorder.Checked = ! CBool(s.Read("ShowBorder", False));
3254 Flag = CBool(s.Read("AutoScroll", True));
3257 AutoScrollFlag = False;
3258 menAutoScroll.Checked = False;
3261 Flag = CBool(s.Read("SoundFX", True));
3262 FXOnFlag = (Flag ? -1 : -1);
3263 menSoundFX.Checked = Flag;
3264 SignatureDelay = CLng(s.Read("SignatureDelay", 3000));
3265 AllowRedDiskCheat = CInt(s.Read("AllowRedDiskCheat", 1));
3266 AllowEatRightRedDiskBug = CInt(s.Read("AllowEatRightRedDiskBug", 1));
3267 MySignature = s.Read("MySignature", "");
3269 X = s.Read("FrameDelayPlay", 1000000 / 35);
3270 i = GetSpeedIndex(X);
3271 menPlaySpeed_Click(i);
3272 X = s.Read("FrameDelayDemo", 1000000 / 35);
3273 i = GetSpeedIndex(X);
3274 menDemoSpeed_Click(i);
3276 i = s.Read("Stretch", 4);
3277 if (i < menStretch.LBound || menStretch.UBound < i)
3280 menStretch_Click (i);
3284 static void SaveSettings()
3290 s.Save "LastPath", (ModifiedFlag ? OrigPath : OrigPath);
3291 if (WindowState != vbMinimized)
3293 s.Save "Width", Width;
3294 s.Save "Height", Height;
3295 s.Save "Left", left;
3297 s.Save "WinState", WindowState;
3300 s.Save "ShowToolTips", menToolTips.Checked;
3301 s.Save "ShowBorder", menBorder.Checked;
3302 s.Save "AutoScroll", menAutoScroll.Checked;
3303 s.Save "SoundFX", menSoundFX.Checked;
3304 s.Save "SignatureDelay", SignatureDelay;
3305 s.Save "AllowRedDiskCheat", AllowRedDiskCheat;
3306 s.Save "AllowEatRightRedDiskBug", AllowEatRightRedDiskBug;
3307 s.Save "MySignature", MySignature;
3309 s.Save "FrameDelayPlay", DeltaTPlay;
3310 s.Save "FrameDelayDemo", DeltaTDemo;
3312 for (i = menStretch.LBound; i <= menStretch.UBound; i++)
3314 if (menStretch(i).Checked)
3318 s.Save "Stretch", i;
3323 void ReLoadStretchSprites()
3326 BitMapObject NBMP, SBMP;
3329 // If Stretch = 1 Then
3330 MpxBmp = App.Path & "/Mpx.bmp";
3332 // MpxBmp = App.Path & "\Mpx" & Stretch & ".bmp"
3333 // tmpMpxBmp = App.Path & "\Mpx.bmp"
3334 // If FileExists(MpxBmp) And FileExists(tmpMpxBmp) Then
3335 // If FileDateTime(MpxBmp) < FileDateTime(tmpMpxBmp) Then
3339 // If Not FileExists(MpxBmp) Then
3340 // MousePointer = 11
3341 // // Set NBMP = New BitMapObject // (handle this later, if needed)
3342 // tmpMpxBmp = App.Path & "\Mpx.bmp"
3343 // If Not FileExists(tmpMpxBmp) Then
3344 // ReportError "ReLoadStretchSprites", "File not found: " & tmpMpxBmp
3345 // MESSAGE_BOX("an error occured"); // MsgBox "File not found: " & tmpMpxBmp, vbCritical, "MegaPlex - Error"
3348 // NBMP.CreateFromFile tmpMpxBmp
3349 // Set SBMP = NBMP.GetStretchCopy(Stretch)
3350 // SBMP.SaveToFile MpxBmp
3351 // Set NBMP = Nothing
3352 // Set SBMP = Nothing
3356 // StretchedSprites = New DDSpriteBuffer; // (handle this later, if needed)
3357 if (! StretchedSprites.CreateFromFile(MpxBmp, 16, 16))
3358 SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites));
3361 void SaveSnapshot(currency Number)
3365 Path = CAT(WithSlash(App.Path), "Capture");
3369 Path = Path & "\" & Format(Number, "00000000") & ".bmp";
3370 SavePicture CaptureWindow(picPane.hWnd, True, 0, 0, picPane.ScaleWidth, picPane.ScaleHeight), Path;