X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_sp%2FMainForm.c;h=f44177c7f6bab040dac44d392e4e172ef449a597;hb=18863a5655e9e07d548e2d673e7f82336703c8fb;hp=8022080ac4759e95f5c6901bbba39ddad32a3694;hpb=ac592f78bbedc4808c5e35fb22bc8fc9f0398c8d;p=rocksndiamonds.git diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index 8022080a..f44177c7 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -7,6 +7,10 @@ #if 1 static void DrawFrame(int Delta); +static void ReStretch(float NewStretch); +static void picPane_Paint(); +static void picViewPort_Resize(); +static void menBorder_Click(); #else @@ -670,16 +674,26 @@ void DrawFieldNoAnimated(int X, int Y); // --- Option Explicit // --- Option Compare Text +#if 0 + long SetParent(long hWndChild, long hWndNewParent); long SetWindowLong(long hWnd, long nIndex, long dwNewLong); long GetWindowLong(long hWnd, long nIndex); +#if 0 long GetTempPath(long nBufferLength, char *lpBuffer); +#endif long GetWindowText(long hWnd, char *lpString, long cch); +#endif + +#if 0 + #define GWL_STYLE ((-16)) #define WS_CHILD (0x40000000) #define WS_POPUP (0x80000000) +#endif + // [UNCOMMENTED] Dim StretchWidth2& char *MpxBmp; @@ -999,29 +1013,56 @@ static boolean InstanceStillRunning(char *TmpFile) #endif +void DrawFrameIfNeeded() +{ + DrawFrame(0); + + /* !!! CHECK THIS !!! */ +#if 1 + if (! menBorder.Checked) + DrawFrame(1); +#endif +} + void DisplayLevel() { int X, Y; +#if 0 + printf("::: MainForm.c: DisplayLevel(): %d, %d, %d\n", + Loaded, LevelLoaded, bPlaying); +#endif + if (! Loaded) return; if (! LevelLoaded) return; -#if 0 + ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); + ClearRectangle(screenBitmap, 0, 0, + MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY); + +#if 1 SetDisplayRegion(); #endif DrawFrame(0); -#if 0 + /* !!! CHECK THIS !!! */ +#if 1 if (! menBorder.Checked) DrawFrame(1); #endif if (bPlaying) { +#if 0 + printf("::: MainForm.c: DisplayLevel(): [%ld, %ld, %ld, %ld] [%d, %d]...\n", + DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY, + FieldWidth, FieldHeight); +#endif + for (Y = DisplayMinY; Y <= DisplayMaxY; Y++) { for (X = DisplayMinX; X <= DisplayMaxX; X++) @@ -1100,8 +1141,8 @@ static void cmbLevel_Click() long InfoCount; boolean Oldflag; int Msg; - long LastIndex; - boolean bBlock; + static long LastIndex = 0; + static boolean bBlock = False; if (bBlock) return; @@ -1305,7 +1346,9 @@ static void Form_KeyUp(int KeyCode, int Shift) picPane_KeyUp(KeyCode, Shift); } -static void Form_Load() +#endif + +void Form_Load() { #if 0 @@ -1320,6 +1363,7 @@ static void Form_Load() EditFlag = False; EditMode = edMove; // FMark = New MarkerObject; // (handle this later, if needed) + InitGlobals(); #if 0 @@ -1346,14 +1390,25 @@ static void Form_Load() picViewPort.ScaleMode = vbPixels; +#endif + PauseMode = 0; // BaseWidth = 16 - menBorder_Click(); + +#if 1 + if (0) + menBorder_Click(); +#endif + Loaded = True; + ReStretch(Stretch); + +#if 0 + LoadKeyIndicators(); - Show; + Show(); FillFileList(CurPath); if (s.Read("ShowSplash", True)) @@ -1365,6 +1420,8 @@ static void Form_Load() #endif } +#if 0 + static void FillLevelList(char *Path, int LevelIndex) { long FNum, LevLen, i, iMax; @@ -1576,7 +1633,7 @@ static void Form_Resize() // NW = ScaleWidth - 2 * Space: If NW < 0 Then NW = 0 // NH = ScaleHeight - 3 * Space - cmbLevel.Height: If NH < 0 Then NH = 0 // picViewPort.Move Space, Space, NW, NH - Tmp = (ShowPanel != 0 ? ScaleHeight - Panel.Height : ScaleHeight - Panel.Height); + Tmp = (ShowPanel != 0 ? ScaleHeight - Panel.Height : ScaleHeight); if (Tmp < 0) Tmp = 0; @@ -1595,6 +1652,35 @@ static void Form_Resize() #endif +#if 1 + +static void DrawFrame(int Delta) +{ + int i, LX, tY, RX, BY; + + LX = -1 + Delta; + tY = -1 + Delta; + RX = FieldWidth - Delta; + BY = FieldHeight - Delta; + DrawImage(LX, tY, imgFrameCorner); + DrawImage(LX, BY, imgFrameCorner); + DrawImage(RX, tY, imgFrameCorner); + DrawImage(RX, BY, imgFrameCorner); + for (i = LX + 1; i <= RX - 1; i++) + { + DrawImage(i, tY, imgFrameHorizontal); + DrawImage(i, BY, imgFrameHorizontal); + } + + for (i = tY + 1; i <= BY - 1; i++) + { + DrawImage(LX, i, imgFrameVertical); + DrawImage(RX, i, imgFrameVertical); + } +} + +#else + static void DrawFrame(int Delta) { int i, LX, tY, RX, BY; @@ -1620,7 +1706,7 @@ static void DrawFrame(int Delta) } } -#if 0 +#endif static void RestoreFrame() { @@ -1643,6 +1729,8 @@ static void RestoreFrame() } } +#if 0 + static void Form_Unload(int Cancel) { EndFlag = True; @@ -1695,7 +1783,7 @@ static void Form_Unload(int Cancel) static void fpsTim_Timer() { currency TickDiff; - int count5; + static int count5 = 0; count5 = count5 + 1; if (4 < count5) @@ -1724,6 +1812,8 @@ static void menAutoScroll_Click() } } +#endif + static void menBorder_Click() { if (menBorder.Checked) @@ -1735,6 +1825,7 @@ static void menBorder_Click() DisplayMinY = 1; DisplayMaxY = FieldHeight - 2; DisplayHeight = FieldHeight; + if (Loaded && LevelLoaded) DrawFrame(1); @@ -1748,6 +1839,7 @@ static void menBorder_Click() DisplayMinY = 0; DisplayMaxY = FieldHeight - 1; DisplayHeight = FieldHeight + 2; + if (Loaded && LevelLoaded) RestoreFrame(); } @@ -1766,6 +1858,7 @@ void SetDisplayRegion() DisplayMinY = 1; DisplayMaxY = FieldHeight - 2; DisplayHeight = FieldHeight; + if (LevelLoaded) DrawFrame(1); @@ -1778,11 +1871,14 @@ void SetDisplayRegion() DisplayMinY = 0; DisplayMaxY = FieldHeight - 1; DisplayHeight = FieldHeight + 2; + if (LevelLoaded) RestoreFrame(); } } +#if 0 + static void menCopy_Click() { FMark.Copy; @@ -1986,7 +2082,7 @@ static void UpdateDeltaT() if (! bPlaying) return; - DeltaT = (DemoFlag != 0 ? DeltaTDemo : DeltaTDemo); + DeltaT = (DemoFlag != 0 ? DeltaTDemo : DeltaTPlay); if (DeltaT < 0) { Stage.Blt(); @@ -2051,7 +2147,7 @@ static void menOpen_Click() */ LFilt = LastOpenFilter; - cmDlg.FilterIndex = (0 < LFilt & LFilt < 5 ? LFilt : LFilt); + cmDlg.FilterIndex = (0 < LFilt & LFilt < 5 ? LFilt : 1); if (FileExists(CurPath)) cmDlg.InitDir = WithSlash(StripDir(CurPath)); @@ -2089,7 +2185,7 @@ static void menPanel_Click() void Let_PanelVisible(boolean NewVal) { - boolean HidePanel; + static boolean HidePanel = False; if (HidePanel != NewVal) return; @@ -2125,10 +2221,10 @@ static void menPaste_Click() static void menPause_Click() { - StdPicture OldPic; - char *OldText; + static StdPicture OldPic; + static char *OldText = 0; - PauseMode = (PauseMode != 0 ? 0 : 0); + PauseMode = (PauseMode != 0 ? 0 : 1); if (PauseMode != 0) { if (IS_NOTHING(&OldPic, sizeof(OldPic))) @@ -2151,7 +2247,7 @@ static void menPlayAll_Click() int FNum; char *LogPath, *OutStr, *ReRecPath, *SPPath; boolean bEqual; - boolean QuitFlag; + static boolean QuitFlag = False; if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play) All Demos") { @@ -2355,7 +2451,7 @@ static void menSoundFX_Click() { { menSoundFX.Checked = ! menSoundFX.Checked; - FXOnFlag = (menSoundFX.Checked ? -1 : -1); + FXOnFlag = (menSoundFX.Checked ? -1 : 0); } } @@ -2364,7 +2460,6 @@ static void menSoundFX_Click() // static void menPlay_Click() void menPlay_Click() { - #if 0 boolean OldEditFlag; @@ -2410,27 +2505,37 @@ void menPlay_Click() #endif LastFrame = 0; + #if 0 LastTick = T.TickNow(); #endif #if 0 - fpsTim.Enabled = True; - #endif // DimPrimary 100 bPlaying = True; #if 0 - UpdateDeltaT(); +#endif + +#if 1 +#endif +#if 0 + printf("::: MainForm.c: menPlay_Click(): subFetchAndInitLevelB(): ...\n"); #endif subFetchAndInitLevelB(); +#if 0 + printf("::: MainForm.c: menPlay_Click(): subFetchAndInitLevelB(): done\n"); +#endif + + ReStretch(Stretch); + // Trace "MainForm", "CountDown 1" CountDown(2, (0 == DemoFlag)); // Trace "MainForm", "Call GoPlay" @@ -2467,7 +2572,9 @@ void menPlay_Click() // Trace "MainForm", "subFetchAndInitLevel returned" +#if 0 Stage.Blt(); +#endif #if 0 @@ -2478,23 +2585,60 @@ void menPlay_Click() // Trace "MainForm", "<-- menPlay_Click()" #endif - } +#if 1 + +// static void menPlayDemo_Click() +void menPlayDemo_Click() +{ + DemoFlag = 1; + RecordDemoFlag = 0; + +#if 0 + lblStatus = "Demo Playback"; +#endif + + menPlay_Click(); + +#if 1 + return; /* return after initialization phase */ +#endif + #if 0 + if (LevelStatus != 1) + lblStatus = "Demo Failed"; +#endif + + DemoFlag = 0; +} + +#else -static void menPlayDemo_Click() +// static void menPlayDemo_Click() +void menPlayDemo_Click() { DemoFlag = 1; RecordDemoFlag = 0; + +#if 0 lblStatus = "Demo Playback"; +#endif + menPlay_Click(); + +#if 0 if (LevelStatus != 1) lblStatus = "Demo Failed"; +#endif DemoFlag = 0; } +#endif + +#if 0 + static void menRec_Click() { Trace("MainForm", "--> menRec_Click()"); @@ -2675,7 +2819,7 @@ static void PanelTim_Timer() Tmp = Panel.Height; if (PanelSeq < Panel.Height && -1 < PanelSeq) { - PanelSeq = (ShowPanel != 0 ? PanelSeq + 2 : PanelSeq + 2); + PanelSeq = (ShowPanel != 0 ? PanelSeq + 2 : PanelSeq - 2); Tmp = ScaleHeight - Tmp + PanelSeq; Panel.top = Tmp; picViewPort.Height = Tmp; @@ -2683,8 +2827,8 @@ static void PanelTim_Timer() else { PanelTim.Enabled = False; - PanelSeq = (PanelSeq < 0 ? 0 : 0); - ShowPanel = (ShowPanel == 0 ? 1 : 1); + PanelSeq = (PanelSeq < 0 ? 0 : PanelSeq - ); + ShowPanel = (ShowPanel == 0 ? 1 : 0); menPanel.Checked = (ShowPanel != 0); } } @@ -2902,39 +3046,66 @@ static void picPane_MouseUp(int Button, int Shift, float X, float Y) } } +#endif + static void picPane_Paint() { boolean Oldflag; Oldflag = NoDisplayFlag; NoDisplayFlag = False; + +#if 0 Stage.Blt(); +#endif + NoDisplayFlag = Oldflag; } static void ReStretch(float NewStretch) { +#if 1 + long BW2, LW, LH; +#else long BW2, LW, LH, i; +#endif + +#if 0 + printf("::: MainForm.c: ReStretch(): %d, %d\n", Loaded, LevelLoaded); +#endif if (! Loaded) { +#if 0 + printf("::: NewStretch == %f\n", NewStretch); +#endif + Stretch = NewStretch; return; } +#if 0 MousePointer = 11; SET_TO_NOTHING(&Stage, sizeof(Stage)); SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites)); menStretch(Stretch / 0.25).Checked = False; +#endif + Stretch = NewStretch; + +#if 0 menStretch(Stretch / 0.25).Checked = True; // StretchWidth = BaseWidth ' * NewStretch // StretchWidth2 = StretchWidth \ 2 // TwoPixels = 2 '* Stretch // StretchLoad Sprites, imgMpx.Picture, 16, 16 +#endif + BW2 = StretchWidth / 2; LW = (FieldWidth + 2) * BaseWidth; // StretchWidth LH = (FieldHeight + 2) * BaseWidth; // StretchWidth + +#if 0 // i = bmpStage.CreateAtSize(LW, LH) // Stage = New DDScrollBuffer; // (handle this later, if needed) i = Stage.CreateAtSize(LW, LH, picPane.hWnd); @@ -2948,38 +3119,72 @@ static void ReStretch(float NewStretch) } else +#endif { StretchedSprites.DestXOff = 1 * BaseWidth; // StretchWidth StretchedSprites.DestYOff = 1 * BaseWidth; // StretchWidth Stage.DestXOff = 1 * StretchWidth; Stage.DestYOff = 1 * StretchWidth; StretchedSprites.DestinationSurface = Stage.Surface; - Stage.Cls; + +#if 0 + Stage.Cls(); +#endif + if (Loaded && LevelLoaded) { +#if 0 + printf("::: MainForm.c: ReStretch(): ...\n"); +#endif + SetDisplayRegion(); picViewPort_Resize(); DisplayLevel(); } subCalculateScreenScrollPos(); + +#if 0 + printf("::: MainForm.c: ReStretch(): %d, %d\n", ScreenScrollXPos, ScreenScrollYPos); +#endif + ScrollTo(ScreenScrollXPos, ScreenScrollYPos); + +#if 0 Stage.Blt(); +#endif + picPane_Paint(); } +#if 0 MousePointer = 0; +#endif } +#if 0 static void SetScrollEdges() +#else +void SetScrollEdges() +#endif { - ScrollMinX = (DisplayMinX - 0.5) * Stretch * BaseWidth; - ScrollMinY = (DisplayMinY - 0.5) * Stretch * BaseWidth; - ScrollMaxX = (DisplayMaxX + 1.5) * Stretch * BaseWidth - picPane.Width; - ScrollMaxY = (DisplayMaxY + 1.5) * Stretch * BaseWidth - picPane.Height; -} +#if 0 + printf("::: MainForm.c: SetScrollEdges() ... [%ld, %ld, %ld, %ld] [%f, %d] [%d, %d, %d, %d]\n", + DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY, + Stretch, BaseWidth, + ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY); +#endif + ScrollMinX = (int)(DisplayMinX - 0.5) * Stretch * BaseWidth; + ScrollMinY = (int)(DisplayMinY - 0.5) * Stretch * BaseWidth; + ScrollMaxX = (int)(DisplayMaxX + 1.5) * Stretch * BaseWidth - picPane.Width; + ScrollMaxY = (int)(DisplayMaxY + 1.5) * Stretch * BaseWidth - picPane.Height; + +#if 0 + printf("::: MainForm.c: SetScrollEdges() done [%d, %d, %d, %d]\n", + ScrollMinX, ScrollMinY, ScrollMaxX, ScrollMaxY); #endif +} void DrawField(int X, int Y) { @@ -2987,7 +3192,7 @@ void DrawField(int X, int Y) tsi = GetSI(X, Y); Tmp = LowByte(PlayField16[tsi]); - if (40 < Tmp) + if (Tmp > 40) Tmp = 0; if (Tmp == fiRAM || Tmp == fiHardWare) @@ -2998,11 +3203,23 @@ void DrawField(int X, int Y) if (EditFlag) { - if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak) + if (Tmp > fiOrangeDisk && Tmp < fiSnikSnak) Tmp = DisPlayField[tsi]; } +#if 1 + if (Tmp >= 0 && Tmp <= 40) + { + subCopyImageToScreen(tsi, fiGraphic[Tmp]); + +#if 1 + if (Tmp != fiSpace && Tmp != fiSnikSnak && Tmp != fiElectron) + GfxGraphic[X][Y] = fiGraphic[Tmp]; +#endif + } +#else StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp); +#endif } void DrawFieldAnimated(int X, int Y) @@ -3042,15 +3259,23 @@ void DrawFieldNoAnimated(int X, int Y) switch (Tmp) { case fiSnikSnak: +#if 1 + subCopyImageToScreen(tsi, aniSpace); +#else StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace); +#endif break; case fiElectron: +#if 1 + subCopyImageToScreen(tsi, aniSpace); +#else StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, fiSpace); +#endif break; default: - if (40 < Tmp) + if (Tmp > 40) Tmp = 0; if (Tmp == fiRAM || Tmp == fiHardWare) @@ -3061,20 +3286,50 @@ void DrawFieldNoAnimated(int X, int Y) if (EditFlag) { - if (fiOrangeDisk < Tmp && Tmp < fiSnikSnak) + if (Tmp > fiOrangeDisk && Tmp < fiSnikSnak) Tmp = DisPlayField[tsi]; } +#if 0 + if (TEST_flag) + printf("::: MainForm.c: DrawFieldNoAnimated(): %d, %d [%d]\n", + X, Y, Tmp); +#endif + +#if 1 + if (Tmp >= 0 && Tmp <= 40) + { + subCopyImageToScreen(tsi, fiGraphic[Tmp]); + +#if 1 + if (Tmp != fiSpace && Tmp != fiSnikSnak && Tmp != fiElectron) + GfxGraphic[X][Y] = fiGraphic[Tmp]; +#endif + } +#else StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp); +#endif + break; } } +#if 1 + +void DrawImage(int X, int Y, int graphic) +{ + StretchedSprites.BltImg(StretchWidth * X, StretchWidth * Y, graphic, 0); +} + +#else + void DrawSprite(int X, int Y, int SpritePos) { StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, SpritePos); } +#endif + #if 0 void InvalidateRect(long XMin, long YMin, long XMax, long YMax) @@ -3098,8 +3353,11 @@ static void picViewPort_Paint() // Debug.Print "picViewPort_Paint()" } +#endif + static void picViewPort_Resize() { +#if 0 long bdX, bdY, PanelVisibility; long X, Y, dx, dY; SettingsObject s; @@ -3123,11 +3381,21 @@ static void picViewPort_Resize() Y = Max((picViewPort.ScaleHeight - dY) / 2, 0); picPane.Move X, Y, dx, dY; picFrame.Move X - bdX / 2, Y - bdY / 2, dx + bdX, dY + bdY; +#endif + SetScrollEdges(); + +#if 0 + printf("::: MainForm.c: picViewPort_Resize(): %d, %d\n", ScrollX, ScrollY); +#endif + ScrollTo(ScrollX, ScrollY); + // SizeTim.Interval = 1 } +#if 0 + // // Private Sub SizeTim_Timer() // Dim wdX&, wdY& @@ -3168,7 +3436,7 @@ void ShowKey(int KeyVar) int i; boolean Tmp; long Col; - boolean LastState[5 + 1]; + static boolean LastState[5 + 1]; // For i = 1 To 5 // State(i) = False @@ -3195,8 +3463,8 @@ void ShowKey(int KeyVar) Tmp = State[i]; if (Tmp ^ LastState[i]) { - Col = (i == 5 ? vbRed : vbRed); - shpKey(i).FillColor = (Tmp ? Col : Col); + Col = (i == 5 ? vbRed : vbGreen); + shpKey(i).FillColor = (Tmp ? Col : vbButtonFace); shpKey(i).Refresh; LastState[i] = Tmp; } @@ -3259,7 +3527,7 @@ static void GetSettings() } Flag = CBool(s.Read("SoundFX", True)); - FXOnFlag = (Flag ? -1 : -1); + FXOnFlag = (Flag ? -1 : 0); menSoundFX.Checked = Flag; SignatureDelay = CLng(s.Read("SignatureDelay", 3000)); AllowRedDiskCheat = CInt(s.Read("AllowRedDiskCheat", 1)); @@ -3287,7 +3555,7 @@ static void SaveSettings() int i; { - s.Save "LastPath", (ModifiedFlag ? OrigPath : OrigPath); + s.Save "LastPath", (ModifiedFlag ? OrigPath : CurPath); if (WindowState != vbMinimized) { s.Save "Width", Width;