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;
669 // --- Option Explicit
670 // --- Option Compare Text
672 long SetParent(long hWndChild, long hWndNewParent);
673 long SetWindowLong(long hWnd, long nIndex, long dwNewLong);
674 long GetWindowLong(long hWnd, long nIndex);
675 long GetTempPath(long nBufferLength, char *lpBuffer);
676 long GetWindowText(long hWnd, char *lpString, long cch);
678 #define GWL_STYLE ((-16))
679 #define WS_CHILD (0x40000000)
680 #define WS_POPUP (0x80000000)
682 // [UNCOMMENTED] Dim StretchWidth2&
686 long OSX, OSY, MDX, MDY;
691 boolean Loaded, DemosAvailable;
693 #define nSpeedCount (17)
694 int SpeedsByDelayUS[nSpeedCount + 1];
695 #define DefaultSpeedIndex (12)
697 currency LastTick, LastFrame;
700 const char *AppTitle = "MegaPlex";
702 static char *GetSpeedDescriptionFPS(currency FrameDelayUS)
704 static char *GetSpeedDescriptionFPS;
708 if (FrameDelayUS == 0)
710 GetSpeedDescriptionFPS = "Fastest possible";
711 return GetSpeedDescriptionFPS;
714 if (FrameDelayUS < 0)
716 GetSpeedDescriptionFPS = "! display (even faster)";
717 return GetSpeedDescriptionFPS;
720 FPS = 1000000 / FrameDelayUS;
721 GetSpeedDescriptionFPS = CAT(INT_TO_STR(FPS), " fps");
723 GetSpeedDescriptionFPS = CAT(GetSpeedDescriptionFPS, "(Default)");
725 return GetSpeedDescriptionFPS;
728 static int InitSpeeds()
730 static int InitSpeeds;
732 SpeedsByDelayUS[1] = -1; // no display
733 SpeedsByDelayUS[2] = 0; // fastest possible
734 SpeedsByDelayUS[3] = 1000000 / 700; // 700 fps
735 SpeedsByDelayUS[4] = 1000000 / 500; // 500 fps
736 SpeedsByDelayUS[5] = 1000000 / 350; // 350 fps
737 SpeedsByDelayUS[6] = 1000000 / 250; // 250 fps
738 SpeedsByDelayUS[7] = 1000000 / 200; // etc.
739 SpeedsByDelayUS[8] = 1000000 / 150;
740 SpeedsByDelayUS[9] = 1000000 / 100;
741 SpeedsByDelayUS[10] = 1000000 / 70;
742 SpeedsByDelayUS[11] = 1000000 / 50;
743 SpeedsByDelayUS[12] = 1000000 / 35; // default
744 SpeedsByDelayUS[13] = 1000000 / 25;
745 SpeedsByDelayUS[14] = 1000000 / 20;
746 SpeedsByDelayUS[15] = 1000000 / 10;
747 SpeedsByDelayUS[16] = 1000000 / 5;
748 SpeedsByDelayUS[17] = 1000000 / 1;
753 static int GetSpeedIndex(long DelayUS)
755 static int GetSpeedIndex;
761 MinIdx = DefaultSpeedIndex;
763 for (i = 1; i <= nSpeedCount; i++)
765 Diff = Abs(DelayUS - SpeedsByDelayUS[i]);
773 GetSpeedIndex = MinIdx;
775 return GetSpeedIndex;
780 static long Get_LastOpenFilter()
782 static long LastOpenFilter;
786 LastOpenFilter = s.Read("LastOpenFilter", 1);
788 return LastOpenFilter;
791 static void Let_LastOpenFilter(long NewVal)
795 SettingsObject_Save("LastOpenFilter", NewVal);
798 static long Get_LastSaveFilter()
800 static long LastSaveFilter;
804 LastSaveFilter = s.Read("LastSaveFilter", 1);
806 return LastSaveFilter;
809 static void Let_LastSaveFilter(long NewVal)
813 SettingsObject_Save("LastSaveFilter", NewVal);
818 static void CountDown(long HalfSeconds, int bDisplayBar)
823 long LeftPos, TopPos, RightPos, MaxWidth; // , MaxHeight&
825 dT = HalfSeconds * 500;
827 LeftPos = cmbFile.left;
828 TopPos = cmbFile.top - shpProgress.Height - cmbFile.top / 8;
829 RightPos = lblFrameCount.left + lblFrameCount.Width;
830 MaxWidth = RightPos - LeftPos;
831 // MaxHeight = lblFrameCount.Top - TopPos + lblFrameCount.Height + 4
834 shpProgress.Move(LeftPos, TopPos, 0); // , MaxHeight
835 shpProgress.Visible = True;
838 for (i = 1; i <= 200; i++)
845 shpProgress.Width = MaxWidth * i / 100;
849 k = MaxWidth * (i - 100) / 100;
850 shpProgress.Move(k, TopPos, RightPos - k);
854 T.DelayMS(Delta, False);
857 shpProgress.Visible = False;
861 static char *GetValidTempPath()
863 static char *GetValidTempPath;
868 GetValidTempPath = "";
870 TP = String(nSize, Chr(32));
871 L = GetTempPath(nSize, TP);
874 // buffer was too small, retry with a properly sized buffer:
876 TP = String(nSize, Chr(32));
877 L = GetTempPath(nSize, TP);
880 TP = SlashLess(left(TP, L));
881 if ((0 == L) || (! IsDir(TP)))
883 // no valid temp path can be retrieved from the system --> create our own
884 TP = CAT(WithSlash(App.Path), "Temp");
888 // --- On Error Resume Next
890 if (! IS_NOTHING(&Err, sizeof(Err)))
892 MESSAGE_BOX("an error occured"); // MsgBox "cannot create directory for temporary files " & TP, vbCritical, "MegaPlex - Error";
893 return GetValidTempPath;
896 // --- On Error GoTo 0
902 GetValidTempPath = TP;
904 return GetValidTempPath;
909 static char *GetMyTempFileName()
911 static char *GetMyTempFileName;
915 (char *)T = Hex(hWnd);
921 GetMyTempFileName = CAT("tmp0x", CAT((char *)T, ".mpx"));
923 return GetMyTempFileName;
926 static long GetHwndFromTempFileName(char *TmpFile)
928 static long GetHwndFromTempFileName;
935 GetHwndFromTempFileName = 0;
936 FN = StripFileName(TmpFile);
940 return GetHwndFromTempFileName;
943 NumString = right(FN, L - LP);
945 NumString = left(NumString, 8);
947 NumString = CAT("&H", NumString);
948 GetHwndFromTempFileName = Val(NumString);
950 return GetHwndFromTempFileName;
953 static void CleanTempDir(char *TmpDir)
957 MFN = GetMyTempFileName();
958 MayKill(CAT(WithSlash(TmpDir), MFN));
959 FN = Dir(CAT(WithSlash(TmpDir), "tmp0x*.mpx"));
962 if (STRING_IS_LIKE(FN, "tmp0x*.mpx"))
964 if (! InstanceStillRunning(FN))
965 MayKill(CAT(WithSlash(TmpDir), FN));
968 FN = Dir_Without_Args();
972 static boolean InstanceStillRunning(char *TmpFile)
974 static boolean InstanceStillRunning;
976 long OtherHwnd, nSize, L;
979 InstanceStillRunning = False;
980 OtherHwnd = GetHwndFromTempFileName(TmpFile);
982 Cap = String(nSize, Chr(32));
983 L = GetWindowText(OtherHwnd, Cap, nSize);
984 if ((L == 0) || (nSize < L))
985 return InstanceStillRunning;
987 if (STRING_IS_LIKE(Cap, CAT(AppTitle, "*")))
988 InstanceStillRunning = True;
990 return InstanceStillRunning;
1012 if (! menBorder.Checked)
1018 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1020 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1022 DrawFieldNoAnimated(X, Y);
1026 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1028 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1030 DrawFieldAnimated(X, Y);
1037 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1039 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1049 static void cmbFile_Click()
1051 CurPath = CAT(StripDir(OrigPath), CAT("/", cmbFile.List(cmbFile.ListIndex)));
1053 FillLevelList(CurPath, LevelNumber);
1054 if (STRING_IS_LIKE(OrigPath, "*.mpx") || STRING_IS_LIKE(OrigPath, "*.sp"))
1056 menSave.Enabled = True;
1060 menSave.Enabled = False;
1064 static void cmbFile_KeyDown(int KeyCode, int Shift)
1066 picPane_KeyDown(KeyCode, Shift);
1069 static void cmbFile_KeyUp(int KeyCode, int Shift)
1071 picPane_KeyUp(KeyCode, Shift);
1074 static int GetFileNameToSave()
1076 static int GetFileNameToSave;
1080 (char *)T = StripFileName(OrigPath);
1081 if (STRING_IS_LIKE(T, "*.dat") || STRING_IS_LIKE(T, "*.d##"))
1083 T = "Level" & Format(LevelNumber, "#000");
1086 GetFileNameToSave = T;
1088 return GetFileNameToSave;
1091 static void cmbLevel_Click()
1102 // //////////////////////////////////////////////////////////////////
1107 Msg = "Save changes to " & GetFileNameToSave() & " ?";
1108 Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - close level");
1109 if (Res == vbCancel) // fallback
1113 // --- On Error Resume Next
1114 cmbLevel.ListIndex = LastIndex;
1115 // --- On Error GoTo 0
1118 Debug.Assert cmbLevel.ListIndex = LastIndex;
1125 // oldCurPath = CurPath
1126 if (FileExists(OrigPath) && menSave.Enabled)
1132 if (! SaveAs()) // fallback
1136 // --- On Error Resume Next
1137 cmbLevel.ListIndex = LastIndex;
1138 // --- On Error GoTo 0
1141 Debug.Assert cmbLevel.ListIndex = LastIndex;
1146 // CurPath = oldCurPath
1149 Let_ModifiedFlag(False);
1153 // //////////////////////////////////////////////////////////////////
1155 LevelNumber = cmbLevel.ListIndex + 1;
1159 Oldflag = NoDisplayFlag;
1160 NoDisplayFlag = False;
1161 subFetchAndInitLevel();
1162 if ((0 < SignatureDelay) && ! (WindowState == vbMinimized))
1164 Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")";
1165 if (DemoAvailable && bSignatureAvailable)
1166 Msg = Msg & vbNewLine & vbNewLine & gSignature;
1168 SignatureForm.Signature = Msg;
1169 SignatureForm.DelayMS = SignatureDelay;
1172 X = left + (Width - SignatureForm.Width) / 2;
1173 Y = top + (Height - SignatureForm.Height) / 2;
1174 SignatureForm.Move X, Y;
1175 SignatureForm.Show vbModeless, Me;
1179 lblStatus = "MegaPlex";
1180 lblFrameCount = GetTotalFramesOfDemo();
1187 NoDisplayFlag = Oldflag;
1188 LastIndex = cmbLevel.ListIndex;
1192 menPlayDemo.Enabled = DemoAvailable;
1193 cmdPlayDemo.Enabled = DemoAvailable;
1196 static void cmblevel_KeyDown(int KeyCode, int Shift)
1198 if (GameLoopRunning != 0)
1204 if (menPlay.Enabled == True)
1210 picPane_KeyDown(KeyCode, Shift);
1215 static void cmbLevel_KeyUp(int KeyCode, int Shift)
1217 picPane_KeyUp(KeyCode, Shift);
1220 static void cmdPause_Click()
1225 static void cmdPause_MouseUp(int Button, int Shift, float X, float Y)
1227 FocusTim.Enabled = True;
1230 static void cmdPlay_Click()
1232 if (menPlay.Enabled)
1236 static void cmdPlay_MouseUp(int Button, int Shift, float X, float Y)
1238 FocusTim.Enabled = True;
1241 static void cmdPlayAll_Click()
1246 static void cmdPlayAll_MouseUp(int Button, int Shift, float X, float Y)
1248 FocusTim.Enabled = True;
1251 static void cmdPlayDemo_Click()
1253 menPlayDemo_Click();
1256 static void cmdPlayDemo_MouseUp(int Button, int Shift, float X, float Y)
1258 FocusTim.Enabled = True;
1261 static void cmdRecordDemo_Click()
1267 static void cmdRecordDemo_MouseUp(int Button, int Shift, float X, float Y)
1269 FocusTim.Enabled = True;
1272 static void cmdStop_Click()
1274 if (menStop.Enabled)
1278 static void cmdStop_MouseUp(int Button, int Shift, float X, float Y)
1280 FocusTim.Enabled = True;
1283 static void FocusTim_Timer()
1285 FocusTim.Enabled = False;
1287 // --- On Error Resume Next
1291 static void Form_KeyDown(int KeyCode, int Shift)
1293 picPane_KeyDown(KeyCode, Shift);
1296 static void Form_KeyUp(int KeyCode, int Shift)
1298 picPane_KeyUp(KeyCode, Shift);
1303 static void Form_Load()
1317 // FMark = New MarkerObject; // (handle this later, if needed)
1324 TmpPath = GetValidTempPath();
1328 CleanTempDir(TmpPath);
1329 TmpPath = CAT(WithSlash(TmpPath), GetMyTempFileName());
1333 InitDirectX(hWnd, picPane.hWnd);
1335 // AllowRedDiskCheat = 1
1336 MpxBmp = CAT(App.Path, "/mpx.bmp");
1337 // // Set NormalSprites = New DDSpriteBuffer // (handle this later, if needed)
1338 // NormalSprites.CreateFromFile MPXBMP, 16, 16
1340 Field = REDIM_2D(sizeof(int), 0, 2 + 1 - 1, 0, 2 + 1 - 1);
1342 picViewPort.ScaleMode = vbPixels;
1349 LoadKeyIndicators();
1353 FillFileList(CurPath);
1354 if (s.Read("ShowSplash", True))
1356 // frmSplash.EnableTimer
1357 frmSplash.Show vbModal, Me;
1365 static void FillLevelList(char *Path, int LevelIndex)
1367 long FNum, LevLen, i, iMax;
1371 if (! FileExists(Path))
1374 if ((STRING_IS_LIKE(Path, "*.D??")) || (STRING_IS_LIKE(Path, "*.sp")))
1378 FNum = fopen(Path, "rb");
1381 FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo));
1382 cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i;
1383 if (STRING_IS_LIKE(Path, "*.D??"))
1385 while (!(EOF(FNum)))
1388 FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo));
1392 cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i;
1396 if (LevelIndex <= i && 0 < LevelIndex)
1401 cmbLevel.ListIndex = i;
1405 else if (STRING_IS_LIKE(Path, "*.mpx"))
1409 FNum = fopen(Path, "rb");
1414 for (i = 1; i <= LevelCount; i++)
1416 if (! MpxLoadLInfo(CInt(i)))
1419 cmbLevel.AddItem Format(i, "#000") & " " & LInfo.LevelTitle, i - 1;
1425 if (LevelIndex < i && 0 < LevelIndex)
1430 if (i < cmbLevel.ListCount)
1431 cmbLevel.ListIndex = i;
1438 static void FillFileList(char *Path)
1440 long FNum, LevLen, i;
1442 char *TFile, *TPath, *OFile;
1447 TPath = WithSlash(StripDir(Path));
1448 OFile = StripFileName(Path);
1449 TFile = Dir(TPath & "*.D??");
1452 if (FileLen(TPath & TFile) == 170496)
1454 cmbFile.AddItem TFile;
1460 TFile = Dir(TPath & "*.SP");
1463 nDemoCount = nDemoCount + 1;
1464 cmbFile.AddItem TFile;
1468 TFile = Dir(TPath & "*.mpx");
1471 nDemoCount = nDemoCount + 1;
1472 cmbFile.AddItem TFile;
1476 i = cmbFile.ListCount - 1;
1477 if (0 < cmbFile.ListCount)
1481 if ((cmbFile.List(i) Like OFile) || i == 0)
1488 cmbFile.ListIndex = i;
1491 DemosAvailable = (1 < nDemoCount);
1492 menPlayAll.Enabled = DemosAvailable;
1493 cmdPlayAll.Enabled = DemosAvailable;
1496 static void LoadMenus()
1501 menFaster.Enabled = False;
1502 menSlower.Enabled = False;
1504 for (i = 1; i <= nSpeedCount; i++)
1508 Load menPlaySpeed(i);
1509 Load menDemoSpeed(i);
1512 menPlaySpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]);
1513 menDemoSpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]);
1517 menStretch(1).Caption = Format(0.25, "#0.00") & ";
1519 if (Stretch == 0.25)
1520 menStretch(1).Checked = True;
1522 for (i = 2; i <= 20; i++)
1525 menStretch(i).Caption = Format(0.25 * i, "#0.00") & ";
1527 menStretch(i).Checked = ((i * 0.25) == Stretch);
1530 menSp.Enabled = False;
1534 // Function DisplayShift&()
1535 // Dim X&, Y&, A&, B&, iX&, iiX&, LD&
1538 // For A = 0 To picPane.ScaleWidth
1539 // For Y = DisplayMinY To DisplayMaxY
1540 // For X = DisplayMinX To DisplayMaxX
1541 // iX = StretchWidth * X + A
1542 // Sprite = Field(X, Y).SpritePos
1543 // If picPane.ScaleWidth < (iX + 1) Then
1544 // iX = iX - picPane.ScaleWidth
1546 // If picPane.ScaleWidth < (iX + 1 + BaseWidth) Then
1547 // iiX = iX - picPane.ScaleWidth
1548 // Sprites.BitBltSprite picPane.hdc, iiX, StretchWidth * Y, Sprite
1551 // Sprites.BitBltSprite picPane.hdc, iX, StretchWidth * Y, Sprite
1554 // DisplayShift = DisplayShift + 1
1559 static void Form_Paint()
1561 // Debug.Print "Form_Paint()"
1564 static void Form_Resize()
1569 if (WindowState == vbMinimized || ! Loaded)
1573 // NW = ScaleWidth - 2 * Space: If NW < 0 Then NW = 0
1574 // NH = ScaleHeight - 3 * Space - cmbLevel.Height: If NH < 0 Then NH = 0
1575 // picViewPort.Move Space, Space, NW, NH
1576 Tmp = (ShowPanel != 0 ? ScaleHeight - Panel.Height : ScaleHeight - Panel.Height);
1580 picViewPort.Move 0, 0, ScaleWidth, Tmp;
1581 // Tmp = 2 * Space + picViewPort.Height
1583 Panel.left = (ScaleWidth - Panel.Width) / 2;
1584 // 'cmdNormal.Top = 2 * Space + picViewPort.Height
1585 // cmbLevel.Top = Tmp
1586 // lblRedDiskCount.Top = Tmp
1587 // lblInfoCount.Top = Tmp
1588 // picKeys.Top = Tmp
1589 // lblFrameCount.Top = Tmp
1590 // cmdPlayAll.Top = Tmp
1595 static void DrawFrame(int Delta)
1597 int i, LX, tY, RX, BY;
1601 RX = FieldWidth - Delta;
1602 BY = FieldHeight - Delta;
1603 DrawSprite(LX, tY, posFrameCorner);
1604 DrawSprite(LX, BY, posFrameCorner);
1605 DrawSprite(RX, tY, posFrameCorner);
1606 DrawSprite(RX, BY, posFrameCorner);
1607 for (i = LX + 1; i <= RX - 1; i++)
1609 DrawSprite(i, tY, posFrameHorizontal);
1610 DrawSprite(i, BY, posFrameHorizontal);
1613 for (i = tY + 1; i <= BY - 1; i++)
1615 DrawSprite(LX, i, posFrameVertical);
1616 DrawSprite(RX, i, posFrameVertical);
1620 static void RestoreFrame()
1622 int i, LX, tY, RX, BY;
1626 RX = FieldWidth - 1;
1627 BY = FieldHeight - 1;
1628 for (i = LX; i <= RX; i++)
1634 for (i = tY + 1; i <= BY - 1; i++)
1643 static void Form_Unload(int Cancel)
1647 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Quit*"))
1652 if (menEdit.Checked)
1660 Msg = "Save changes to " & GetFileNameToSave() & " ?";
1661 Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - closing");
1662 if (Res == vbCancel)
1670 if (FileExists(OrigPath) && menSave.Enabled)
1681 if (FileExists(TmpPath) || ModifiedFlag)
1687 ReleaseDirectDraw();
1692 static void fpsTim_Timer()
1697 count5 = count5 + 1;
1700 TickDiff = T.TickDiffUS(LastTick);
1701 lblFps.Caption = CLng(Round((1000000 * (TimerVar - LastFrame)) / (TickDiff), 0));
1702 LastFrame = TimerVar;
1703 LastTick = T.TickNow();
1707 // If NoDisplayFlag Then lblFrameCount = TimerVar
1708 lblFrameCount = TimerVar;
1711 static void menAbout_Click()
1713 frmSplash.Show vbModal, Me;
1716 static void menAutoScroll_Click()
1719 menAutoScroll.Checked = ! menAutoScroll.Checked;
1720 AutoScrollFlag = menAutoScroll.Checked;
1724 static void menBorder_Click()
1726 if (menBorder.Checked)
1728 menBorder.Checked = False;
1730 DisplayMaxX = FieldWidth - 2;
1731 DisplayWidth = FieldWidth;
1733 DisplayMaxY = FieldHeight - 2;
1734 DisplayHeight = FieldHeight;
1735 if (Loaded && LevelLoaded)
1741 menBorder.Checked = True;
1743 DisplayMaxX = FieldWidth - 1;
1744 DisplayWidth = FieldWidth + 2;
1746 DisplayMaxY = FieldHeight - 1;
1747 DisplayHeight = FieldHeight + 2;
1748 if (Loaded && LevelLoaded)
1753 // DisplayLevel True
1756 void SetDisplayRegion()
1758 if (! menBorder.Checked)
1761 DisplayMaxX = FieldWidth - 2;
1762 DisplayWidth = FieldWidth;
1764 DisplayMaxY = FieldHeight - 2;
1765 DisplayHeight = FieldHeight;
1773 DisplayMaxX = FieldWidth - 1;
1774 DisplayWidth = FieldWidth + 2;
1776 DisplayMaxY = FieldHeight - 1;
1777 DisplayHeight = FieldHeight + 2;
1783 static void menCopy_Click()
1788 void menEdit_Click()
1792 if (menEdit.Checked)
1794 menEdit.Checked = False;
1801 FMark.ShowMarker False;
1802 picViewPort.MousePointer = 0;
1805 if (! STRING_IS_LIKE(CurPath, TmpPath))
1827 if (! STRING_IS_LIKE(CurPath, TmpPath))
1836 subFetchAndInitLevel();
1837 menEdit.Checked = True;
1840 // ScaleMode = vbTwips
1841 ToolBox.Move (Width - ToolBox.Width) / 2, Height - ToolBox.Height;
1842 // ScaleMode = vbPixels
1843 // L = GetWindowLong(ToolBox.hWnd, GWL_STYLE)
1844 // L = L And (Not WS_POPUP)
1845 // L = L Or WS_CHILD
1846 // SetWindowLong ToolBox.hWnd, GWL_STYLE, L
1847 // SetParent ToolBox.hWnd, hWnd
1848 ToolBox.Show vbModeless, Me;
1852 FMark.ShowMarker True;
1856 static void menEnOff_Click()
1858 menEnOn.Checked = False;
1859 menEnOff.Checked = True;
1864 static void menEnOn_Click()
1866 menEnOn.Checked = True;
1867 menEnOff.Checked = False;
1872 static void menExit_Click()
1877 static void menFaster_Click()
1883 Debug.Assert(False);
1887 if (DemoFlag != 0) // demoplayback
1889 i = GetSpeedIndex(DeltaTDemo);
1891 If i < 2 Then i = 2;
1892 menDemoSpeed_Click (i);
1896 i = GetSpeedIndex(DeltaTPlay);
1898 If i < 2 Then i = 2;
1899 menPlaySpeed_Click (i);
1903 static void menSlower_Click()
1909 Debug.Assert(False);
1913 if (DemoFlag != 0) // demoplayback
1915 i = GetSpeedIndex(DeltaTDemo);
1917 If nSpeedCount < i Then i = nSpeedCount;
1918 menDemoSpeed_Click (i);
1922 i = GetSpeedIndex(DeltaTPlay);
1924 If nSpeedCount < i Then i = nSpeedCount;
1925 menPlaySpeed_Click (i);
1929 void menPlaySpeed_Click(int Index)
1933 // If NoDisplayFlag And (GameLoopRunning <> 0) Then
1934 // NoDisplayFlag = False
1937 // NoDisplayFlag = False
1938 for (i = menPlaySpeed.LBound; i <= menPlaySpeed.UBound; i++)
1941 menPlaySpeed(i).Checked = (Index == i);
1945 BlockingSpeed = False;
1946 DeltaTPlay = SpeedsByDelayUS[Index];
1948 // If DeltaTPlay < 0 Then
1951 // NoDisplayFlag = True
1955 void menDemoSpeed_Click(int Index)
1959 // If NoDisplayFlag And (GameLoopRunning <> 0) Then
1960 // NoDisplayFlag = False
1963 NoDisplayFlag = False;
1964 for (i = menDemoSpeed.LBound; i <= menDemoSpeed.UBound; i++)
1967 menDemoSpeed(i).Checked = (Index == i);
1971 BlockingSpeed = False;
1972 DeltaTDemo = SpeedsByDelayUS[Index];
1974 // If DeltaTPlay < 0 Then
1977 // NoDisplayFlag = True
1981 static void UpdateDeltaT()
1986 DeltaT = (DemoFlag != 0 ? DeltaTDemo : DeltaTDemo);
1991 NoDisplayFlag = True;
1995 if (NoDisplayFlag && GameLoopRunning != 0)
1997 NoDisplayFlag = False;
2002 NoDisplayFlag = False;
2007 static void menGravOff_Click()
2009 menGravOn.Checked = False;
2010 menGravOff.Checked = True;
2015 static void menGravOn_Click()
2017 menGravOn.Checked = True;
2018 menGravOff.Checked = False;
2023 static void menNew_Click()
2025 NewForm.Show vbModal, Me;
2026 CreateLevel(FieldWidth, FieldHeight);
2030 static void menNewStd_Click()
2032 CreateLevel(60, 24);
2036 static void menOpen_Click()
2041 // cmDlg.DefaultExt = "sp"
2045 (prevent compiler warning here due to suspected use of trigraph)
2047 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";
2050 LFilt = LastOpenFilter;
2051 cmDlg.FilterIndex = (0 < LFilt & LFilt < 5 ? LFilt : LFilt);
2052 if (FileExists(CurPath))
2053 cmDlg.InitDir = WithSlash(StripDir(CurPath));
2055 cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames;
2058 // --- On Error GoTo menOpenEH
2060 // --- On Error GoTo 0
2062 LFilt = cmDlg.FilterIndex;
2063 LastOpenFilter = LFilt;
2064 CurPath = cmDlg.FileName;
2066 FillFileList (CurPath);
2071 static void menOptions_Click()
2075 oFrm.Show vbModal, Me;
2077 picViewPort_Resize();
2080 static void menPanel_Click()
2083 PanelVisible = ! menPanel.Checked;
2087 void Let_PanelVisible(boolean NewVal)
2091 if (HidePanel != NewVal)
2094 HidePanel = ! NewVal;
2095 PanelTim.Enabled = True;
2098 static void DrawPauseLayer(long Layer)
2100 DirectDrawPalette Pal;
2105 // For Y = 0 To bmpStage.Height Step BaseWidth
2106 // For X = 0 To bmpStage.Width Step BaseWidth
2107 // Pause.TransparentDraw bmpStageHDC, X, Y, Layer
2110 // With Stage.Surface
2111 // Set Pal = .GetPalette
2112 // for i=1 to pal.GetEntries(
2113 // Stage.Surface.SetPalette
2116 static void menPaste_Click()
2123 static void menPause_Click()
2128 PauseMode = (PauseMode != 0 ? 0 : 0);
2131 if (IS_NOTHING(&OldPic, sizeof(OldPic)))
2132 OldPic = cmdPause.Picture;
2134 cmdPause.Picture = cmdPause.DownPicture;
2135 OldText = lblStatus.Caption;
2136 lblStatus = "Paused ...";
2140 cmdPause.Picture = OldPic;
2141 lblStatus.Caption = OldText;
2145 static void menPlayAll_Click()
2149 char *LogPath, *OutStr, *ReRecPath, *SPPath;
2153 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play) All Demos")
2155 cmdPlayAll.Caption = "Quit All";
2156 menPlayAll.Caption = "Quit All";
2157 FocusTim.Enabled = True;
2160 iMax = cmbFile.ListCount - 1;
2161 LogPath = StripDir(CurPath) & "/Error.Log";
2162 if (Dir(LogPath) != "")
2165 for (i = iMin; i <= iMax; i++)
2167 cmbFile.ListIndex = i;
2168 // If CurPath Like "*.sp" Or CurPath Like "*.mpx" Then
2172 ReRecPath = SPPath & ".ReRec";
2173 menPlayDemo_Click();
2175 // bEqual = FilesEqual(ReRecPath, SPPath)
2176 // If bEqual Then MayKill ReRecPath
2178 OutStr = cmbFile.List(i) & " -> ";
2180 if (Val(lblFrameCount) != GetTotalFramesOfDemo())
2182 OutStr = OutStr & "Error in GetTotalFramesOfDemo()! ";
2183 Debug.Assert(False);
2187 if ((LevelStatus == 1) && bEqual)
2189 OutStr = OutStr & "Success";
2193 OutStr = OutStr & "All Demos (float)Canceled";
2197 if (LevelStatus != 1)
2199 OutStr = OutStr & "### Level Failed ### (TimerVar == " & TimerVar & ")";
2204 OutStr = OutStr & "### ReRecording is binary different ###";
2209 FNum = fopen(LogPath, "ab");
2210 Print #FNum, OutStr;
2217 cmdPlayAll.Caption = "Play All Demos";
2218 menPlayAll.Caption = "Play All Demos";
2219 SettingsObject Settings;
2221 MySignature = Settings.Read("MySignature", "");
2222 FirstDemoByte = 0x81;
2227 if (menStop.Enabled)
2232 static void menRemSP_Click()
2238 static void menRestoreBorder_Click()
2243 static void menSave_Click()
2248 if (STRING_IS_LIKE(CurPath, TmpPath))
2251 if (STRING_IS_LIKE(CurPath, "") || STRING_IS_LIKE(CurPath, "*.dat"))
2257 if (STRING_IS_LIKE(CurPath, "*.sp"))
2263 if (! FileExists(CurPath) || STRING_IS_LIKE(CurPath, "Untitled"))
2270 Let_ModifiedFlag(False);
2273 static void menSaveAs_Click()
2276 FillFileList (CurPath);
2279 static boolean SaveAs()
2281 static boolean SaveAs;
2288 // cmDlg.DefaultExt = "sp"
2289 cmDlg.Filter = "MegaPlex Level (*.mpx)|*.mpx|SpeedFix Demo (*.sp)|*.sp";
2290 cmDlg.FilterIndex = LastSaveFilter;
2291 // If OrigPath Like "*.sp" Then cmDlg.FilterIndex = 1 Else cmDlg.FilterIndex = 0
2292 if (FileExists(OrigPath))
2294 cmDlg.InitDir = WithSlash(StripDir(OrigPath));
2295 cmDlg.InitDir = s.Read("LastSaveDir", cmDlg.InitDir);
2296 cmDlg.FileName = StripExtensionlessFileName(GetFileNameToSave());
2299 cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames;
2302 // --- On Error GoTo SaveAsEH
2304 // --- On Error GoTo 0
2306 LastSaveFilter = cmDlg.FilterIndex;
2307 FN = cmDlg.FileName;
2308 SettingsObject_Save("LastSaveDir", WithSlash(StripDir(FN)));
2309 if (STRING_IS_LIKE(FN, "*.sp"))
2313 else if (STRING_IS_LIKE(FN, "*.mpx"))
2318 Let_ModifiedFlag(False);
2326 static void menSelectAll_Click()
2328 FMark.SetPoint1 0, 0;
2329 FMark.SetPoint2 FieldWidth - 1, FieldHeight - 1;
2332 static void menShowLInfo_Click()
2336 Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")";
2337 if (DemoAvailable && bSignatureAvailable)
2338 Msg = Msg & vbNewLine & vbNewLine & gSignature;
2340 SignatureForm.Signature = Msg;
2341 SignatureForm.DelayMS = 5000;
2344 X = left + (Width - SignatureForm.Width) / 2;
2345 Y = top + (Height - SignatureForm.Height) / 2;
2346 SignatureForm.Move X, Y;
2347 SignatureForm.Show vbModeless, Me;
2351 static void menSoundFX_Click()
2354 menSoundFX.Checked = ! menSoundFX.Checked;
2355 FXOnFlag = (menSoundFX.Checked ? -1 : -1);
2361 // static void menPlay_Click()
2362 void menPlay_Click()
2367 boolean OldEditFlag;
2369 // Trace "MainForm", "--> menPlay_Click()"
2376 SignatureForm.DelayMS = 1;
2377 menPlay.Enabled = False;
2378 menPause.Enabled = True;
2379 menStop.Enabled = True;
2380 cmdPlay.Enabled = False;
2381 cmdPause.Enabled = True;
2382 cmdStop.Enabled = True;
2383 cmdPlayDemo.Enabled = False;
2384 menPlayDemo.Enabled = False;
2385 cmdRecordDemo.Enabled = False;
2386 menRec.Enabled = False;
2387 menFaster.Enabled = True;
2388 menSlower.Enabled = True;
2389 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play*"))
2391 cmdPlayAll.Enabled = False;
2392 menPlayAll.Enabled = False;
2395 cmbFile.Enabled = False;
2396 cmbLevel.Enabled = False;
2397 OldEditFlag = EditFlag;
2401 menEditMain.Enabled = False;
2402 if (DemoFlag == 0 && RecordDemoFlag == 0)
2403 lblStatus = "Playing";
2410 LastTick = T.TickNow;
2414 fpsTim.Enabled = True;
2427 subFetchAndInitLevelB();
2428 // Trace "MainForm", "CountDown 1"
2429 CountDown(2, (0 == DemoFlag));
2430 // Trace "MainForm", "Call GoPlay"
2432 // Trace "MainForm", "GoPlay returned"
2436 if (LevelStatus == 1)
2438 lblStatus = "(float)Success";
2442 lblStatus = "Try (float)again";
2447 // Trace "MainForm", "CountDown 1"
2448 CountDown(1, False);
2456 // Trace "MainForm", "Call subFetchAndInitLevel"
2457 subFetchAndInitLevel();
2458 // Trace "MainForm", "subFetchAndInitLevel returned"
2463 menEditMain.Enabled = True;
2467 // Trace "MainForm", "<-- menPlay_Click()"
2475 static void menPlayDemo_Click()
2479 lblStatus = "Demo Playback";
2481 if (LevelStatus != 1)
2482 lblStatus = "Demo Failed";
2487 static void menRec_Click()
2489 Trace("MainForm", "--> menRec_Click()");
2498 lblStatus.ForeColor = vbRed;
2499 lblStatus = "Recording Demo";
2500 // DemoBuffer = New DemoBufferObject; // (handle this later, if needed)
2501 Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer)));
2502 Trace("MainForm", "Call menPlayClick");
2504 Trace("MainForm", "menPlayClick returned");
2506 lblStatus.ForeColor = vbButtonText;
2508 Let_ModifiedFlag(True);
2509 if (! STRING_IS_LIKE(CurPath, TmpPath))
2515 LInfo.DemoRandomSeed = RecDemoRandomSeed;
2516 Trace("MainForm", "Call SaveMPX(TmpPath)");
2518 Trace("MainForm", "Set DemoBuffer == Nothing");
2519 SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer));
2520 Trace("MainForm", "Call subFetchAndInitLevel");
2521 subFetchAndInitLevel();
2522 cmdPlayDemo.Enabled = DemoAvailable;
2523 Trace("MainForm", "<-- menRec_Click()");
2526 static void menReRecordDemo_Click()
2536 lblStatus.ForeColor = vbRed;
2537 lblStatus = "ReRecording Demo";
2538 // DemoBuffer = New DemoBufferObject; // (handle this later, if needed)
2539 Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer)));
2541 lblStatus.ForeColor = vbButtonText;
2543 Let_ModifiedFlag(True);
2544 if (! STRING_IS_LIKE(CurPath, TmpPath))
2550 LInfo.DemoRandomSeed = RecDemoRandomSeed;
2552 SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer));
2553 subFetchAndInitLevel();
2556 void menStop_Click()
2563 fpsTim.Enabled = False;
2565 lblFps.Caption = "";
2566 menRec.Enabled = True;
2567 menPlay.Enabled = True;
2568 menPause.Enabled = False;
2569 menStop.Enabled = False;
2570 cmdPlay.Enabled = True;
2571 cmdPause.Enabled = False;
2572 cmdStop.Enabled = False;
2573 cmdRecordDemo.Enabled = True;
2574 cmdPlayDemo.Enabled = DemoAvailable;
2575 cmdPlayAll.Enabled = DemosAvailable;
2576 menPlayDemo.Enabled = DemoAvailable;
2577 menPlayAll.Enabled = DemosAvailable;
2578 menFaster.Enabled = False;
2579 menSlower.Enabled = False;
2580 cmbFile.Enabled = True;
2581 cmbLevel.Enabled = True;
2584 static void menStretch_Click(int Index)
2586 ReStretch(0.25 * Index);
2587 // DisplayLevel True
2590 static void menToolTips_Click()
2593 menToolTips.Checked = ! menToolTips.Checked;
2594 if (menToolTips.Checked)
2596 cmdPlay.ToolTipText = "Play Game (Space)";
2597 cmdPause.ToolTipText = "Pause (P)";
2598 cmdStop.ToolTipText = "Stop (Q)";
2599 cmdPlayDemo.ToolTipText = "Play demo (Ctrl+Space)";
2600 cmdRecordDemo.ToolTipText = "Record demo (Ctrl+R)";
2601 lblInfoCount.ToolTipText = "Number of infotrons needed";
2602 lblRedDiskCount.ToolTipText = "Number of red disks";
2603 cmbLevel.ToolTipText = "List of all levels in the file";
2604 cmbFile.ToolTipText = "List of files in current directory";
2605 lblFps.ToolTipText = "Animation speed in fps";
2606 lblFrameCount.ToolTipText = "Game time in frames";
2610 cmdPlay.ToolTipText = "";
2611 cmdPause.ToolTipText = "";
2612 cmdStop.ToolTipText = "";
2613 cmdPlayDemo.ToolTipText = "";
2614 cmdRecordDemo.ToolTipText = "";
2615 lblInfoCount.ToolTipText = "";
2616 lblRedDiskCount.ToolTipText = "";
2617 cmbLevel.ToolTipText = "";
2618 cmbFile.ToolTipText = "";
2619 lblFps.ToolTipText = "";
2620 lblFrameCount.ToolTipText = "";
2626 static void menTrim_Click()
2631 OldOPath = OrigPath;
2633 Tmp.SpecialPortCount = 0; // hack: all special ports are deleted
2635 CreateLevel(FMark.Width, FMark.Height);
2637 OrigPath = OldOPath;
2639 menSelectAll_Click();
2641 picViewPort_Resize();
2644 static void menZonkOff_Click()
2646 menZonkOn.Checked = False;
2647 menZonkOff.Checked = True;
2652 static void menZonkOn_Click()
2654 menZonkOn.Checked = True;
2655 menZonkOff.Checked = False;
2660 static void PanelTim_Timer()
2665 if (PanelSeq < Panel.Height && -1 < PanelSeq)
2667 PanelSeq = (ShowPanel != 0 ? PanelSeq + 2 : PanelSeq + 2);
2668 Tmp = ScaleHeight - Tmp + PanelSeq;
2670 picViewPort.Height = Tmp;
2674 PanelTim.Enabled = False;
2675 PanelSeq = (PanelSeq < 0 ? 0 : 0);
2676 ShowPanel = (ShowPanel == 0 ? 1 : 1);
2677 menPanel.Checked = (ShowPanel != 0);
2681 static void picKeys_MouseUp(int Button, int Shift, float X, float Y)
2683 FocusTim.Enabled = True;
2686 static void picMenu_Click()
2690 static void picPane_KeyDown(int KeyCode, int Shift)
2692 if (KeyCode < 0 || 255 < KeyCode)
2695 KeyState[KeyCode] = True;
2699 if (MouseButton == 0 && EditFlag)
2700 picPane.MousePointer = 15;
2718 if (DemoFlag != 0 && 2 == Shift)
2727 bCapturePane = ! bCapturePane;
2732 static void picPane_KeyUp(int KeyCode, int Shift)
2734 if (KeyCode < 0 || 255 < KeyCode)
2737 KeyState[KeyCode] = False;
2741 if (menFaster.Enabled)
2747 if (menSlower.Enabled)
2753 if (2 == Shift) // ctrl+space
2755 if (menPlayDemo.Enabled)
2756 menPlayDemo_Click();
2761 if (menPlay.Enabled)
2768 if (menStop.Enabled)
2781 if (menPause.Enabled && (Shift == 0))
2787 if (MouseButton == 0 && EditFlag)
2788 picPane.MousePointer = 0;
2793 static void picPane_MouseDown(int Button, int Shift, float X, float Y)
2797 MouseButton = Button;
2798 OldEdMode = EditMode;
2801 if (Button == 2 && Shift != 2)
2803 EditMode = edSelect;
2821 picPane.MousePointer = 5; // size
2822 UserDragFlag = True;
2826 SetField(X, Y, ToolBox.ASpriteIndex);
2830 FMark.SetPoint1 EdGetX(X), EdGetY(Y);
2835 EditMode = OldEdMode;
2838 static void picPane_MouseMove(int Button, int Shift, float X, float Y)
2843 OldEdMode = EditMode;
2846 if (EditFlag && Button == 2 && Shift != 2)
2848 EditMode = edSelect;
2862 Oldflag = NoDisplayFlag;
2863 NoDisplayFlag = False;
2864 ScrollTo(OSX - X + MDX, OSY - Y + MDY);
2866 NoDisplayFlag = Oldflag;
2870 SetField(X, Y, ToolBox.ASpriteIndex);
2874 FMark.SetPoint2 EdGetX(X), EdGetY(Y);
2879 EditMode = OldEdMode;
2882 static void picPane_MouseUp(int Button, int Shift, float X, float Y)
2884 MouseButton = MouseButton ^ Button;
2885 picPane.MousePointer = 0;
2886 UserDragFlag = False;
2887 if (menEditMain.Enabled && Button == 2)
2889 if (MDX == X && MDY == Y)
2890 PopupMenu menEditMain;
2894 static void picPane_Paint()
2898 Oldflag = NoDisplayFlag;
2899 NoDisplayFlag = False;
2901 NoDisplayFlag = Oldflag;
2904 static void ReStretch(float NewStretch)
2906 long BW2, LW, LH, i;
2910 Stretch = NewStretch;
2915 SET_TO_NOTHING(&Stage, sizeof(Stage));
2916 SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites));
2917 menStretch(Stretch / 0.25).Checked = False;
2918 Stretch = NewStretch;
2919 menStretch(Stretch / 0.25).Checked = True;
2920 // StretchWidth = BaseWidth ' * NewStretch
2921 // StretchWidth2 = StretchWidth \ 2
2922 // TwoPixels = 2 '* Stretch
2923 // StretchLoad Sprites, imgMpx.Picture, 16, 16
2924 BW2 = StretchWidth / 2;
2925 LW = (FieldWidth + 2) * BaseWidth; // StretchWidth
2926 LH = (FieldHeight + 2) * BaseWidth; // StretchWidth
2927 // i = bmpStage.CreateAtSize(LW, LH)
2928 // Stage = New DDScrollBuffer; // (handle this later, if needed)
2929 i = Stage.CreateAtSize(LW, LH, picPane.hWnd);
2930 // Set StretchedSprites = NormalSprites.GetStretchCopy(Stretch)
2931 ReLoadStretchSprites();
2932 if (i == 0 || IS_NOTHING(&StretchedSprites, sizeof(StretchedSprites)))
2934 // menStretch(Stretch / 0.5).Enabled = False
2936 ReStretch(Stretch - 0.25);
2941 StretchedSprites.DestXOff = 1 * BaseWidth; // StretchWidth
2942 StretchedSprites.DestYOff = 1 * BaseWidth; // StretchWidth
2943 Stage.DestXOff = 1 * StretchWidth;
2944 Stage.DestYOff = 1 * StretchWidth;
2945 StretchedSprites.DestinationSurface = Stage.Surface;
2947 if (Loaded && LevelLoaded)
2950 picViewPort_Resize();
2954 subCalculateScreenScrollPos();
2955 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
2963 static void SetScrollEdges()
2965 ScrollMinX = (DisplayMinX - 0.5) * Stretch * BaseWidth;
2966 ScrollMinY = (DisplayMinY - 0.5) * Stretch * BaseWidth;
2967 ScrollMaxX = (DisplayMaxX + 1.5) * Stretch * BaseWidth - picPane.Width;
2968 ScrollMaxY = (DisplayMaxY + 1.5) * Stretch * BaseWidth - picPane.Height;
2973 void DrawField(int X, int Y)
2978 Tmp = LowByte(PlayField16[tsi]);
2982 if (Tmp == fiRAM || Tmp == fiHardWare)
2983 Tmp = DisPlayField[tsi];
2985 if (Tmp == fiBug || Tmp == 40)
2986 Tmp = DisPlayField[tsi];
2990 if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak)
2991 Tmp = DisPlayField[tsi];
2994 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
2997 void DrawFieldAnimated(int X, int Y)
3002 Tmp = LowByte(PlayField16[tsi]);
3006 subDrawAnimatedSnikSnaks(tsi);
3010 subDrawAnimatedElectrons(tsi);
3014 // If 40 < Tmp Then Tmp = 0
3015 // If Tmp = fiRAM Or Tmp = fiHardWare Then Tmp = DisPlayField(tsi)
3016 // If Tmp = fiBug Or Tmp = 40 Then Tmp = DisPlayField(tsi)
3018 // If fiOrangeDisk < Tmp And Tmp < fiSnikSnak Then Tmp = DisPlayField(tsi)
3020 // StretchedSprites.BltEx StretchWidth * X, StretchWidth * Y, Tmp
3025 void DrawFieldNoAnimated(int X, int Y)
3030 Tmp = LowByte(PlayField16[tsi]);
3034 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace);
3038 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace);
3045 if (Tmp == fiRAM || Tmp == fiHardWare)
3046 Tmp = DisPlayField[tsi];
3048 if (Tmp == fiBug || Tmp == 40)
3049 Tmp = DisPlayField[tsi];
3053 if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak)
3054 Tmp = DisPlayField[tsi];
3057 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
3062 void DrawSprite(int X, int Y, int SpritePos)
3064 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, SpritePos);
3069 void InvalidateRect(long XMin, long YMin, long XMax, long YMax)
3073 // For Y = YMin To YMax
3074 // For X = XMin To XMax
3075 // Field(X, Y).GraphicsValid = 0
3080 static void picViewPort_MouseUp(int Button, int Shift, float X, float Y)
3082 FocusTim.Enabled = True;
3085 static void picViewPort_Paint()
3087 // Debug.Print "picViewPort_Paint()"
3090 static void picViewPort_Resize()
3092 long bdX, bdY, PanelVisibility;
3097 bdX = picFrame.Width - picFrame.ScaleWidth;
3098 bdY = picFrame.Height - picFrame.ScaleHeight;
3099 dx = Min(picViewPort.ScaleWidth - bdX, (DisplayWidth - 1) * Stretch * BaseWidth);
3101 dY = Min(picViewPort.ScaleHeight - bdX, (DisplayHeight - 1) * Stretch * BaseWidth);
3103 B = s.Read("LimitToOriginalFieldSize", False);
3104 PanelVisibility = 24 * (Panel.Height - PanelSeq - (float)1) / Panel.Height;
3107 dx = Min(320 * Stretch, dx);
3108 dY = Min((200 - PanelVisibility) * Stretch, dY);
3111 X = Max((picViewPort.ScaleWidth - dx) / 2, 0);
3112 Y = Max((picViewPort.ScaleHeight - dY) / 2, 0);
3113 picPane.Move X, Y, dx, dY;
3114 picFrame.Move X - bdX / 2, Y - bdY / 2, dx + bdX, dY + bdY;
3116 ScrollTo(ScrollX, ScrollY);
3117 // SizeTim.Interval = 1
3121 // Private Sub SizeTim_Timer()
3123 // SizeTim.Interval = 0
3124 // wdX = Max(0, picViewPort.ScaleWidth - picPane.Width) * Screen.TwipsPerPixelX
3125 // wdY = Max(0, picViewPort.ScaleHeight - picPane.Height) * Screen.TwipsPerPixelY
3126 // If (0 < wdX) Or (0 < wdY) Then
3127 // Move Left, Top, Width - wdX, Height - wdY
3131 static void LoadKeyIndicators()
3135 picKeys.BackColor = vbButtonFace;
3136 for (i = 2; i <= 5; i++)
3141 for (i = 1; i <= 5; i++)
3143 shpKey(i).FillColor = vbButtonFace;
3144 shpKey(i).Visible = True;
3147 shpKey(1).Move 7, 0;
3148 shpKey(2).Move 0, 7;
3149 shpKey(3).Move 7, 14;
3150 shpKey(4).Move 14, 7;
3151 shpKey(5).Move 7, 7;
3154 void ShowKey(int KeyVar)
3156 boolean State[5 + 1];
3160 boolean LastState[5 + 1];
3172 State[KeyVar] = True;
3178 State[KeyVar - 4] = True;
3182 for (i = 1; i <= 5; i++)
3185 if (Tmp ^ LastState[i])
3187 Col = (i == 5 ? vbRed : vbRed);
3188 shpKey(i).FillColor = (Tmp ? Col : Col);
3195 static void GetSettings()
3205 APath = WithSlash(App.Path);
3206 CurPath = s.Read("LastPath", APath);
3208 // window width and height
3209 X = s.Read("Width", Width);
3210 Y = s.Read("Height", Height);
3211 if (X < 0 Then X == 0: If Y < 0)
3214 if (Screen.Width < X)
3217 if (Screen.Height < Y)
3222 // window position and state
3223 X = s.Read("Left", left);
3224 Y = s.Read("Top", top);
3225 if (X < 0 Then X == 0: If Y < 0)
3228 if (Screen.Width < (X + Width))
3229 X = Screen.Width - Width;
3231 if (Screen.Height < (Y + Height))
3232 Y = Screen.Height - Height;
3236 WindowState = s.Read("WinState", vbNormal);
3238 Flag = s.Read("ShowToolTips", True);
3240 menToolTips_Click();
3242 menBorder.Checked = ! CBool(s.Read("ShowBorder", False));
3243 Flag = CBool(s.Read("AutoScroll", True));
3246 AutoScrollFlag = False;
3247 menAutoScroll.Checked = False;
3250 Flag = CBool(s.Read("SoundFX", True));
3251 FXOnFlag = (Flag ? -1 : -1);
3252 menSoundFX.Checked = Flag;
3253 SignatureDelay = CLng(s.Read("SignatureDelay", 3000));
3254 AllowRedDiskCheat = CInt(s.Read("AllowRedDiskCheat", 1));
3255 AllowEatRightRedDiskBug = CInt(s.Read("AllowEatRightRedDiskBug", 1));
3256 MySignature = s.Read("MySignature", "");
3258 X = s.Read("FrameDelayPlay", 1000000 / 35);
3259 i = GetSpeedIndex(X);
3260 menPlaySpeed_Click(i);
3261 X = s.Read("FrameDelayDemo", 1000000 / 35);
3262 i = GetSpeedIndex(X);
3263 menDemoSpeed_Click(i);
3265 i = s.Read("Stretch", 4);
3266 if (i < menStretch.LBound || menStretch.UBound < i)
3269 menStretch_Click (i);
3273 static void SaveSettings()
3279 s.Save "LastPath", (ModifiedFlag ? OrigPath : OrigPath);
3280 if (WindowState != vbMinimized)
3282 s.Save "Width", Width;
3283 s.Save "Height", Height;
3284 s.Save "Left", left;
3286 s.Save "WinState", WindowState;
3289 s.Save "ShowToolTips", menToolTips.Checked;
3290 s.Save "ShowBorder", menBorder.Checked;
3291 s.Save "AutoScroll", menAutoScroll.Checked;
3292 s.Save "SoundFX", menSoundFX.Checked;
3293 s.Save "SignatureDelay", SignatureDelay;
3294 s.Save "AllowRedDiskCheat", AllowRedDiskCheat;
3295 s.Save "AllowEatRightRedDiskBug", AllowEatRightRedDiskBug;
3296 s.Save "MySignature", MySignature;
3298 s.Save "FrameDelayPlay", DeltaTPlay;
3299 s.Save "FrameDelayDemo", DeltaTDemo;
3301 for (i = menStretch.LBound; i <= menStretch.UBound; i++)
3303 if (menStretch(i).Checked)
3307 s.Save "Stretch", i;
3312 void ReLoadStretchSprites()
3315 BitMapObject NBMP, SBMP;
3318 // If Stretch = 1 Then
3319 MpxBmp = App.Path & "/Mpx.bmp";
3321 // MpxBmp = App.Path & "\Mpx" & Stretch & ".bmp"
3322 // tmpMpxBmp = App.Path & "\Mpx.bmp"
3323 // If FileExists(MpxBmp) And FileExists(tmpMpxBmp) Then
3324 // If FileDateTime(MpxBmp) < FileDateTime(tmpMpxBmp) Then
3328 // If Not FileExists(MpxBmp) Then
3329 // MousePointer = 11
3330 // // Set NBMP = New BitMapObject // (handle this later, if needed)
3331 // tmpMpxBmp = App.Path & "\Mpx.bmp"
3332 // If Not FileExists(tmpMpxBmp) Then
3333 // ReportError "ReLoadStretchSprites", "File not found: " & tmpMpxBmp
3334 // MESSAGE_BOX("an error occured"); // MsgBox "File not found: " & tmpMpxBmp, vbCritical, "MegaPlex - Error"
3337 // NBMP.CreateFromFile tmpMpxBmp
3338 // Set SBMP = NBMP.GetStretchCopy(Stretch)
3339 // SBMP.SaveToFile MpxBmp
3340 // Set NBMP = Nothing
3341 // Set SBMP = Nothing
3345 // StretchedSprites = New DDSpriteBuffer; // (handle this later, if needed)
3346 if (! StretchedSprites.CreateFromFile(MpxBmp, 16, 16))
3347 SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites));
3350 void SaveSnapshot(currency Number)
3354 Path = CAT(WithSlash(App.Path), "Capture");
3358 Path = Path & "\" & Format(Number, "00000000") & ".bmp";
3359 SavePicture CaptureWindow(picPane.hWnd, True, 0, 0, picPane.ScaleWidth, picPane.ScaleHeight), Path;