1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
9 static void DrawFrame(int Delta);
10 static void ReStretch(float NewStretch);
11 static void picPane_Paint();
12 static void picViewPort_Resize();
13 static void menBorder_Click();
17 static void CleanTempDir(char *TmpDir);
18 static void CountDown(long HalfSeconds, int bDisplayBar);
19 static void DrawFrame(int Delta);
20 static void DrawPauseLayer(long Layer);
21 static void FillFileList(char *Path);
22 static void FillLevelList(char *Path, int LevelIndex);
23 static void FocusTim_Timer();
24 static void Form_KeyDown(int KeyCode, int Shift);
25 static void Form_KeyUp(int KeyCode, int Shift);
26 static void Form_Paint();
27 static int GetFileNameToSave();
28 static long GetHwndFromTempFileName(char *TmpFile);
29 static char * GetMyTempFileName();
30 static void GetSettings();
31 static char * GetSpeedDescriptionFPS(currency FrameDelayUS);
32 static int GetSpeedIndex(long DelayUS);
33 static char * GetValidTempPath();
34 static long Get_LastOpenFilter();
35 static long Get_LastSaveFilter();
36 static int InitSpeeds();
37 static boolean InstanceStillRunning(char *TmpFile);
38 static void Let_LastOpenFilter(long NewVal);
39 static void Let_LastSaveFilter(long NewVal);
40 static void LoadKeyIndicators();
41 static void LoadMenus();
42 static void PanelTim_Timer();
43 static void ReStretch(float NewStretch);
44 static void RestoreFrame();
45 static boolean SaveAs();
46 static void SaveSettings();
47 static void SetScrollEdges();
48 static void UpdateDeltaT();
49 static void cmbFile_Click();
50 static void cmbFile_KeyDown(int KeyCode, int Shift);
51 static void cmbFile_KeyUp(int KeyCode, int Shift);
52 static void cmbLevel_Click();
53 static void cmbLevel_KeyUp(int KeyCode, int Shift);
54 static void cmblevel_KeyDown(int KeyCode, int Shift);
55 static void cmdPause_Click();
56 static void cmdPause_MouseUp(int Button, int Shift, float X, float Y);
57 static void cmdPlayAll_Click();
58 static void cmdPlayAll_MouseUp(int Button, int Shift, float X, float Y);
59 static void cmdPlayDemo_Click();
60 static void cmdPlayDemo_MouseUp(int Button, int Shift, float X, float Y);
61 static void cmdPlay_Click();
62 static void cmdPlay_MouseUp(int Button, int Shift, float X, float Y);
63 static void cmdRecordDemo_Click();
64 static void cmdRecordDemo_MouseUp(int Button, int Shift, float X, float Y);
65 static void cmdStop_Click();
66 static void cmdStop_MouseUp(int Button, int Shift, float X, float Y);
67 static void fpsTim_Timer();
68 static void menAbout_Click();
69 static void menAutoScroll_Click();
70 static void menBorder_Click();
71 static void menCopy_Click();
72 static void menEnOff_Click();
73 static void menEnOn_Click();
74 static void menExit_Click();
75 static void menFaster_Click();
76 static void menGravOff_Click();
77 static void menGravOn_Click();
78 static void menNewStd_Click();
79 static void menNew_Click();
80 static void menOpen_Click();
81 static void menOptions_Click();
82 static void menPanel_Click();
83 static void menPaste_Click();
84 static void menPause_Click();
85 static void menPlayAll_Click();
86 static void menPlayDemo_Click();
87 static void menPlay_Click();
88 static void menReRecordDemo_Click();
89 static void menRec_Click();
90 static void menRemSP_Click();
91 static void menRestoreBorder_Click();
92 static void menSaveAs_Click();
93 static void menSave_Click();
94 static void menSelectAll_Click();
95 static void menShowLInfo_Click();
96 static void menSlower_Click();
97 static void menSoundFX_Click();
98 static void menStretch_Click(int Index);
99 static void menToolTips_Click();
100 static void menTrim_Click();
101 static void menZonkOff_Click();
102 static void menZonkOn_Click();
103 static void picKeys_MouseUp(int Button, int Shift, float X, float Y);
104 static void picMenu_Click();
105 static void picPane_KeyDown(int KeyCode, int Shift);
106 static void picPane_KeyUp(int KeyCode, int Shift);
107 static void picPane_MouseDown(int Button, int Shift, float X, float Y);
108 static void picPane_MouseMove(int Button, int Shift, float X, float Y);
109 static void picPane_MouseUp(int Button, int Shift, float X, float Y);
110 static void picPane_Paint();
111 static void picViewPort_MouseUp(int Button, int Shift, float X, float Y);
112 static void picViewPort_Paint();
113 static void picViewPort_Resize();
117 void DrawField(int X, int Y);
118 void DrawFieldAnimated(int X, int Y);
119 void DrawFieldNoAnimated(int X, int Y);
122 // --- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
123 // --- Begin VB.Form MainForm
124 // --- AutoRedraw = -1 'True // True
125 // --- Caption = "MegaPlex"
126 // --- ClientHeight = 5850
127 // --- ClientLeft = 2580
128 // --- ClientTop = 2205
129 // --- ClientWidth = 9285
130 // --- Icon = "MainForm.frx":0000
131 // --- LinkTopic = "Form1"
132 // --- ScaleHeight = 390
133 // --- ScaleMode = 3 'Pixel // Pixel
134 // --- ScaleWidth = 619
135 // --- Begin VB.Timer fpsTim
136 // --- Enabled = 0 'False // False
137 // --- Interval = 200
141 // --- Begin VB.Timer FocusTim
146 // --- Begin MSComDlg.CommonDialog cmDlg
149 // --- _ExtentX = 847
150 // --- _ExtentY = 847
151 // --- _Version = 393216
152 // --- CancelError = -1 'True // True
154 // --- Begin VB.Timer PanelTim
155 // --- Enabled = 0 'False // False
160 // --- Begin VB.Frame Panel
166 // --- Begin VB.CommandButton cmdPlay
167 // --- DisabledPicture = "MainForm.frx":0442
168 // --- DownPicture = "MainForm.frx":058C
171 // --- Picture = "MainForm.frx":06D6
172 // --- Style = 1 'Graphical // Graphical
174 // --- TabStop = 0 'False // False
178 // --- Begin VB.CommandButton cmdStop
179 // --- DisabledPicture = "MainForm.frx":0820
180 // --- DownPicture = "MainForm.frx":096A
181 // --- Enabled = 0 'False // False
184 // --- Picture = "MainForm.frx":0AB4
185 // --- Style = 1 'Graphical // Graphical
187 // --- TabStop = 0 'False // False
191 // --- Begin VB.CommandButton cmdPlayDemo
192 // --- DisabledPicture = "MainForm.frx":0BFE
193 // --- DownPicture = "MainForm.frx":0D48
194 // --- Enabled = 0 'False // False
197 // --- Picture = "MainForm.frx":0E92
198 // --- Style = 1 'Graphical // Graphical
200 // --- TabStop = 0 'False // False
204 // --- Begin VB.CommandButton cmdPause
205 // --- DisabledPicture = "MainForm.frx":0FDC
206 // --- DownPicture = "MainForm.frx":1126
207 // --- Enabled = 0 'False // False
210 // --- Picture = "MainForm.frx":1270
211 // --- Style = 1 'Graphical // Graphical
213 // --- TabStop = 0 'False // False
217 // --- Begin VB.CommandButton cmdRecordDemo
218 // --- DisabledPicture = "MainForm.frx":13BA
219 // --- DownPicture = "MainForm.frx":1504
222 // --- Picture = "MainForm.frx":164E
223 // --- Style = 1 'Graphical // Graphical
225 // --- TabStop = 0 'False // False
229 // --- Begin VB.ComboBox cmbFile
230 // --- BackColor = &H00000000&
231 // --- BeginProperty Font
232 // --- Name = "Fixedsys"
236 // --- Underline = 0 'False // False
237 // --- Italic = 0 'False // False
238 // --- Strikethrough = 0 'False // False
240 // --- ForeColor = &H00FF8080&
243 // --- Sorted = -1 'True // True
244 // --- Style = 2 'Dropdown List // Dropdown List
249 // --- Begin VB.ComboBox cmbLevel
250 // --- BackColor = &H00000000&
251 // --- BeginProperty Font
252 // --- Name = "Fixedsys"
256 // --- Underline = 0 'False // False
257 // --- Italic = 0 'False // False
258 // --- Strikethrough = 0 'False // False
260 // --- ForeColor = &H00FF8080&
263 // --- Sorted = -1 'True // True
264 // --- Style = 2 'Dropdown List // Dropdown List
269 // --- Begin VB.PictureBox picKeys
270 // --- BackColor = &H00008080&
271 // --- BorderStyle = 0 'None // None
274 // --- ScaleHeight = 22
275 // --- ScaleMode = 3 'Pixel // Pixel
276 // --- ScaleWidth = 22
278 // --- TabStop = 0 'False // False
281 // --- Begin VB.Shape shpKey
282 // --- FillColor = &H00008000&
283 // --- FillStyle = 0 'Solid // Solid
287 // --- Shape = 5 'Rounded Square // Rounded Square
292 // --- Begin VB.CommandButton cmdPlayAll
293 // --- Caption = "Play All Demos"
294 // --- Enabled = 0 'False // False
298 // --- TabStop = 0 'False // False
300 // --- Visible = 0 'False // False
303 // --- Begin VB.Shape shpProgress
304 // --- BackColor = &H00800000&
305 // --- BackStyle = 1 'Opaque // Opaque
309 // --- Visible = 0 'False // False
312 // --- Begin VB.Label lblStatus
313 // --- Alignment = 2 'Center // Center
314 // --- BorderStyle = 1 'Fixed Single // Fixed Single
315 // --- Caption = "MegaPlex"
316 // --- BeginProperty Font
317 // --- Name = "Fixedsys"
321 // --- Underline = 0 'False // False
322 // --- Italic = 0 'False // False
323 // --- Strikethrough = 0 'False // False
331 // --- Begin VB.Image Image2
334 // --- Picture = "MainForm.frx":1BD8
338 // --- Begin VB.Image Image1
341 // --- Picture = "MainForm.frx":1D22
345 // --- Begin VB.Label lblFps
346 // --- Alignment = 2 'Center // Center
347 // --- BackColor = &H00000000&
348 // --- BorderStyle = 1 'Fixed Single // Fixed Single
349 // --- BeginProperty Font
350 // --- Name = "Fixedsys"
354 // --- Underline = 0 'False // False
355 // --- Italic = 0 'False // False
356 // --- Strikethrough = 0 'False // False
358 // --- ForeColor = &H0000C0C0&
365 // --- Begin VB.Label lblInfoCount
366 // --- Alignment = 2 'Center // Center
367 // --- BackColor = &H00000000&
368 // --- BorderStyle = 1 'Fixed Single // Fixed Single
369 // --- BeginProperty Font
370 // --- Name = "Fixedsys"
374 // --- Underline = 0 'False // False
375 // --- Italic = 0 'False // False
376 // --- Strikethrough = 0 'False // False
378 // --- ForeColor = &H00FF8080&
385 // --- Begin VB.Label lblRedDiskCount
386 // --- Alignment = 2 'Center // Center
387 // --- BackColor = &H00000000&
388 // --- BorderStyle = 1 'Fixed Single // Fixed Single
389 // --- BeginProperty Font
390 // --- Name = "Fixedsys"
394 // --- Underline = 0 'False // False
395 // --- Italic = 0 'False // False
396 // --- Strikethrough = 0 'False // False
398 // --- ForeColor = &H000000FF&
405 // --- Begin VB.Label lblFrameCount
406 // --- Alignment = 2 'Center // Center
407 // --- BorderStyle = 1 'Fixed Single // Fixed Single
409 // --- BeginProperty Font
410 // --- Name = "Fixedsys"
414 // --- Underline = 0 'False // False
415 // --- Italic = 0 'False // False
416 // --- Strikethrough = 0 'False // False
425 // --- Begin VB.PictureBox picViewPort
426 // --- BorderStyle = 0 'None // None
429 // --- ScaleHeight = 169
430 // --- ScaleMode = 3 'Pixel // Pixel
431 // --- ScaleWidth = 265
433 // --- TabStop = 0 'False // False
436 // --- Begin VB.PictureBox picPane
437 // --- AutoSize = -1 'True // True
438 // --- BackColor = &H00000000&
439 // --- BorderStyle = 0 'None // None
443 // --- ScaleHeight = 109
444 // --- ScaleMode = 3 'Pixel // Pixel
445 // --- ScaleWidth = 129
450 // --- Begin VB.PictureBox picFrame
453 // --- ScaleHeight = 57
454 // --- ScaleMode = 3 'Pixel // Pixel
455 // --- ScaleWidth = 81
457 // --- TabStop = 0 'False // False
462 // --- Begin VB.Menu menFile
463 // --- Caption = "&File"
464 // --- Begin VB.Menu menNewStd
465 // --- Caption = "New S&tandard Level"
467 // --- Begin VB.Menu menNew
468 // --- Caption = "&New Level"
470 // --- Begin VB.Menu menDash5
473 // --- Begin VB.Menu menOpen
474 // --- Caption = "&Open"
476 // --- Begin VB.Menu menSave
477 // --- Caption = "&Save"
480 // --- Begin VB.Menu menSaveAs
481 // --- Caption = "Save &As ..."
483 // --- Begin VB.Menu menDash4
486 // --- Begin VB.Menu menExit
487 // --- Caption = "E&xit"
491 // --- Begin VB.Menu menEditMain
492 // --- Caption = "&Edit"
493 // --- Begin VB.Menu menEdit
494 // --- Caption = "&Edit Level"
496 // --- Begin VB.Menu menDash3
499 // --- Begin VB.Menu menCopy
500 // --- Caption = "&Copy"
503 // --- Begin VB.Menu menPaste
504 // --- Caption = "&Paste"
507 // --- Begin VB.Menu menTrim
508 // --- Caption = "&Trim"
511 // --- Begin VB.Menu menDash8
515 // --- Begin VB.Menu menSelectAll
516 // --- Caption = "Select &All"
519 // --- Begin VB.Menu menDash6
522 // --- Begin VB.Menu menRestoreBorder
523 // --- Caption = "Restore &border"
526 // --- Begin VB.Menu menSp
527 // --- Caption = "Special Port"
528 // --- Begin VB.Menu menGravOn
529 // --- Caption = "&Gravity On"
531 // --- Begin VB.Menu menZonkOn
532 // --- Caption = "Freeze &Zonks On"
534 // --- Begin VB.Menu menEnOn
535 // --- Caption = "Freeze &Enemies On"
537 // --- Begin VB.Menu menDash7
540 // --- Begin VB.Menu menGravOff
541 // --- Caption = "Gravity &Off"
543 // --- Begin VB.Menu menZonkOff
544 // --- Caption = "Freeze Zon&ks Off"
546 // --- Begin VB.Menu menEnOff
547 // --- Caption = "Freeze E&nemies Off"
549 // --- Begin VB.Menu menDash10
552 // --- Begin VB.Menu menRemSP
553 // --- Caption = "&Remove (Make Normal Port)"
557 // --- Begin VB.Menu menView
558 // --- Caption = "&View"
559 // --- Begin VB.Menu menZoom
560 // --- Caption = "&Zoom"
561 // --- Begin VB.Menu menStretch
562 // --- Caption = "0.25 : 1"
566 // --- Begin VB.Menu menBorder
567 // --- Caption = "Show &Border"
568 // --- Checked = -1 'True // True
570 // --- Begin VB.Menu menPanel
571 // --- Caption = "Show &Panel"
572 // --- Checked = -1 'True // True
574 // --- Begin VB.Menu menAutoScroll
575 // --- Caption = "&Autoscroll"
576 // --- Checked = -1 'True // True
578 // --- Begin VB.Menu menDash9
581 // --- Begin VB.Menu menShowLInfo
582 // --- Caption = "Show Level &Info"
585 // --- Begin VB.Menu menSound
586 // --- Caption = "&Sound"
587 // --- Begin VB.Menu menSoundFX
588 // --- Caption = "&FX"
590 // --- Begin VB.Menu menMusic
591 // --- Caption = "&Music"
592 // --- Enabled = 0 'False // False
595 // --- Begin VB.Menu menSpeed
596 // --- Caption = "Speed"
597 // --- Begin VB.Menu menSpeedPlay
598 // --- Caption = "Game play"
600 // --- Begin VB.Menu menPlaySpeed
605 // --- Begin VB.Menu menSpeedDemo
606 // --- Caption = "Demo playback"
607 // --- Begin VB.Menu menDemoSpeed
612 // --- Begin VB.Menu menSpeedDash
615 // --- Begin VB.Menu menFaster
616 // --- Caption = "Faster (Pg Up)"
618 // --- Begin VB.Menu menSlower
619 // --- Caption = "Slower (Pg Down)"
622 // --- Begin VB.Menu menRun
623 // --- Caption = "&Play"
624 // --- Begin VB.Menu menPlay
625 // --- Caption = "P&lay Game (Space)"
627 // --- Begin VB.Menu menPause
628 // --- Caption = "&Pause (P)"
629 // --- Enabled = 0 'False // False
631 // --- Begin VB.Menu menStop
632 // --- Caption = "&Stop (Q)"
633 // --- Enabled = 0 'False // False
635 // --- Begin VB.Menu menDash0
638 // --- Begin VB.Menu menRec
639 // --- Caption = "&Record Demo (Ctrl+R)"
641 // --- Begin VB.Menu menPlayDemo
642 // --- Caption = "Play &Demo (Ctrl+Space)"
644 // --- Begin VB.Menu menPlayAll
645 // --- Caption = "Play &All Demos"
648 // --- Begin VB.Menu menOptionsMain
649 // --- Caption = "&Options"
650 // --- Begin VB.Menu menOptions
651 // --- Caption = "&Options ..."
654 // --- Begin VB.Menu menHelp
655 // --- Caption = "Help"
656 // --- Begin VB.Menu menToolTips
657 // --- Caption = "Show &ToolTips"
659 // --- Begin VB.Menu menDash1
662 // --- Begin VB.Menu menAbout
663 // --- Caption = "&About MegaPlex"
668 // static char *VB_Name = "MainForm";
669 // static boolean VB_GlobalNameSpace = False;
670 // static boolean VB_Creatable = False;
671 // static boolean VB_PredeclaredId = True;
672 // static boolean VB_Exposed = False;
674 // --- Option Explicit
675 // --- Option Compare Text
677 long SetParent(long hWndChild, long hWndNewParent);
678 long SetWindowLong(long hWnd, long nIndex, long dwNewLong);
679 long GetWindowLong(long hWnd, long nIndex);
680 long GetTempPath(long nBufferLength, char *lpBuffer);
681 long GetWindowText(long hWnd, char *lpString, long cch);
683 #define GWL_STYLE ((-16))
684 #define WS_CHILD (0x40000000)
685 #define WS_POPUP (0x80000000)
687 // [UNCOMMENTED] Dim StretchWidth2&
691 long OSX, OSY, MDX, MDY;
696 boolean Loaded, DemosAvailable;
698 #define nSpeedCount (17)
699 int SpeedsByDelayUS[nSpeedCount + 1];
700 #define DefaultSpeedIndex (12)
702 currency LastTick, LastFrame;
705 const char *AppTitle = "MegaPlex";
709 static char *GetSpeedDescriptionFPS(currency FrameDelayUS)
711 static char *GetSpeedDescriptionFPS;
715 if (FrameDelayUS == 0)
717 GetSpeedDescriptionFPS = "Fastest possible";
718 return GetSpeedDescriptionFPS;
721 if (FrameDelayUS < 0)
723 GetSpeedDescriptionFPS = "! display (even faster)";
724 return GetSpeedDescriptionFPS;
727 FPS = 1000000 / FrameDelayUS;
728 GetSpeedDescriptionFPS = CAT(INT_TO_STR(FPS), " fps");
730 GetSpeedDescriptionFPS = CAT(GetSpeedDescriptionFPS, "(Default)");
732 return GetSpeedDescriptionFPS;
735 static int InitSpeeds()
737 static int InitSpeeds;
739 SpeedsByDelayUS[1] = -1; // no display
740 SpeedsByDelayUS[2] = 0; // fastest possible
741 SpeedsByDelayUS[3] = 1000000 / 700; // 700 fps
742 SpeedsByDelayUS[4] = 1000000 / 500; // 500 fps
743 SpeedsByDelayUS[5] = 1000000 / 350; // 350 fps
744 SpeedsByDelayUS[6] = 1000000 / 250; // 250 fps
745 SpeedsByDelayUS[7] = 1000000 / 200; // etc.
746 SpeedsByDelayUS[8] = 1000000 / 150;
747 SpeedsByDelayUS[9] = 1000000 / 100;
748 SpeedsByDelayUS[10] = 1000000 / 70;
749 SpeedsByDelayUS[11] = 1000000 / 50;
750 SpeedsByDelayUS[12] = 1000000 / 35; // default
751 SpeedsByDelayUS[13] = 1000000 / 25;
752 SpeedsByDelayUS[14] = 1000000 / 20;
753 SpeedsByDelayUS[15] = 1000000 / 10;
754 SpeedsByDelayUS[16] = 1000000 / 5;
755 SpeedsByDelayUS[17] = 1000000 / 1;
760 static int GetSpeedIndex(long DelayUS)
762 static int GetSpeedIndex;
768 MinIdx = DefaultSpeedIndex;
770 for (i = 1; i <= nSpeedCount; i++)
772 Diff = Abs(DelayUS - SpeedsByDelayUS[i]);
780 GetSpeedIndex = MinIdx;
782 return GetSpeedIndex;
785 static long Get_LastOpenFilter()
787 static long LastOpenFilter;
791 LastOpenFilter = s.Read("LastOpenFilter", 1);
793 return LastOpenFilter;
796 static void Let_LastOpenFilter(long NewVal)
800 SettingsObject_Save("LastOpenFilter", NewVal);
803 static long Get_LastSaveFilter()
805 static long LastSaveFilter;
809 LastSaveFilter = s.Read("LastSaveFilter", 1);
811 return LastSaveFilter;
814 static void Let_LastSaveFilter(long NewVal)
818 SettingsObject_Save("LastSaveFilter", NewVal);
823 static void CountDown(long HalfSeconds, int bDisplayBar)
831 long LeftPos, TopPos, RightPos, MaxWidth; // , MaxHeight&
833 dT = HalfSeconds * 500;
835 LeftPos = cmbFile.left;
836 TopPos = cmbFile.top - shpProgress.Height - cmbFile.top / 8;
837 RightPos = lblFrameCount.left + lblFrameCount.Width;
838 MaxWidth = RightPos - LeftPos;
839 // MaxHeight = lblFrameCount.Top - TopPos + lblFrameCount.Height + 4
842 shpProgress.Move(LeftPos, TopPos, 0); // , MaxHeight
843 shpProgress.Visible = True;
846 for (i = 1; i <= 200; i++)
853 shpProgress.Width = MaxWidth * i / 100;
857 k = MaxWidth * (i - 100) / 100;
858 shpProgress.Move(k, TopPos, RightPos - k);
862 T.DelayMS(Delta, False);
865 shpProgress.Visible = False;
874 static char *GetValidTempPath()
876 static char *GetValidTempPath;
881 GetValidTempPath = "";
883 TP = String(nSize, Chr(32));
884 L = GetTempPath(nSize, TP);
887 // buffer was too small, retry with a properly sized buffer:
889 TP = String(nSize, Chr(32));
890 L = GetTempPath(nSize, TP);
893 TP = SlashLess(left(TP, L));
894 if ((0 == L) || (! IsDir(TP)))
896 // no valid temp path can be retrieved from the system --> create our own
897 TP = CAT(WithSlash(App.Path), "Temp");
901 // --- On Error Resume Next
903 if (! IS_NOTHING(&Err, sizeof(Err)))
905 MESSAGE_BOX("an error occured"); // MsgBox "cannot create directory for temporary files " & TP, vbCritical, "MegaPlex - Error";
906 return GetValidTempPath;
909 // --- On Error GoTo 0
915 GetValidTempPath = TP;
917 return GetValidTempPath;
920 static char *GetMyTempFileName()
922 static char *GetMyTempFileName;
926 (char *)T = Hex(hWnd);
932 GetMyTempFileName = CAT("tmp0x", CAT((char *)T, ".mpx"));
934 return GetMyTempFileName;
937 static long GetHwndFromTempFileName(char *TmpFile)
939 static long GetHwndFromTempFileName;
946 GetHwndFromTempFileName = 0;
947 FN = StripFileName(TmpFile);
951 return GetHwndFromTempFileName;
954 NumString = right(FN, L - LP);
956 NumString = left(NumString, 8);
958 NumString = CAT("&H", NumString);
959 GetHwndFromTempFileName = Val(NumString);
961 return GetHwndFromTempFileName;
964 static void CleanTempDir(char *TmpDir)
968 MFN = GetMyTempFileName();
969 MayKill(CAT(WithSlash(TmpDir), MFN));
970 FN = Dir(CAT(WithSlash(TmpDir), "tmp0x*.mpx"));
973 if (STRING_IS_LIKE(FN, "tmp0x*.mpx"))
975 if (! InstanceStillRunning(FN))
976 MayKill(CAT(WithSlash(TmpDir), FN));
979 FN = Dir_Without_Args();
983 static boolean InstanceStillRunning(char *TmpFile)
985 static boolean InstanceStillRunning;
987 long OtherHwnd, nSize, L;
990 InstanceStillRunning = False;
991 OtherHwnd = GetHwndFromTempFileName(TmpFile);
993 Cap = String(nSize, Chr(32));
994 L = GetWindowText(OtherHwnd, Cap, nSize);
995 if ((L == 0) || (nSize < L))
996 return InstanceStillRunning;
998 if (STRING_IS_LIKE(Cap, CAT(AppTitle, "*")))
999 InstanceStillRunning = True;
1001 return InstanceStillRunning;
1011 printf("::: MainForm.c: DisplayLevel(): %d, %d, %d\n",
1012 Loaded, LevelLoaded, bPlaying);
1028 if (! menBorder.Checked)
1035 printf("::: MainForm.c: DisplayLevel(): [%ld, %ld, %ld, %ld] [%d, %d]...\n",
1036 DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
1037 FieldWidth, FieldHeight);
1040 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1042 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1044 DrawFieldNoAnimated(X, Y);
1048 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1050 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1052 DrawFieldAnimated(X, Y);
1059 for (Y = DisplayMinY; Y <= DisplayMaxY; Y++)
1061 for (X = DisplayMinX; X <= DisplayMaxX; X++)
1071 static void cmbFile_Click()
1073 CurPath = CAT(StripDir(OrigPath), CAT("/", cmbFile.List(cmbFile.ListIndex)));
1075 FillLevelList(CurPath, LevelNumber);
1076 if (STRING_IS_LIKE(OrigPath, "*.mpx") || STRING_IS_LIKE(OrigPath, "*.sp"))
1078 menSave.Enabled = True;
1082 menSave.Enabled = False;
1086 static void cmbFile_KeyDown(int KeyCode, int Shift)
1088 picPane_KeyDown(KeyCode, Shift);
1091 static void cmbFile_KeyUp(int KeyCode, int Shift)
1093 picPane_KeyUp(KeyCode, Shift);
1096 static int GetFileNameToSave()
1098 static int GetFileNameToSave;
1102 (char *)T = StripFileName(OrigPath);
1103 if (STRING_IS_LIKE(T, "*.dat") || STRING_IS_LIKE(T, "*.d##"))
1105 T = "Level" & Format(LevelNumber, "#000");
1108 GetFileNameToSave = T;
1110 return GetFileNameToSave;
1113 static void cmbLevel_Click()
1118 static long LastIndex = 0;
1119 static boolean bBlock = False;
1124 // //////////////////////////////////////////////////////////////////
1129 Msg = "Save changes to " & GetFileNameToSave() & " ?";
1130 Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - close level");
1131 if (Res == vbCancel) // fallback
1135 // --- On Error Resume Next
1136 cmbLevel.ListIndex = LastIndex;
1137 // --- On Error GoTo 0
1140 Debug.Assert cmbLevel.ListIndex = LastIndex;
1147 // oldCurPath = CurPath
1148 if (FileExists(OrigPath) && menSave.Enabled)
1154 if (! SaveAs()) // fallback
1158 // --- On Error Resume Next
1159 cmbLevel.ListIndex = LastIndex;
1160 // --- On Error GoTo 0
1163 Debug.Assert cmbLevel.ListIndex = LastIndex;
1168 // CurPath = oldCurPath
1171 Let_ModifiedFlag(False);
1175 // //////////////////////////////////////////////////////////////////
1177 LevelNumber = cmbLevel.ListIndex + 1;
1181 Oldflag = NoDisplayFlag;
1182 NoDisplayFlag = False;
1183 subFetchAndInitLevel();
1184 if ((0 < SignatureDelay) && ! (WindowState == vbMinimized))
1186 Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")";
1187 if (DemoAvailable && bSignatureAvailable)
1188 Msg = Msg & vbNewLine & vbNewLine & gSignature;
1190 SignatureForm.Signature = Msg;
1191 SignatureForm.DelayMS = SignatureDelay;
1194 X = left + (Width - SignatureForm.Width) / 2;
1195 Y = top + (Height - SignatureForm.Height) / 2;
1196 SignatureForm.Move X, Y;
1197 SignatureForm.Show vbModeless, Me;
1201 lblStatus = "MegaPlex";
1202 lblFrameCount = GetTotalFramesOfDemo();
1209 NoDisplayFlag = Oldflag;
1210 LastIndex = cmbLevel.ListIndex;
1214 menPlayDemo.Enabled = DemoAvailable;
1215 cmdPlayDemo.Enabled = DemoAvailable;
1218 static void cmblevel_KeyDown(int KeyCode, int Shift)
1220 if (GameLoopRunning != 0)
1226 if (menPlay.Enabled == True)
1232 picPane_KeyDown(KeyCode, Shift);
1237 static void cmbLevel_KeyUp(int KeyCode, int Shift)
1239 picPane_KeyUp(KeyCode, Shift);
1242 static void cmdPause_Click()
1247 static void cmdPause_MouseUp(int Button, int Shift, float X, float Y)
1249 FocusTim.Enabled = True;
1252 static void cmdPlay_Click()
1254 if (menPlay.Enabled)
1258 static void cmdPlay_MouseUp(int Button, int Shift, float X, float Y)
1260 FocusTim.Enabled = True;
1263 static void cmdPlayAll_Click()
1268 static void cmdPlayAll_MouseUp(int Button, int Shift, float X, float Y)
1270 FocusTim.Enabled = True;
1273 static void cmdPlayDemo_Click()
1275 menPlayDemo_Click();
1278 static void cmdPlayDemo_MouseUp(int Button, int Shift, float X, float Y)
1280 FocusTim.Enabled = True;
1283 static void cmdRecordDemo_Click()
1289 static void cmdRecordDemo_MouseUp(int Button, int Shift, float X, float Y)
1291 FocusTim.Enabled = True;
1294 static void cmdStop_Click()
1296 if (menStop.Enabled)
1300 static void cmdStop_MouseUp(int Button, int Shift, float X, float Y)
1302 FocusTim.Enabled = True;
1305 static void FocusTim_Timer()
1307 FocusTim.Enabled = False;
1309 // --- On Error Resume Next
1313 static void Form_KeyDown(int KeyCode, int Shift)
1315 picPane_KeyDown(KeyCode, Shift);
1318 static void Form_KeyUp(int KeyCode, int Shift)
1320 picPane_KeyUp(KeyCode, Shift);
1339 // FMark = New MarkerObject; // (handle this later, if needed)
1347 TmpPath = GetValidTempPath();
1351 CleanTempDir(TmpPath);
1352 TmpPath = CAT(WithSlash(TmpPath), GetMyTempFileName());
1356 InitDirectX(hWnd, picPane.hWnd);
1358 // AllowRedDiskCheat = 1
1359 MpxBmp = CAT(App.Path, "/mpx.bmp");
1360 // // Set NormalSprites = New DDSpriteBuffer // (handle this later, if needed)
1361 // NormalSprites.CreateFromFile MPXBMP, 16, 16
1363 Field = REDIM_2D(sizeof(int), 0, 2 + 1 - 1, 0, 2 + 1 - 1);
1365 picViewPort.ScaleMode = vbPixels;
1380 LoadKeyIndicators();
1384 FillFileList(CurPath);
1385 if (s.Read("ShowSplash", True))
1387 // frmSplash.EnableTimer
1388 frmSplash.Show vbModal, Me;
1396 static void FillLevelList(char *Path, int LevelIndex)
1398 long FNum, LevLen, i, iMax;
1402 if (! FileExists(Path))
1405 if ((STRING_IS_LIKE(Path, "*.D??")) || (STRING_IS_LIKE(Path, "*.sp")))
1409 FNum = fopen(Path, "rb");
1412 FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo));
1413 cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i;
1414 if (STRING_IS_LIKE(Path, "*.D??"))
1416 while (!(EOF(FNum)))
1419 FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo));
1423 cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i;
1427 if (LevelIndex <= i && 0 < LevelIndex)
1432 cmbLevel.ListIndex = i;
1436 else if (STRING_IS_LIKE(Path, "*.mpx"))
1440 FNum = fopen(Path, "rb");
1445 for (i = 1; i <= LevelCount; i++)
1447 if (! MpxLoadLInfo(CInt(i)))
1450 cmbLevel.AddItem Format(i, "#000") & " " & LInfo.LevelTitle, i - 1;
1456 if (LevelIndex < i && 0 < LevelIndex)
1461 if (i < cmbLevel.ListCount)
1462 cmbLevel.ListIndex = i;
1469 static void FillFileList(char *Path)
1471 long FNum, LevLen, i;
1473 char *TFile, *TPath, *OFile;
1478 TPath = WithSlash(StripDir(Path));
1479 OFile = StripFileName(Path);
1480 TFile = Dir(TPath & "*.D??");
1483 if (FileLen(TPath & TFile) == 170496)
1485 cmbFile.AddItem TFile;
1491 TFile = Dir(TPath & "*.SP");
1494 nDemoCount = nDemoCount + 1;
1495 cmbFile.AddItem TFile;
1499 TFile = Dir(TPath & "*.mpx");
1502 nDemoCount = nDemoCount + 1;
1503 cmbFile.AddItem TFile;
1507 i = cmbFile.ListCount - 1;
1508 if (0 < cmbFile.ListCount)
1512 if ((cmbFile.List(i) Like OFile) || i == 0)
1519 cmbFile.ListIndex = i;
1522 DemosAvailable = (1 < nDemoCount);
1523 menPlayAll.Enabled = DemosAvailable;
1524 cmdPlayAll.Enabled = DemosAvailable;
1527 static void LoadMenus()
1532 menFaster.Enabled = False;
1533 menSlower.Enabled = False;
1535 for (i = 1; i <= nSpeedCount; i++)
1539 Load menPlaySpeed(i);
1540 Load menDemoSpeed(i);
1543 menPlaySpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]);
1544 menDemoSpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]);
1548 menStretch(1).Caption = Format(0.25, "#0.00") & ";
1550 if (Stretch == 0.25)
1551 menStretch(1).Checked = True;
1553 for (i = 2; i <= 20; i++)
1556 menStretch(i).Caption = Format(0.25 * i, "#0.00") & ";
1558 menStretch(i).Checked = ((i * 0.25) == Stretch);
1561 menSp.Enabled = False;
1565 // Function DisplayShift&()
1566 // Dim X&, Y&, A&, B&, iX&, iiX&, LD&
1569 // For A = 0 To picPane.ScaleWidth
1570 // For Y = DisplayMinY To DisplayMaxY
1571 // For X = DisplayMinX To DisplayMaxX
1572 // iX = StretchWidth * X + A
1573 // Sprite = Field(X, Y).SpritePos
1574 // If picPane.ScaleWidth < (iX + 1) Then
1575 // iX = iX - picPane.ScaleWidth
1577 // If picPane.ScaleWidth < (iX + 1 + BaseWidth) Then
1578 // iiX = iX - picPane.ScaleWidth
1579 // Sprites.BitBltSprite picPane.hdc, iiX, StretchWidth * Y, Sprite
1582 // Sprites.BitBltSprite picPane.hdc, iX, StretchWidth * Y, Sprite
1585 // DisplayShift = DisplayShift + 1
1590 static void Form_Paint()
1592 // Debug.Print "Form_Paint()"
1595 static void Form_Resize()
1600 if (WindowState == vbMinimized || ! Loaded)
1604 // NW = ScaleWidth - 2 * Space: If NW < 0 Then NW = 0
1605 // NH = ScaleHeight - 3 * Space - cmbLevel.Height: If NH < 0 Then NH = 0
1606 // picViewPort.Move Space, Space, NW, NH
1607 Tmp = (ShowPanel != 0 ? ScaleHeight - Panel.Height : ScaleHeight - Panel.Height);
1611 picViewPort.Move 0, 0, ScaleWidth, Tmp;
1612 // Tmp = 2 * Space + picViewPort.Height
1614 Panel.left = (ScaleWidth - Panel.Width) / 2;
1615 // 'cmdNormal.Top = 2 * Space + picViewPort.Height
1616 // cmbLevel.Top = Tmp
1617 // lblRedDiskCount.Top = Tmp
1618 // lblInfoCount.Top = Tmp
1619 // picKeys.Top = Tmp
1620 // lblFrameCount.Top = Tmp
1621 // cmdPlayAll.Top = Tmp
1626 static void DrawFrame(int Delta)
1628 int i, LX, tY, RX, BY;
1632 RX = FieldWidth - Delta;
1633 BY = FieldHeight - Delta;
1634 DrawSprite(LX, tY, posFrameCorner);
1635 DrawSprite(LX, BY, posFrameCorner);
1636 DrawSprite(RX, tY, posFrameCorner);
1637 DrawSprite(RX, BY, posFrameCorner);
1638 for (i = LX + 1; i <= RX - 1; i++)
1640 DrawSprite(i, tY, posFrameHorizontal);
1641 DrawSprite(i, BY, posFrameHorizontal);
1644 for (i = tY + 1; i <= BY - 1; i++)
1646 DrawSprite(LX, i, posFrameVertical);
1647 DrawSprite(RX, i, posFrameVertical);
1651 static void RestoreFrame()
1653 int i, LX, tY, RX, BY;
1657 RX = FieldWidth - 1;
1658 BY = FieldHeight - 1;
1659 for (i = LX; i <= RX; i++)
1665 for (i = tY + 1; i <= BY - 1; i++)
1674 static void Form_Unload(int Cancel)
1678 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Quit*"))
1683 if (menEdit.Checked)
1691 Msg = "Save changes to " & GetFileNameToSave() & " ?";
1692 Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - closing");
1693 if (Res == vbCancel)
1701 if (FileExists(OrigPath) && menSave.Enabled)
1712 if (FileExists(TmpPath) || ModifiedFlag)
1718 ReleaseDirectDraw();
1723 static void fpsTim_Timer()
1726 static int count5 = 0;
1728 count5 = count5 + 1;
1731 TickDiff = T.TickDiffUS(LastTick);
1732 lblFps.Caption = CLng(Round((1000000 * (TimerVar - LastFrame)) / (TickDiff), 0));
1733 LastFrame = TimerVar;
1734 LastTick = T.TickNow();
1738 // If NoDisplayFlag Then lblFrameCount = TimerVar
1739 lblFrameCount = TimerVar;
1742 static void menAbout_Click()
1744 frmSplash.Show vbModal, Me;
1747 static void menAutoScroll_Click()
1750 menAutoScroll.Checked = ! menAutoScroll.Checked;
1751 AutoScrollFlag = menAutoScroll.Checked;
1757 static void menBorder_Click()
1759 if (menBorder.Checked)
1761 menBorder.Checked = False;
1763 DisplayMaxX = FieldWidth - 2;
1764 DisplayWidth = FieldWidth;
1766 DisplayMaxY = FieldHeight - 2;
1767 DisplayHeight = FieldHeight;
1769 if (Loaded && LevelLoaded)
1775 menBorder.Checked = True;
1777 DisplayMaxX = FieldWidth - 1;
1778 DisplayWidth = FieldWidth + 2;
1780 DisplayMaxY = FieldHeight - 1;
1781 DisplayHeight = FieldHeight + 2;
1783 if (Loaded && LevelLoaded)
1788 // DisplayLevel True
1791 void SetDisplayRegion()
1793 if (! menBorder.Checked)
1796 DisplayMaxX = FieldWidth - 2;
1797 DisplayWidth = FieldWidth;
1799 DisplayMaxY = FieldHeight - 2;
1800 DisplayHeight = FieldHeight;
1809 DisplayMaxX = FieldWidth - 1;
1810 DisplayWidth = FieldWidth + 2;
1812 DisplayMaxY = FieldHeight - 1;
1813 DisplayHeight = FieldHeight + 2;
1822 static void menCopy_Click()
1827 void menEdit_Click()
1831 if (menEdit.Checked)
1833 menEdit.Checked = False;
1840 FMark.ShowMarker False;
1841 picViewPort.MousePointer = 0;
1844 if (! STRING_IS_LIKE(CurPath, TmpPath))
1866 if (! STRING_IS_LIKE(CurPath, TmpPath))
1875 subFetchAndInitLevel();
1876 menEdit.Checked = True;
1879 // ScaleMode = vbTwips
1880 ToolBox.Move (Width - ToolBox.Width) / 2, Height - ToolBox.Height;
1881 // ScaleMode = vbPixels
1882 // L = GetWindowLong(ToolBox.hWnd, GWL_STYLE)
1883 // L = L And (Not WS_POPUP)
1884 // L = L Or WS_CHILD
1885 // SetWindowLong ToolBox.hWnd, GWL_STYLE, L
1886 // SetParent ToolBox.hWnd, hWnd
1887 ToolBox.Show vbModeless, Me;
1891 FMark.ShowMarker True;
1895 static void menEnOff_Click()
1897 menEnOn.Checked = False;
1898 menEnOff.Checked = True;
1903 static void menEnOn_Click()
1905 menEnOn.Checked = True;
1906 menEnOff.Checked = False;
1911 static void menExit_Click()
1916 static void menFaster_Click()
1922 Debug.Assert(False);
1926 if (DemoFlag != 0) // demoplayback
1928 i = GetSpeedIndex(DeltaTDemo);
1930 If i < 2 Then i = 2;
1931 menDemoSpeed_Click (i);
1935 i = GetSpeedIndex(DeltaTPlay);
1937 If i < 2 Then i = 2;
1938 menPlaySpeed_Click (i);
1942 static void menSlower_Click()
1948 Debug.Assert(False);
1952 if (DemoFlag != 0) // demoplayback
1954 i = GetSpeedIndex(DeltaTDemo);
1956 If nSpeedCount < i Then i = nSpeedCount;
1957 menDemoSpeed_Click (i);
1961 i = GetSpeedIndex(DeltaTPlay);
1963 If nSpeedCount < i Then i = nSpeedCount;
1964 menPlaySpeed_Click (i);
1968 void menPlaySpeed_Click(int Index)
1972 // If NoDisplayFlag And (GameLoopRunning <> 0) Then
1973 // NoDisplayFlag = False
1976 // NoDisplayFlag = False
1977 for (i = menPlaySpeed.LBound; i <= menPlaySpeed.UBound; i++)
1980 menPlaySpeed(i).Checked = (Index == i);
1984 BlockingSpeed = False;
1985 DeltaTPlay = SpeedsByDelayUS[Index];
1987 // If DeltaTPlay < 0 Then
1990 // NoDisplayFlag = True
1994 void menDemoSpeed_Click(int Index)
1998 // If NoDisplayFlag And (GameLoopRunning <> 0) Then
1999 // NoDisplayFlag = False
2002 NoDisplayFlag = False;
2003 for (i = menDemoSpeed.LBound; i <= menDemoSpeed.UBound; i++)
2006 menDemoSpeed(i).Checked = (Index == i);
2010 BlockingSpeed = False;
2011 DeltaTDemo = SpeedsByDelayUS[Index];
2013 // If DeltaTPlay < 0 Then
2016 // NoDisplayFlag = True
2020 static void UpdateDeltaT()
2025 DeltaT = (DemoFlag != 0 ? DeltaTDemo : DeltaTDemo);
2030 NoDisplayFlag = True;
2034 if (NoDisplayFlag && GameLoopRunning != 0)
2036 NoDisplayFlag = False;
2041 NoDisplayFlag = False;
2046 static void menGravOff_Click()
2048 menGravOn.Checked = False;
2049 menGravOff.Checked = True;
2054 static void menGravOn_Click()
2056 menGravOn.Checked = True;
2057 menGravOff.Checked = False;
2062 static void menNew_Click()
2064 NewForm.Show vbModal, Me;
2065 CreateLevel(FieldWidth, FieldHeight);
2069 static void menNewStd_Click()
2071 CreateLevel(60, 24);
2075 static void menOpen_Click()
2080 // cmDlg.DefaultExt = "sp"
2084 (prevent compiler warning here due to suspected use of trigraph)
2086 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";
2089 LFilt = LastOpenFilter;
2090 cmDlg.FilterIndex = (0 < LFilt & LFilt < 5 ? LFilt : LFilt);
2091 if (FileExists(CurPath))
2092 cmDlg.InitDir = WithSlash(StripDir(CurPath));
2094 cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames;
2097 // --- On Error GoTo menOpenEH
2099 // --- On Error GoTo 0
2101 LFilt = cmDlg.FilterIndex;
2102 LastOpenFilter = LFilt;
2103 CurPath = cmDlg.FileName;
2105 FillFileList (CurPath);
2110 static void menOptions_Click()
2114 oFrm.Show vbModal, Me;
2116 picViewPort_Resize();
2119 static void menPanel_Click()
2122 PanelVisible = ! menPanel.Checked;
2126 void Let_PanelVisible(boolean NewVal)
2128 static boolean HidePanel = False;
2130 if (HidePanel != NewVal)
2133 HidePanel = ! NewVal;
2134 PanelTim.Enabled = True;
2137 static void DrawPauseLayer(long Layer)
2139 DirectDrawPalette Pal;
2144 // For Y = 0 To bmpStage.Height Step BaseWidth
2145 // For X = 0 To bmpStage.Width Step BaseWidth
2146 // Pause.TransparentDraw bmpStageHDC, X, Y, Layer
2149 // With Stage.Surface
2150 // Set Pal = .GetPalette
2151 // for i=1 to pal.GetEntries(
2152 // Stage.Surface.SetPalette
2155 static void menPaste_Click()
2162 static void menPause_Click()
2164 static StdPicture OldPic;
2165 static char *OldText = 0;
2167 PauseMode = (PauseMode != 0 ? 0 : 0);
2170 if (IS_NOTHING(&OldPic, sizeof(OldPic)))
2171 OldPic = cmdPause.Picture;
2173 cmdPause.Picture = cmdPause.DownPicture;
2174 OldText = lblStatus.Caption;
2175 lblStatus = "Paused ...";
2179 cmdPause.Picture = OldPic;
2180 lblStatus.Caption = OldText;
2184 static void menPlayAll_Click()
2188 char *LogPath, *OutStr, *ReRecPath, *SPPath;
2190 static boolean QuitFlag = False;
2192 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play) All Demos")
2194 cmdPlayAll.Caption = "Quit All";
2195 menPlayAll.Caption = "Quit All";
2196 FocusTim.Enabled = True;
2199 iMax = cmbFile.ListCount - 1;
2200 LogPath = StripDir(CurPath) & "/Error.Log";
2201 if (Dir(LogPath) != "")
2204 for (i = iMin; i <= iMax; i++)
2206 cmbFile.ListIndex = i;
2207 // If CurPath Like "*.sp" Or CurPath Like "*.mpx" Then
2211 ReRecPath = SPPath & ".ReRec";
2212 menPlayDemo_Click();
2214 // bEqual = FilesEqual(ReRecPath, SPPath)
2215 // If bEqual Then MayKill ReRecPath
2217 OutStr = cmbFile.List(i) & " -> ";
2219 if (Val(lblFrameCount) != GetTotalFramesOfDemo())
2221 OutStr = OutStr & "Error in GetTotalFramesOfDemo()! ";
2222 Debug.Assert(False);
2226 if ((LevelStatus == 1) && bEqual)
2228 OutStr = OutStr & "Success";
2232 OutStr = OutStr & "All Demos (float)Canceled";
2236 if (LevelStatus != 1)
2238 OutStr = OutStr & "### Level Failed ### (TimerVar == " & TimerVar & ")";
2243 OutStr = OutStr & "### ReRecording is binary different ###";
2248 FNum = fopen(LogPath, "ab");
2249 Print #FNum, OutStr;
2256 cmdPlayAll.Caption = "Play All Demos";
2257 menPlayAll.Caption = "Play All Demos";
2258 SettingsObject Settings;
2260 MySignature = Settings.Read("MySignature", "");
2261 FirstDemoByte = 0x81;
2266 if (menStop.Enabled)
2271 static void menRemSP_Click()
2277 static void menRestoreBorder_Click()
2282 static void menSave_Click()
2287 if (STRING_IS_LIKE(CurPath, TmpPath))
2290 if (STRING_IS_LIKE(CurPath, "") || STRING_IS_LIKE(CurPath, "*.dat"))
2296 if (STRING_IS_LIKE(CurPath, "*.sp"))
2302 if (! FileExists(CurPath) || STRING_IS_LIKE(CurPath, "Untitled"))
2309 Let_ModifiedFlag(False);
2312 static void menSaveAs_Click()
2315 FillFileList (CurPath);
2318 static boolean SaveAs()
2320 static boolean SaveAs;
2327 // cmDlg.DefaultExt = "sp"
2328 cmDlg.Filter = "MegaPlex Level (*.mpx)|*.mpx|SpeedFix Demo (*.sp)|*.sp";
2329 cmDlg.FilterIndex = LastSaveFilter;
2330 // If OrigPath Like "*.sp" Then cmDlg.FilterIndex = 1 Else cmDlg.FilterIndex = 0
2331 if (FileExists(OrigPath))
2333 cmDlg.InitDir = WithSlash(StripDir(OrigPath));
2334 cmDlg.InitDir = s.Read("LastSaveDir", cmDlg.InitDir);
2335 cmDlg.FileName = StripExtensionlessFileName(GetFileNameToSave());
2338 cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames;
2341 // --- On Error GoTo SaveAsEH
2343 // --- On Error GoTo 0
2345 LastSaveFilter = cmDlg.FilterIndex;
2346 FN = cmDlg.FileName;
2347 SettingsObject_Save("LastSaveDir", WithSlash(StripDir(FN)));
2348 if (STRING_IS_LIKE(FN, "*.sp"))
2352 else if (STRING_IS_LIKE(FN, "*.mpx"))
2357 Let_ModifiedFlag(False);
2365 static void menSelectAll_Click()
2367 FMark.SetPoint1 0, 0;
2368 FMark.SetPoint2 FieldWidth - 1, FieldHeight - 1;
2371 static void menShowLInfo_Click()
2375 Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")";
2376 if (DemoAvailable && bSignatureAvailable)
2377 Msg = Msg & vbNewLine & vbNewLine & gSignature;
2379 SignatureForm.Signature = Msg;
2380 SignatureForm.DelayMS = 5000;
2383 X = left + (Width - SignatureForm.Width) / 2;
2384 Y = top + (Height - SignatureForm.Height) / 2;
2385 SignatureForm.Move X, Y;
2386 SignatureForm.Show vbModeless, Me;
2390 static void menSoundFX_Click()
2393 menSoundFX.Checked = ! menSoundFX.Checked;
2394 FXOnFlag = (menSoundFX.Checked ? -1 : -1);
2400 // static void menPlay_Click()
2401 void menPlay_Click()
2405 boolean OldEditFlag;
2407 // Trace "MainForm", "--> menPlay_Click()"
2414 SignatureForm.DelayMS = 1;
2415 menPlay.Enabled = False;
2416 menPause.Enabled = True;
2417 menStop.Enabled = True;
2418 cmdPlay.Enabled = False;
2419 cmdPause.Enabled = True;
2420 cmdStop.Enabled = True;
2421 cmdPlayDemo.Enabled = False;
2422 menPlayDemo.Enabled = False;
2423 cmdRecordDemo.Enabled = False;
2424 menRec.Enabled = False;
2425 menFaster.Enabled = True;
2426 menSlower.Enabled = True;
2427 if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play*"))
2429 cmdPlayAll.Enabled = False;
2430 menPlayAll.Enabled = False;
2433 cmbFile.Enabled = False;
2434 cmbLevel.Enabled = False;
2435 OldEditFlag = EditFlag;
2439 menEditMain.Enabled = False;
2440 if (DemoFlag == 0 && RecordDemoFlag == 0)
2441 lblStatus = "Playing";
2450 LastTick = T.TickNow();
2454 fpsTim.Enabled = True;
2465 printf("::: MainForm.c: menPlay_Click(): subFetchAndInitLevelB(): ...\n");
2468 subFetchAndInitLevelB();
2471 printf("::: MainForm.c: menPlay_Click(): subFetchAndInitLevelB(): done\n");
2476 // Trace "MainForm", "CountDown 1"
2477 CountDown(2, (0 == DemoFlag));
2478 // Trace "MainForm", "Call GoPlay"
2482 // Trace "MainForm", "GoPlay returned"
2486 if (LevelStatus == 1)
2488 lblStatus = "(float)Success";
2492 lblStatus = "Try (float)again";
2497 // Trace "MainForm", "CountDown 1"
2498 CountDown(1, False);
2506 // Trace "MainForm", "Call subFetchAndInitLevel"
2508 subFetchAndInitLevel();
2510 // Trace "MainForm", "subFetchAndInitLevel returned"
2516 menEditMain.Enabled = True;
2520 // Trace "MainForm", "<-- menPlay_Click()"
2528 static void menPlayDemo_Click()
2532 lblStatus = "Demo Playback";
2534 if (LevelStatus != 1)
2535 lblStatus = "Demo Failed";
2540 static void menRec_Click()
2542 Trace("MainForm", "--> menRec_Click()");
2551 lblStatus.ForeColor = vbRed;
2552 lblStatus = "Recording Demo";
2553 // DemoBuffer = New DemoBufferObject; // (handle this later, if needed)
2554 Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer)));
2555 Trace("MainForm", "Call menPlayClick");
2557 Trace("MainForm", "menPlayClick returned");
2559 lblStatus.ForeColor = vbButtonText;
2561 Let_ModifiedFlag(True);
2562 if (! STRING_IS_LIKE(CurPath, TmpPath))
2568 LInfo.DemoRandomSeed = RecDemoRandomSeed;
2569 Trace("MainForm", "Call SaveMPX(TmpPath)");
2571 Trace("MainForm", "Set DemoBuffer == Nothing");
2572 SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer));
2573 Trace("MainForm", "Call subFetchAndInitLevel");
2574 subFetchAndInitLevel();
2575 cmdPlayDemo.Enabled = DemoAvailable;
2576 Trace("MainForm", "<-- menRec_Click()");
2579 static void menReRecordDemo_Click()
2589 lblStatus.ForeColor = vbRed;
2590 lblStatus = "ReRecording Demo";
2591 // DemoBuffer = New DemoBufferObject; // (handle this later, if needed)
2592 Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer)));
2594 lblStatus.ForeColor = vbButtonText;
2596 Let_ModifiedFlag(True);
2597 if (! STRING_IS_LIKE(CurPath, TmpPath))
2603 LInfo.DemoRandomSeed = RecDemoRandomSeed;
2605 SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer));
2606 subFetchAndInitLevel();
2609 void menStop_Click()
2616 fpsTim.Enabled = False;
2618 lblFps.Caption = "";
2619 menRec.Enabled = True;
2620 menPlay.Enabled = True;
2621 menPause.Enabled = False;
2622 menStop.Enabled = False;
2623 cmdPlay.Enabled = True;
2624 cmdPause.Enabled = False;
2625 cmdStop.Enabled = False;
2626 cmdRecordDemo.Enabled = True;
2627 cmdPlayDemo.Enabled = DemoAvailable;
2628 cmdPlayAll.Enabled = DemosAvailable;
2629 menPlayDemo.Enabled = DemoAvailable;
2630 menPlayAll.Enabled = DemosAvailable;
2631 menFaster.Enabled = False;
2632 menSlower.Enabled = False;
2633 cmbFile.Enabled = True;
2634 cmbLevel.Enabled = True;
2637 static void menStretch_Click(int Index)
2639 ReStretch(0.25 * Index);
2640 // DisplayLevel True
2643 static void menToolTips_Click()
2646 menToolTips.Checked = ! menToolTips.Checked;
2647 if (menToolTips.Checked)
2649 cmdPlay.ToolTipText = "Play Game (Space)";
2650 cmdPause.ToolTipText = "Pause (P)";
2651 cmdStop.ToolTipText = "Stop (Q)";
2652 cmdPlayDemo.ToolTipText = "Play demo (Ctrl+Space)";
2653 cmdRecordDemo.ToolTipText = "Record demo (Ctrl+R)";
2654 lblInfoCount.ToolTipText = "Number of infotrons needed";
2655 lblRedDiskCount.ToolTipText = "Number of red disks";
2656 cmbLevel.ToolTipText = "List of all levels in the file";
2657 cmbFile.ToolTipText = "List of files in current directory";
2658 lblFps.ToolTipText = "Animation speed in fps";
2659 lblFrameCount.ToolTipText = "Game time in frames";
2663 cmdPlay.ToolTipText = "";
2664 cmdPause.ToolTipText = "";
2665 cmdStop.ToolTipText = "";
2666 cmdPlayDemo.ToolTipText = "";
2667 cmdRecordDemo.ToolTipText = "";
2668 lblInfoCount.ToolTipText = "";
2669 lblRedDiskCount.ToolTipText = "";
2670 cmbLevel.ToolTipText = "";
2671 cmbFile.ToolTipText = "";
2672 lblFps.ToolTipText = "";
2673 lblFrameCount.ToolTipText = "";
2679 static void menTrim_Click()
2684 OldOPath = OrigPath;
2686 Tmp.SpecialPortCount = 0; // hack: all special ports are deleted
2688 CreateLevel(FMark.Width, FMark.Height);
2690 OrigPath = OldOPath;
2692 menSelectAll_Click();
2694 picViewPort_Resize();
2697 static void menZonkOff_Click()
2699 menZonkOn.Checked = False;
2700 menZonkOff.Checked = True;
2705 static void menZonkOn_Click()
2707 menZonkOn.Checked = True;
2708 menZonkOff.Checked = False;
2713 static void PanelTim_Timer()
2718 if (PanelSeq < Panel.Height && -1 < PanelSeq)
2720 PanelSeq = (ShowPanel != 0 ? PanelSeq + 2 : PanelSeq + 2);
2721 Tmp = ScaleHeight - Tmp + PanelSeq;
2723 picViewPort.Height = Tmp;
2727 PanelTim.Enabled = False;
2728 PanelSeq = (PanelSeq < 0 ? 0 : 0);
2729 ShowPanel = (ShowPanel == 0 ? 1 : 1);
2730 menPanel.Checked = (ShowPanel != 0);
2734 static void picKeys_MouseUp(int Button, int Shift, float X, float Y)
2736 FocusTim.Enabled = True;
2739 static void picMenu_Click()
2743 static void picPane_KeyDown(int KeyCode, int Shift)
2745 if (KeyCode < 0 || 255 < KeyCode)
2748 KeyState[KeyCode] = True;
2752 if (MouseButton == 0 && EditFlag)
2753 picPane.MousePointer = 15;
2771 if (DemoFlag != 0 && 2 == Shift)
2780 bCapturePane = ! bCapturePane;
2785 static void picPane_KeyUp(int KeyCode, int Shift)
2787 if (KeyCode < 0 || 255 < KeyCode)
2790 KeyState[KeyCode] = False;
2794 if (menFaster.Enabled)
2800 if (menSlower.Enabled)
2806 if (2 == Shift) // ctrl+space
2808 if (menPlayDemo.Enabled)
2809 menPlayDemo_Click();
2814 if (menPlay.Enabled)
2821 if (menStop.Enabled)
2834 if (menPause.Enabled && (Shift == 0))
2840 if (MouseButton == 0 && EditFlag)
2841 picPane.MousePointer = 0;
2846 static void picPane_MouseDown(int Button, int Shift, float X, float Y)
2850 MouseButton = Button;
2851 OldEdMode = EditMode;
2854 if (Button == 2 && Shift != 2)
2856 EditMode = edSelect;
2874 picPane.MousePointer = 5; // size
2875 UserDragFlag = True;
2879 SetField(X, Y, ToolBox.ASpriteIndex);
2883 FMark.SetPoint1 EdGetX(X), EdGetY(Y);
2888 EditMode = OldEdMode;
2891 static void picPane_MouseMove(int Button, int Shift, float X, float Y)
2896 OldEdMode = EditMode;
2899 if (EditFlag && Button == 2 && Shift != 2)
2901 EditMode = edSelect;
2915 Oldflag = NoDisplayFlag;
2916 NoDisplayFlag = False;
2917 ScrollTo(OSX - X + MDX, OSY - Y + MDY);
2919 NoDisplayFlag = Oldflag;
2923 SetField(X, Y, ToolBox.ASpriteIndex);
2927 FMark.SetPoint2 EdGetX(X), EdGetY(Y);
2932 EditMode = OldEdMode;
2935 static void picPane_MouseUp(int Button, int Shift, float X, float Y)
2937 MouseButton = MouseButton ^ Button;
2938 picPane.MousePointer = 0;
2939 UserDragFlag = False;
2940 if (menEditMain.Enabled && Button == 2)
2942 if (MDX == X && MDY == Y)
2943 PopupMenu menEditMain;
2949 static void picPane_Paint()
2953 Oldflag = NoDisplayFlag;
2954 NoDisplayFlag = False;
2956 NoDisplayFlag = Oldflag;
2959 static void ReStretch(float NewStretch)
2964 long BW2, LW, LH, i;
2968 printf("::: MainForm.c: ReStretch(): %d, %d\n", Loaded, LevelLoaded);
2974 printf("::: NewStretch == %f\n", NewStretch);
2977 Stretch = NewStretch;
2983 SET_TO_NOTHING(&Stage, sizeof(Stage));
2984 SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites));
2985 menStretch(Stretch / 0.25).Checked = False;
2988 Stretch = NewStretch;
2991 menStretch(Stretch / 0.25).Checked = True;
2992 // StretchWidth = BaseWidth ' * NewStretch
2993 // StretchWidth2 = StretchWidth \ 2
2994 // TwoPixels = 2 '* Stretch
2995 // StretchLoad Sprites, imgMpx.Picture, 16, 16
2998 BW2 = StretchWidth / 2;
2999 LW = (FieldWidth + 2) * BaseWidth; // StretchWidth
3000 LH = (FieldHeight + 2) * BaseWidth; // StretchWidth
3003 // i = bmpStage.CreateAtSize(LW, LH)
3004 // Stage = New DDScrollBuffer; // (handle this later, if needed)
3005 i = Stage.CreateAtSize(LW, LH, picPane.hWnd);
3006 // Set StretchedSprites = NormalSprites.GetStretchCopy(Stretch)
3007 ReLoadStretchSprites();
3008 if (i == 0 || IS_NOTHING(&StretchedSprites, sizeof(StretchedSprites)))
3010 // menStretch(Stretch / 0.5).Enabled = False
3012 ReStretch(Stretch - 0.25);
3018 StretchedSprites.DestXOff = 1 * BaseWidth; // StretchWidth
3019 StretchedSprites.DestYOff = 1 * BaseWidth; // StretchWidth
3020 Stage.DestXOff = 1 * StretchWidth;
3021 Stage.DestYOff = 1 * StretchWidth;
3022 StretchedSprites.DestinationSurface = Stage.Surface;
3028 if (Loaded && LevelLoaded)
3031 printf("::: MainForm.c: ReStretch(): ...\n");
3035 picViewPort_Resize();
3039 subCalculateScreenScrollPos();
3042 printf("::: MainForm.c: ReStretch(): %d, %d\n", ScreenScrollXPos, ScreenScrollYPos);
3045 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
3057 static void SetScrollEdges()
3060 printf("::: MainForm.c: SetScrollEdges() ... [%ld, %ld, %ld, %ld] [%f, %d] [%d, %d, %d, %d]\n",
3061 DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY,
3063 ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY);
3066 ScrollMinX = (int)(DisplayMinX - 0.5) * Stretch * BaseWidth;
3067 ScrollMinY = (int)(DisplayMinY - 0.5) * Stretch * BaseWidth;
3068 ScrollMaxX = (int)(DisplayMaxX + 1.5) * Stretch * BaseWidth - picPane.Width;
3069 ScrollMaxY = (int)(DisplayMaxY + 1.5) * Stretch * BaseWidth - picPane.Height;
3072 printf("::: MainForm.c: SetScrollEdges() done [%d, %d, %d, %d]\n",
3073 ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY);
3077 void DrawField(int X, int Y)
3082 Tmp = LowByte(PlayField16[tsi]);
3086 if (Tmp == fiRAM || Tmp == fiHardWare)
3087 Tmp = DisPlayField[tsi];
3089 if (Tmp == fiBug || Tmp == 40)
3090 Tmp = DisPlayField[tsi];
3094 if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak)
3095 Tmp = DisPlayField[tsi];
3098 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
3101 void DrawFieldAnimated(int X, int Y)
3106 Tmp = LowByte(PlayField16[tsi]);
3110 subDrawAnimatedSnikSnaks(tsi);
3114 subDrawAnimatedElectrons(tsi);
3118 // If 40 < Tmp Then Tmp = 0
3119 // If Tmp = fiRAM Or Tmp = fiHardWare Then Tmp = DisPlayField(tsi)
3120 // If Tmp = fiBug Or Tmp = 40 Then Tmp = DisPlayField(tsi)
3122 // If fiOrangeDisk < Tmp And Tmp < fiSnikSnak Then Tmp = DisPlayField(tsi)
3124 // StretchedSprites.BltEx StretchWidth * X, StretchWidth * Y, Tmp
3129 void DrawFieldNoAnimated(int X, int Y)
3134 Tmp = LowByte(PlayField16[tsi]);
3138 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace);
3142 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace);
3149 if (Tmp == fiRAM || Tmp == fiHardWare)
3150 Tmp = DisPlayField[tsi];
3152 if (Tmp == fiBug || Tmp == 40)
3153 Tmp = DisPlayField[tsi];
3157 if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak)
3158 Tmp = DisPlayField[tsi];
3162 printf("::: MainForm.c: DrawFieldNoAnimated(): %d, %d [%d]\n",
3166 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp);
3171 void DrawSprite(int X, int Y, int SpritePos)
3173 StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, SpritePos);
3178 void InvalidateRect(long XMin, long YMin, long XMax, long YMax)
3182 // For Y = YMin To YMax
3183 // For X = XMin To XMax
3184 // Field(X, Y).GraphicsValid = 0
3189 static void picViewPort_MouseUp(int Button, int Shift, float X, float Y)
3191 FocusTim.Enabled = True;
3194 static void picViewPort_Paint()
3196 // Debug.Print "picViewPort_Paint()"
3201 static void picViewPort_Resize()
3204 long bdX, bdY, PanelVisibility;
3209 bdX = picFrame.Width - picFrame.ScaleWidth;
3210 bdY = picFrame.Height - picFrame.ScaleHeight;
3211 dx = Min(picViewPort.ScaleWidth - bdX, (DisplayWidth - 1) * Stretch * BaseWidth);
3213 dY = Min(picViewPort.ScaleHeight - bdX, (DisplayHeight - 1) * Stretch * BaseWidth);
3215 B = s.Read("LimitToOriginalFieldSize", False);
3216 PanelVisibility = 24 * (Panel.Height - PanelSeq - (float)1) / Panel.Height;
3219 dx = Min(320 * Stretch, dx);
3220 dY = Min((200 - PanelVisibility) * Stretch, dY);
3223 X = Max((picViewPort.ScaleWidth - dx) / 2, 0);
3224 Y = Max((picViewPort.ScaleHeight - dY) / 2, 0);
3225 picPane.Move X, Y, dx, dY;
3226 picFrame.Move X - bdX / 2, Y - bdY / 2, dx + bdX, dY + bdY;
3232 printf("::: MainForm.c: picViewPort_Resize(): %d, %d\n", ScrollX, ScrollY);
3235 ScrollTo(ScrollX, ScrollY);
3237 // SizeTim.Interval = 1
3243 // Private Sub SizeTim_Timer()
3245 // SizeTim.Interval = 0
3246 // wdX = Max(0, picViewPort.ScaleWidth - picPane.Width) * Screen.TwipsPerPixelX
3247 // wdY = Max(0, picViewPort.ScaleHeight - picPane.Height) * Screen.TwipsPerPixelY
3248 // If (0 < wdX) Or (0 < wdY) Then
3249 // Move Left, Top, Width - wdX, Height - wdY
3253 static void LoadKeyIndicators()
3257 picKeys.BackColor = vbButtonFace;
3258 for (i = 2; i <= 5; i++)
3263 for (i = 1; i <= 5; i++)
3265 shpKey(i).FillColor = vbButtonFace;
3266 shpKey(i).Visible = True;
3269 shpKey(1).Move 7, 0;
3270 shpKey(2).Move 0, 7;
3271 shpKey(3).Move 7, 14;
3272 shpKey(4).Move 14, 7;
3273 shpKey(5).Move 7, 7;
3276 void ShowKey(int KeyVar)
3278 boolean State[5 + 1];
3282 static boolean LastState[5 + 1];
3294 State[KeyVar] = True;
3300 State[KeyVar - 4] = True;
3304 for (i = 1; i <= 5; i++)
3307 if (Tmp ^ LastState[i])
3309 Col = (i == 5 ? vbRed : vbRed);
3310 shpKey(i).FillColor = (Tmp ? Col : Col);
3317 static void GetSettings()
3327 APath = WithSlash(App.Path);
3328 CurPath = s.Read("LastPath", APath);
3330 // window width and height
3331 X = s.Read("Width", Width);
3332 Y = s.Read("Height", Height);
3333 if (X < 0 Then X == 0: If Y < 0)
3336 if (Screen.Width < X)
3339 if (Screen.Height < Y)
3344 // window position and state
3345 X = s.Read("Left", left);
3346 Y = s.Read("Top", top);
3347 if (X < 0 Then X == 0: If Y < 0)
3350 if (Screen.Width < (X + Width))
3351 X = Screen.Width - Width;
3353 if (Screen.Height < (Y + Height))
3354 Y = Screen.Height - Height;
3358 WindowState = s.Read("WinState", vbNormal);
3360 Flag = s.Read("ShowToolTips", True);
3362 menToolTips_Click();
3364 menBorder.Checked = ! CBool(s.Read("ShowBorder", False));
3365 Flag = CBool(s.Read("AutoScroll", True));
3368 AutoScrollFlag = False;
3369 menAutoScroll.Checked = False;
3372 Flag = CBool(s.Read("SoundFX", True));
3373 FXOnFlag = (Flag ? -1 : -1);
3374 menSoundFX.Checked = Flag;
3375 SignatureDelay = CLng(s.Read("SignatureDelay", 3000));
3376 AllowRedDiskCheat = CInt(s.Read("AllowRedDiskCheat", 1));
3377 AllowEatRightRedDiskBug = CInt(s.Read("AllowEatRightRedDiskBug", 1));
3378 MySignature = s.Read("MySignature", "");
3380 X = s.Read("FrameDelayPlay", 1000000 / 35);
3381 i = GetSpeedIndex(X);
3382 menPlaySpeed_Click(i);
3383 X = s.Read("FrameDelayDemo", 1000000 / 35);
3384 i = GetSpeedIndex(X);
3385 menDemoSpeed_Click(i);
3387 i = s.Read("Stretch", 4);
3388 if (i < menStretch.LBound || menStretch.UBound < i)
3391 menStretch_Click (i);
3395 static void SaveSettings()
3401 s.Save "LastPath", (ModifiedFlag ? OrigPath : OrigPath);
3402 if (WindowState != vbMinimized)
3404 s.Save "Width", Width;
3405 s.Save "Height", Height;
3406 s.Save "Left", left;
3408 s.Save "WinState", WindowState;
3411 s.Save "ShowToolTips", menToolTips.Checked;
3412 s.Save "ShowBorder", menBorder.Checked;
3413 s.Save "AutoScroll", menAutoScroll.Checked;
3414 s.Save "SoundFX", menSoundFX.Checked;
3415 s.Save "SignatureDelay", SignatureDelay;
3416 s.Save "AllowRedDiskCheat", AllowRedDiskCheat;
3417 s.Save "AllowEatRightRedDiskBug", AllowEatRightRedDiskBug;
3418 s.Save "MySignature", MySignature;
3420 s.Save "FrameDelayPlay", DeltaTPlay;
3421 s.Save "FrameDelayDemo", DeltaTDemo;
3423 for (i = menStretch.LBound; i <= menStretch.UBound; i++)
3425 if (menStretch(i).Checked)
3429 s.Save "Stretch", i;
3434 void ReLoadStretchSprites()
3437 BitMapObject NBMP, SBMP;
3440 // If Stretch = 1 Then
3441 MpxBmp = App.Path & "/Mpx.bmp";
3443 // MpxBmp = App.Path & "\Mpx" & Stretch & ".bmp"
3444 // tmpMpxBmp = App.Path & "\Mpx.bmp"
3445 // If FileExists(MpxBmp) And FileExists(tmpMpxBmp) Then
3446 // If FileDateTime(MpxBmp) < FileDateTime(tmpMpxBmp) Then
3450 // If Not FileExists(MpxBmp) Then
3451 // MousePointer = 11
3452 // // Set NBMP = New BitMapObject // (handle this later, if needed)
3453 // tmpMpxBmp = App.Path & "\Mpx.bmp"
3454 // If Not FileExists(tmpMpxBmp) Then
3455 // ReportError "ReLoadStretchSprites", "File not found: " & tmpMpxBmp
3456 // MESSAGE_BOX("an error occured"); // MsgBox "File not found: " & tmpMpxBmp, vbCritical, "MegaPlex - Error"
3459 // NBMP.CreateFromFile tmpMpxBmp
3460 // Set SBMP = NBMP.GetStretchCopy(Stretch)
3461 // SBMP.SaveToFile MpxBmp
3462 // Set NBMP = Nothing
3463 // Set SBMP = Nothing
3467 // StretchedSprites = New DDSpriteBuffer; // (handle this later, if needed)
3468 if (! StretchedSprites.CreateFromFile(MpxBmp, 16, 16))
3469 SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites));
3472 void SaveSnapshot(currency Number)
3476 Path = CAT(WithSlash(App.Path), "Capture");
3480 Path = Path & "\" & Format(Number, "00000000") & ".bmp";
3481 SavePicture CaptureWindow(picPane.hWnd, True, 0, 0, picPane.ScaleWidth, picPane.ScaleHeight), Path;