From 4591885cdbcfec145d1ac0510fed1519af1eea1d Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 16 Mar 2010 01:23:54 +0100 Subject: [PATCH] rnd-20100316-1-src --- src/conftime.h | 2 +- src/game_sp/ASM.h | 5 - src/game_sp/BugsTerminals.h | 5 - src/game_sp/DDScrollBuffer.c | 16 +- src/game_sp/DDScrollBuffer.h | 5 - src/game_sp/DDSpriteBuffer.h | 5 - src/game_sp/Demo.c | 89 - src/game_sp/Demo.h | 10 - src/game_sp/Display.c | 28 +- src/game_sp/Display.h | 5 - src/game_sp/DoGameStuff.h | 5 - src/game_sp/Electrons.c | 20 +- src/game_sp/Electrons.h | 5 - src/game_sp/Explosions.c | 2 +- src/game_sp/Explosions.h | 5 - src/game_sp/FakeDeclares.c | 28 +- src/game_sp/FakeDeclares.h | 27 +- src/game_sp/Globals.c | 517 +---- src/game_sp/Globals.h | 224 +- src/game_sp/Infotrons.c | 20 +- src/game_sp/Infotrons.h | 5 - src/game_sp/InitGameConditions.c | 41 +- src/game_sp/InitGameConditions.h | 7 +- src/game_sp/Input.c | 3 - src/game_sp/Input.h | 8 - src/game_sp/MainForm.c | 3471 +----------------------------- src/game_sp/MainForm.h | 21 +- src/game_sp/MainGameLoop.c | 46 +- src/game_sp/MainGameLoop.h | 9 - src/game_sp/Makefile | 20 +- src/game_sp/Murphy.c | 222 +- src/game_sp/Murphy.h | 5 - src/game_sp/OrangeDisk.c | 4 +- src/game_sp/OrangeDisk.h | 5 - src/game_sp/PathTools.c | 304 --- src/game_sp/PathTools.h | 31 - src/game_sp/SettingsObject.c | 44 - src/game_sp/SettingsObject.h | 18 - src/game_sp/SnikSnaks.c | 397 ++-- src/game_sp/SnikSnaks.h | 10 +- src/game_sp/Sound.c | 207 -- src/game_sp/Sound.h | 17 - src/game_sp/TickCountObject.c | 190 -- src/game_sp/TickCountObject.h | 23 - src/game_sp/TopMost.c | 54 - src/game_sp/TopMost.h | 42 - src/game_sp/Zonk.c | 50 +- src/game_sp/Zonk.h | 5 - src/game_sp/file.c | 4 - src/game_sp/global.h | 9 +- src/game_sp/init.c | 29 +- src/game_sp/main.c | 2 +- src/game_sp/modAnimations.c | 78 - src/game_sp/modAnimations.h | 72 - src/game_sp/modMPX.c | 455 ---- src/game_sp/modMPX.h | 40 - src/game_sp/vb_defs.h | 87 - src/game_sp/vb_lib.c | 197 +- src/game_sp/vb_lib.h | 46 - src/game_sp/vb_types.h | 305 --- src/game_sp/vb_vars.c | 20 - src/game_sp/vb_vars.h | 27 - 62 files changed, 526 insertions(+), 7127 deletions(-) delete mode 100644 src/game_sp/PathTools.c delete mode 100644 src/game_sp/PathTools.h delete mode 100644 src/game_sp/SettingsObject.c delete mode 100644 src/game_sp/SettingsObject.h delete mode 100644 src/game_sp/TickCountObject.c delete mode 100644 src/game_sp/TickCountObject.h delete mode 100644 src/game_sp/TopMost.c delete mode 100644 src/game_sp/TopMost.h delete mode 100644 src/game_sp/modAnimations.c delete mode 100644 src/game_sp/modAnimations.h delete mode 100644 src/game_sp/modMPX.c delete mode 100644 src/game_sp/modMPX.h delete mode 100644 src/game_sp/vb_defs.h delete mode 100644 src/game_sp/vb_types.h delete mode 100644 src/game_sp/vb_vars.c delete mode 100644 src/game_sp/vb_vars.h diff --git a/src/conftime.h b/src/conftime.h index 9fca65af..57960484 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-03-15 19:50" +#define COMPILE_DATE_STRING "2010-03-16 01:16" diff --git a/src/game_sp/ASM.h b/src/game_sp/ASM.h index ae23113d..a149c808 100644 --- a/src/game_sp/ASM.h +++ b/src/game_sp/ASM.h @@ -5,11 +5,6 @@ #ifndef ASM_H #define ASM_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/BugsTerminals.h b/src/game_sp/BugsTerminals.h index 1bd00886..2d3d98a2 100644 --- a/src/game_sp/BugsTerminals.h +++ b/src/game_sp/BugsTerminals.h @@ -5,11 +5,6 @@ #ifndef BUGSTERMINALS_H #define BUGSTERMINALS_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index e74e4a7e..816127b4 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -8,7 +8,6 @@ long mWidth, mHeight; -long mhWnd; long mScrollX, mScrollY; long mScrollX_last, mScrollY_last; long mDestXOff, mDestYOff; @@ -198,7 +197,7 @@ void UpdatePlayfield(boolean force_redraw) printf("::: REDRAW (%d, %d): %d, %d\n", x, y, graphic, sync_frame); #endif - StretchedSprites.BltImg(sx, sy, graphic, sync_frame); + DDSpriteBuffer_BltImg(sx, sy, graphic, sync_frame); #if 1 num_redrawn++; @@ -222,15 +221,15 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) int xsize = SXSIZE; int ysize = SYSIZE; - int full_xsize = (FieldWidth - (menBorder.Checked ? 0 : 1)) * TILEX; - int full_ysize = (FieldHeight - (menBorder.Checked ? 0 : 1)) * TILEY; + int full_xsize = (FieldWidth - (menBorder ? 0 : 1)) * TILEX; + int full_ysize = (FieldHeight - (menBorder ? 0 : 1)) * TILEY; sxsize = (full_xsize < xsize ? full_xsize : xsize); sysize = (full_ysize < ysize ? full_ysize : ysize); sx = SX + (full_xsize < xsize ? (xsize - full_xsize) / 2 : 0); sy = SY + (full_ysize < ysize ? (ysize - full_ysize) / 2 : 0); - if (!menBorder.Checked) + if (!menBorder) { px += TILEX / 2; py += TILEY / 2; @@ -365,24 +364,17 @@ void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) for (T = (double)tStep; T <= (double)1; T += tStep) { - if (UserDragFlag) - goto SoftScrollEH; - mScrollX = oldX + T * dx; mScrollY = oldY + T * dY; ScrollX = mScrollX; ScrollY = mScrollY; } - if (UserDragFlag) - goto SoftScrollEH; - mScrollX = X; mScrollY = Y; ScrollX = mScrollX; ScrollY = mScrollY; -SoftScrollEH: AlreadyRunning = False; ScrollPlayfieldIfNeeded(); diff --git a/src/game_sp/DDScrollBuffer.h b/src/game_sp/DDScrollBuffer.h index 3224d72a..b3ac17e5 100644 --- a/src/game_sp/DDScrollBuffer.h +++ b/src/game_sp/DDScrollBuffer.h @@ -5,11 +5,6 @@ #ifndef DDSCROLLBUFFER_H #define DDSCROLLBUFFER_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/DDSpriteBuffer.h b/src/game_sp/DDSpriteBuffer.h index 5840a175..c9e8747a 100644 --- a/src/game_sp/DDSpriteBuffer.h +++ b/src/game_sp/DDSpriteBuffer.h @@ -5,11 +5,6 @@ #ifndef DDSPRITEBUFFER_H #define DDSPRITEBUFFER_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/Demo.c b/src/game_sp/Demo.c index 7189f5c0..c9ed3917 100644 --- a/src/game_sp/Demo.c +++ b/src/game_sp/Demo.c @@ -5,92 +5,3 @@ #include "Demo.h" -int RecDemoRandomSeed; -byte FirstDemoByte; -char *MySignature; - -void subGetNextDemoKey() -{ - int ax; - - if (0 < DemoKeyRepeatCounter) - { - DemoKeyRepeatCounter = DemoKeyRepeatCounter - 1; - } - else - { - DemoOffset = DemoOffset + 1; - if (DemoOffset <= FileMax) - { - ax = PlayField8[DemoOffset]; - if (ax == 0xFF) - { - demo_stopped = 1; - ExitToMenuFlag = 1; - } - else - { - DemoKeyCode = ax & 0xF; - DemoKeyRepeatCounter = (ax & 0xF0) / 0x10; - } - - } - else - { - ExitToMenuFlag = 1; - } - } - -#if 0 - printf("::: %04d [%03ld, %02d] ----------> %s [%d] [%d, %d] [%d, %d]\n", - TimerVar, - DemoOffset - DemoPointer, DemoKeyRepeatCounter, - (DemoKeyCode == keyNone ? "(none)" : - DemoKeyCode == keyLeft ? "left" : - DemoKeyCode == keyRight ? "right" : - DemoKeyCode == keyUp ? "up" : - DemoKeyCode == keyDown ? "down" : - DemoKeyCode == keySpace ? "space" : - DemoKeyCode == keySpaceLeft ? "space + left" : - DemoKeyCode == keySpaceRight ? "space + right" : - DemoKeyCode == keySpaceUp ? "space + up" : - DemoKeyCode == keySpaceDown ? "space + down" : "(unknown)"), - DemoKeyCode, - MurphyScreenXPos, MurphyScreenYPos, - MurphyPosIndex % 60, MurphyPosIndex / 60); -#endif - -} - -currency GetTotalFramesOfDemo() -{ - currency GetTotalFramesOfDemo; - - long i; - currency nFrames; - byte db; - - GetTotalFramesOfDemo = 0; - if (! DemoAvailable) - return GetTotalFramesOfDemo; - - nFrames = 1; - i = DemoPointer + 1; - - // --- On Error GoTo GetTotalFramesOfDemoEH - db = PlayField8[i]; - while (db != 0xFF) - { - nFrames = nFrames + (db & 0xF0) / 0x10 + 1; - i = i + 1; - db = PlayField8[i]; - } - - GetTotalFramesOfDemo = nFrames; - return GetTotalFramesOfDemo; - - GetTotalFramesOfDemo = 0; - DemoAvailable = False; - - return GetTotalFramesOfDemo; -} diff --git a/src/game_sp/Demo.h b/src/game_sp/Demo.h index a9daa14f..339a17dd 100644 --- a/src/game_sp/Demo.h +++ b/src/game_sp/Demo.h @@ -5,18 +5,8 @@ #ifndef DEMO_H #define DEMO_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" -extern currency GetTotalFramesOfDemo(); -extern void subGetNextDemoKey(); -extern byte FirstDemoByte; -extern char *MySignature; -extern int RecDemoRandomSeed; #endif /* DEMO_H */ diff --git a/src/game_sp/Display.c b/src/game_sp/Display.c index 32923d63..156b828d 100644 --- a/src/game_sp/Display.c +++ b/src/game_sp/Display.c @@ -25,67 +25,45 @@ void subDisplayLevel() void ScrollTo(int X, int Y) { - long oldX, oldY; - -#if 0 - printf("::: Display.c: ScrollTo(): %d, %d\n", X, Y); -#endif - if (NoDisplayFlag) return; - oldX = ScrollX; - oldY = ScrollY; X = ScrollDelta * (X / ScrollDelta); X = Max(X, ScrollMinX); X = Min(X, ScrollMaxX); Y = ScrollDelta * (Y / ScrollDelta); Y = Max(Y, ScrollMinY); Y = Min(Y, ScrollMaxY); - // ScrollX = X - // ScrollY = Y - Stage.ScrollTo(X, Y); + DDScrollBuffer_ScrollTo(X, Y); } void ScrollTowards(int X, int Y) { - long oldX, oldY; - if (NoDisplayFlag) return; - oldX = ScrollX; - oldY = ScrollY; X = ScrollDelta * (X / ScrollDelta); X = Max(X, ScrollMinX); X = Min(X, ScrollMaxX); Y = ScrollDelta * (Y / ScrollDelta); Y = Max(Y, ScrollMinY); Y = Min(Y, ScrollMaxY); - // ScrollX = X - // ScrollY = Y - Stage.ScrollTowards(X, Y, 2 * Stretch * ZoomFactor); + DDScrollBuffer_ScrollTowards(X, Y, 2 * Stretch * ZoomFactor); } void SoftScrollTo(int X, int Y, long TimeMS, int FPS) { - long oldX, oldY; - if (NoDisplayFlag) return; - oldX = ScrollX; - oldY = ScrollY; X = ScrollDelta * (X / ScrollDelta); X = Max(X, ScrollMinX); X = Min(X, ScrollMaxX); Y = ScrollDelta * (Y / ScrollDelta); Y = Max(Y, ScrollMinY); Y = Min(Y, ScrollMaxY); - // ScrollX = X - // ScrollY = Y - Stage.SoftScrollTo(X, Y, TimeMS, FPS); + DDScrollBuffer_SoftScrollTo(X, Y, TimeMS, FPS); } diff --git a/src/game_sp/Display.h b/src/game_sp/Display.h index d80a07d9..a6bd3683 100644 --- a/src/game_sp/Display.h +++ b/src/game_sp/Display.h @@ -5,11 +5,6 @@ #ifndef DISPLAY_H #define DISPLAY_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/DoGameStuff.h b/src/game_sp/DoGameStuff.h index ac822b1a..9051e4d1 100644 --- a/src/game_sp/DoGameStuff.h +++ b/src/game_sp/DoGameStuff.h @@ -5,11 +5,6 @@ #ifndef DOGAMESTUFF_H #define DOGAMESTUFF_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/Electrons.c b/src/game_sp/Electrons.c index e618994a..496e3507 100644 --- a/src/game_sp/Electrons.c +++ b/src/game_sp/Electrons.c @@ -548,7 +548,7 @@ void subDrawElectronTurnLeft(int si, int bx) // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si); Y = GetStretchY(si); - StretchedSprites.BltImg(X, Y, aniElectron, bx); + DDSpriteBuffer_BltImg(X, Y, aniElectron, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ } @@ -559,7 +559,7 @@ void subDrawElectronTurnRight(int si, int bx) // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si); Y = GetStretchY(si); - StretchedSprites.BltImg(X, Y, aniElectron, 0x10 - bx); + DDSpriteBuffer_BltImg(X, Y, aniElectron, 0x10 - bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ } @@ -572,8 +572,8 @@ void subDrawElectronFromBelow(int si, int bx) // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si); Y = GetStretchY(si + FieldWidth); - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X, Y - bx * TwoPixels, aniElectron, bx); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X, Y - bx * TwoPixels, aniElectron, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ } @@ -586,8 +586,8 @@ void subDrawElectronFromRight(int si, int bx) // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si + 1); Y = GetStretchY(si); - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X - bx * TwoPixels, Y, aniElectron, bx); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X - bx * TwoPixels, Y, aniElectron, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ } @@ -600,8 +600,8 @@ void subDrawElectronFromAbove(int si, int bx) // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si); Y = GetStretchY(si - FieldWidth); - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X, Y + bx * TwoPixels, aniElectron, bx); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X, Y + bx * TwoPixels, aniElectron, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ } @@ -614,7 +614,7 @@ void subDrawElectronFromLeft(int si, int bx) // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si - 1); Y = GetStretchY(si); - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X + bx * TwoPixels, Y, aniElectron, bx); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X + bx * TwoPixels, Y, aniElectron, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ } diff --git a/src/game_sp/Electrons.h b/src/game_sp/Electrons.h index 7dec2429..2e12dd37 100644 --- a/src/game_sp/Electrons.h +++ b/src/game_sp/Electrons.h @@ -5,11 +5,6 @@ #ifndef ELECTRONS_H #define ELECTRONS_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/Explosions.c b/src/game_sp/Explosions.c index ea9368c5..ccd75b8f 100644 --- a/src/game_sp/Explosions.c +++ b/src/game_sp/Explosions.c @@ -301,7 +301,7 @@ void subRedDiskReleaseExplosion() // !!! causes flicker -- fix in Murphy.c !!! GfxGraphic[GetX(si)][GetY(si)] = aniRedDisk; #else - StretchedSprites.BltImg(X, Y, aniRedDisk, 0); + DDSpriteBuffer_BltImg(X, Y, aniRedDisk, 0); #endif // +++++++++++++++++++++++++++++++++++++++++ diff --git a/src/game_sp/Explosions.h b/src/game_sp/Explosions.h index 8cd98ba8..b62ea8b3 100644 --- a/src/game_sp/Explosions.h +++ b/src/game_sp/Explosions.h @@ -5,11 +5,6 @@ #ifndef EXPLOSIONS_H #define EXPLOSIONS_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/FakeDeclares.c b/src/game_sp/FakeDeclares.c index b9e584b4..abb63c46 100644 --- a/src/game_sp/FakeDeclares.c +++ b/src/game_sp/FakeDeclares.c @@ -13,9 +13,7 @@ long YawnSleepCounter; int MurphyVarFaceLeft; int ScratchGravity, GravityFlag; int RedDiskReleaseFlag, MovingPictureSequencePhase; -int data_h_DemoDone, LevelStatus; -int data_h_165A; int YellowDisksExploded; int AllowRedDiskCheat, AllowEatRightRedDiskBug; @@ -24,30 +22,6 @@ int InfotronsNeeded, TotalInfotronsNeeded; int RedDiskCount; int SnikSnaksElectronsFrozen; -boolean EditFlag; -int EditMode; -int edSelect = 2; -int edMove = 3; - -int DemoFlag, data_scr_demo, demo_stopped; -int WasDemoFlag; -int EP_GameDemoVar0DAA; -int RecordDemoFlag; // , DemoRecordingFlag% -int DemoKeyCode, DemoPointer; -long DemoOffset; -int DemoKeyRepeatCounter; +int DemoKeyCode; int RedDiskReleasePhase; -int UpdatedFlag; - -int DebugVersionFlag, D_ModeFlag; -int keyEnter; - -int UpdateTimeFlag; - -boolean ModifiedFlag; - - -void Let_ModifiedFlag(boolean NewVal) -{ -} diff --git a/src/game_sp/FakeDeclares.h b/src/game_sp/FakeDeclares.h index 0ccf44d9..a3c22a5c 100644 --- a/src/game_sp/FakeDeclares.h +++ b/src/game_sp/FakeDeclares.h @@ -5,28 +5,12 @@ #ifndef FAKEDECLARES_H #define FAKEDECLARES_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" -#define edDraw (1) - -extern boolean ModifiedFlag; -extern void Let_ModifiedFlag(boolean NewVal); - -extern boolean EditFlag; extern int AllowRedDiskCheat, AllowEatRightRedDiskBug; extern int Data_SubRest, Data_SubRstFlg; -extern int DebugVersionFlag, D_ModeFlag; -extern int DemoFlag, data_scr_demo, demo_stopped; -extern int DemoKeyCode, DemoPointer; -extern int DemoKeyRepeatCounter; -extern int EP_GameDemoVar0DAA; -extern int EditMode; +extern int DemoKeyCode; extern int GameBusyFlag; extern int InfotronsNeeded, TotalInfotronsNeeded; extern int KillMurphyFlag, MurphyMoveCounter; @@ -34,21 +18,12 @@ extern int MurphyExplodePos, SplitMoveFlag, RedDiskReleaseMurphyPos; extern int MurphyPosIndex, MurphyXPos, MurphyYPos; extern int MurphyScreenXPos, MurphyScreenYPos; extern int MurphyVarFaceLeft; -extern int RecordDemoFlag; extern int RedDiskCount; extern int RedDiskReleaseFlag, MovingPictureSequencePhase; extern int RedDiskReleasePhase; extern int ScratchGravity, GravityFlag; extern int SnikSnaksElectronsFrozen; -extern int UpdateTimeFlag; -extern int UpdatedFlag; -extern int WasDemoFlag; extern int YellowDisksExploded; -extern int data_h_DemoDone, LevelStatus; -extern int edMove; -extern int edSelect; -extern int keyEnter; -extern long DemoOffset; extern long YawnSleepCounter; #endif /* FAKEDECLARES_H */ diff --git a/src/game_sp/Globals.c b/src/game_sp/Globals.c index cca754aa..82d3a014 100644 --- a/src/game_sp/Globals.c +++ b/src/game_sp/Globals.c @@ -4,57 +4,14 @@ #include "Globals.h" -static void ReadDemo(); -void ReadLevel(); -// static char *VB_Name = "modGlobals"; - -// --- Option Explicit -// --- Option Compare Text -// --- Option Base 0 - -// --- const long StretchWidth = 16; -// --- const long StretchWidth2 = StretchWidth / 2; -// --- const long BaseWidth = 16; -// --- const int TwoPixels = 2; - -boolean Original; -boolean Cracked; -boolean Level_Arg; -boolean EGA_Arg; -boolean Record_Fix; -boolean SpeedKeys; -boolean Level_Fix; -boolean Dead_Code; -boolean Redundant; -boolean Alignments; -boolean Ctrl_Alt_Fix; -boolean Protection; -boolean EP_ENHANCE; -boolean EP_DEMO; -boolean EP_DEBUG; -boolean EXTRASPEED; -boolean TIMINGFIX; -boolean SafeRecord; -boolean Norm_Time; -boolean EP_OLD8; -boolean SAVEGAME; -boolean HP_DEMO; -boolean ScreenFix; -boolean DemoRecordFix; -boolean DebugSwitch; -boolean Ver62; -boolean Ver62test; -boolean Ver63; -boolean Ver64; +void ReadLevel(); int LevelNumber; -char *CurPath, *OrigPath, *TmpPath; boolean LevelLoaded; -long SignatureDelay; -boolean bSignatureAvailable; -boolean bCapturePane; +boolean DemoAvailable; +boolean menBorder; int FieldWidth; // = 60 int FieldHeight; // = 24 @@ -73,16 +30,16 @@ short RandomSeed; #else int RandomSeed; #endif -currency DeltaT; // Interval between two frames (in ms) -long DeltaTPlay, DeltaTDemo; -boolean BlockingSpeed; - -// --- const int posFrameCorner = 55; -// --- const int posFrameVertical = 110; -// --- const int posFrameHorizontal = 111; int FreezeZonks; +LevelInfoType LInfo; + +float Stretch = 1; // , StretchWidth%, TwoPixels! + +int ScrollMinX, ScrollMaxX, ScrollMinY, ScrollMaxY; +int ScrollX, ScrollY; + // constants for Fixed Fields: // --- const int fiSpace = 0; // &H00 space(28 = wall space ...) // --- const int fiZonk = 1; // &H01 zonk @@ -146,33 +103,6 @@ int FreezeZonks; // --- const int keySpace = 9; #if 0 -int *aniBug, *aniZonkRollRight, *aniZonkRollLeft; -int *aniInfotronRollRight, *aniInfotronRollLeft; -int *aniSnikSnak, *aniElectron, *aniExplosion; -int *aniTouchBase, *aniTouchInfotron, *aniTouchRedDisk; -// --- const int aniExplosionInfo = 111; -// --- const int aniSnikSnakUp = 159; -// --- const int aniSnikSnakDown = 167; -// --- const int aniSnikSnakLeft = 239; -// --- const int aniSnikSnakRight = 247; -// --- const int aniMurphyYawn = 56; -// --- const int aniMurphySleepLeft = 71; -// --- const int aniMurphySleepRight = 68; -int *aniMurphyExit; // , aniMurphyFaceLeft%, aniMurphyFaceRight% -int *aniMurphyEatLeft, *aniMurphyEatRight; // , aniMurphyEatRightRedDisk -int *aniMurphyEatUpLeft, *aniMurphyEatUpRight, *aniSplitUpDown; -int *aniYellowDisk, *aniOrangeDisk, *aniRedDisk; -// --- const int aniMurphyTouchUp = 46; -// --- const int aniMurphyTouchLeft = 95; -// --- const int aniMurphyTouchDown = 47; -// --- const int aniMurphyTouchRight = 94; -int *aniEatInfotronLeft, *aniEatInfotronRight; -// --- const int aniPushLeft = 45; -// --- const int aniPushRight = 44; -// --- const int aniPushUpDown = 79; -#endif - -#if 1 int aniFramesBug[] = { 74, 75, 76, 77, 78, 77, 76, 77, 78, 77, 76, 75, 74, 25 }; int aniFramesZonkRollRight[] = { 198, 197, 196, 195, 194, 193, 192, 1, -1 }; int aniFramesZonkRollLeft[] = { 192, 193, 194, 195, 196, 197, 198, 1, -1 }; @@ -198,8 +128,6 @@ int aniFramesOrangeDisk[] = { 8, 8, 8, 8, 8, 8, 8, 8, -1 }; int aniFramesRedDisk[] = { 20, -1 }; #endif -#if 1 - int fiGraphic[] = { aniSpace, @@ -301,438 +229,46 @@ boolean isSnappingSequence(int sequence) } } -#endif - void InitGlobals() { -#if 0 - aniBug = Array(74, 75, 76, 77, 78, 77, 76, 77, 78, 77, 76, 75, 74, 25); - aniZonkRollRight = Array(198, 197, 196, 195, 194, 193, 192, 1, -1); - aniZonkRollLeft = Array(192, 193, 194, 195, 196, 197, 198, 1, -1); - aniInfotronRollRight = Array(206, 205, 204, 203, 202, 201, 200, 4); - aniInfotronRollLeft = Array(200, 201, 202, 203, 204, 205, 206, 4); - aniSnikSnak = Array(121, 122, 123, 124, 125, 126, 127, 120, 121); - aniElectron = Array(144, 145, 146, 147, 148, 149, 150, 151, 144); - aniExplosion = Array(3, 103, 104, 105, 106, 107, 108, 109, 0); - aniTouchBase = Array(80, 81, 82, 83, 84, 85, 86, 0, -1); - aniTouchInfotron = Array(87, 88, 89, 91, 92, 93, 0, -1); // Only seven frames!!!! - aniTouchRedDisk = Array(96, 97, 98, 99, 100, 101, 102, 0, -1); - aniMurphyExit = Array(46, 46, 46, 46, 47, 47, 47, 47, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 54, 0, 0, 0, 0, -1); - aniMurphyEatLeft = Array(176, 177, 178, 179, 180, 181, 182, 183, -1); - aniMurphyEatRight = Array(184, 185, 186, 187, 188, 189, 190, 191, -1); - aniMurphyEatUpLeft = Array(183, 182, 181, 180, 179, 178, 177, 176, -1); - aniMurphyEatUpRight = Array(191, 190, 189, 188, 187, 186, 185, 184, -1); - // aniMurphyEatRightRedDisk = Array(184, 184, 185, 186, 187, 188, 189, 190, 191, -1) '9 frames! - aniEatInfotronLeft = Array(209, 211, 213, 215, 217, 219, 221, 223, -1); - aniEatInfotronRight = Array(224, 226, 228, 230, 232, 234, 236, 238, -1); - aniSplitUpDown = Array(3, 3, 3, 3, 3, 3, 3, 3, -1); - aniYellowDisk = Array(18, 18, 18, 18, 18, 18, 18, 18, -1); - aniOrangeDisk = Array(8, 8, 8, 8, 8, 8, 8, 8, -1); - aniRedDisk = Array(20, -1); -#endif - - InitPseudoCompileFlags(); - UserDragFlag = False; AutoScrollFlag = True; FreezeZonks = 0; - BlockingSpeed = False; LevelLoaded = False; FieldWidth = 60; FieldHeight = 24; HeaderSize = 96; FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1; LevelMax = (FieldWidth * FieldHeight) - 1; - Let_ModifiedFlag(False); bPlaying = False; - gSignature = ""; - bSignatureAvailable = False; - FirstDemoByte = 0x81; - MySignature = ""; -} - -void InitPseudoCompileFlags() -{ - Cracked = 1; // If protection Then crack it - Level_Arg = 1; // :number is cmd line option - // Level_Arg = 0 ' Remove Level cmd line option - EGA_Arg = 1; // EGA is command line option - Record_Fix = 1; // Assemble with fixed Demo rec - SpeedKeys = 0; // Remove Speed Keys fix - Level_Fix = 1; // Assemble with Level Fix - Dead_Code = 0; // Remove dead code - Redundant = 0; // Remove redundant code - Alignments = 1; // Assemble with alignments - Ctrl_Alt_Fix = 1; // Assemble with Ctrl/Alt fix - Protection = 0; // Remove protection code,do HP - // EP added by EP for version 5. - EP_ENHANCE = 1; // Some more nice things (EP) - EP_DEMO = 1; // Use .SP files for demos (EP) - // Including record demo! - EP_DEBUG = 0; // little cmdline debugging - EXTRASPEED = 1; // '@' option, superfast! - TIMINGFIX = 1; // "Fixed" the timing problem.. - // Inactive If DemoRecordFix Then1 - SafeRecord = 1; // skip debug keys in recording - Norm_Time = 1; // force automatic speed test, - // save result and then do as - // requested from cmd line. - EP_OLD8 = 1; // call old int8 from current. - SAVEGAME = 1; // Allow saving to SUPAPLEX.SAV - HP_DEMO = 1; // Use fixed demo routines 5.5 - ScreenFix = 1; // No menu-write to gamy field - DemoRecordFix = 1; // Demo record timing fix on - DebugSwitch = 1; // Allow Ctrl/Alt-ScrollLock - Ver62 = 1; // Version 6.2 stuff - Ver62test = 0; // Version 6.2 test stuff - Ver63 = 1; // Version 6.3 stuff - Ver64 = 1; // Version 6.4 stuff - } int GetSI(int X, int Y) { - int GetSI; - - GetSI = Y * FieldWidth + X; - - return GetSI; + return Y * FieldWidth + X; } int GetX(int si) { - int GetX; - - GetX = si % FieldWidth; - - return GetX; + return si % FieldWidth; } int GetY(int si) { - int GetY; - - GetY = si / FieldWidth; - - return GetY; + return si / FieldWidth; } int GetStretchX(int si) { - int GetStretchX; - - GetStretchX = StretchWidth * (si % FieldWidth); - - return GetStretchX; + return StretchWidth * (si % FieldWidth); } int GetStretchY(int si) { - int GetStretchY; - - GetStretchY = StretchWidth * (si / FieldWidth); - - return GetStretchY; -} - -void OLD_ReadLevel() -{ -#if 1 - static char CurPathTEST[1024]; -#endif - - // int FNum; - FILE *FNum; - long i; - // byte T; - -#if 1 - // CurPath = "/home/aeglos/projects/rocksndiamonds/levels/TEST_supaplex/supaplex/levels.dat"; - -#if 0 - CurPath = "/home/aeglos/projects/rocksndiamonds/supaplex_demo_JENS0001.sp"; - LevelNumber = 1; -#else - -#if 0 - // sprintf(CurPathTEST, "/home/aeglos/projects/rocksndiamonds/levels/TEST_supaplex/test_solutions/%03d.sp", level_nr); - - sprintf(CurPathTEST, "/home/aeglos/projects/Level_Stuff/SUPAPLEX/SUPAPLEX_LEVELS/Set77/77S%03d.SP", level_nr); -#else - sprintf(CurPathTEST, "/home/aeglos/projects/Level_Stuff/SUPAPLEX/SUPAPLEX_LEVELS/solve00/JENS%04d.SP", level_nr); -#endif - - CurPath = CurPathTEST; - LevelNumber = level_nr; -#endif - -#endif - - DemoAvailable = False; - - if (STRING_IS_LIKE(CurPath, "*.mpx") || - STRING_IS_LIKE(CurPath, "*.MPX")) - { - printf("::: reading MPX file ...\n"); - - ReadMPX(); - return; - } - - if (STRING_IS_LIKE(CurPath, "*.sp") || - STRING_IS_LIKE(CurPath, "*.SP")) - { - printf("::: reading SP file ...\n"); - - ReadDemo(); - return; - } - - if (DemoFlag != 0) - { - printf("::: reading demo file ...\n"); - - ReadDemo(); - return; - } - - printf("::: reading level file ...\n"); - - FileMax = 0; - FieldWidth = 60; - FieldHeight = 24; - HeaderSize = 96; - - FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1; - LevelMax = (FieldWidth * FieldHeight) - 1; - - PlayField8 = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); - DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); - - // FNum = FreeFile(); - - // --- On Error GoTo ReadLevelEH - - printf("::: '%s', %d\n", CurPath, LevelNumber); - - FNum = fopen(CurPath, "rb"); - - i = (LevelNumber - 1) * ((long)(FieldMax) + 1) + 1; -#if 1 - FILE_GET(FNum, i, PlayField8, FieldMax + 1); -#else - FILE_GET(FNum, i, &PlayField8, sizeof(PlayField8)); -#endif - - i = (LevelNumber) * ((long)(FieldMax) + 1) + 1 - HeaderSize; - FILE_GET(FNum, i, &LInfo, sizeof(LInfo)); // store level info in an extra structure - - fclose(FNum); - - // --- On Error GoTo 0 - - if (FieldMax < FileMax) - DemoAvailable = True; - - ReadSignature(); - - PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax); - - for (i = 0; i <= FieldMax; i++) - { - PlayField16[i] = PlayField8[i]; - DisPlayField[i] = PlayField8[i]; - PlayField8[i] = 0; - } - -#if 0 - { - int x, y; - - for (x = 0; x < 60; x++) - printf("%02d.", x); - printf("\n"); - - for (x = 0; x < 60; x++) - printf("..."); - printf("\n"); - - for (y = 0; y < 24; y++) - { - for (x = 0; x < 60; x++) - { - printf("%02d.", PlayField16[y * 60 + x]); - } - - printf("\n"); - } - } -#endif - - AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 * FieldWidth); - AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 * FieldWidth); - TerminalState = REDIM_1D(sizeof(byte), FieldWidth, LevelMax - FieldWidth); - - GravityFlag = LInfo.InitialGravity; - FreezeZonks = LInfo.InitialFreezeZonks; - - subRandomize(); - - LevelLoaded = True; - - return; - -#if 0 -ReadLevelEH: - Close(); -#endif -} - -static void ReadDemo() -{ - // int FNum, i; - FILE *FNum; - int i; - // byte T; - - int RecordNumber = LevelNumber; - -#if 1 - RecordNumber = 1; // always "1" for "*.sp" style one level/demo files -#endif - - FieldWidth = 60; - FieldHeight = 24; - HeaderSize = 96; - - FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1; - LevelMax = (FieldWidth * FieldHeight) - 1; - - // --- On Error GoTo ReadDemoEH - - FileMax = FileLen(CurPath) - 1; - - PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax + 1 - 1); - DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); - - // FNum = FreeFile(); - - FNum = fopen(CurPath, "rb"); - - i = (RecordNumber - 1) * ((long)(FieldMax) + 1) + 1; -#if 1 - FILE_GET(FNum, i, PlayField8, FileMax + 1); -#else - FILE_GET(FNum, i, &PlayField8, sizeof(PlayField8)); -#endif - - i = (RecordNumber) * ((long)(FieldMax) + 1) + 1 - HeaderSize; - FILE_GET(FNum, i, &LInfo, sizeof(LInfo)); // store level info in an extra structure - - fclose(FNum); - - // --- On Error GoTo 0 - - if (FieldMax < FileMax) - DemoAvailable = True; - - ReadSignature(); - - PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax); - - for (i = 0; i <= FieldMax; i++) - { - PlayField16[i] = PlayField8[i]; - DisPlayField[i] = PlayField8[i]; - PlayField8[i] = 0; - } - - AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 * FieldWidth); - AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 * FieldWidth); - TerminalState = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); - - DemoPointer = FieldMax + 1; - DemoOffset = DemoPointer; - DemoKeyRepeatCounter = 0; - - // DemoFlag = 1 - // DemoAvailable = True - - GravityFlag = LInfo.InitialGravity; - FreezeZonks = LInfo.InitialFreezeZonks; - -#if 0 - printf("::: Globals.c: ReadDemo(): %d / %d\n", GravityFlag, FreezeZonks); -#endif - - - -#if 0 - /* !!! TESTING BIG / LITTLE ENDIAN STUFF !!! */ - LInfo.DemoRandomSeed = - LowByte(LInfo.DemoRandomSeed) << 8 | - HighByte(LInfo.DemoRandomSeed); - for (i = 0; i < 10; i++) - LInfo.SpecialPort[i].PortLocation = - LowByte(LInfo.SpecialPort[i].PortLocation) << 8 | - HighByte(LInfo.SpecialPort[i].PortLocation); - - printf("::: swapping file bytes for DemoRandomSeed etc.\n"); -#else - printf("::: keeping file bytes in (maybe wrong) 'native' order.\n"); -#endif - -#if 1 - printf("::: LInfo.DemoRandomSeed == %d\n", LInfo.DemoRandomSeed); -#endif - -#if 0 - printf("::: LInfo.SpecialPortCount == %d\n", LInfo.SpecialPortCount); - for (i = 0; i < LInfo.SpecialPortCount; i++) - { - int port_x = (LInfo.SpecialPort[i].PortLocation / 2) % FieldWidth; - int port_y = (LInfo.SpecialPort[i].PortLocation / 2) / FieldWidth; - - printf("::: %d: port_location == %d => (%d, %d)\n", - i, LInfo.SpecialPort[i].PortLocation, port_x, port_y); - } -#endif - - RandomSeed = LInfo.DemoRandomSeed; - -#if 0 - printf("::: SpeedByte == %d\n", LInfo.SpeedByte); - printf("::: CheckSumByte == %d\n", LInfo.CheckSumByte); - printf("::: RandomSeed == %d\n", RandomSeed); - -#if 0 - { - int i; - - for (i = 0; i < 10; i++) - printf("::: TEST random number: %d\n", subGetRandomNumber()); - } -#endif - -#endif - - LevelLoaded = True; - - return; - -#if 0 -ReadDemoEH: - Close(); -#endif + return StretchWidth * (si / FieldWidth); } void ReadLevel() { -#if 0 - OLD_ReadLevel(); - - // return; -#endif - copyInternalEngineVars_SP(); #if 1 @@ -742,11 +278,6 @@ void ReadLevel() LevelNumber = level_nr; -#if 0 - if (!DemoFlag || !DemoAvailable) - subRandomize(); -#endif - LevelLoaded = True; } @@ -762,24 +293,10 @@ void ReportError(char *Source, char *Message) int Min(int A, int B) { - int Min; - - if (A < B) - Min = A; - else - Min = B; - - return Min; + return (A < B ? A : B); } int Max(int A, int B) { - int Max; - - if (A < B) - Max = B; - else - Max = A; - - return Max; + return (A < B ? B : A); } diff --git a/src/game_sp/Globals.h b/src/game_sp/Globals.h index 7e127054..194f1b9d 100644 --- a/src/game_sp/Globals.h +++ b/src/game_sp/Globals.h @@ -5,38 +5,26 @@ #ifndef GLOBALS_H #define GLOBALS_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" -#if 1 -#define ZoomFactor (2) +#ifndef False +#define False 0 +#define True (!False) +#endif +#define ScrollDelta ((long)1) + +#define ZoomFactor (2) #define BaseWidth (ZoomFactor * 16) #define StretchWidth (ZoomFactor * 16) -#define StretchWidth2 (StretchWidth / 2) #define TwoPixels (ZoomFactor * 2) -#else - -#define BaseWidth (16) -#define StretchWidth (16) -#define StretchWidth2 (StretchWidth / 2) -#define TwoPixels (2) - -#endif - // ---------------------------------------------------------------------------- // elements (stored in file and playfield) // ---------------------------------------------------------------------------- -#if 1 - #define fiSpace (0) #define fiZonk (1) #define fiBase (2) @@ -86,55 +74,11 @@ #define fiExplosion (0x1F) -#else - -#define fiBase (2) -#define fiBug (25) -#define fiElectron (24) -#define fiExit (7) -#define fiExplosion (0x1F) -#define fiHWFirst (28) -#define fiHWLast (37) -#define fiHWMurphy (43) -#define fiHWTrash1 (41) -#define fiHWTrash2 (42) -#define fiHardWare (6) -#define fiInfotron (4) -#define fiMurphy (3) -#define fiOrangeDisk (8) -#define fiPortAllDirections (23) -#define fiPortDown (10) -#define fiPortLeft (11) -#define fiPortLeftAndRight (22) -#define fiPortRight (9) -#define fiPortUp (12) -#define fiPortUpAndDown (21) -#define fiRAM (5) -#define fiRAMBottom (39) -#define fiRAMLeft (26) -#define fiRAMRight (27) -#define fiRAMTop (38) -#define fiRedDisk (20) -#define fiSnikSnak (17) -#define fiSpPortDown (14) -#define fiSpPortLeft (15) -#define fiSpPortRight (13) -#define fiSpPortUp (16) -#define fiSpace (0) -#define fiTerminal (19) -#define fiWallSpace (40) -#define fiYellowDisk (18) -#define fiZonk (1) - -#endif - // ---------------------------------------------------------------------------- // graphics and animations (used at runtime to display the elements) // ---------------------------------------------------------------------------- -#if 1 - // graphics and animations directly related to file elements #define aniSpace IMG_EMPTY_SPACE @@ -255,37 +199,6 @@ #define imgFrameHorizontal IMG_SP_FRAME_HORIZONTAL #define imgFrameVertical IMG_SP_FRAME_VERTICAL -#else - -#define aniMurphySleepLeft (71) -#define aniMurphySleepRight (68) -#define aniMurphyTouchDown (47) -#define aniMurphyTouchLeft (95) -#define aniMurphyTouchRight (94) -#define aniMurphyTouchUp (46) -#define aniMurphyYawn (56) -#define aniPushLeft (45) -#define aniPushRight (44) -#define aniPushUpDown (79) - -#define aniSnikSnakDown (167) -#define aniSnikSnakLeft (239) -#define aniSnikSnakRight (247) -#define aniSnikSnakUp (159) - -#define aniTerminal (0x80) -#define aniTerminalActive (0x88) - -#define aniExplosionInfo (111) - -#define posFrameCorner (55) -#define posFrameHorizontal (111) -#define posFrameVertical (110) - -#endif - - -#if 1 extern int aniFramesBug[], aniFramesZonkRollRight[], aniFramesZonkRollLeft[]; extern int aniFramesEatInfotronLeft[], aniFramesEatInfotronRight[]; @@ -297,27 +210,11 @@ extern int aniFramesSnikSnak[], aniFramesElectron[], aniFramesExplosion[]; extern int aniFramesTouchBase[], aniFramesTouchInfotron[], aniFramesTouchRedDisk[]; extern int aniFramesYellowDisk[], aniFramesOrangeDisk[], aniFramesRedDisk[]; -#else - -extern int *aniBug, *aniZonkRollRight, *aniZonkRollLeft; -extern int *aniEatInfotronLeft, *aniEatInfotronRight; -extern int *aniInfotronRollRight, *aniInfotronRollLeft; -extern int *aniMurphyEatLeft, *aniMurphyEatRight; -extern int *aniMurphyEatUpLeft, *aniMurphyEatUpRight, *aniSplitUpDown; -extern int *aniMurphyExit; -extern int *aniSnikSnak, *aniElectron, *aniExplosion; -extern int *aniTouchBase, *aniTouchInfotron, *aniTouchRedDisk; -extern int *aniYellowDisk, *aniOrangeDisk, *aniRedDisk; - -#endif - // ---------------------------------------------------------------------------- // input keys // ---------------------------------------------------------------------------- -#if 1 - #define keyNone (0) #define keyUp (1) #define keyLeft (2) @@ -329,19 +226,54 @@ extern int *aniYellowDisk, *aniOrangeDisk, *aniRedDisk; #define keySpaceRight (8) #define keySpace (9) -#else -#define keyDown (3) -#define keyLeft (2) -#define keyNone (0) -#define keyRight (4) -#define keySpace (9) -#define keySpaceDown (7) -#define keySpaceLeft (6) -#define keySpaceRight (8) -#define keySpaceUp (5) -#define keyUp (1) +// ---------------------------------------------------------------------------- +// data structures +// ---------------------------------------------------------------------------- + +#ifndef HAS_LevelDescriptor +typedef struct +{ + int Width; + int Height; + long OffSet; + long Size; +} LevelDescriptor; +#define HAS_LevelDescriptor +#endif + +#ifndef HAS_SpecialPortType +typedef struct +{ + short PortLocation; // = 2*(x+(y*60)) + byte Gravity; // 1 = turn on, anything else (0) = turn off + byte FreezeZonks; // 2 = turn on, anything else (0) = turn off (1=off!) + byte FreezeEnemies; // 1 = turn on, anything else (0) = turn off + byte UnUsed; +} SpecialPortType; +#define HAS_SpecialPortType +#endif +#ifndef HAS_LevelInfoType +typedef struct +{ + byte UnUsed[4]; + byte InitialGravity; // 1=on, anything else (0) = off + byte Version; // SpeedFixVersion XOR &H20 + char LevelTitle[23]; + byte InitialFreezeZonks; // 2=on, anything else (0) = off. (1=off too!) + byte InfotronsNeeded; + + // Number of Infotrons needed. 0 means that Supaplex will count the total + // amount of Infotrons in the level, and use the low byte of that number. + // (A multiple of 256 Infotrons will then result in 0-to-eat, etc.!) + byte SpecialPortCount; // Maximum 10 allowed! + SpecialPortType SpecialPort[10]; + byte SpeedByte; // = Speed XOR Highbyte(RandomSeed) + byte CheckSumByte; // = CheckSum XOR SpeedByte + short DemoRandomSeed; +} LevelInfoType; +#define HAS_LevelInfoType #endif @@ -351,7 +283,6 @@ extern int GetStretchY(int si); extern int GetX(int si); extern int GetY(int si); extern void InitGlobals(); -extern void InitPseudoCompileFlags(); extern void ReadLevel(); @@ -368,43 +299,14 @@ extern int fiGraphic[]; extern int aniSnikSnakTurningLeft[]; extern int aniSnikSnakTurningRight[]; -extern boolean Alignments; -extern boolean BlockingSpeed; -extern boolean Cracked; -extern boolean Ctrl_Alt_Fix; -extern boolean Dead_Code; -extern boolean DebugSwitch; -extern boolean DemoRecordFix; -extern boolean EGA_Arg; -extern boolean EP_DEBUG; -extern boolean EP_DEMO; -extern boolean EP_ENHANCE; -extern boolean EP_OLD8; -extern boolean EXTRASPEED; -extern boolean HP_DEMO; extern boolean LevelLoaded; -extern boolean Level_Arg; -extern boolean Level_Fix; -extern boolean Norm_Time; -extern boolean Original; -extern boolean Protection; -extern boolean Record_Fix; -extern boolean Redundant; -extern boolean SAVEGAME; -extern boolean SafeRecord; -extern boolean ScreenFix; -extern boolean SpeedKeys; -extern boolean TIMINGFIX; -extern boolean Ver62; -extern boolean Ver62test; -extern boolean Ver63; -extern boolean Ver64; -extern boolean bCapturePane; -extern byte *DisPlayField; -extern byte *PlayField8; -extern char *CurPath, *OrigPath, *TmpPath; -extern currency DeltaT; + +extern boolean DemoAvailable; +extern boolean menBorder; + extern int *PlayField16; +extern byte *PlayField8; +extern byte *DisPlayField; extern int FieldHeight; extern int FieldMax, LevelMax; @@ -414,8 +316,12 @@ extern int HeaderSize; extern int LevelNumber; extern int TimerVar; extern short RandomSeed; -extern long DeltaTPlay, DeltaTDemo; + extern long FileMax; -extern long SignatureDelay; + +extern LevelInfoType LInfo; +extern float Stretch; +extern int ScrollMinX, ScrollMaxX, ScrollMinY, ScrollMaxY; +extern int ScrollX, ScrollY; #endif /* GLOBALS_H */ diff --git a/src/game_sp/Infotrons.c b/src/game_sp/Infotrons.c index 08a16662..c671c606 100644 --- a/src/game_sp/Infotrons.c +++ b/src/game_sp/Infotrons.c @@ -115,8 +115,8 @@ loc_g_1242: // infotron comes falling from above X = GetStretchX(si); Y = GetStretchY(si - FieldWidth); dx = bl & 0x7; - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X, Y + TwoPixels * (dx + 1), aniInfotron, dx); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X, Y + TwoPixels * (dx + 1), aniInfotron, dx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ bl = HighByte(PlayField16[si]) + 1; @@ -239,8 +239,8 @@ loc_g_138D: // infotron comes rolling from right to left X = GetStretchX(si + 1); Y = GetStretchY(si); dx = (bl & 0x7) + 1; - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X - (TwoPixels * dx), Y, aniInfotronRollLeft, dx - 1); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X - (TwoPixels * dx), Y, aniInfotronRollLeft, dx - 1); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ bl = HighByte(PlayField16[si]) + 1; // get and increment sequence# @@ -270,8 +270,8 @@ loc_g_13E9: // infotron comes rolling from left to right X = GetStretchX(si - 1); Y = GetStretchY(si); dx = (bl & 0x7) + 1; - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X + (TwoPixels * dx), Y, aniInfotronRollRight, dx - 1); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X + (TwoPixels * dx), Y, aniInfotronRollRight, dx - 1); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ bl = HighByte(PlayField16[si]) + 1; @@ -321,8 +321,8 @@ loc_g_1472: // infotron rolls left X = GetStretchX(si); Y = GetStretchY(si); dx = (bl & 0xF) + 1; - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X - (TwoPixels * dx), Y, aniInfotronRollLeft, dx - 1); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X - (TwoPixels * dx), Y, aniInfotronRollLeft, dx - 1); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ bl = HighByte(PlayField16[si]) + 1; // retrieve and increment sequence# @@ -362,8 +362,8 @@ loc_g_14E0: // infotron rolls right X = GetStretchX(si); Y = GetStretchY(si); dx = (bl & 0x7) + 1; - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X + (TwoPixels * dx), Y, aniInfotronRollRight, dx - 1); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X + (TwoPixels * dx), Y, aniInfotronRollRight, dx - 1); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ bl = HighByte(PlayField16[si]) + 1; diff --git a/src/game_sp/Infotrons.h b/src/game_sp/Infotrons.h index 485f868c..a18fedd0 100644 --- a/src/game_sp/Infotrons.h +++ b/src/game_sp/Infotrons.h @@ -5,11 +5,6 @@ #ifndef INFOTRONS_H #define INFOTRONS_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/InitGameConditions.c b/src/game_sp/InitGameConditions.c index ef5ce12c..73c6ec11 100644 --- a/src/game_sp/InitGameConditions.c +++ b/src/game_sp/InitGameConditions.c @@ -12,8 +12,6 @@ void subInitGameConditions() { - bCapturePane = False; - MurphyVarFaceLeft = 0; KillMurphyFlag = 0; // no "kill Murphy" ExitToMenuFlag = 0; @@ -65,7 +63,7 @@ void InitMurphyPosB(int si) MurphyScreenYPos = GetStretchY(si); // Murphy's screen y-position // To Do: draw Murphy in location ax - StretchedSprites.BltImg(MurphyScreenXPos, MurphyScreenYPos, aniMurphy, 0); + DDSpriteBuffer_BltImg(MurphyScreenXPos, MurphyScreenYPos, aniMurphy, 0); MurphyScreenXPos = MurphyScreenXPos / Stretch; MurphyScreenYPos = MurphyScreenYPos / Stretch; @@ -235,47 +233,18 @@ void ResetInfotronsNeeded(int dx) void subFetchAndInitLevelB() { - boolean UpdatePlayTime; - - data_scr_demo = 0; - UpdatePlayTime = (0 == demo_stopped ? True : False); - demo_stopped = 0; - - subFetchAndInitLevelA(UpdatePlayTime); + subFetchAndInitLevelA(); } -void subFetchAndInitLevelA(boolean UpdatePlayTime) +void subFetchAndInitLevelA() { - D_ModeFlag = 0; // 1=debug D pressed (CPU use) - if (0 != demo_stopped) // 1=demo, 0=game - DemoFlag = 1; - GameBusyFlag = 0; // restore scissors too subFetchAndInitLevel(); // Fetch and initialize a level GameBusyFlag = 1; // no free screen write - if (1 <= demo_stopped) - { - if (1 == demo_stopped) - { - DemoFlag = 0; // 1=demo, 0=game - demo_stopped = demo_stopped + 1; - } - else - { - DemoFlag = 0; // 1=demo, 0=game - } - } - DemoKeyCode = 0; // delete last demo key! - if (DemoFlag != 0) // don't allow during game! only in Demo - { - DemoOffset = DemoPointer; // init demo pointer - DemoKeyRepeatCounter = 1; - subGetNextDemoKey(); // get next demo byte - } } void subFetchAndInitLevel() @@ -284,12 +253,10 @@ void subFetchAndInitLevel() ReadLevel(); // Read LEVELS.DAT - if (RecordDemoFlag == 1) - RecDemoRandomSeed = RandomSeed; - GameBusyFlag = -GameBusyFlag; // make <>1 InfoCountInLevel = subConvertToEasySymbols(); // Convert to easy symbols + GameBusyFlag = -GameBusyFlag; // restore subDisplayLevel(); // Paint (Init) game field diff --git a/src/game_sp/InitGameConditions.h b/src/game_sp/InitGameConditions.h index c78da128..eb4249ff 100644 --- a/src/game_sp/InitGameConditions.h +++ b/src/game_sp/InitGameConditions.h @@ -5,11 +5,6 @@ #ifndef INITGAMECONDITIONS_H #define INITGAMECONDITIONS_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" @@ -19,7 +14,7 @@ extern void InitMurphyPos(); extern void InitMurphyPosB(int); extern void ResetInfotronsNeeded(int); extern void subFetchAndInitLevel(); -extern void subFetchAndInitLevelA(boolean); +extern void subFetchAndInitLevelA(); extern void subFetchAndInitLevelB(); extern void subInitGameConditions(); diff --git a/src/game_sp/Input.c b/src/game_sp/Input.c index 3abfb289..5a469575 100644 --- a/src/game_sp/Input.c +++ b/src/game_sp/Input.c @@ -5,9 +5,6 @@ #include "Input.h" -DemoBufferObject DemoBuffer; -boolean KeyState[255 + 1]; - int map_key_RND_to_SP(int key) { if (key & KEY_BUTTON) diff --git a/src/game_sp/Input.h b/src/game_sp/Input.h index 0183b702..55f6aaf9 100644 --- a/src/game_sp/Input.h +++ b/src/game_sp/Input.h @@ -5,17 +5,9 @@ #ifndef INPUT_H #define INPUT_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" -extern DemoBufferObject DemoBuffer; -extern boolean KeyState[255 + 1]; - extern void subProcessKeyboardInput(byte); #endif /* INPUT_H */ diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index 731cd0fb..f169bac3 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -4,1014 +4,16 @@ #include "MainForm.h" -#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 -static void CleanTempDir(char *TmpDir); -static void CountDown(long HalfSeconds, int bDisplayBar); static void DrawFrame(int Delta); -static void DrawPauseLayer(long Layer); -static void FillFileList(char *Path); -static void FillLevelList(char *Path, int LevelIndex); -static void FocusTim_Timer(); -static void Form_KeyDown(int KeyCode, int Shift); -static void Form_KeyUp(int KeyCode, int Shift); -static void Form_Paint(); -static int GetFileNameToSave(); -static long GetHwndFromTempFileName(char *TmpFile); -static char * GetMyTempFileName(); -static void GetSettings(); -static char * GetSpeedDescriptionFPS(currency FrameDelayUS); -static int GetSpeedIndex(long DelayUS); -static char * GetValidTempPath(); -static long Get_LastOpenFilter(); -static long Get_LastSaveFilter(); -static int InitSpeeds(); -static boolean InstanceStillRunning(char *TmpFile); -static void Let_LastOpenFilter(long NewVal); -static void Let_LastSaveFilter(long NewVal); -static void LoadKeyIndicators(); -static void LoadMenus(); -static void PanelTim_Timer(); static void ReStretch(float NewStretch); -static void RestoreFrame(); -static boolean SaveAs(); -static void SaveSettings(); -static void SetScrollEdges(); -static void UpdateDeltaT(); -static void cmbFile_Click(); -static void cmbFile_KeyDown(int KeyCode, int Shift); -static void cmbFile_KeyUp(int KeyCode, int Shift); -static void cmbLevel_Click(); -static void cmbLevel_KeyUp(int KeyCode, int Shift); -static void cmblevel_KeyDown(int KeyCode, int Shift); -static void cmdPause_Click(); -static void cmdPause_MouseUp(int Button, int Shift, float X, float Y); -static void cmdPlayAll_Click(); -static void cmdPlayAll_MouseUp(int Button, int Shift, float X, float Y); -static void cmdPlayDemo_Click(); -static void cmdPlayDemo_MouseUp(int Button, int Shift, float X, float Y); -static void cmdPlay_Click(); -static void cmdPlay_MouseUp(int Button, int Shift, float X, float Y); -static void cmdRecordDemo_Click(); -static void cmdRecordDemo_MouseUp(int Button, int Shift, float X, float Y); -static void cmdStop_Click(); -static void cmdStop_MouseUp(int Button, int Shift, float X, float Y); -static void fpsTim_Timer(); -static void menAbout_Click(); -static void menAutoScroll_Click(); -static void menBorder_Click(); -static void menCopy_Click(); -static void menEnOff_Click(); -static void menEnOn_Click(); -static void menExit_Click(); -static void menFaster_Click(); -static void menGravOff_Click(); -static void menGravOn_Click(); -static void menNewStd_Click(); -static void menNew_Click(); -static void menOpen_Click(); -static void menOptions_Click(); -static void menPanel_Click(); -static void menPaste_Click(); -static void menPause_Click(); -static void menPlayAll_Click(); -static void menPlayDemo_Click(); -static void menPlay_Click(); -static void menReRecordDemo_Click(); -static void menRec_Click(); -static void menRemSP_Click(); -static void menRestoreBorder_Click(); -static void menSaveAs_Click(); -static void menSave_Click(); -static void menSelectAll_Click(); -static void menShowLInfo_Click(); -static void menSlower_Click(); -static void menSoundFX_Click(); -static void menStretch_Click(int Index); -static void menToolTips_Click(); -static void menTrim_Click(); -static void menZonkOff_Click(); -static void menZonkOn_Click(); -static void picKeys_MouseUp(int Button, int Shift, float X, float Y); -static void picMenu_Click(); -static void picPane_KeyDown(int KeyCode, int Shift); -static void picPane_KeyUp(int KeyCode, int Shift); -static void picPane_MouseDown(int Button, int Shift, float X, float Y); -static void picPane_MouseMove(int Button, int Shift, float X, float Y); -static void picPane_MouseUp(int Button, int Shift, float X, float Y); -static void picPane_Paint(); -static void picViewPort_MouseUp(int Button, int Shift, float X, float Y); -static void picViewPort_Paint(); static void picViewPort_Resize(); -#endif - void DrawField(int X, int Y); void DrawFieldAnimated(int X, int Y); void DrawFieldNoAnimated(int X, int Y); -// --- VERSION 5.00 -// --- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX" -// --- Begin VB.Form MainForm -// --- AutoRedraw = -1 'True // True -// --- Caption = "MegaPlex" -// --- ClientHeight = 5850 -// --- ClientLeft = 2580 -// --- ClientTop = 2205 -// --- ClientWidth = 9285 -// --- Icon = "MainForm.frx":0000 -// --- LinkTopic = "Form1" -// --- ScaleHeight = 390 -// --- ScaleMode = 3 'Pixel // Pixel -// --- ScaleWidth = 619 -// --- Begin VB.Timer fpsTim -// --- Enabled = 0 'False // False -// --- Interval = 200 -// --- Left = 1380 -// --- Top = 2940 -// --- End -// --- Begin VB.Timer FocusTim -// --- Interval = 50 -// --- Left = 1920 -// --- Top = 2940 -// --- End -// --- Begin MSComDlg.CommonDialog cmDlg -// --- Left = 240 -// --- Top = 2880 -// --- _ExtentX = 847 -// --- _ExtentY = 847 -// --- _Version = 393216 -// --- CancelError = -1 'True // True -// --- End -// --- Begin VB.Timer PanelTim -// --- Enabled = 0 'False // False -// --- Interval = 5 -// --- Left = 840 -// --- Top = 2940 -// --- End -// --- Begin VB.Frame Panel -// --- Height = 1140 -// --- Left = 180 -// --- TabIndex = 2 -// --- Top = 3540 -// --- Width = 9015 -// --- Begin VB.CommandButton cmdPlay -// --- DisabledPicture = "MainForm.frx":0442 -// --- DownPicture = "MainForm.frx":058C -// --- Height = 345 -// --- Left = 5820 -// --- Picture = "MainForm.frx":06D6 -// --- Style = 1 'Graphical // Graphical -// --- TabIndex = 16 -// --- TabStop = 0 'False // False -// --- Top = 240 -// --- Width = 495 -// --- End -// --- Begin VB.CommandButton cmdStop -// --- DisabledPicture = "MainForm.frx":0820 -// --- DownPicture = "MainForm.frx":096A -// --- Enabled = 0 'False // False -// --- Height = 345 -// --- Left = 7020 -// --- Picture = "MainForm.frx":0AB4 -// --- Style = 1 'Graphical // Graphical -// --- TabIndex = 15 -// --- TabStop = 0 'False // False -// --- Top = 240 -// --- Width = 495 -// --- End -// --- Begin VB.CommandButton cmdPlayDemo -// --- DisabledPicture = "MainForm.frx":0BFE -// --- DownPicture = "MainForm.frx":0D48 -// --- Enabled = 0 'False // False -// --- Height = 345 -// --- Left = 7740 -// --- Picture = "MainForm.frx":0E92 -// --- Style = 1 'Graphical // Graphical -// --- TabIndex = 14 -// --- TabStop = 0 'False // False -// --- Top = 240 -// --- Width = 495 -// --- End -// --- Begin VB.CommandButton cmdPause -// --- DisabledPicture = "MainForm.frx":0FDC -// --- DownPicture = "MainForm.frx":1126 -// --- Enabled = 0 'False // False -// --- Height = 345 -// --- Left = 6420 -// --- Picture = "MainForm.frx":1270 -// --- Style = 1 'Graphical // Graphical -// --- TabIndex = 13 -// --- TabStop = 0 'False // False -// --- Top = 240 -// --- Width = 495 -// --- End -// --- Begin VB.CommandButton cmdRecordDemo -// --- DisabledPicture = "MainForm.frx":13BA -// --- DownPicture = "MainForm.frx":1504 -// --- Height = 345 -// --- Left = 8340 -// --- Picture = "MainForm.frx":164E -// --- Style = 1 'Graphical // Graphical -// --- TabIndex = 12 -// --- TabStop = 0 'False // False -// --- Top = 240 -// --- Width = 495 -// --- End -// --- Begin VB.ComboBox cmbFile -// --- BackColor = &H00000000& -// --- BeginProperty Font -// --- Name = "Fixedsys" -// --- Size = 9 -// --- Charset = 0 -// --- Weight = 400 -// --- Underline = 0 'False // False -// --- Italic = 0 'False // False -// --- Strikethrough = 0 'False // False -// --- EndProperty -// --- ForeColor = &H00FF8080& -// --- Height = 345 -// --- Left = 120 -// --- Sorted = -1 'True // True -// --- Style = 2 'Dropdown List // Dropdown List -// --- TabIndex = 9 -// --- Top = 240 -// --- Width = 3015 -// --- End -// --- Begin VB.ComboBox cmbLevel -// --- BackColor = &H00000000& -// --- BeginProperty Font -// --- Name = "Fixedsys" -// --- Size = 9 -// --- Charset = 0 -// --- Weight = 400 -// --- Underline = 0 'False // False -// --- Italic = 0 'False // False -// --- Strikethrough = 0 'False // False -// --- EndProperty -// --- ForeColor = &H00FF8080& -// --- Height = 345 -// --- Left = 840 -// --- Sorted = -1 'True // True -// --- Style = 2 'Dropdown List // Dropdown List -// --- TabIndex = 5 -// --- Top = 660 -// --- Width = 4035 -// --- End -// --- Begin VB.PictureBox picKeys -// --- BackColor = &H00008080& -// --- BorderStyle = 0 'None // None -// --- Height = 330 -// --- Left = 5400 -// --- ScaleHeight = 22 -// --- ScaleMode = 3 'Pixel // Pixel -// --- ScaleWidth = 22 -// --- TabIndex = 4 -// --- TabStop = 0 'False // False -// --- Top = 240 -// --- Width = 330 -// --- Begin VB.Shape shpKey -// --- FillColor = &H00008000& -// --- FillStyle = 0 'Solid // Solid -// --- Height = 120 -// --- Index = 1 -// --- Left = 0 -// --- Shape = 5 'Rounded Square // Rounded Square -// --- Top = 0 -// --- Width = 120 -// --- End -// --- End -// --- Begin VB.CommandButton cmdPlayAll -// --- Caption = "Play All Demos" -// --- Enabled = 0 'False // False -// --- Height = 345 -// --- Left = 7380 -// --- TabIndex = 3 -// --- TabStop = 0 'False // False -// --- Top = 960 -// --- Visible = 0 'False // False -// --- Width = 1395 -// --- End -// --- Begin VB.Shape shpProgress -// --- BackColor = &H00800000& -// --- BackStyle = 1 'Opaque // Opaque -// --- Height = 75 -// --- Left = 120 -// --- Top = 1020 -// --- Visible = 0 'False // False -// --- Width = 7515 -// --- End -// --- Begin VB.Label lblStatus -// --- Alignment = 2 'Center // Center -// --- BorderStyle = 1 'Fixed Single // Fixed Single -// --- Caption = "MegaPlex" -// --- BeginProperty Font -// --- Name = "Fixedsys" -// --- Size = 9 -// --- Charset = 0 -// --- Weight = 400 -// --- Underline = 0 'False // False -// --- Italic = 0 'False // False -// --- Strikethrough = 0 'False // False -// --- EndProperty -// --- Height = 345 -// --- Left = 3240 -// --- TabIndex = 11 -// --- Top = 240 -// --- Width = 2055 -// --- End -// --- Begin VB.Image Image2 -// --- Height = 240 -// --- Left = 6780 -// --- Picture = "MainForm.frx":1BD8 -// --- Top = 720 -// --- Width = 240 -// --- End -// --- Begin VB.Image Image1 -// --- Height = 240 -// --- Left = 5880 -// --- Picture = "MainForm.frx":1D22 -// --- Top = 720 -// --- Width = 240 -// --- End -// --- Begin VB.Label lblFps -// --- Alignment = 2 'Center // Center -// --- BackColor = &H00000000& -// --- BorderStyle = 1 'Fixed Single // Fixed Single -// --- BeginProperty Font -// --- Name = "Fixedsys" -// --- Size = 9 -// --- Charset = 0 -// --- Weight = 400 -// --- Underline = 0 'False // False -// --- Italic = 0 'False // False -// --- Strikethrough = 0 'False // False -// --- EndProperty -// --- ForeColor = &H0000C0C0& -// --- Height = 345 -// --- Left = 120 -// --- TabIndex = 10 -// --- Top = 660 -// --- Width = 615 -// --- End -// --- Begin VB.Label lblInfoCount -// --- Alignment = 2 'Center // Center -// --- BackColor = &H00000000& -// --- BorderStyle = 1 'Fixed Single // Fixed Single -// --- BeginProperty Font -// --- Name = "Fixedsys" -// --- Size = 9 -// --- Charset = 0 -// --- Weight = 400 -// --- Underline = 0 'False // False -// --- Italic = 0 'False // False -// --- Strikethrough = 0 'False // False -// --- EndProperty -// --- ForeColor = &H00FF8080& -// --- Height = 345 -// --- Left = 5040 -// --- TabIndex = 8 -// --- Top = 660 -// --- Width = 795 -// --- End -// --- Begin VB.Label lblRedDiskCount -// --- Alignment = 2 'Center // Center -// --- BackColor = &H00000000& -// --- BorderStyle = 1 'Fixed Single // Fixed Single -// --- BeginProperty Font -// --- Name = "Fixedsys" -// --- Size = 9 -// --- Charset = 0 -// --- Weight = 400 -// --- Underline = 0 'False // False -// --- Italic = 0 'False // False -// --- Strikethrough = 0 'False // False -// --- EndProperty -// --- ForeColor = &H000000FF& -// --- Height = 345 -// --- Left = 6240 -// --- TabIndex = 7 -// --- Top = 660 -// --- Width = 495 -// --- End -// --- Begin VB.Label lblFrameCount -// --- Alignment = 2 'Center // Center -// --- BorderStyle = 1 'Fixed Single // Fixed Single -// --- Caption = "0" -// --- BeginProperty Font -// --- Name = "Fixedsys" -// --- Size = 9 -// --- Charset = 0 -// --- Weight = 400 -// --- Underline = 0 'False // False -// --- Italic = 0 'False // False -// --- Strikethrough = 0 'False // False -// --- EndProperty -// --- Height = 345 -// --- Left = 7200 -// --- TabIndex = 6 -// --- Top = 660 -// --- Width = 1635 -// --- End -// --- End -// --- Begin VB.PictureBox picViewPort -// --- BorderStyle = 0 'None // None -// --- Height = 2535 -// --- Left = 180 -// --- ScaleHeight = 169 -// --- ScaleMode = 3 'Pixel // Pixel -// --- ScaleWidth = 265 -// --- TabIndex = 0 -// --- TabStop = 0 'False // False -// --- Top = 180 -// --- Width = 3975 -// --- Begin VB.PictureBox picPane -// --- AutoSize = -1 'True // True -// --- BackColor = &H00000000& -// --- BorderStyle = 0 'None // None -// --- DrawWidth = 3 -// --- Height = 1635 -// --- Left = 240 -// --- ScaleHeight = 109 -// --- ScaleMode = 3 'Pixel // Pixel -// --- ScaleWidth = 129 -// --- TabIndex = 1 -// --- Top = 180 -// --- Width = 1935 -// --- End -// --- Begin VB.PictureBox picFrame -// --- Height = 915 -// --- Left = 1320 -// --- ScaleHeight = 57 -// --- ScaleMode = 3 'Pixel // Pixel -// --- ScaleWidth = 81 -// --- TabIndex = 17 -// --- TabStop = 0 'False // False -// --- Top = 1200 -// --- Width = 1275 -// --- End -// --- End -// --- Begin VB.Menu menFile -// --- Caption = "&File" -// --- Begin VB.Menu menNewStd -// --- Caption = "New S&tandard Level" -// --- End -// --- Begin VB.Menu menNew -// --- Caption = "&New Level" -// --- End -// --- Begin VB.Menu menDash5 -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menOpen -// --- Caption = "&Open" -// --- End -// --- Begin VB.Menu menSave -// --- Caption = "&Save" -// --- Shortcut = ^S -// --- End -// --- Begin VB.Menu menSaveAs -// --- Caption = "Save &As ..." -// --- End -// --- Begin VB.Menu menDash4 -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menExit -// --- Caption = "E&xit" -// --- Shortcut = ^Q -// --- End -// --- End -// --- Begin VB.Menu menEditMain -// --- Caption = "&Edit" -// --- Begin VB.Menu menEdit -// --- Caption = "&Edit Level" -// --- End -// --- Begin VB.Menu menDash3 -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menCopy -// --- Caption = "&Copy" -// --- Shortcut = ^C -// --- End -// --- Begin VB.Menu menPaste -// --- Caption = "&Paste" -// --- Shortcut = ^V -// --- End -// --- Begin VB.Menu menTrim -// --- Caption = "&Trim" -// --- Shortcut = ^T -// --- End -// --- Begin VB.Menu menDash8 -// --- Caption = "-" -// --- Index = 1 -// --- End -// --- Begin VB.Menu menSelectAll -// --- Caption = "Select &All" -// --- Shortcut = ^A -// --- End -// --- Begin VB.Menu menDash6 -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menRestoreBorder -// --- Caption = "Restore &border" -// --- Shortcut = ^B -// --- End -// --- Begin VB.Menu menSp -// --- Caption = "Special Port" -// --- Begin VB.Menu menGravOn -// --- Caption = "&Gravity On" -// --- End -// --- Begin VB.Menu menZonkOn -// --- Caption = "Freeze &Zonks On" -// --- End -// --- Begin VB.Menu menEnOn -// --- Caption = "Freeze &Enemies On" -// --- End -// --- Begin VB.Menu menDash7 -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menGravOff -// --- Caption = "Gravity &Off" -// --- End -// --- Begin VB.Menu menZonkOff -// --- Caption = "Freeze Zon&ks Off" -// --- End -// --- Begin VB.Menu menEnOff -// --- Caption = "Freeze E&nemies Off" -// --- End -// --- Begin VB.Menu menDash10 -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menRemSP -// --- Caption = "&Remove (Make Normal Port)" -// --- End -// --- End -// --- End -// --- Begin VB.Menu menView -// --- Caption = "&View" -// --- Begin VB.Menu menZoom -// --- Caption = "&Zoom" -// --- Begin VB.Menu menStretch -// --- Caption = "0.25 : 1" -// --- Index = 1 -// --- End -// --- End -// --- Begin VB.Menu menBorder -// --- Caption = "Show &Border" -// --- Checked = -1 'True // True -// --- End -// --- Begin VB.Menu menPanel -// --- Caption = "Show &Panel" -// --- Checked = -1 'True // True -// --- End -// --- Begin VB.Menu menAutoScroll -// --- Caption = "&Autoscroll" -// --- Checked = -1 'True // True -// --- End -// --- Begin VB.Menu menDash9 -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menShowLInfo -// --- Caption = "Show Level &Info" -// --- End -// --- End -// --- Begin VB.Menu menSound -// --- Caption = "&Sound" -// --- Begin VB.Menu menSoundFX -// --- Caption = "&FX" -// --- End -// --- Begin VB.Menu menMusic -// --- Caption = "&Music" -// --- Enabled = 0 'False // False -// --- End -// --- End -// --- Begin VB.Menu menSpeed -// --- Caption = "Speed" -// --- Begin VB.Menu menSpeedPlay -// --- Caption = "Game play" -// --- Index = 11 -// --- Begin VB.Menu menPlaySpeed -// --- Caption = "1" -// --- Index = 1 -// --- End -// --- End -// --- Begin VB.Menu menSpeedDemo -// --- Caption = "Demo playback" -// --- Begin VB.Menu menDemoSpeed -// --- Caption = "1" -// --- Index = 1 -// --- End -// --- End -// --- Begin VB.Menu menSpeedDash -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menFaster -// --- Caption = "Faster (Pg Up)" -// --- End -// --- Begin VB.Menu menSlower -// --- Caption = "Slower (Pg Down)" -// --- End -// --- End -// --- Begin VB.Menu menRun -// --- Caption = "&Play" -// --- Begin VB.Menu menPlay -// --- Caption = "P&lay Game (Space)" -// --- End -// --- Begin VB.Menu menPause -// --- Caption = "&Pause (P)" -// --- Enabled = 0 'False // False -// --- End -// --- Begin VB.Menu menStop -// --- Caption = "&Stop (Q)" -// --- Enabled = 0 'False // False -// --- End -// --- Begin VB.Menu menDash0 -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menRec -// --- Caption = "&Record Demo (Ctrl+R)" -// --- End -// --- Begin VB.Menu menPlayDemo -// --- Caption = "Play &Demo (Ctrl+Space)" -// --- End -// --- Begin VB.Menu menPlayAll -// --- Caption = "Play &All Demos" -// --- End -// --- End -// --- Begin VB.Menu menOptionsMain -// --- Caption = "&Options" -// --- Begin VB.Menu menOptions -// --- Caption = "&Options ..." -// --- End -// --- End -// --- Begin VB.Menu menHelp -// --- Caption = "Help" -// --- Begin VB.Menu menToolTips -// --- Caption = "Show &ToolTips" -// --- End -// --- Begin VB.Menu menDash1 -// --- Caption = "-" -// --- End -// --- Begin VB.Menu menAbout -// --- Caption = "&About MegaPlex" -// --- End -// --- End -// --- End - -// static char *VB_Name = "MainForm"; -// static boolean VB_GlobalNameSpace = False; -// static boolean VB_Creatable = False; -// static boolean VB_PredeclaredId = True; -// static boolean VB_Exposed = False; - -// --- 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; -int OldPointer; -long OSX, OSY, MDX, MDY; -int MouseButton; - -int PanelSeq; - -boolean Loaded, DemosAvailable; - -#define nSpeedCount (17) -int SpeedsByDelayUS[nSpeedCount + 1]; -#define DefaultSpeedIndex (12) - -currency LastTick, LastFrame; -TickCountObject T; - -const char *AppTitle = "MegaPlex"; - -#if 0 - -static char *GetSpeedDescriptionFPS(currency FrameDelayUS) -{ - static char *GetSpeedDescriptionFPS; - - long FPS; - - if (FrameDelayUS == 0) - { - GetSpeedDescriptionFPS = "Fastest possible"; - return GetSpeedDescriptionFPS; - } - - if (FrameDelayUS < 0) - { - GetSpeedDescriptionFPS = "! display (even faster)"; - return GetSpeedDescriptionFPS; - } - - FPS = 1000000 / FrameDelayUS; - GetSpeedDescriptionFPS = CAT(INT_TO_STR(FPS), " fps"); - if (35 == FPS) - GetSpeedDescriptionFPS = CAT(GetSpeedDescriptionFPS, "(Default)"); - - return GetSpeedDescriptionFPS; -} - -static int InitSpeeds() -{ - static int InitSpeeds; - - SpeedsByDelayUS[1] = -1; // no display - SpeedsByDelayUS[2] = 0; // fastest possible - SpeedsByDelayUS[3] = 1000000 / 700; // 700 fps - SpeedsByDelayUS[4] = 1000000 / 500; // 500 fps - SpeedsByDelayUS[5] = 1000000 / 350; // 350 fps - SpeedsByDelayUS[6] = 1000000 / 250; // 250 fps - SpeedsByDelayUS[7] = 1000000 / 200; // etc. - SpeedsByDelayUS[8] = 1000000 / 150; - SpeedsByDelayUS[9] = 1000000 / 100; - SpeedsByDelayUS[10] = 1000000 / 70; - SpeedsByDelayUS[11] = 1000000 / 50; - SpeedsByDelayUS[12] = 1000000 / 35; // default - SpeedsByDelayUS[13] = 1000000 / 25; - SpeedsByDelayUS[14] = 1000000 / 20; - SpeedsByDelayUS[15] = 1000000 / 10; - SpeedsByDelayUS[16] = 1000000 / 5; - SpeedsByDelayUS[17] = 1000000 / 1; - - return InitSpeeds; -} - -static int GetSpeedIndex(long DelayUS) -{ - static int GetSpeedIndex; - - int i; - long Diff, MinDiff; - int MinIdx; - - MinIdx = DefaultSpeedIndex; - MinDiff = 1000000; - for (i = 1; i <= nSpeedCount; i++) - { - Diff = Abs(DelayUS - SpeedsByDelayUS[i]); - if (Diff < MinDiff) - { - MinDiff = Diff; - MinIdx = i; - } - } - - GetSpeedIndex = MinIdx; - - return GetSpeedIndex; -} - -static long Get_LastOpenFilter() -{ - static long LastOpenFilter; - - SettingsObject s; - - LastOpenFilter = s.Read("LastOpenFilter", 1); - - return LastOpenFilter; -} - -static void Let_LastOpenFilter(long NewVal) -{ - SettingsObject s; - - SettingsObject_Save("LastOpenFilter", NewVal); -} - -static long Get_LastSaveFilter() -{ - static long LastSaveFilter; - - SettingsObject s; - - LastSaveFilter = s.Read("LastSaveFilter", 1); - - return LastSaveFilter; -} - -static void Let_LastSaveFilter(long NewVal) -{ - SettingsObject s; - - SettingsObject_Save("LastSaveFilter", NewVal); -} - -#endif - -static void CountDown(long HalfSeconds, int bDisplayBar) -{ - -#if 0 - - long i; - int k; - long dT, Delta; - long LeftPos, TopPos, RightPos, MaxWidth; // , MaxHeight& - - dT = HalfSeconds * 500; - Delta = dT / 200; - LeftPos = cmbFile.left; - TopPos = cmbFile.top - shpProgress.Height - cmbFile.top / 8; - RightPos = lblFrameCount.left + lblFrameCount.Width; - MaxWidth = RightPos - LeftPos; - // MaxHeight = lblFrameCount.Top - TopPos + lblFrameCount.Height + 4 - if (bDisplayBar) - { - shpProgress.Move(LeftPos, TopPos, 0); // , MaxHeight - shpProgress.Visible = True; - } - - for (i = 1; i <= 200; i++) - { - // lblFrameCount = i - if (bDisplayBar) - { - if (i < 101) - { - shpProgress.Width = MaxWidth * i / 100; - } - else - { - k = MaxWidth * (i - 100) / 100; - shpProgress.Move(k, TopPos, RightPos - k); - } - } - - T.DelayMS(Delta, False); - } - - shpProgress.Visible = False; - // lblFrameCount = 0 - -#endif - -} - -#if 0 - -static char *GetValidTempPath() -{ - static char *GetValidTempPath; - - char *TP; - long nSize, L; - - GetValidTempPath = ""; - nSize = 255; - TP = String(nSize, Chr(32)); - L = GetTempPath(nSize, TP); - if (nSize < L) - { - // buffer was too small, retry with a properly sized buffer: - nSize = L; - TP = String(nSize, Chr(32)); - L = GetTempPath(nSize, TP); - } - - TP = SlashLess(left(TP, L)); - if ((0 == L) || (! IsDir(TP))) - { - // no valid temp path can be retrieved from the system --> create our own - TP = CAT(WithSlash(App.Path), "Temp"); - if (! IsDir(TP)) - { - - // --- On Error Resume Next - MkDir(TP); - if (! IS_NOTHING(&Err, sizeof(Err))) - { - MESSAGE_BOX("an error occured"); // MsgBox "cannot create directory for temporary files " & TP, vbCritical, "MegaPlex - Error"; - return GetValidTempPath; - } - - // --- On Error GoTo 0 - - } - } - - if (IsDir(TP)) - GetValidTempPath = TP; - - return GetValidTempPath; -} - -static char *GetMyTempFileName() -{ - static char *GetMyTempFileName; - - char *T; - - (char *)T = Hex(hWnd); - while (Len(T) < 8) - { - T = CAT("0", T); - } - - GetMyTempFileName = CAT("tmp0x", CAT((char *)T, ".mpx")); - - return GetMyTempFileName; -} - -static long GetHwndFromTempFileName(char *TmpFile) -{ - static long GetHwndFromTempFileName; - - char *FN; - long LP; - int L; - char *NumString; - - GetHwndFromTempFileName = 0; - FN = StripFileName(TmpFile); - LP = Len("tmp0x"); - L = Len(TmpFile); - if (LP < L) - return GetHwndFromTempFileName; - - L = L - LP; - NumString = right(FN, L - LP); - if (8 < L) - NumString = left(NumString, 8); - - NumString = CAT("&H", NumString); - GetHwndFromTempFileName = Val(NumString); - - return GetHwndFromTempFileName; -} - -static void CleanTempDir(char *TmpDir) -{ - char *FN, *MFN; - - MFN = GetMyTempFileName(); - MayKill(CAT(WithSlash(TmpDir), MFN)); - FN = Dir(CAT(WithSlash(TmpDir), "tmp0x*.mpx")); - while (FN != "") - { - if (STRING_IS_LIKE(FN, "tmp0x*.mpx")) - { - if (! InstanceStillRunning(FN)) - MayKill(CAT(WithSlash(TmpDir), FN)); - } - - FN = Dir_Without_Args(); - } -} - -static boolean InstanceStillRunning(char *TmpFile) -{ - static boolean InstanceStillRunning; - - long OtherHwnd, nSize, L; - char *Cap; - - InstanceStillRunning = False; - OtherHwnd = GetHwndFromTempFileName(TmpFile); - nSize = 255; - Cap = String(nSize, Chr(32)); - L = GetWindowText(OtherHwnd, Cap, nSize); - if ((L == 0) || (nSize < L)) - return InstanceStillRunning; - - if (STRING_IS_LIKE(Cap, CAT(AppTitle, "*"))) - InstanceStillRunning = True; - - return InstanceStillRunning; -} - -#endif +boolean Loaded; void DrawFrameIfNeeded() { @@ -1019,7 +21,7 @@ void DrawFrameIfNeeded() /* !!! CHECK THIS !!! */ #if 1 - if (! menBorder.Checked) + if (! menBorder) DrawFrame(1); #endif } @@ -1028,11 +30,6 @@ void DisplayLevel() { int X, Y; -#if 0 - printf("::: MainForm.c: DisplayLevel(): %d, %d, %d\n", - Loaded, LevelLoaded, bPlaying); -#endif - if (! Loaded) return; @@ -1051,7 +48,7 @@ void DisplayLevel() /* !!! CHECK THIS !!! */ #if 1 - if (! menBorder.Checked) + if (! menBorder) DrawFrame(1); #endif @@ -1086,2104 +83,152 @@ void DisplayLevel() { for (X = DisplayMinX; X <= DisplayMaxX; X++) { - DrawField(X, Y); - } - } - } -} - -#if 0 - -static void cmbFile_Click() -{ - CurPath = CAT(StripDir(OrigPath), CAT("/", cmbFile.List(cmbFile.ListIndex))); - OrigPath = CurPath; - FillLevelList(CurPath, LevelNumber); - if (STRING_IS_LIKE(OrigPath, "*.mpx") || STRING_IS_LIKE(OrigPath, "*.sp")) - { - menSave.Enabled = True; - } - else - { - menSave.Enabled = False; - } -} - -static void cmbFile_KeyDown(int KeyCode, int Shift) -{ - picPane_KeyDown(KeyCode, Shift); -} - -static void cmbFile_KeyUp(int KeyCode, int Shift) -{ - picPane_KeyUp(KeyCode, Shift); -} - -static int GetFileNameToSave() -{ - static int GetFileNameToSave; - - char *T; - - (char *)T = StripFileName(OrigPath); - if (STRING_IS_LIKE(T, "*.dat") || STRING_IS_LIKE(T, "*.d##")) - { - T = "Level" & Format(LevelNumber, "#000"); - } - - GetFileNameToSave = T; - - return GetFileNameToSave; -} - -static void cmbLevel_Click() -{ - long InfoCount; - boolean Oldflag; - int Msg; - static long LastIndex = 0; - static boolean bBlock = False; - - if (bBlock) - return; - - // ////////////////////////////////////////////////////////////////// - if (ModifiedFlag) - { - VbMsgBoxResult Res; - - Msg = "Save changes to " & GetFileNameToSave() & " ?"; - Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - close level"); - if (Res == vbCancel) // fallback - { - bBlock = True; - - // --- On Error Resume Next - cmbLevel.ListIndex = LastIndex; - // --- On Error GoTo 0 - - bBlock = False; - Debug.Assert cmbLevel.ListIndex = LastIndex; - return; - } - - if (Res == vbYes) - { - // Dim oldCurPath$ - // oldCurPath = CurPath - if (FileExists(OrigPath) && menSave.Enabled) - { - menSave_Click(); - } - else - { - if (! SaveAs()) // fallback - { - bBlock = True; - - // --- On Error Resume Next - cmbLevel.ListIndex = LastIndex; - // --- On Error GoTo 0 - - bBlock = False; - Debug.Assert cmbLevel.ListIndex = LastIndex; - return; - } - } - - // CurPath = oldCurPath - } - - Let_ModifiedFlag(False); - CurPath = OrigPath; - } - - // ////////////////////////////////////////////////////////////////// - { - LevelNumber = cmbLevel.ListIndex + 1; - DemoFlag = False; - if (Loaded) - { - Oldflag = NoDisplayFlag; - NoDisplayFlag = False; - subFetchAndInitLevel(); - if ((0 < SignatureDelay) && ! (WindowState == vbMinimized)) - { - Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")"; - if (DemoAvailable && bSignatureAvailable) - Msg = Msg & vbNewLine & vbNewLine & gSignature; - - SignatureForm.Signature = Msg; - SignatureForm.DelayMS = SignatureDelay; - int X, Y; - - X = left + (Width - SignatureForm.Width) / 2; - Y = top + (Height - SignatureForm.Height) / 2; - SignatureForm.Move X, Y; - SignatureForm.Show vbModeless, Me; - Me.SetFocus; - } - - lblStatus = "MegaPlex"; - lblFrameCount = GetTotalFramesOfDemo(); - if (EditFlag) - EdAll(); - - ReStretch(Stretch); - // picPane_Paint - Stage.Blt(); - NoDisplayFlag = Oldflag; - LastIndex = cmbLevel.ListIndex; - } - - } - menPlayDemo.Enabled = DemoAvailable; - cmdPlayDemo.Enabled = DemoAvailable; -} - -static void cmblevel_KeyDown(int KeyCode, int Shift) -{ - if (GameLoopRunning != 0) - return; - - switch (KeyCode) - { - case vbKeySpace: - if (menPlay.Enabled == True) - menPlay_Click(); - - break; - - default: - picPane_KeyDown(KeyCode, Shift); - break; - } -} - -static void cmbLevel_KeyUp(int KeyCode, int Shift) -{ - picPane_KeyUp(KeyCode, Shift); -} - -static void cmdPause_Click() -{ - menPause_Click(); -} - -static void cmdPause_MouseUp(int Button, int Shift, float X, float Y) -{ - FocusTim.Enabled = True; -} - -static void cmdPlay_Click() -{ - if (menPlay.Enabled) - menPlay_Click(); -} - -static void cmdPlay_MouseUp(int Button, int Shift, float X, float Y) -{ - FocusTim.Enabled = True; -} - -static void cmdPlayAll_Click() -{ - menPlayAll_Click(); -} - -static void cmdPlayAll_MouseUp(int Button, int Shift, float X, float Y) -{ - FocusTim.Enabled = True; -} - -static void cmdPlayDemo_Click() -{ - menPlayDemo_Click(); -} - -static void cmdPlayDemo_MouseUp(int Button, int Shift, float X, float Y) -{ - FocusTim.Enabled = True; -} - -static void cmdRecordDemo_Click() -{ - if (menRec.Enabled) - menRec_Click(); -} - -static void cmdRecordDemo_MouseUp(int Button, int Shift, float X, float Y) -{ - FocusTim.Enabled = True; -} - -static void cmdStop_Click() -{ - if (menStop.Enabled) - menStop_Click(); -} - -static void cmdStop_MouseUp(int Button, int Shift, float X, float Y) -{ - FocusTim.Enabled = True; -} - -static void FocusTim_Timer() -{ - FocusTim.Enabled = False; - - // --- On Error Resume Next - picPane.SetFocus; -} - -static void Form_KeyDown(int KeyCode, int Shift) -{ - picPane_KeyDown(KeyCode, Shift); -} - -static void Form_KeyUp(int KeyCode, int Shift) -{ - picPane_KeyUp(KeyCode, Shift); -} - -#endif - -void Form_Load() -{ -#if 0 - - long i; - SettingsObject s; - -#endif - - Loaded = False; - DemoFlag = 0; - PanelSeq = 0; - EditFlag = False; - EditMode = edMove; - // FMark = New MarkerObject; // (handle this later, if needed) - - InitGlobals(); - -#if 0 - - LoadMenus(); - - TmpPath = GetValidTempPath(); - if (TmpPath == "") - exit(-1); - - CleanTempDir(TmpPath); - TmpPath = CAT(WithSlash(TmpPath), GetMyTempFileName()); - GetSettings(); - ShowPanel = 1; - - InitDirectX(hWnd, picPane.hWnd); - - // AllowRedDiskCheat = 1 - MpxBmp = CAT(App.Path, "/mpx.bmp"); - // // Set NormalSprites = New DDSpriteBuffer // (handle this later, if needed) - // NormalSprites.CreateFromFile MPXBMP, 16, 16 - - Field = REDIM_2D(sizeof(int), 0, 2 + 1 - 1, 0, 2 + 1 - 1); - - picViewPort.ScaleMode = vbPixels; - -#endif - - PauseMode = 0; - // BaseWidth = 16 - -#if 1 - if (0) - menBorder_Click(); -#endif - - Loaded = True; - - ReStretch(Stretch); - -#if 0 - - LoadKeyIndicators(); - - Show(); - - FillFileList(CurPath); - if (s.Read("ShowSplash", True)) - { - // frmSplash.EnableTimer - frmSplash.Show vbModal, Me; - } - -#endif -} - -#if 0 - -static void FillLevelList(char *Path, int LevelIndex) -{ - long FNum, LevLen, i, iMax; - char *TFile; - - cmbLevel.Clear; - if (! FileExists(Path)) - return; - - if ((STRING_IS_LIKE(Path, "*.D??")) || (STRING_IS_LIKE(Path, "*.sp"))) - { - FNum = FreeFile(); - LevLen = 1536; - FNum = fopen(Path, "rb"); - { - i = 0; - FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo)); - cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i; - if (STRING_IS_LIKE(Path, "*.D??")) - { - while (!(EOF(FNum))) - { - i = i + 1; - FILE_GET(FNum, (long)1441 + i * LevLen, &LInfo, sizeof(LInfo)); - if (EOF(FNum)) - break; - - cmbLevel.AddItem Format(i + 1, "#000") & " " & LInfo.LevelTitle, i; - } - } - - if (LevelIndex <= i && 0 < LevelIndex) - i = LevelIndex - 1; - else - i = 0; - - cmbLevel.ListIndex = i; - } - fclose(FNum); - } - else if (STRING_IS_LIKE(Path, "*.mpx")) - { - FNum = FreeFile(); - LevLen = 1536; - FNum = fopen(Path, "rb"); - { - i = 0; - if (MpxOpen(Path)) - { - for (i = 1; i <= LevelCount; i++) - { - if (! MpxLoadLInfo(CInt(i))) - break; - - cmbLevel.AddItem Format(i, "#000") & " " & LInfo.LevelTitle, i - 1; - } - - MpxClose(); - } - - if (LevelIndex < i && 0 < LevelIndex) - i = LevelIndex - 1; - else - i = 0; - - if (i < cmbLevel.ListCount) - cmbLevel.ListIndex = i; - - } - fclose(FNum); - } -} - -static void FillFileList(char *Path) -{ - long FNum, LevLen, i; - int nDemoCount; - char *TFile, *TPath, *OFile; - - cmbFile.Clear; - i = 0; - nDemoCount = 0; - TPath = WithSlash(StripDir(Path)); - OFile = StripFileName(Path); - TFile = Dir(TPath & "*.D??"); - while (TFile != "") - { - if (FileLen(TPath & TFile) == 170496) - { - cmbFile.AddItem TFile; - } - - TFile = Dir; - } - - TFile = Dir(TPath & "*.SP"); - while (TFile != "") - { - nDemoCount = nDemoCount + 1; - cmbFile.AddItem TFile; - TFile = Dir; - } - - TFile = Dir(TPath & "*.mpx"); - while (TFile != "") - { - nDemoCount = nDemoCount + 1; - cmbFile.AddItem TFile; - TFile = Dir; - } - - i = cmbFile.ListCount - 1; - if (0 < cmbFile.ListCount) - { - do - { - if ((cmbFile.List(i) Like OFile) || i == 0) - break; - - i = i - 1; - } - while (!(i < 1)); - - cmbFile.ListIndex = i; - } - - DemosAvailable = (1 < nDemoCount); - menPlayAll.Enabled = DemosAvailable; - cmdPlayAll.Enabled = DemosAvailable; -} - -static void LoadMenus() -{ - long i; - - // speeds - menFaster.Enabled = False; - menSlower.Enabled = False; - InitSpeeds(); - for (i = 1; i <= nSpeedCount; i++) - { - if (1 < i) - { - Load menPlaySpeed(i); - Load menDemoSpeed(i); - } - - menPlaySpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]); - menDemoSpeed(i).Caption = GetSpeedDescriptionFPS(SpeedsByDelayUS[i]); - } - - // zoom - menStretch(1).Caption = Format(0.25, "#0.00") & "; - 1"; - if (Stretch == 0.25) - menStretch(1).Checked = True; - - for (i = 2; i <= 20; i++) - { - Load menStretch(i); - menStretch(i).Caption = Format(0.25 * i, "#0.00") & "; - 1"; - menStretch(i).Checked = ((i * 0.25) == Stretch); - } - - menSp.Enabled = False; -} - -// -// Function DisplayShift&() -// Dim X&, Y&, A&, B&, iX&, iiX&, LD& -// Dim Sprite& -// DisplayShift = 0 -// For A = 0 To picPane.ScaleWidth -// For Y = DisplayMinY To DisplayMaxY -// For X = DisplayMinX To DisplayMaxX -// iX = StretchWidth * X + A -// Sprite = Field(X, Y).SpritePos -// If picPane.ScaleWidth < (iX + 1) Then -// iX = iX - picPane.ScaleWidth -// Else -// If picPane.ScaleWidth < (iX + 1 + BaseWidth) Then -// iiX = iX - picPane.ScaleWidth -// Sprites.BitBltSprite picPane.hdc, iiX, StretchWidth * Y, Sprite -// End If -// End If -// Sprites.BitBltSprite picPane.hdc, iX, StretchWidth * Y, Sprite -// Next X -// Next Y -// DisplayShift = DisplayShift + 1 -// 'DoEvents -// Next A -// End Function - -static void Form_Paint() -{ - // Debug.Print "Form_Paint()" -} - -static void Form_Resize() -{ - long Space, NW, NH; - int Tmp; - - if (WindowState == vbMinimized || ! Loaded) - return; - - Space = Panel.left; - // 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); - if (Tmp < 0) - Tmp = 0; - - picViewPort.Move 0, 0, ScaleWidth, Tmp; - // Tmp = 2 * Space + picViewPort.Height - Panel.top = Tmp; - Panel.left = (ScaleWidth - Panel.Width) / 2; - // 'cmdNormal.Top = 2 * Space + picViewPort.Height - // cmbLevel.Top = Tmp - // lblRedDiskCount.Top = Tmp - // lblInfoCount.Top = Tmp - // picKeys.Top = Tmp - // lblFrameCount.Top = Tmp - // cmdPlayAll.Top = Tmp -} - -#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; - - LX = -1 + Delta; - tY = -1 + Delta; - RX = FieldWidth - Delta; - BY = FieldHeight - Delta; - DrawSprite(LX, tY, posFrameCorner); - DrawSprite(LX, BY, posFrameCorner); - DrawSprite(RX, tY, posFrameCorner); - DrawSprite(RX, BY, posFrameCorner); - for (i = LX + 1; i <= RX - 1; i++) - { - DrawSprite(i, tY, posFrameHorizontal); - DrawSprite(i, BY, posFrameHorizontal); - } - - for (i = tY + 1; i <= BY - 1; i++) - { - DrawSprite(LX, i, posFrameVertical); - DrawSprite(RX, i, posFrameVertical); - } -} - -#endif - -static void RestoreFrame() -{ - int i, LX, tY, RX, BY; - - LX = 0; - tY = 0; - RX = FieldWidth - 1; - BY = FieldHeight - 1; - for (i = LX; i <= RX; i++) - { - DrawField(i, tY); - DrawField(i, BY); - } - - for (i = tY + 1; i <= BY - 1; i++) - { - DrawField(LX, i); - DrawField(RX, i); - } -} - -#if 0 - -static void Form_Unload(int Cancel) -{ - EndFlag = True; - ExitToMenuFlag = 1; - if (cmdPlayAll.STRING_IS_LIKE(Caption, "Quit*")) - { - cmdPlayAll_Click(); - } - - if (menEdit.Checked) - menEdit_Click(); - - if (ModifiedFlag) - { - char *Msg; - VbMsgBoxResult Res; - - Msg = "Save changes to " & GetFileNameToSave() & " ?"; - Res = MsgBox(Msg, vbYesNoCancel, AppTitle & " - closing"); - if (Res == vbCancel) - { - Cancel = -1; - return; - } - - if (Res == vbYes) - { - if (FileExists(OrigPath) && menSave.Enabled) - { - menSave_Click(); - } - else - { - menSaveAs_Click(); - } - } - } - - if (FileExists(TmpPath) || ModifiedFlag) - { - MayKill(TmpPath); - CurPath = OrigPath; - } - - ReleaseDirectDraw(); - SaveSettings(); - End; -} - -static void fpsTim_Timer() -{ - currency TickDiff; - static int count5 = 0; - - count5 = count5 + 1; - if (4 < count5) - { - TickDiff = T.TickDiffUS(LastTick); - lblFps.Caption = CLng(Round((1000000 * (TimerVar - LastFrame)) / (TickDiff), 0)); - LastFrame = TimerVar; - LastTick = T.TickNow(); - count5 = 0; - } - - // If NoDisplayFlag Then lblFrameCount = TimerVar - lblFrameCount = TimerVar; -} - -static void menAbout_Click() -{ - frmSplash.Show vbModal, Me; -} - -static void menAutoScroll_Click() -{ - { - menAutoScroll.Checked = ! menAutoScroll.Checked; - AutoScrollFlag = menAutoScroll.Checked; - } -} - -#endif - -static void menBorder_Click() -{ - if (menBorder.Checked) - { - menBorder.Checked = False; - DisplayMinX = 1; - DisplayMaxX = FieldWidth - 2; - DisplayWidth = FieldWidth; - DisplayMinY = 1; - DisplayMaxY = FieldHeight - 2; - DisplayHeight = FieldHeight; - - if (Loaded && LevelLoaded) - DrawFrame(1); - - } - else - { - menBorder.Checked = True; - DisplayMinX = 0; - DisplayMaxX = FieldWidth - 1; - DisplayWidth = FieldWidth + 2; - DisplayMinY = 0; - DisplayMaxY = FieldHeight - 1; - DisplayHeight = FieldHeight + 2; - - if (Loaded && LevelLoaded) - RestoreFrame(); - } - - ReStretch(Stretch); - // DisplayLevel True -} - -void SetDisplayRegion() -{ - if (! menBorder.Checked) - { - DisplayMinX = 1; - DisplayMaxX = FieldWidth - 2; - DisplayWidth = FieldWidth; - DisplayMinY = 1; - DisplayMaxY = FieldHeight - 2; - DisplayHeight = FieldHeight; - - if (LevelLoaded) - DrawFrame(1); - - } - else - { - DisplayMinX = 0; - DisplayMaxX = FieldWidth - 1; - DisplayWidth = FieldWidth + 2; - DisplayMinY = 0; - DisplayMaxY = FieldHeight - 1; - DisplayHeight = FieldHeight + 2; - - if (LevelLoaded) - RestoreFrame(); - } -} - -#if 0 - -static void menCopy_Click() -{ - FMark.Copy; -} - -void menEdit_Click() -{ - long L; - - if (menEdit.Checked) - { - menEdit.Checked = False; - // leave edit mode - if (EditFlag) - Unload ToolBox; - - EditFlag = False; - UnEdAll(); - FMark.ShowMarker False; - picViewPort.MousePointer = 0; - if (ModifiedFlag) - { - if (! STRING_IS_LIKE(CurPath, TmpPath)) - { - OrigPath = CurPath; - CurPath = TmpPath; - } - - SaveMPX(TmpPath); - } - - DisplayLevel(); - Stage.Blt(); - } - else - { - if (! LevelLoaded) - { - Beep(); - return; - } - - if (ModifiedFlag) - { - if (! STRING_IS_LIKE(CurPath, TmpPath)) - { - OrigPath = CurPath; - CurPath = TmpPath; - } - - SaveMPX(TmpPath); - } - - subFetchAndInitLevel(); - menEdit.Checked = True; - // enter edit mode - EditFlag = True; - // ScaleMode = vbTwips - ToolBox.Move (Width - ToolBox.Width) / 2, Height - ToolBox.Height; - // ScaleMode = vbPixels - // L = GetWindowLong(ToolBox.hWnd, GWL_STYLE) - // L = L And (Not WS_POPUP) - // L = L Or WS_CHILD - // SetWindowLong ToolBox.hWnd, GWL_STYLE, L - // SetParent ToolBox.hWnd, hWnd - ToolBox.Show vbModeless, Me; - EdAll(); - DisplayLevel(); - Stage.Blt(); - FMark.ShowMarker True; - } -} - -static void menEnOff_Click() -{ - menEnOn.Checked = False; - menEnOff.Checked = True; - SpSaveMenu(); - SpLoadMenu(); -} - -static void menEnOn_Click() -{ - menEnOn.Checked = True; - menEnOff.Checked = False; - SpSaveMenu(); - SpLoadMenu(); -} - -static void menExit_Click() -{ - Unload Me; -} - -static void menFaster_Click() -{ - int i; - - if (! bPlaying) - { - Debug.Assert(False); - return; - } - - if (DemoFlag != 0) // demoplayback - { - i = GetSpeedIndex(DeltaTDemo); - i = i - 1; - If i < 2 Then i = 2; - menDemoSpeed_Click (i); - } - else - { - i = GetSpeedIndex(DeltaTPlay); - i = i - 1; - If i < 2 Then i = 2; - menPlaySpeed_Click (i); - } -} - -static void menSlower_Click() -{ - int i; - - if (! bPlaying) - { - Debug.Assert(False); - return; - } - - if (DemoFlag != 0) // demoplayback - { - i = GetSpeedIndex(DeltaTDemo); - i = i + 1; - If nSpeedCount < i Then i = nSpeedCount; - menDemoSpeed_Click (i); - } - else - { - i = GetSpeedIndex(DeltaTPlay); - i = i + 1; - If nSpeedCount < i Then i = nSpeedCount; - menPlaySpeed_Click (i); - } -} - -void menPlaySpeed_Click(int Index) -{ - int i; - - // If NoDisplayFlag And (GameLoopRunning <> 0) Then - // NoDisplayFlag = False - // DisplayLevel - // End If - // NoDisplayFlag = False - for (i = menPlaySpeed.LBound; i <= menPlaySpeed.UBound; i++) - { - { - menPlaySpeed(i).Checked = (Index == i); - } - } - - BlockingSpeed = False; - DeltaTPlay = SpeedsByDelayUS[Index]; - UpdateDeltaT(); - // If DeltaTPlay < 0 Then - // Stage.Blt - // DeltaT = 0 - // NoDisplayFlag = True - // End If -} - -void menDemoSpeed_Click(int Index) -{ - int i; - - // If NoDisplayFlag And (GameLoopRunning <> 0) Then - // NoDisplayFlag = False - // DisplayLevel - // End If - NoDisplayFlag = False; - for (i = menDemoSpeed.LBound; i <= menDemoSpeed.UBound; i++) - { - { - menDemoSpeed(i).Checked = (Index == i); - } - } - - BlockingSpeed = False; - DeltaTDemo = SpeedsByDelayUS[Index]; - UpdateDeltaT(); - // If DeltaTPlay < 0 Then - // Stage.Blt - // DeltaT = 0 - // NoDisplayFlag = True - // End If -} - -static void UpdateDeltaT() -{ - if (! bPlaying) - return; - - DeltaT = (DemoFlag != 0 ? DeltaTDemo : DeltaTPlay); - if (DeltaT < 0) - { - Stage.Blt(); - DeltaT = 0; - NoDisplayFlag = True; - } - else - { - if (NoDisplayFlag && GameLoopRunning != 0) - { - NoDisplayFlag = False; - DisplayLevel(); - } - else - { - NoDisplayFlag = False; - } - } -} - -static void menGravOff_Click() -{ - menGravOn.Checked = False; - menGravOff.Checked = True; - SpSaveMenu(); - SpLoadMenu(); -} - -static void menGravOn_Click() -{ - menGravOn.Checked = True; - menGravOff.Checked = False; - SpSaveMenu(); - SpLoadMenu(); -} - -static void menNew_Click() -{ - NewForm.Show vbModal, Me; - CreateLevel(FieldWidth, FieldHeight); - ReStretch(Stretch); -} - -static void menNewStd_Click() -{ - CreateLevel(60, 24); - ReStretch(Stretch); -} - -static void menOpen_Click() -{ - long LFilt; - - { - // cmDlg.DefaultExt = "sp" - - /* - - (prevent compiler warning here due to suspected use of trigraph) - - 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"; - */ - - LFilt = LastOpenFilter; - cmDlg.FilterIndex = (0 < LFilt & LFilt < 5 ? LFilt : 1); - if (FileExists(CurPath)) - cmDlg.InitDir = WithSlash(StripDir(CurPath)); - - cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames; - } - - // --- On Error GoTo menOpenEH - cmDlg.ShowOpen; - // --- On Error GoTo 0 - - LFilt = cmDlg.FilterIndex; - LastOpenFilter = LFilt; - CurPath = cmDlg.FileName; - OrigPath = CurPath; - FillFileList (CurPath); - -menOpenEH: -} - -static void menOptions_Click() -{ - OptionsForm oFrm; - - oFrm.Show vbModal, Me; - SaveSettings(); - picViewPort_Resize(); -} - -static void menPanel_Click() -{ - { - PanelVisible = ! menPanel.Checked; - } -} - -void Let_PanelVisible(boolean NewVal) -{ - static boolean HidePanel = False; - - if (HidePanel != NewVal) - return; - - HidePanel = ! NewVal; - PanelTim.Enabled = True; -} - -static void DrawPauseLayer(long Layer) -{ - DirectDrawPalette Pal; - PALETTEENTRY *Val; - long i; - - // Dim X&, Y& - // For Y = 0 To bmpStage.Height Step BaseWidth - // For X = 0 To bmpStage.Width Step BaseWidth - // Pause.TransparentDraw bmpStageHDC, X, Y, Layer - // Next X - // Next Y - // With Stage.Surface - // Set Pal = .GetPalette - // for i=1 to pal.GetEntries( - // Stage.Surface.SetPalette -} - -static void menPaste_Click() -{ - FMark.Paste; - DisplayLevel(); - Stage.Blt(); -} - -static void menPause_Click() -{ - static StdPicture OldPic; - static char *OldText = 0; - - PauseMode = (PauseMode != 0 ? 0 : 1); - if (PauseMode != 0) - { - if (IS_NOTHING(&OldPic, sizeof(OldPic))) - OldPic = cmdPause.Picture; - - cmdPause.Picture = cmdPause.DownPicture; - OldText = lblStatus.Caption; - lblStatus = "Paused ..."; - } - else - { - cmdPause.Picture = OldPic; - lblStatus.Caption = OldText; - } -} - -static void menPlayAll_Click() -{ - long iMin, iMax, i; - int FNum; - char *LogPath, *OutStr, *ReRecPath, *SPPath; - boolean bEqual; - static boolean QuitFlag = False; - - if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play) All Demos") - { - cmdPlayAll.Caption = "Quit All"; - menPlayAll.Caption = "Quit All"; - FocusTim.Enabled = True; - QuitFlag = False; - iMin = 0; - iMax = cmbFile.ListCount - 1; - LogPath = StripDir(CurPath) & "/Error.Log"; - if (Dir(LogPath) != "") - Kill(LogPath); - - for (i = iMin; i <= iMax; i++) - { - cmbFile.ListIndex = i; - // If CurPath Like "*.sp" Or CurPath Like "*.mpx" Then - if (DemoAvailable) - { - SPPath = CurPath; - ReRecPath = SPPath & ".ReRec"; - menPlayDemo_Click(); - // SaveSP ReRecPath - // bEqual = FilesEqual(ReRecPath, SPPath) - // If bEqual Then MayKill ReRecPath - bEqual = True; - OutStr = cmbFile.List(i) & " -> "; - // - if (Val(lblFrameCount) != GetTotalFramesOfDemo()) - { - OutStr = OutStr & "Error in GetTotalFramesOfDemo()! "; - Debug.Assert(False); - } - - // - if ((LevelStatus == 1) && bEqual) - { - OutStr = OutStr & "Success"; - } - else if (QuitFlag) - { - OutStr = OutStr & "All Demos (float)Canceled"; - } - else - { - if (LevelStatus != 1) - { - OutStr = OutStr & "### Level Failed ### (TimerVar == " & TimerVar & ")"; - } - - if (! bEqual) - { - OutStr = OutStr & "### ReRecording is binary different ###"; - } - } - - FNum = FreeFile(); - FNum = fopen(LogPath, "ab"); - Print #FNum, OutStr; - fclose(FNum); - if (QuitFlag) - break; - } - } - - cmdPlayAll.Caption = "Play All Demos"; - menPlayAll.Caption = "Play All Demos"; - SettingsObject Settings; - - MySignature = Settings.Read("MySignature", ""); - FirstDemoByte = 0x81; - } - else - { - QuitFlag = True; - if (menStop.Enabled) - menStop_Click(); - } -} - -static void menRemSP_Click() -{ - RemoveSP(); - SpLoadMenu(); -} - -static void menRestoreBorder_Click() -{ - RestoreBorder(); -} - -static void menSave_Click() -{ - if (! ModifiedFlag) - return; - - if (STRING_IS_LIKE(CurPath, TmpPath)) - CurPath = OrigPath; - - if (STRING_IS_LIKE(CurPath, "") || STRING_IS_LIKE(CurPath, "*.dat")) - { - menSaveAs_Click(); - return; - } - - if (STRING_IS_LIKE(CurPath, "*.sp")) - { - menSaveAs_Click(); - return; - } - - if (! FileExists(CurPath) || STRING_IS_LIKE(CurPath, "Untitled")) - { - menSaveAs_Click(); - return; - } - - SaveMPX(CurPath); - Let_ModifiedFlag(False); -} - -static void menSaveAs_Click() -{ - if (SaveAs()) - FillFileList (CurPath); -} - -static boolean SaveAs() -{ - static boolean SaveAs; - - char *FN; - SettingsObject s; - - SaveAs = False; - { - // cmDlg.DefaultExt = "sp" - cmDlg.Filter = "MegaPlex Level (*.mpx)|*.mpx|SpeedFix Demo (*.sp)|*.sp"; - cmDlg.FilterIndex = LastSaveFilter; - // If OrigPath Like "*.sp" Then cmDlg.FilterIndex = 1 Else cmDlg.FilterIndex = 0 - if (FileExists(OrigPath)) - { - cmDlg.InitDir = WithSlash(StripDir(OrigPath)); - cmDlg.InitDir = s.Read("LastSaveDir", cmDlg.InitDir); - cmDlg.FileName = StripExtensionlessFileName(GetFileNameToSave()); - } - - cmDlg.flags = cdlOFNHideReadOnly | cdlOFNLongNames; - } - - // --- On Error GoTo SaveAsEH - cmDlg.ShowSave; - // --- On Error GoTo 0 - - LastSaveFilter = cmDlg.FilterIndex; - FN = cmDlg.FileName; - SettingsObject_Save("LastSaveDir", WithSlash(StripDir(FN))); - if (STRING_IS_LIKE(FN, "*.sp")) - { - SaveSP(FN); - } - else if (STRING_IS_LIKE(FN, "*.mpx")) - { - SaveMPX(FN); - } - - Let_ModifiedFlag(False); - SaveAs = True; - -SaveAsEH: - - return SaveAs; -} - -static void menSelectAll_Click() -{ - FMark.SetPoint1 0, 0; - FMark.SetPoint2 FieldWidth - 1, FieldHeight - 1; -} - -static void menShowLInfo_Click() -{ - char *Msg; - - Msg = LInfo.LevelTitle & vbNewLine & "(" & FieldWidth & " x " & FieldHeight & ")"; - if (DemoAvailable && bSignatureAvailable) - Msg = Msg & vbNewLine & vbNewLine & gSignature; - - SignatureForm.Signature = Msg; - SignatureForm.DelayMS = 5000; - int X, Y; - - X = left + (Width - SignatureForm.Width) / 2; - Y = top + (Height - SignatureForm.Height) / 2; - SignatureForm.Move X, Y; - SignatureForm.Show vbModeless, Me; - Me.SetFocus; -} - -static void menSoundFX_Click() -{ - { - menSoundFX.Checked = ! menSoundFX.Checked; - FXOnFlag = (menSoundFX.Checked ? -1 : 0); - } -} - -#endif - -// static void menPlay_Click() -void menPlay_Click() -{ -#if 0 - - boolean OldEditFlag; - - // Trace "MainForm", "--> menPlay_Click()" - if (! LevelLoaded) - { - Beep(); - return; - } - - SignatureForm.DelayMS = 1; - menPlay.Enabled = False; - menPause.Enabled = True; - menStop.Enabled = True; - cmdPlay.Enabled = False; - cmdPause.Enabled = True; - cmdStop.Enabled = True; - cmdPlayDemo.Enabled = False; - menPlayDemo.Enabled = False; - cmdRecordDemo.Enabled = False; - menRec.Enabled = False; - menFaster.Enabled = True; - menSlower.Enabled = True; - if (cmdPlayAll.STRING_IS_LIKE(Caption, "Play*")) - { - cmdPlayAll.Enabled = False; - menPlayAll.Enabled = False; - } - - cmbFile.Enabled = False; - cmbLevel.Enabled = False; - OldEditFlag = EditFlag; - if (EditFlag) - menEdit_Click(); - - menEditMain.Enabled = False; - if (DemoFlag == 0 && RecordDemoFlag == 0) - lblStatus = "Playing"; - - lblFrameCount = 0; - -#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" - - GoPlay(); - - // Trace "MainForm", "GoPlay returned" - -#if 0 - - if (LevelStatus == 1) - { - lblStatus = "(float)Success"; - } - else - { - lblStatus = "Try (float)again"; - } - -#endif - - // Trace "MainForm", "CountDown 1" - CountDown(1, False); - RecordDemoFlag = 0; - -#if 0 - ShowKey(0); -#endif - - bPlaying = False; - // Trace "MainForm", "Call subFetchAndInitLevel" - - subFetchAndInitLevel(); - - // Trace "MainForm", "subFetchAndInitLevel returned" - -#if 0 - Stage.Blt(); -#endif - -#if 0 - - menEditMain.Enabled = True; - if (OldEditFlag) - menEdit_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() -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()"); - if (! LevelLoaded) - { - Beep(); - return; - } - - RecordDemoFlag = 1; - DemoFlag = 0; - lblStatus.ForeColor = vbRed; - lblStatus = "Recording Demo"; - // DemoBuffer = New DemoBufferObject; // (handle this later, if needed) - Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer))); - Trace("MainForm", "Call menPlayClick"); - menPlay_Click(); - Trace("MainForm", "menPlayClick returned"); - - lblStatus.ForeColor = vbButtonText; - RecordDemoFlag = 0; - Let_ModifiedFlag(True); - if (! STRING_IS_LIKE(CurPath, TmpPath)) - { - OrigPath = CurPath; - CurPath = TmpPath; - } - - LInfo.DemoRandomSeed = RecDemoRandomSeed; - Trace("MainForm", "Call SaveMPX(TmpPath)"); - SaveMPX(TmpPath); - Trace("MainForm", "Set DemoBuffer == Nothing"); - SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer)); - Trace("MainForm", "Call subFetchAndInitLevel"); - subFetchAndInitLevel(); - cmdPlayDemo.Enabled = DemoAvailable; - Trace("MainForm", "<-- menRec_Click()"); -} - -static void menReRecordDemo_Click() -{ - if (! LevelLoaded) - { - Beep(); - return; - } - - RecordDemoFlag = 1; - DemoFlag = 1; - lblStatus.ForeColor = vbRed; - lblStatus = "ReRecording Demo"; - // DemoBuffer = New DemoBufferObject; // (handle this later, if needed) - Debug.Assert(! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer))); - menPlay_Click(); - lblStatus.ForeColor = vbButtonText; - RecordDemoFlag = 0; - Let_ModifiedFlag(True); - if (! STRING_IS_LIKE(CurPath, TmpPath)) - { - OrigPath = CurPath; - CurPath = TmpPath; - } - - LInfo.DemoRandomSeed = RecDemoRandomSeed; - SaveMPX(TmpPath); - SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer)); - subFetchAndInitLevel(); -} - -void menStop_Click() -{ - EndFlag = True; - LeadOutCounter = 1; - if (PauseMode != 0) - menPause_Click(); - - fpsTim.Enabled = False; - fpsTim_Timer(); - lblFps.Caption = ""; - menRec.Enabled = True; - menPlay.Enabled = True; - menPause.Enabled = False; - menStop.Enabled = False; - cmdPlay.Enabled = True; - cmdPause.Enabled = False; - cmdStop.Enabled = False; - cmdRecordDemo.Enabled = True; - cmdPlayDemo.Enabled = DemoAvailable; - cmdPlayAll.Enabled = DemosAvailable; - menPlayDemo.Enabled = DemoAvailable; - menPlayAll.Enabled = DemosAvailable; - menFaster.Enabled = False; - menSlower.Enabled = False; - cmbFile.Enabled = True; - cmbLevel.Enabled = True; -} - -static void menStretch_Click(int Index) -{ - ReStretch(0.25 * Index); - // DisplayLevel True -} - -static void menToolTips_Click() -{ - { - menToolTips.Checked = ! menToolTips.Checked; - if (menToolTips.Checked) - { - cmdPlay.ToolTipText = "Play Game (Space)"; - cmdPause.ToolTipText = "Pause (P)"; - cmdStop.ToolTipText = "Stop (Q)"; - cmdPlayDemo.ToolTipText = "Play demo (Ctrl+Space)"; - cmdRecordDemo.ToolTipText = "Record demo (Ctrl+R)"; - lblInfoCount.ToolTipText = "Number of infotrons needed"; - lblRedDiskCount.ToolTipText = "Number of red disks"; - cmbLevel.ToolTipText = "List of all levels in the file"; - cmbFile.ToolTipText = "List of files in current directory"; - lblFps.ToolTipText = "Animation speed in fps"; - lblFrameCount.ToolTipText = "Game time in frames"; - } - else - { - cmdPlay.ToolTipText = ""; - cmdPause.ToolTipText = ""; - cmdStop.ToolTipText = ""; - cmdPlayDemo.ToolTipText = ""; - cmdRecordDemo.ToolTipText = ""; - lblInfoCount.ToolTipText = ""; - lblRedDiskCount.ToolTipText = ""; - cmbLevel.ToolTipText = ""; - cmbFile.ToolTipText = ""; - lblFps.ToolTipText = ""; - lblFrameCount.ToolTipText = ""; - } - - } -} - -static void menTrim_Click() -{ - LevelInfoType Tmp; - char *OldOPath; - - OldOPath = OrigPath; - Tmp = LInfo; - Tmp.SpecialPortCount = 0; // hack: all special ports are deleted - menCopy_Click(); - CreateLevel(FMark.Width, FMark.Height); - LInfo = Tmp; - OrigPath = OldOPath; - CurPath = OldOPath; - menSelectAll_Click(); - menPaste_Click(); - picViewPort_Resize(); -} - -static void menZonkOff_Click() -{ - menZonkOn.Checked = False; - menZonkOff.Checked = True; - SpSaveMenu(); - SpLoadMenu(); -} - -static void menZonkOn_Click() -{ - menZonkOn.Checked = True; - menZonkOff.Checked = False; - SpSaveMenu(); - SpLoadMenu(); -} - -static void PanelTim_Timer() -{ - int Tmp; - - Tmp = Panel.Height; - if (PanelSeq < Panel.Height && -1 < PanelSeq) - { - PanelSeq = (ShowPanel != 0 ? PanelSeq + 2 : PanelSeq - 2); - Tmp = ScaleHeight - Tmp + PanelSeq; - Panel.top = Tmp; - picViewPort.Height = Tmp; - } - else - { - PanelTim.Enabled = False; - PanelSeq = (PanelSeq < 0 ? 0 : PanelSeq - ); - ShowPanel = (ShowPanel == 0 ? 1 : 0); - menPanel.Checked = (ShowPanel != 0); - } -} - -static void picKeys_MouseUp(int Button, int Shift, float X, float Y) -{ - FocusTim.Enabled = True; -} - -static void picMenu_Click() -{ -} - -static void picPane_KeyDown(int KeyCode, int Shift) -{ - if (KeyCode < 0 || 255 < KeyCode) - return; - - KeyState[KeyCode] = True; - switch (KeyCode) - { - case vbKeyControl: - if (MouseButton == 0 && EditFlag) - picPane.MousePointer = 15; - - break; - - case vbKeyUp: - case vbKeyLeft: - case vbKeyDown: - case vbKeyRight: - case vbKeySpace: - if (DemoFlag != 0) - { - DemoFlag = 0; - UpdateDeltaT(); - } - - break; - - case vbKeyF12: - if (DemoFlag != 0 && 2 == Shift) - { - DemoFlag = 0; - UpdateDeltaT(); - } - - break; - - case vbKeyF11: - bCapturePane = ! bCapturePane; - break; - } -} - -static void picPane_KeyUp(int KeyCode, int Shift) -{ - if (KeyCode < 0 || 255 < KeyCode) - return; - - KeyState[KeyCode] = False; - switch (KeyCode) - { - case vbKeyPageUp: - if (menFaster.Enabled) - menFaster_Click(); - - break; - - case vbKeyPageDown: - if (menSlower.Enabled) - menSlower_Click(); - - break; - - case vbKeySpace: - if (2 == Shift) // ctrl+space - { - if (menPlayDemo.Enabled) - menPlayDemo_Click(); - - } - else - { - if (menPlay.Enabled) - menPlay_Click(); - } - - break; - - case vbKeyQ: - if (menStop.Enabled) - menStop_Click(); - - break; - - case vbKeyR: - if (menRec.Enabled) - menRec_Click(); + DrawField(X, Y); + } + } + } +} - break; +void Form_Load() +{ + Loaded = False; - case vbKeyP: - case vbKeyPause: - if (menPause.Enabled && (Shift == 0)) - menPause_Click(); + InitGlobals(); - break; + Loaded = True; - case vbKeyControl: - if (MouseButton == 0 && EditFlag) - picPane.MousePointer = 0; - break; - } + ReStretch(Stretch); } -static void picPane_MouseDown(int Button, int Shift, float X, float Y) +static void DrawFrame(int Delta) { - int OldEdMode; + int i, LX, tY, RX, BY; - MouseButton = Button; - OldEdMode = EditMode; - if (Button != 1) + 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++) { - if (Button == 2 && Shift != 2) - { - EditMode = edSelect; - } - else - { - return; - } + DrawImage(i, tY, imgFrameHorizontal); + DrawImage(i, BY, imgFrameHorizontal); } - if (Shift == 2) - EditMode = edMove; - - OSX = ScrollX; - OSY = ScrollY; - MDX = X; - MDY = Y; - switch (EditMode) + for (i = tY + 1; i <= BY - 1; i++) { - case edMove: - picPane.MousePointer = 5; // size - UserDragFlag = True; - break; - - case edDraw: - SetField(X, Y, ToolBox.ASpriteIndex); - break; - - case edSelect: - FMark.SetPoint1 EdGetX(X), EdGetY(Y); - FMark.MoveMarker; - break; + DrawImage(LX, i, imgFrameVertical); + DrawImage(RX, i, imgFrameVertical); } - - EditMode = OldEdMode; } -static void picPane_MouseMove(int Button, int Shift, float X, float Y) +static void RestoreFrame() { - boolean Oldflag; - int OldEdMode; + int i, LX, tY, RX, BY; + + LX = 0; + tY = 0; + RX = FieldWidth - 1; + BY = FieldHeight - 1; - OldEdMode = EditMode; - if (Button != 1) + for (i = LX; i <= RX; i++) { - if (EditFlag && Button == 2 && Shift != 2) - { - EditMode = edSelect; - } - else - { - return; - } + DrawField(i, tY); + DrawField(i, BY); } - if (Shift == 2) - EditMode = edMove; - - switch (EditMode) + for (i = tY + 1; i <= BY - 1; i++) { - case edMove: - Oldflag = NoDisplayFlag; - NoDisplayFlag = False; - ScrollTo(OSX - X + MDX, OSY - Y + MDY); - Stage.Blt(); - NoDisplayFlag = Oldflag; - break; - - case edDraw: - SetField(X, Y, ToolBox.ASpriteIndex); - break; - - case edSelect: - FMark.SetPoint2 EdGetX(X), EdGetY(Y); - FMark.MoveMarker; - break; + DrawField(LX, i); + DrawField(RX, i); } - - EditMode = OldEdMode; } -static void picPane_MouseUp(int Button, int Shift, float X, float Y) +void SetDisplayRegion() { - MouseButton = MouseButton ^ Button; - picPane.MousePointer = 0; - UserDragFlag = False; - if (menEditMain.Enabled && Button == 2) + if (! menBorder) { - if (MDX == X && MDY == Y) - PopupMenu menEditMain; + DisplayMinX = 1; + DisplayMaxX = FieldWidth - 2; + DisplayWidth = FieldWidth; + DisplayMinY = 1; + DisplayMaxY = FieldHeight - 2; + DisplayHeight = FieldHeight; + + if (LevelLoaded) + DrawFrame(1); } -} + else + { + DisplayMinX = 0; + DisplayMaxX = FieldWidth - 1; + DisplayWidth = FieldWidth + 2; + DisplayMinY = 0; + DisplayMaxY = FieldHeight - 1; + DisplayHeight = FieldHeight + 2; -#endif + if (LevelLoaded) + RestoreFrame(); + } +} -static void picPane_Paint() +void menPlay_Click() { - boolean Oldflag; + bPlaying = True; - Oldflag = NoDisplayFlag; - NoDisplayFlag = False; + subFetchAndInitLevelB(); -#if 0 - Stage.Blt(); + ReStretch(Stretch); + + subMainGameLoop_Init(); + +#if 1 + return; #endif - NoDisplayFlag = Oldflag; + bPlaying = False; + + subFetchAndInitLevel(); } 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); - // Set StretchedSprites = NormalSprites.GetStretchCopy(Stretch) - ReLoadStretchSprites(); - if (i == 0 || IS_NOTHING(&StretchedSprites, sizeof(StretchedSprites))) + if (Loaded && LevelLoaded) { - // menStretch(Stretch / 0.5).Enabled = False - if (0.5 <= Stretch) - ReStretch(Stretch - 0.25); - + SetDisplayRegion(); + picViewPort_Resize(); + DisplayLevel(); } - else -#endif - { - StretchedSprites.DestXOff = 1 * BaseWidth; // StretchWidth - StretchedSprites.DestYOff = 1 * BaseWidth; // StretchWidth - Stage.DestXOff = 1 * StretchWidth; - Stage.DestYOff = 1 * StretchWidth; - StretchedSprites.DestinationSurface = Stage.Surface; - -#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); + subCalculateScreenScrollPos(); -#if 0 - Stage.Blt(); -#endif - - picPane_Paint(); - } - -#if 0 - MousePointer = 0; -#endif + ScrollTo(ScreenScrollXPos, ScreenScrollYPos); } -#if 0 -static void SetScrollEdges() -#else void SetScrollEdges() -#endif { -#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 + ScrollMaxX = (int)(DisplayMaxX + 1.5) * Stretch * BaseWidth - SXSIZE; + ScrollMaxY = (int)(DisplayMaxY + 1.5) * Stretch * BaseWidth - SYSIZE; } void DrawField(int X, int Y) @@ -3201,12 +246,6 @@ void DrawField(int X, int Y) if (Tmp == fiBug || Tmp == 40) Tmp = DisPlayField[tsi]; - if (EditFlag) - { - if (Tmp > fiOrangeDisk && Tmp < fiSnikSnak) - Tmp = DisPlayField[tsi]; - } - #if 1 if (Tmp >= 0 && Tmp <= 40) { @@ -3218,7 +257,7 @@ void DrawField(int X, int Y) #endif } #else - StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp); + DDSpriteBuffer_BltEx(StretchWidth * X, StretchWidth * Y, Tmp); #endif } @@ -3245,7 +284,7 @@ void DrawFieldAnimated(int X, int Y) // If EditFlag Then // If fiOrangeDisk < Tmp And Tmp < fiSnikSnak Then Tmp = DisPlayField(tsi) // End If - // StretchedSprites.BltEx StretchWidth * X, StretchWidth * Y, Tmp + // DDSpriteBuffer_BltEx StretchWidth * X, StretchWidth * Y, Tmp break; } } @@ -3259,19 +298,11 @@ 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: @@ -3284,12 +315,6 @@ void DrawFieldNoAnimated(int X, int Y) if (Tmp == fiBug || Tmp == 40) Tmp = DisPlayField[tsi]; - if (EditFlag) - { - if (Tmp > fiOrangeDisk && Tmp < fiSnikSnak) - Tmp = DisPlayField[tsi]; - } - #if 1 if (Tmp >= 0 && Tmp <= 40) { @@ -3301,335 +326,21 @@ void DrawFieldNoAnimated(int X, int Y) #endif } #else - StretchedSprites.BltEx(StretchWidth * X, StretchWidth * Y, Tmp); + DDSpriteBuffer_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) -{ - long X, Y; - - // For Y = YMin To YMax - // For X = XMin To XMax - // Field(X, Y).GraphicsValid = 0 - // Next X - // Next Y -} - -static void picViewPort_MouseUp(int Button, int Shift, float X, float Y) -{ - FocusTim.Enabled = True; -} - -static void picViewPort_Paint() -{ - // Debug.Print "picViewPort_Paint()" + DDSpriteBuffer_BltImg(StretchWidth * X, StretchWidth * Y, graphic, 0); } -#endif - static void picViewPort_Resize() { -#if 0 - long bdX, bdY, PanelVisibility; - long X, Y, dx, dY; - SettingsObject s; - boolean B; - - bdX = picFrame.Width - picFrame.ScaleWidth; - bdY = picFrame.Height - picFrame.ScaleHeight; - dx = Min(picViewPort.ScaleWidth - bdX, (DisplayWidth - 1) * Stretch * BaseWidth); - dx = Max(dx, 0); - dY = Min(picViewPort.ScaleHeight - bdX, (DisplayHeight - 1) * Stretch * BaseWidth); - dY = Max(dY, 0); - B = s.Read("LimitToOriginalFieldSize", False); - PanelVisibility = 24 * (Panel.Height - PanelSeq - (float)1) / Panel.Height; - if (B) - { - dx = Min(320 * Stretch, dx); - dY = Min((200 - PanelVisibility) * Stretch, dY); - } - - X = Max((picViewPort.ScaleWidth - dx) / 2, 0); - 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& -// SizeTim.Interval = 0 -// wdX = Max(0, picViewPort.ScaleWidth - picPane.Width) * Screen.TwipsPerPixelX -// wdY = Max(0, picViewPort.ScaleHeight - picPane.Height) * Screen.TwipsPerPixelY -// If (0 < wdX) Or (0 < wdY) Then -// Move Left, Top, Width - wdX, Height - wdY -// End If -// End Sub - -static void LoadKeyIndicators() -{ - int i; - - picKeys.BackColor = vbButtonFace; - for (i = 2; i <= 5; i++) - { - Load shpKey(i); - } - - for (i = 1; i <= 5; i++) - { - shpKey(i).FillColor = vbButtonFace; - shpKey(i).Visible = True; - } - - shpKey(1).Move 7, 0; - shpKey(2).Move 0, 7; - shpKey(3).Move 7, 14; - shpKey(4).Move 14, 7; - shpKey(5).Move 7, 7; -} - -void ShowKey(int KeyVar) -{ - boolean State[5 + 1]; - int i; - boolean Tmp; - long Col; - static boolean LastState[5 + 1]; - - // For i = 1 To 5 - // State(i) = False - // Next i - switch (KeyVar) - { - case 0: - // do nothing - break; - - case Is < 5: - State[KeyVar] = True; - break; - - default: - State[5] = True; - if (KeyVar < 9) - State[KeyVar - 4] = True; - break; - } - - for (i = 1; i <= 5; i++) - { - Tmp = State[i]; - if (Tmp ^ LastState[i]) - { - Col = (i == 5 ? vbRed : vbGreen); - shpKey(i).FillColor = (Tmp ? Col : vbButtonFace); - shpKey(i).Refresh; - LastState[i] = Tmp; - } - } -} - -static void GetSettings() -{ - SettingsObject s; - char *APath; - long X, Y; - int i; - boolean Flag; - - { - // last file info - APath = WithSlash(App.Path); - CurPath = s.Read("LastPath", APath); - OrigPath = CurPath; - // window width and height - X = s.Read("Width", Width); - Y = s.Read("Height", Height); - if (X < 0 Then X == 0: If Y < 0) - Y = 0; - - if (Screen.Width < X) - X = Screen.Width; - - if (Screen.Height < Y) - Y = Screen.Height; - - Width = X; - Height = Y; - // window position and state - X = s.Read("Left", left); - Y = s.Read("Top", top); - if (X < 0 Then X == 0: If Y < 0) - Y = 0; - - if (Screen.Width < (X + Width)) - X = Screen.Width - Width; - - if (Screen.Height < (Y + Height)) - Y = Screen.Height - Height; - - left = X; - top = Y; - WindowState = s.Read("WinState", vbNormal); - // flags/options - Flag = s.Read("ShowToolTips", True); - if (Flag) - menToolTips_Click(); - - menBorder.Checked = ! CBool(s.Read("ShowBorder", False)); - Flag = CBool(s.Read("AutoScroll", True)); - if (! Flag) - { - AutoScrollFlag = False; - menAutoScroll.Checked = False; - } - - Flag = CBool(s.Read("SoundFX", True)); - FXOnFlag = (Flag ? -1 : 0); - menSoundFX.Checked = Flag; - SignatureDelay = CLng(s.Read("SignatureDelay", 3000)); - AllowRedDiskCheat = CInt(s.Read("AllowRedDiskCheat", 1)); - AllowEatRightRedDiskBug = CInt(s.Read("AllowEatRightRedDiskBug", 1)); - MySignature = s.Read("MySignature", ""); - // speed - X = s.Read("FrameDelayPlay", 1000000 / 35); - i = GetSpeedIndex(X); - menPlaySpeed_Click(i); - X = s.Read("FrameDelayDemo", 1000000 / 35); - i = GetSpeedIndex(X); - menDemoSpeed_Click(i); - // Zoom - i = s.Read("Stretch", 4); - if (i < menStretch.LBound || menStretch.UBound < i) - i = 4; - - menStretch_Click (i); - } -} - -static void SaveSettings() -{ - SettingsObject s; - int i; - - { - s.Save "LastPath", (ModifiedFlag ? OrigPath : CurPath); - if (WindowState != vbMinimized) - { - s.Save "Width", Width; - s.Save "Height", Height; - s.Save "Left", left; - s.Save "Top", top; - s.Save "WinState", WindowState; - } - - s.Save "ShowToolTips", menToolTips.Checked; - s.Save "ShowBorder", menBorder.Checked; - s.Save "AutoScroll", menAutoScroll.Checked; - s.Save "SoundFX", menSoundFX.Checked; - s.Save "SignatureDelay", SignatureDelay; - s.Save "AllowRedDiskCheat", AllowRedDiskCheat; - s.Save "AllowEatRightRedDiskBug", AllowEatRightRedDiskBug; - s.Save "MySignature", MySignature; - // speeds - s.Save "FrameDelayPlay", DeltaTPlay; - s.Save "FrameDelayDemo", DeltaTDemo; - // zoom - for (i = menStretch.LBound; i <= menStretch.UBound; i++) - { - if (menStretch(i).Checked) - break; - } - - s.Save "Stretch", i; - // s.Save "", - } -} - -void ReLoadStretchSprites() -{ - long Tmp; - BitMapObject NBMP, SBMP; - char *tmpMpxBmp; - - // If Stretch = 1 Then - MpxBmp = App.Path & "/Mpx.bmp"; - // Else - // MpxBmp = App.Path & "\Mpx" & Stretch & ".bmp" - // tmpMpxBmp = App.Path & "\Mpx.bmp" - // If FileExists(MpxBmp) And FileExists(tmpMpxBmp) Then - // If FileDateTime(MpxBmp) < FileDateTime(tmpMpxBmp) Then - // MayKill MpxBmp - // End If - // End If - // If Not FileExists(MpxBmp) Then - // MousePointer = 11 - // // Set NBMP = New BitMapObject // (handle this later, if needed) - // tmpMpxBmp = App.Path & "\Mpx.bmp" - // If Not FileExists(tmpMpxBmp) Then - // ReportError "ReLoadStretchSprites", "File not found: " & tmpMpxBmp - // MESSAGE_BOX("an error occured"); // MsgBox "File not found: " & tmpMpxBmp, vbCritical, "MegaPlex - Error" - // End - // End If - // NBMP.CreateFromFile tmpMpxBmp - // Set SBMP = NBMP.GetStretchCopy(Stretch) - // SBMP.SaveToFile MpxBmp - // Set NBMP = Nothing - // Set SBMP = Nothing - // MousePointer = 0 - // End If - // End If - // StretchedSprites = New DDSpriteBuffer; // (handle this later, if needed) - if (! StretchedSprites.CreateFromFile(MpxBmp, 16, 16)) - SET_TO_NOTHING(&StretchedSprites, sizeof(StretchedSprites)); -} - -void SaveSnapshot(currency Number) -{ - char *Path; - - Path = CAT(WithSlash(App.Path), "Capture"); - if (! IsDir(Path)) - MkDir(Path); - - Path = Path & "\" & Format(Number, "00000000") & ".bmp"; - SavePicture CaptureWindow(picPane.hWnd, True, 0, 0, picPane.ScaleWidth, picPane.ScaleHeight), Path; } - -#endif diff --git a/src/game_sp/MainForm.h b/src/game_sp/MainForm.h index 8265e821..24cbd46e 100644 --- a/src/game_sp/MainForm.h +++ b/src/game_sp/MainForm.h @@ -5,13 +5,9 @@ #ifndef MAINFORM_H #define MAINFORM_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" + extern void DrawFrameIfNeeded(); extern void DisplayLevel(); @@ -20,21 +16,12 @@ extern void DrawFieldAnimated(int X, int Y); extern void DrawFieldNoAnimated(int X, int Y); extern void DrawSprite(int X, int Y, int SpritePos); extern void DrawImage(int X, int Y, int graphic); -#if 0 -extern void InvalidateRect(long XMin, long YMin, long XMax, long YMax); -#endif -extern void Let_PanelVisible(boolean NewVal); -extern void ReLoadStretchSprites(); -extern void SaveSnapshot(currency Number); + extern void SetDisplayRegion(); extern void SetScrollEdges(); -extern void ShowKey(int KeyVar); -extern void menDemoSpeed_Click(int Index); -extern void menEdit_Click(); -extern void menPlaySpeed_Click(int Index); -extern void menStop_Click(); + extern void menPlay_Click(); -extern void menPlayDemo_Click(); + extern void Form_Load(); #endif /* MAINFORM_H */ diff --git a/src/game_sp/MainGameLoop.c b/src/game_sp/MainGameLoop.c index ee955cb6..a82c8732 100644 --- a/src/game_sp/MainGameLoop.c +++ b/src/game_sp/MainGameLoop.c @@ -5,13 +5,9 @@ #include "MainGameLoop.h" -int GameLoopRunning; boolean bPlaying; int LeadOutCounter, EnterRepeatCounter; -int ForcedExitFlag; int ExitToMenuFlag; -int SavedGameFlag; -boolean UserDragFlag; boolean AutoScrollFlag; @@ -22,27 +18,11 @@ boolean AutoScrollFlag; void subMainGameLoop_Init() { - if (DemoFlag != 0) - { - // EP set level success byte: demo, not game - WasDemoFlag = 1; - EP_GameDemoVar0DAA = 0; // demo - } - else // loc_g_1836: - { - // EP set level success byte: game, not demo - WasDemoFlag = 0; - EP_GameDemoVar0DAA = 1; // game - } - // This was a bug in the original Supaplex: sometimes red disks could not // be released. This happened if Murphy was killed DURING a red disk release // and the next try started. RedDiskReleasePhase = 0; // (re-)enable red disk release - UpdatedFlag = 0; - GameLoopRunning = 1; - LevelStatus = 0; } void subMainGameLoop_Main(byte action, boolean warp_mode) @@ -51,15 +31,6 @@ void subMainGameLoop_Main(byte action, boolean warp_mode) // --------------------- START OF GAME-BUSY LOOP ----------------------------- // --------------------------------------------------------------------------- - if (EndFlag) - { - // (should never happen) - - // printf("::: EndFlag == True\n"); - - goto locExitMainGameLoop; - } - subProcessKeyboardInput(action); // check keyboard, act on keys // --------------------------------------------------------------------------- @@ -75,18 +46,9 @@ void subMainGameLoop_Main(byte action, boolean warp_mode) subCalculateScreenScrollPos(); // calculate screen start addrs - if ((! UserDragFlag) && AutoScrollFlag) + if (AutoScrollFlag) ScrollTowards(ScreenScrollXPos, ScreenScrollYPos); - if (ForcedExitFlag != 0) // Forced Exit?' yes--exit! - { - // (should never happen) - - // printf("::: ForcedExitFlag == True\n"); - - goto locExitMainGameLoop; - } - TimerVar = TimerVar + 1; #if 1 @@ -118,7 +80,9 @@ void subMainGameLoop_Main(byte action, boolean warp_mode) // lead-out done: exit now // ---------------------- END OF GAME-BUSY LOOP (including lead-out) --------- +#if 0 locExitMainGameLoop: +#endif #if 1 printf("::: locExitMainGameLoop reached [%d]\n", LeadOutCounter); @@ -159,8 +123,8 @@ void subCalculateScreenScrollPos() } { - ax = MainForm.picPane.Width / 2; - Ay = MainForm.picPane.Height / 2; + ax = SXSIZE / 2; + Ay = SYSIZE / 2; } ScreenScrollXPos = Stretch * (MurphyScreenXPos + TILEX / 2) - ax; diff --git a/src/game_sp/MainGameLoop.h b/src/game_sp/MainGameLoop.h index a0d7e5d1..ee7c4de4 100644 --- a/src/game_sp/MainGameLoop.h +++ b/src/game_sp/MainGameLoop.h @@ -5,22 +5,13 @@ #ifndef MAINGAMELOOP_H #define MAINGAMELOOP_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" extern boolean AutoScrollFlag; -extern boolean UserDragFlag; extern boolean bPlaying; extern int ExitToMenuFlag; -extern int ForcedExitFlag; -extern int GameLoopRunning; extern int LeadOutCounter, EnterRepeatCounter; -extern int SavedGameFlag; extern void subMainGameLoop_Init(); extern void subMainGameLoop_Main(byte, boolean); diff --git a/src/game_sp/Makefile b/src/game_sp/Makefile index 75e97e9f..9837aef7 100644 --- a/src/game_sp/Makefile +++ b/src/game_sp/Makefile @@ -16,13 +16,11 @@ SRCS = init.c \ file.c \ main.c \ vb_lib.c \ - vb_vars.c \ \ ASM.c \ BugsTerminals.c \ DDScrollBuffer.c \ DDSpriteBuffer.c \ - Demo.c \ Display.c \ DoGameStuff.c \ Electrons.c \ @@ -36,27 +34,19 @@ SRCS = init.c \ MainGameLoop.c \ Murphy.c \ OrangeDisk.c \ - PathTools.c \ - SettingsObject.c \ SnikSnaks.c \ Sound.c \ - TickCountObject.c \ - TopMost.c \ - Zonk.c \ - modAnimations.c \ - modMPX.c + Zonk.c OBJS = init.o \ file.o \ main.o \ vb_lib.o \ - vb_vars.o \ \ ASM.o \ BugsTerminals.o \ DDScrollBuffer.o \ DDSpriteBuffer.o \ - Demo.o \ Display.o \ DoGameStuff.o \ Electrons.o \ @@ -70,15 +60,9 @@ OBJS = init.o \ MainGameLoop.o \ Murphy.o \ OrangeDisk.o \ - PathTools.o \ - SettingsObject.o \ SnikSnaks.o \ Sound.o \ - TickCountObject.o \ - TopMost.o \ - Zonk.o \ - modAnimations.o \ - modMPX.o + Zonk.o GAME_SP = game_sp.a diff --git a/src/game_sp/Murphy.c b/src/game_sp/Murphy.c index 0bc114ff..2d939a31 100644 --- a/src/game_sp/Murphy.c +++ b/src/game_sp/Murphy.c @@ -32,7 +32,9 @@ void subAnimateMurphy(int *si) int tDeltaX, tDeltaY, tPos, Tmp; // Variables that hold information about the animation sequence +#if 0 static int *dx = 0; // an array of image positions in moving.mpx, finalized with -1 +#endif static int dx1 = 0; // same as "*dx" above, but as image/animation token static int dx2 = 0; // an additional image position of a second sprite, for instance: yellow disk if pushed static int MurphyDX = 0, MurphyDY = 0; // murphys move steps @@ -667,8 +669,11 @@ loc_g_62E2: MovHighByte(&PlayField16[*si], 0x2A); MovingPictureSequencePhase = 0x40; // init picture move sequence +#if 0 dx = aniFramesRedDisk; +#else dx1 = aniRedDisk; +#endif MovLowByte(&RedDiskReleasePhase, 1); RedDiskReleaseMurphyPos = *si; // remember Murphy's location goto loc_Split; @@ -678,8 +683,11 @@ loc_g_62E2: // ========================================================================== loc_g_6312: +#if 0 dx = (MurphyVarFaceLeft == 0 ? aniFramesMurphyEatUpRight : aniFramesMurphyEatUpLeft); +#else dx1 = (MurphyVarFaceLeft == 0 ? aniMurphyMoveUpRight : aniMurphyMoveUpLeft); +#endif PlayField16[*si - FieldWidth] = 0x103; PlayField16[*si] = 0x300; *si = *si - FieldWidth; @@ -690,8 +698,11 @@ loc_g_6312: // ========================================================================== loc_g_6341: +#if 0 dx = aniFramesMurphyEatLeft; +#else dx1 = aniMurphyMoveLeft; +#endif PlayField16[*si - 1] = 0x203; PlayField16[*si] = 0x300; *si = *si - 1; @@ -702,8 +713,11 @@ loc_g_6341: // ========================================================================== loc_g_6364: +#if 0 dx = (MurphyVarFaceLeft == 0 ? aniFramesMurphyEatUpRight : aniFramesMurphyEatUpLeft); +#else dx1 = (MurphyVarFaceLeft == 0 ? aniMurphyMoveUpRight : aniMurphyMoveUpLeft); +#endif PlayField16[*si + FieldWidth] = 0x303; PlayField16[*si] = 0x300; *si = *si + FieldWidth; @@ -714,8 +728,11 @@ loc_g_6364: // ========================================================================== loc_g_6399: +#if 0 dx = aniFramesMurphyEatRight; +#else dx1 = aniMurphyMoveRight; +#endif PlayField16[*si + 1] = 0x403; PlayField16[*si] = 0x300; *si = *si + 1; @@ -745,8 +762,11 @@ loc_g_63D3: subSoundFXBase(); #endif +#if 0 dx = (MurphyVarFaceLeft == 0 ? aniFramesMurphyEatUpRight : aniFramesMurphyEatUpLeft); +#else dx1 = (MurphyVarFaceLeft == 0 ? aniMurphyDigUpRight : aniMurphyDigUpLeft); +#endif PlayField16[*si - FieldWidth] = 0x503; PlayField16[*si] = 0x300; *si = *si - FieldWidth; @@ -776,8 +796,11 @@ loc_g_641C: subSoundFXBase(); #endif +#if 0 dx = aniFramesMurphyEatLeft; +#else dx1 = aniMurphyDigLeft; +#endif PlayField16[*si - 1] = 0x203; PlayField16[*si] = 0x300; *si = *si - 1; @@ -807,8 +830,11 @@ loc_g_6459: subSoundFXBase(); #endif +#if 0 dx = (MurphyVarFaceLeft == 0 ? aniFramesMurphyEatUpRight : aniFramesMurphyEatUpLeft); +#else dx1 = (MurphyVarFaceLeft == 0 ? aniMurphyDigUpRight : aniMurphyDigUpLeft); +#endif PlayField16[*si + FieldWidth] = 0x703; PlayField16[*si] = 0x300; *si = *si + FieldWidth; @@ -838,8 +864,11 @@ loc_g_64A2: subSoundFXBase(); #endif +#if 0 dx = aniFramesMurphyEatRight; +#else dx1 = aniMurphyDigRight; +#endif PlayField16[*si + 1] = 0x803; PlayField16[*si] = 0x300; *si = *si + 1; @@ -870,8 +899,11 @@ loc_g_64DF: subSoundFXBase(); #endif +#if 0 dx = aniFramesTouchBase; +#else dx1 = aniTouchBase; +#endif dxPos = *si - FieldWidth; MovHighByte(&PlayField16[*si], 0x10); goto loc_StopNoSplit; @@ -901,8 +933,11 @@ loc_g_651D: subSoundFXBase(); #endif +#if 0 dx = aniFramesTouchBase; +#else dx1 = aniTouchBase; +#endif dxPos = *si - 1; MovHighByte(&PlayField16[*si], 0x11); goto loc_StopNoSplit; @@ -932,8 +967,11 @@ loc_g_655B: subSoundFXBase(); #endif +#if 0 dx = aniFramesTouchBase; +#else dx1 = aniTouchBase; +#endif dxPos = *si + FieldWidth; MovHighByte(&PlayField16[*si], 0x12); goto loc_StopNoSplit; @@ -963,8 +1001,11 @@ loc_g_6599: subSoundFXBase(); #endif +#if 0 dx = aniFramesTouchBase; +#else dx1 = aniTouchBase; +#endif dxPos = *si + 1; MovHighByte(&PlayField16[*si], 0x13); goto loc_StopNoSplit; @@ -980,8 +1021,11 @@ loc_g_65C6: subSoundFXInfotron(); #endif +#if 0 dx = (MurphyVarFaceLeft == 0 ? aniFramesMurphyEatUpRight : aniFramesMurphyEatUpLeft); +#else dx1 = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft); +#endif PlayField16[*si - FieldWidth] = 0x903; PlayField16[*si] = 0x300; *si = *si - FieldWidth; @@ -998,8 +1042,11 @@ loc_g_65FE: subSoundFXInfotron(); #endif +#if 0 dx = aniFramesEatInfotronLeft; +#else dx1 = aniEatInfotronLeft; +#endif #if 0 dx2 = fiInfotron; dx2Step = -1; @@ -1021,8 +1068,11 @@ loc_g_662A: subSoundFXInfotron(); #endif +#if 0 dx = (MurphyVarFaceLeft == 0 ? aniFramesMurphyEatUpRight : aniFramesMurphyEatUpLeft); +#else dx1 = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft); +#endif PlayField16[*si + FieldWidth] = 0xB03; PlayField16[*si] = 0x300; *si = *si + FieldWidth; @@ -1039,8 +1089,11 @@ loc_g_6662: subSoundFXInfotron(); #endif +#if 0 dx = aniFramesEatInfotronRight; +#else dx1 = aniEatInfotronRight; +#endif #if 0 dx2 = fiInfotron; dx2Step = 1; @@ -1063,8 +1116,11 @@ loc_g_668E: subSoundFXInfotron(); #endif +#if 0 dx = aniFramesTouchInfotron; +#else dx1 = aniTouchInfotron; +#endif MovHighByte(&PlayField16[*si], 0x14); MovHighByte(&PlayField16[*si - FieldWidth], 0xFF); goto loc_StopNoSplit; @@ -1081,8 +1137,11 @@ loc_g_66C0: subSoundFXInfotron(); #endif +#if 0 dx = aniFramesTouchInfotron; +#else dx1 = aniTouchInfotron; +#endif MovHighByte(&PlayField16[*si], 0x15); MovHighByte(&PlayField16[*si - 1], 0xFF); goto loc_StopNoSplit; @@ -1099,8 +1158,11 @@ loc_g_66F2: subSoundFXInfotron(); #endif +#if 0 dx = aniFramesTouchInfotron; +#else dx1 = aniTouchInfotron; +#endif MovHighByte(&PlayField16[*si], 0x16); MovHighByte(&PlayField16[*si + FieldWidth], 0xFF); goto loc_StopNoSplit; @@ -1117,8 +1179,11 @@ loc_g_6724: subSoundFXInfotron(); #endif +#if 0 dx = aniFramesTouchInfotron; +#else dx1 = aniTouchInfotron; +#endif MovHighByte(&PlayField16[*si], 0x17); MovHighByte(&PlayField16[*si + 1], 0xFF); goto loc_StopNoSplit; @@ -1151,24 +1216,12 @@ loc_g_6756: subSoundFXExit(); #endif - data_h_DemoDone = 1; // EP set level success bytes - LevelStatus = 1; // set Level Status DONE - EP_GameDemoVar0DAA = 0; // force demo for lead-out - if (SavedGameFlag == 0) // saved game running? - { - if (UpdateTimeFlag != 0) // update time? - { - UpdatedFlag = 1; // prevent double update - } - } - -#if 0 - subUpdateHallOfFame(); // update time + Hall-Of-Fame -#endif - LeadOutCounter = 0x40; // quit: start lead-out +#if 0 dx = aniFramesMurphyExit; +#else dx1 = aniMurphyExit; +#endif MovHighByte(&PlayField16[*si], 0xD); goto loc_StopNoSplit; @@ -1183,8 +1236,11 @@ loc_g_679B: MovHighByte(&PlayField16[*si - 2], 1); subCopyImageToScreen(*si, aniPushLeft); // draw pushing murphy +#if 0 dx = aniFramesZonkRollLeft; +#else dx1 = aniZonkRollLeft; +#endif dxPos = *si - 1; dx2 = aniPushLeft; dx2Step = 1; @@ -1206,8 +1262,11 @@ loc_g_67D4: MovHighByte(&PlayField16[*si + 2], 1); subCopyImageToScreen(*si, aniPushRight); // draw pushing murphy +#if 0 dx = aniFramesZonkRollRight; +#else dx1 = aniZonkRollRight; +#endif dxPos = *si + 1; dx2 = aniPushRight; dx2Step = -1; @@ -1339,8 +1398,11 @@ loc_g_6916: if (PlayField16[*si - 2 * FieldWidth] != 0) return; +#if 0 dx = aniFramesSplitUpDown; +#else dx1 = aniSplitUpDown; +#endif dx2Step = -FieldWidth; PlayField16[*si] = 0x1803; PlayField16[*si - 2 * FieldWidth] = 0x300; @@ -1354,8 +1416,11 @@ loc_g_693A: if (PlayField16[*si - 2] != 0) return; +#if 0 dx = aniFramesMurphyEatLeft; +#else dx1 = aniMurphyMoveLeft; +#endif dx2Step = -1; PlayField16[*si] = 0x1903; PlayField16[*si - 2] = 0x300; @@ -1369,8 +1434,11 @@ loc_g_695E: if (PlayField16[*si + 2 * FieldWidth] != 0) return; +#if 0 dx = aniFramesSplitUpDown; +#else dx1 = aniSplitUpDown; +#endif dx2Step = FieldWidth; PlayField16[*si] = 0x1A03; PlayField16[*si + 2 * FieldWidth] = 0x300; @@ -1384,8 +1452,11 @@ loc_g_6982: if (PlayField16[*si + 2] != 0) return; +#if 0 dx = aniFramesMurphyEatRight; +#else dx1 = aniMurphyMoveRight; +#endif dx2Step = 1; PlayField16[*si] = 0x1B03; PlayField16[*si + 2] = 0x300; @@ -1400,8 +1471,11 @@ loc_StopSplit: // ========================================================================== loc_g_69A6: +#if 0 dx = (MurphyVarFaceLeft == 0 ? aniFramesMurphyEatUpRight : aniFramesMurphyEatUpLeft); +#else dx1 = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft); +#endif PlayField16[*si] = 0x1C03; PlayField16[*si - FieldWidth] = 0x300; goto loc_StopNoSplit; @@ -1411,8 +1485,11 @@ loc_g_69A6: // ========================================================================== loc_g_69CE: +#if 0 dx = aniFramesMurphyEatLeft; +#else dx1 = aniMurphyEatLeft; +#endif PlayField16[*si] = 0x300; // !!!!!! this time we move murphy at sequence-start! PlayField16[*si - 1] = 0x1D03; *si = *si - 1; @@ -1423,8 +1500,11 @@ loc_g_69CE: // ========================================================================== loc_g_69F7: +#if 0 dx = (MurphyVarFaceLeft == 0 ? aniFramesMurphyEatUpRight : aniFramesMurphyEatUpLeft); +#else dx1 = (MurphyVarFaceLeft == 0 ? aniMurphyEatUpRight : aniMurphyEatUpLeft); +#endif PlayField16[*si] = 0x1E03; PlayField16[*si + FieldWidth] = 0x300; goto loc_StopNoSplit; @@ -1434,9 +1514,12 @@ loc_g_69F7: // ========================================================================== loc_g_6A1F: +#if 0 // dx = aniFramesMurphyEatRightRedDisk 'this sequence is 9 steps long! dx = aniFramesMurphyEatRight; +#else dx1 = aniMurphyEatRight; +#endif // -------------------------------------------------------------------------- // BugFix // Table data_h_145A, pointed to by table data_h_105E, has a severe bug: @@ -1448,13 +1531,8 @@ loc_g_6A1F: // Remember that this is not the real bug-fix, but we must live with // this existing bug and correct for the consequences of it. -#if 1 - if (0 == AllowEatRightRedDiskBug) // Murphy's screen x-position + if (AllowEatRightRedDiskBug == 0) // Murphy's screen x-position MurphyScreenXPos = MurphyScreenXPos - 2 * MurphyZoomFactor; -#else - if (0 == AllowEatRightRedDiskBug) // Murphy's screen x-position - MurphyScreenXPos = MurphyScreenXPos - 2; -#endif SeqPos = -1; // FS: for me this means to blit the first animation frame twice @@ -1470,8 +1548,11 @@ loc_g_6A1F: // ========================================================================== loc_g_6A48: +#if 0 dx = aniFramesTouchRedDisk; +#else dx1 = aniTouchRedDisk; +#endif MovHighByte(&PlayField16[*si], 0x20); MovHighByte(&PlayField16[*si - FieldWidth], 3); goto loc_StopNoSplit; @@ -1481,8 +1562,11 @@ loc_g_6A48: // ========================================================================== loc_g_6A64: +#if 0 dx = aniFramesTouchRedDisk; +#else dx1 = aniTouchRedDisk; +#endif MovHighByte(&PlayField16[*si], 0x21); MovHighByte(&PlayField16[*si - 1], 3); goto loc_StopNoSplit; @@ -1492,8 +1576,11 @@ loc_g_6A64: // ========================================================================== loc_g_6A80: +#if 0 dx = aniFramesTouchRedDisk; +#else dx1 = aniTouchRedDisk; +#endif MovHighByte(&PlayField16[*si], 0x22); MovHighByte(&PlayField16[*si + FieldWidth], 3); goto loc_StopNoSplit; @@ -1503,8 +1590,11 @@ loc_g_6A80: // ========================================================================== loc_g_6A9C: +#if 0 dx = aniFramesTouchRedDisk; +#else dx1 = aniTouchRedDisk; +#endif MovHighByte(&PlayField16[*si], 0x23); MovHighByte(&PlayField16[*si + 1], 3); @@ -1524,8 +1614,11 @@ loc_g_6AB8: #if 0 subCopyImageToScreen(*si, aniPushRight); #endif +#if 0 dx = aniFramesYellowDisk; +#else dx1 = aniYellowDisk; +#endif dxPos = *si - FieldWidth; #if 1 dx2 = (MurphyVarFaceLeft == 0 ? aniPushRight : aniPushLeft); @@ -1549,8 +1642,11 @@ loc_g_6AF1: PlayField16[*si - 2] = 0x1200; subCopyImageToScreen(*si, aniPushLeft); +#if 0 dx = aniFramesYellowDisk; +#else dx1 = aniYellowDisk; +#endif dxPos = *si - 1; dx2 = aniPushLeft; dx2Step = 1; @@ -1569,8 +1665,11 @@ loc_g_6B2A: #if 0 subCopyImageToScreen(*si, aniPushRight); #endif +#if 0 dx = aniFramesYellowDisk; +#else dx1 = aniYellowDisk; +#endif dxPos = *si + FieldWidth; #if 1 dx2 = (MurphyVarFaceLeft == 0 ? aniPushRight : aniPushLeft); @@ -1594,8 +1693,11 @@ loc_g_6B63: PlayField16[*si + 2] = 0x1200; subCopyImageToScreen(*si, aniPushRight); +#if 0 dx = aniFramesYellowDisk; +#else dx1 = aniYellowDisk; +#endif dxPos = *si + 1; dx2 = aniPushRight; dx2Step = -1; @@ -1612,8 +1714,11 @@ loc_g_6B9B: PlayField16[*si - 2] = 0x800; subCopyImageToScreen(*si, aniPushLeft); +#if 0 dx = aniFramesOrangeDisk; +#else dx1 = aniOrangeDisk; +#endif dxPos = *si - 1; dx2 = aniPushLeft; dx2Step = 1; @@ -1633,8 +1738,11 @@ loc_g_6BD3: PlayField16[*si + 2] = 0x100; subCopyImageToScreen(*si, aniPushRight); +#if 0 dx = aniFramesOrangeDisk; +#else dx1 = aniOrangeDisk; +#endif dxPos = *si + 1; dx2 = aniPushRight; dx2Step = -1; @@ -1741,51 +1849,11 @@ loc_g_6C8F: { // ++++++++++++++++++++++++++ // Begin of normal movement -#if 1 MurphyScreenXPos = MurphyScreenXPos + MurphyDX * MurphyZoomFactor; MurphyScreenYPos = MurphyScreenYPos + MurphyDY * MurphyZoomFactor; -#else - MurphyScreenXPos = MurphyScreenXPos + MurphyDX; - MurphyScreenYPos = MurphyScreenYPos + MurphyDY; -#endif - - -#if 0 - printf("::: %04d [%03ld, %02d] ----------> %s [%d] [%d, %d] [%d, %d] [%d]\n", - TimerVar, - DemoOffset - DemoPointer, DemoKeyRepeatCounter, - (DemoKeyCode == keyNone ? "(none)" : - DemoKeyCode == keyLeft ? "left" : - DemoKeyCode == keyRight ? "right" : - DemoKeyCode == keyUp ? "up" : - DemoKeyCode == keyDown ? "down" : - DemoKeyCode == keySpace ? "space" : - DemoKeyCode == keySpaceLeft ? "space + left" : - DemoKeyCode == keySpaceRight ? "space + right" : - DemoKeyCode == keySpaceUp ? "space + up" : - DemoKeyCode == keySpaceDown ? "space + down" : "(unknown)"), - DemoKeyCode, - MurphyScreenXPos, MurphyScreenYPos, - MurphyPosIndex % 60, MurphyPosIndex / 60, - ClearPos); -#endif - -#if 0 - Delay(500); -#endif -#if 1 if (!(ClearPos < 0)) // clear field that murphy is leaving subCopyImageToScreen(ClearPos, aniSpace); -#else - if (! ClearPos < 0) // clear field that murphy is leaving - subCopyFieldToScreen(ClearPos, 0); -#endif - -#if 0 - printf("::: ---------------> %d, %d [%d, %d]\n", - MurphyScreenXPos, MurphyScreenYPos, MurphyDX, MurphyDY); -#endif #if 0 // !!! special two-tile animation currently not used !!! @@ -1811,7 +1879,7 @@ loc_g_6C8F: #endif #if 1 - StretchedSprites.BltImg(X, Y, dx1, Tmp); + DDSpriteBuffer_BltImg(X, Y, dx1, Tmp); GfxGraphic[GetX(*si)][GetY(*si)] = -1; // (Murphy's position) GfxGraphic[GetX(dxPos)][GetY(dxPos)] = -1; // (snapping position) // printf("::: Tmp: %d\n", Tmp); @@ -1837,13 +1905,8 @@ loc_g_6C8F: else // pushing something #endif { -#if 1 // (SeqPos iterates from 0 to 7 while pushing) - StretchedSprites.BltImg(X + tDeltaX, Y + tDeltaY, dx2, SeqPos); - // printf("::: SeqPos: %d\n", SeqPos); -#else - StretchedSprites.BltEx(X + tDeltaX, Y + tDeltaY, dx2); -#endif + DDSpriteBuffer_BltImg(X + tDeltaX, Y + tDeltaY, dx2, SeqPos); } } @@ -1854,33 +1917,20 @@ loc_g_6C8F: { // ++++++++++++++++++++++++++++++++ // Begin of split movement (port) -#if 1 MurphyScreenXPos = MurphyScreenXPos + 2 * MurphyDX * MurphyZoomFactor; MurphyScreenYPos = MurphyScreenYPos + 2 * MurphyDY * MurphyZoomFactor; -#else - MurphyScreenXPos = MurphyScreenXPos + 2 * MurphyDX; - MurphyScreenYPos = MurphyScreenYPos + 2 * MurphyDY; -#endif subCopyImageToScreen(ClearPos, aniSpace); // clear the field that murphy leaves tDeltaX = MurphyDX * LocalStretch * (SeqPos + 1); tDeltaY = MurphyDY * LocalStretch * (SeqPos + 1); X = GetStretchX(dxPos) + tDeltaX; Y = GetStretchY(dxPos) + tDeltaY; -#if 1 - StretchedSprites.BltImg(X, Y, dx1, SeqPos); // plot first murphy -#else - StretchedSprites.BltEx(X, Y, dx[SeqPos]); // plot first murphy -#endif + DDSpriteBuffer_BltImg(X, Y, dx1, SeqPos); // plot first murphy + tPos = dxPos + dx2Step; X = GetStretchX(tPos); Y = GetStretchY(tPos); -#if 1 - StretchedSprites.BltImg(X + tDeltaX, Y + tDeltaY, dx1, SeqPos); // plot second murphy - StretchedSprites.BltImg(X, Y, fiGraphic[LowByte(PlayField16[tPos])], 0); // replot the port on top -#else - StretchedSprites.BltEx(X + tDeltaX, Y + tDeltaY, dx[SeqPos]); // plot second murphy - StretchedSprites.BltEx(X, Y, LowByte(PlayField16[tPos])); // replot the port on top -#endif + DDSpriteBuffer_BltImg(X + tDeltaX, Y + tDeltaY, dx1, SeqPos); // plot second murphy + DDSpriteBuffer_BltImg(X, Y, fiGraphic[LowByte(PlayField16[tPos])], 0); // replot the port on top // End of split movement (port) // ------------------------------ } // loc_g_6D1E:'loc_g_6D28: @@ -2797,7 +2847,7 @@ void subCopyAnimToScreen(int si, int graphic, int sync_frame) // +++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si); Y = GetStretchY(si); - StretchedSprites.BltImg(X, Y, graphic, sync_frame); + DDSpriteBuffer_BltImg(X, Y, graphic, sync_frame); // +++++++++++++++++++++++++++++++++++++++++ } diff --git a/src/game_sp/Murphy.h b/src/game_sp/Murphy.h index 8a2b3f64..ece70c44 100644 --- a/src/game_sp/Murphy.h +++ b/src/game_sp/Murphy.h @@ -5,11 +5,6 @@ #ifndef MURPHY_H #define MURPHY_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" extern void subAdjustZonksInfotronsAboveMurphy(int si); diff --git a/src/game_sp/OrangeDisk.c b/src/game_sp/OrangeDisk.c index 0e741395..dc83e9ea 100644 --- a/src/game_sp/OrangeDisk.c +++ b/src/game_sp/OrangeDisk.c @@ -56,8 +56,8 @@ loc_g_2804: // disk is falling dx = HighByte(PlayField16[si]) & 0x7; X = GetStretchX(si); Y = GetStretchY(si); - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X, Y + TwoPixels * (dx + 1), aniOrangeDisk, dx); + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X, Y + TwoPixels * (dx + 1), aniOrangeDisk, dx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bl = HighByte(PlayField16[si]) + 1; diff --git a/src/game_sp/OrangeDisk.h b/src/game_sp/OrangeDisk.h index cc1e1f26..410aab4d 100644 --- a/src/game_sp/OrangeDisk.h +++ b/src/game_sp/OrangeDisk.h @@ -5,11 +5,6 @@ #ifndef ORANGEDISK_H #define ORANGEDISK_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" diff --git a/src/game_sp/PathTools.c b/src/game_sp/PathTools.c deleted file mode 100644 index e66dfb86..00000000 --- a/src/game_sp/PathTools.c +++ /dev/null @@ -1,304 +0,0 @@ -// ---------------------------------------------------------------------------- -// PathTools.c -// ---------------------------------------------------------------------------- - -#include "PathTools.h" - -// static char *VB_Name = "PathTools_Module"; - -// --- Option Explicit -// --- Option Compare Text - -// ########### Quote & UnQuote ################################################## - -void UnQuote(char *ST) -{ - long L; - - L = strlen(ST); - while (STRING_IS_LIKE(ST, "\"*")) - { - ST = Right(ST, L - 1); - L = L - 1; - } - - while (STRING_IS_LIKE(ST, "*\"")) - { - ST = Left(ST, L - 1); - } -} - -void Quote(char *ST) -{ - if (! STRING_IS_LIKE(ST, "\"*")) - ST = CAT("\"", ST); - - if (! STRING_IS_LIKE(ST, "*\"")) - ST = CAT(ST, "\""); -} - -char *UnQuoted(char *STRG) -{ - char *UnQuoted; - - long L; - char *ST; - - ST = STRG; - L = strlen(ST); - while (STRING_IS_LIKE(ST, "\"*")) - { - ST = Right(ST, L - 1); - L = L - 1; - } - - while (STRING_IS_LIKE(ST, "*\"")) - { - ST = Left(ST, L - 1); - } - - UnQuoted = ST; - - return UnQuoted; -} - -char *Quoted(char *STRG) -{ - char *Quoted; - - char *ST; - - ST = STRG; - if (! STRING_IS_LIKE(ST, "\"*")) - ST = CAT("\"", ST); - - if (! STRING_IS_LIKE(ST, "*\"")) - ST = CAT(ST, "\""); - - Quoted = ST; - - return Quoted; -} - -// ############ Path-/FileName-Extraction and concatanation ###################### - -char *StripDir(char *Path) -{ - char *StripDir; - - char *T; - long i; - - T = StrReverse(Path); - i = InStr(1, T, "/"); - if (i == 0) - StripDir = ""; - else - StripDir = StrReverse(Right(T, strlen(T) - i)); - - return StripDir; -} - -char *StripFileName(char *Path) -{ - char *StripFileName; - - char *T; - long i; - - T = StrReverse(Path); - if (STRING_IS_LIKE(T, "/*")) - T = Right(T, strlen(T) - 1); - - i = InStr(1, T, "/"); - if (i == 0) - i = strlen(T) + 1; - - if (i < 2) - StripFileName = ""; - else - StripFileName = StrReverse(Left(T, i - 1)); - - return StripFileName; -} - -char *StripExtension(char *Path) -{ - char *StripExtension; - - char *T; - long i, iSlash; - - T = StrReverse(Path); - iSlash = InStr(1, T, "/"); - i = InStr(1, T, "."); - if ((i < 2) || (iSlash < i)) - StripExtension = ""; - else - StripExtension = StrReverse(Left(T, i - 1)); - - return StripExtension; -} - -char *NewExtension(char *Path, char *NewExt) -{ - char *NewExtension; - - // NewExtension("C:\MyPath\MyFile.Old","New") returns "C:\MyPath\MyFile.New" - // NewExtension("C:\MyPath.dir\MyFile","New") returns "C:\MyPath\MyFile.New" - char *T; - long i, iSlash, ELen; - - T = StrReverse(Path); - iSlash = InStr(1, T, "/"); - i = InStr(1, T, "."); - if ((i < 1) || (iSlash < i)) - ELen = 0; - else - ELen = i; - - NewExtension = CAT(Left(StrReverse(T), strlen(T) - i), ".", NewExt); - - return NewExtension; -} - -char *StripExtensionlessFileName(char *Path) -{ - char *StripExtensionlessFileName; - - char *T, *T2; - // long i, iSlash; - - T = StripFileName(Path); - T2 = StripExtension(Path); - StripExtensionlessFileName = Left(T, strlen(T) - strlen(T2) - (0 < strlen(T2) ? 1 : 0)); - - return StripExtensionlessFileName; -} - -char *WithSlash(char *Path) -{ - char *WithSlash; - - if (STRING_IS_LIKE(Path, "*/")) - { - WithSlash = Path; - } - else - { - WithSlash = CAT(Path, "/"); - } - - return WithSlash; -} - -char *SlashLess(char *Path) -{ - char *SlashLess; - - SlashLess = Path; - while (STRING_IS_LIKE(SlashLess, "*/")) - { - SlashLess = Left(Path, strlen(Path) - 1); - } - - return SlashLess; -} - -// ############ File-/Diresctory-Operations ###################################### - -boolean FileExists(char *Path) -{ - boolean FileExists; - - if ((STRING_IS_LIKE(Dir(Path), "")) || (STRING_IS_LIKE(Path, ""))) - FileExists = False; - else - FileExists = True; - - return FileExists; -} - -void MayKill(char *Path) -{ - - // --- On Error GoTo MayKillEH - Kill(Path); - // MayKillEH: -} - -boolean IsDir(char *Path) -{ - boolean IsDir; - - - // --- On Error Resume Next - IsDir = (vbDirectory == (GetAttr(Path) & vbDirectory)); - if (Err.Number != 0) - IsDir = False; - - return IsDir; -} - -// ######### binary comparison of files ########################################## - -boolean FilesEqual(char *Path1, char *Path2) -{ - boolean FilesEqual; - - FILE *FNum1, *FNum2; - long nSize, i; - boolean b1Open, b2Open; - byte *bin1, *bin2; - - FilesEqual = False; - // Debug.Assert(FileExists(Path1)); - // Debug.Assert(FileExists(Path2)); - if (! (FileExists(Path1) && FileExists(Path2))) - return FilesEqual; - - nSize = FileLen(Path1); - if (nSize != FileLen(Path2)) - return FilesEqual; - - bin1 = REDIM_1D(sizeof(byte), 0, nSize + 1 - 1); - bin2 = REDIM_1D(sizeof(byte), 0, nSize + 1 - 1); - b1Open = False; - b2Open = False; - - // --- On Error GoTo FilesEqualEH - // FNum1 = FreeFile(); - FNum1 = fopen(Path1, "rb"); - b1Open = True; - FILE_GET(FNum1, -1, &bin1, sizeof(bin1)); - fclose(FNum1); - b1Open = False; - // FNum2 = FreeFile(); - FNum2 = fopen(Path2, "rb"); - b2Open = True; - FILE_GET(FNum2, -1, &bin2, sizeof(bin2)); - fclose(FNum2); - b2Open = False; - // --- On Error GoTo 0 - - for (i = 1; i <= nSize; i++) - { - if (bin1[i] != bin2[i]) // return false - return FilesEqual; - } - - FilesEqual = True; - return FilesEqual; - -#if 0 -FilesEqualEH: - if (b1Open) - fclose(FNum1); - - if (b2Open) - fclose(FNum2); - - return FilesEqual; -#endif - -} diff --git a/src/game_sp/PathTools.h b/src/game_sp/PathTools.h deleted file mode 100644 index ce8fda49..00000000 --- a/src/game_sp/PathTools.h +++ /dev/null @@ -1,31 +0,0 @@ -// ---------------------------------------------------------------------------- -// PathTools.h -// ---------------------------------------------------------------------------- - -#ifndef PATHTOOLS_H -#define PATHTOOLS_H - -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - -#include "global.h" - -extern boolean FileExists(char *Path); -extern boolean FilesEqual(char *Path1, char *Path2); -extern boolean IsDir(char *Path); -extern void MayKill(char *Path); -extern char *NewExtension(char *Path, char *NewExt); -extern void Quote(char *ST); -extern char *Quoted(char *STRG); -extern char *SlashLess(char *Path); -extern char *StripDir(char *Path); -extern char *StripExtension(char *Path); -extern char *StripExtensionlessFileName(char *Path); -extern char *StripFileName(char *Path); -extern void UnQuote(char *ST); -extern char *UnQuoted(char *STRG); -extern char *WithSlash(char *Path); - -#endif /* PATHTOOLS_H */ diff --git a/src/game_sp/SettingsObject.c b/src/game_sp/SettingsObject.c deleted file mode 100644 index a241fe50..00000000 --- a/src/game_sp/SettingsObject.c +++ /dev/null @@ -1,44 +0,0 @@ -// ---------------------------------------------------------------------------- -// SettingsObject.c -// ---------------------------------------------------------------------------- - -#include "SettingsObject.h" - -// --- VERSION 1.0 CLASS -// --- BEGIN -// --- MultiUse = -1 'True // True -// --- Persistable = 0 'NotPersistable // NotPersistable -// --- DataBindingBehavior = 0 'vbNone // vbNone -// --- DataSourceBehavior = 0 'vbNone // vbNone -// --- MTSTransactionMode = 0 'NotAnMTSObject // NotAnMTSObject -// --- END - -// static char *VB_Name = "SettingsObject"; -// static boolean VB_GlobalNameSpace = False; -// static boolean VB_Creatable = True; -// static boolean VB_PredeclaredId = False; -// static boolean VB_Exposed = False; - -// --- Option Explicit -// --- Option Compare Text - -#if 0 - -const char *AppName = "MegaPlex"; -const char *Config = "Config"; - -void SettingsObject_Save(char *ValName, int Val) -{ - SaveSetting(AppName, Config, ValName, Val); -} - -int SettingsObject_Read(char *ValName, int Default) -{ - int Read; - - Read = GetSetting(AppName, Config, ValName, Default); - - return Read; -} - -#endif diff --git a/src/game_sp/SettingsObject.h b/src/game_sp/SettingsObject.h deleted file mode 100644 index a25e4f28..00000000 --- a/src/game_sp/SettingsObject.h +++ /dev/null @@ -1,18 +0,0 @@ -// ---------------------------------------------------------------------------- -// SettingsObject.h -// ---------------------------------------------------------------------------- - -#ifndef SETTINGSOBJECT_H -#define SETTINGSOBJECT_H - -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - -#include "global.h" - -extern int SettingsObject_Read(char *ValName, int Default); -extern void SettingsObject_Save(char *ValName, int Val); - -#endif /* SETTINGSOBJECT_H */ diff --git a/src/game_sp/SnikSnaks.c b/src/game_sp/SnikSnaks.c index 5053b363..e23dc902 100644 --- a/src/game_sp/SnikSnaks.c +++ b/src/game_sp/SnikSnaks.c @@ -4,18 +4,19 @@ #include "SnikSnaks.h" -static int subDrawSnikSnakFromAbove(int si, int bx); -static int subDrawSnikSnakFromBelow(int si, int bx); -static int subDrawSnikSnakFromLeft(int si, int bx); -static int subDrawSnikSnakFromRight(int si, int bx); -static int subDrawSnikSnakTurnLeft(int si, int bx); -static int subDrawSnikSnakTurnRight(int si, int bx); -static int subSnikSnakFromAbove(int si, int bx); -static int subSnikSnakFromBelow(int si, int bx); -static int subSnikSnakFromLeft(int si, int bx); -static int subSnikSnakFromRight(int si, int bx); -static int subSnikSnakTurnLeft(int si, int bx); -static int subSnikSnakTurnRight(int si, int bx); + +static void subDrawSnikSnakFromAbove(int, int); +static void subDrawSnikSnakFromBelow(int, int); +static void subDrawSnikSnakFromLeft(int, int); +static void subDrawSnikSnakFromRight(int, int); +static void subDrawSnikSnakTurnLeft(int, int); +static void subDrawSnikSnakTurnRight(int, int); +static void subSnikSnakFromAbove(int, int); +static void subSnikSnakFromBelow(int, int); +static void subSnikSnakFromLeft(int, int); +static void subSnikSnakFromRight(int, int); +static void subSnikSnakTurnLeft(int, int); +static void subSnikSnakTurnRight(int, int); // static char *VB_Name = "modSnikSnak"; @@ -25,23 +26,22 @@ static int subSnikSnakTurnRight(int si, int bx); // Animate/move Snik-Snaks // ========================================================================== -int subAnimateSnikSnaks(int si) +void subAnimateSnikSnaks(int si) { - int subAnimateSnikSnaks; - int bx, Tmp; if (SnikSnaksElectronsFrozen == 1) - return subAnimateSnikSnaks; + return; #if 1 /* (not sure why this was removed -- this broke several level solutions) */ if (LowByte(PlayField16[si]) != fiSnikSnak) - return subAnimateSnikSnaks; + return; #endif - // If LowByte(PlayField16(si)) <> fiSnikSnak Then Exit Function + // If LowByte(PlayField16(si)) <> fiSnikSnak Then Exit Function // Debug.Assert (LowByte(PlayField16[si]) == fiSnikSnak); + bx = HighByte(PlayField16[si]); Tmp = bx / 8; switch (Tmp) @@ -74,19 +74,16 @@ int subAnimateSnikSnaks(int si) // Debug.Assert(False); break; } +} - return subAnimateSnikSnaks; -} // subAnimateSnikSnaks - -int subDrawAnimatedSnikSnaks(int si) +void subDrawAnimatedSnikSnaks(int si) { - int subDrawAnimatedSnikSnaks; - int bx, Tmp; // If SnikSnaksElectronsFrozen = 1 Then Exit Function + if (LowByte(PlayField16[si]) != fiSnikSnak) - return subDrawAnimatedSnikSnaks; + return; bx = HighByte(PlayField16[si]); Tmp = bx / 8; @@ -116,15 +113,10 @@ int subDrawAnimatedSnikSnaks(int si) subDrawSnikSnakFromLeft(si, bx); // access si from left break; } +} - return subDrawAnimatedSnikSnaks; -} // subAnimateSnikSnaks - -static int subSnikSnakTurnLeft(int si, int bx) +static void subSnikSnakTurnLeft(int si, int bx) { - static int subSnikSnakTurnLeft; - - // int ax, ah, bl, dx, X, Y; int ax, ah, bl; ax = (TimerVar & 3); @@ -133,39 +125,35 @@ static int subSnikSnakTurnLeft(int si, int bx) if (ax == 3) goto loc_g_7622; - return subSnikSnakTurnLeft; + return; } // loc_g_75E0: -#if 1 - subDrawSnikSnakTurnLeft(si, bx); -#else // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - X = GetStretchX(si); - Y = GetStretchY(si); - StretchedSprites.BltEx(X, Y, aniFramesSnikSnak[bx]); + subDrawSnikSnakTurnLeft(si, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ -#endif bx = (bx + 1) & 0x7; MovHighByte(&PlayField16[si], bx); - return subSnikSnakTurnLeft; + + return; locMayExplode760A: ah = HighByte(ax); if (ah == 0x1B) - return subSnikSnakTurnLeft; + return; if (ah == 0x19) - return subSnikSnakTurnLeft; + return; if (ah == 0x18) - return subSnikSnakTurnLeft; + return; if (ah == 0x1A) - return subSnikSnakTurnLeft; + return; ExplodeFieldSP(si); // Explode - return subSnikSnakTurnLeft; + + return; loc_g_7622: bl = HighByte(PlayField16[si]); @@ -181,7 +169,7 @@ loc_g_7622: if (bl == 6) goto loc_g_76A7; - return subSnikSnakTurnLeft; + return; loc_g_763B: // pointing up ax = PlayField16[si - FieldWidth]; @@ -191,13 +179,14 @@ loc_g_763B: // pointing up if (LowByte(ax) == fiMurphy) // above is murphy -> explode goto locMayExplode760A; - return subSnikSnakTurnLeft; + return; loc_g_764E: // above is empty -> go up PlayField16[si] = 0x1BB; si = si - FieldWidth; PlayField16[si] = 0x1011; - return subSnikSnakTurnLeft; + + return; loc_g_765E: // pointing left ax = PlayField16[si - 1]; @@ -207,13 +196,14 @@ loc_g_765E: // pointing left if (LowByte(ax) == fiMurphy) // left is murphy -> explode goto locMayExplode760A; - return subSnikSnakTurnLeft; + return; loc_g_7671: // left is empty -> go there PlayField16[si] = 0x2BB; si = si - 1; PlayField16[si] = 0x1811; - return subSnikSnakTurnLeft; + + return; loc_g_7681: // pointing down ax = PlayField16[si + FieldWidth]; @@ -223,13 +213,14 @@ loc_g_7681: // pointing down if (LowByte(ax) == fiMurphy) // below is murphy -> explode goto locMayExplode760A; - return subSnikSnakTurnLeft; + return; loc_g_7697: // below is empty -> go down PlayField16[si] = 0x3BB; si = si + FieldWidth; PlayField16[si] = 0x2011; - return subSnikSnakTurnLeft; + + return; loc_g_76A7: // pointing Right ax = PlayField16[si + 1]; @@ -239,21 +230,16 @@ loc_g_76A7: // pointing Right if (LowByte(ax) == fiMurphy) // right is murphy -> explode goto locMayExplode760A; - return subSnikSnakTurnLeft; + return; loc_g_76BD: // right is empty -> go there PlayField16[si] = 0x4BB; si = si + 1; PlayField16[si] = 0x2811; +} - return subSnikSnakTurnLeft; -} // subSnikSnakTurnLeft - -static int subSnikSnakTurnRight(int si, int bx) +static void subSnikSnakTurnRight(int si, int bx) { - static int subSnikSnakTurnRight; - - // int ax, ah, bl, dx, X, Y; int ax, ah, bl; ax = (TimerVar & 3); @@ -262,39 +248,35 @@ static int subSnikSnakTurnRight(int si, int bx) if (ax == 3) goto loc_g_771F; - return subSnikSnakTurnRight; + return; } // loc_g_76DB: -#if 1 - subDrawSnikSnakTurnRight(si, bx); -#else // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - X = GetStretchX(si); - Y = GetStretchY(si); - StretchedSprites.BltEx(X, Y, aniFramesSnikSnak[0x10 - bx]); + subDrawSnikSnakTurnRight(si, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ -#endif bx = ((bx + 1) & 0x7) | 8; MovHighByte(&PlayField16[si], bx); - return subSnikSnakTurnRight; + + return; locMayExplode7707: ah = HighByte(ax); if (ah == 0x1B) - return subSnikSnakTurnRight; + return; if (ah == 0x19) - return subSnikSnakTurnRight; + return; if (ah == 0x18) - return subSnikSnakTurnRight; + return; if (ah == 0x1A) - return subSnikSnakTurnRight; + return; ExplodeFieldSP(si); // Explode - return subSnikSnakTurnRight; + + return; loc_g_771F: bl = HighByte(PlayField16[si]); @@ -310,7 +292,7 @@ loc_g_771F: if (bl == 0xE) goto loc_g_775B; - return subSnikSnakTurnRight; + return; loc_g_7738: // pointing up ax = PlayField16[si - FieldWidth]; @@ -320,13 +302,14 @@ loc_g_7738: // pointing up if (LowByte(ax) == fiMurphy) // above is murphy -> explode goto locMayExplode7707; - return subSnikSnakTurnRight; + return; loc_g_774B: // above is empty -> go up PlayField16[si] = 0x1BB; si = si - FieldWidth; PlayField16[si] = 0x1011; - return subSnikSnakTurnRight; + + return; loc_g_775B: // pointing left ax = PlayField16[si - 1]; @@ -336,13 +319,14 @@ loc_g_775B: // pointing left if (LowByte(ax) == fiMurphy) // left is murphy -> explode goto locMayExplode7707; - return subSnikSnakTurnRight; + return; loc_g_776E: // left is empty -> go there PlayField16[si] = 0x2BB; si = si - 1; PlayField16[si] = 0x1811; - return subSnikSnakTurnRight; + + return; loc_g_777E: // pointing down ax = PlayField16[si + FieldWidth]; @@ -352,13 +336,14 @@ loc_g_777E: // pointing down if (LowByte(ax) == fiMurphy) // below is murphy -> explode goto locMayExplode7707; - return subSnikSnakTurnRight; + return; loc_g_7794: // below is empty -> go down PlayField16[si] = 0x3BB; si = si + FieldWidth; PlayField16[si] = 0x2011; - return subSnikSnakTurnRight; + + return; loc_g_77A4: // pointing Right ax = PlayField16[si + 1]; @@ -368,35 +353,22 @@ loc_g_77A4: // pointing Right if (LowByte(ax) == fiMurphy) // right is murphy -> explode goto locMayExplode7707; - return subSnikSnakTurnRight; + return; loc_g_77BA: // right is empty -> go there PlayField16[si] = 0x4BB; si = si + 1; PlayField16[si] = 0x2811; +} - return subSnikSnakTurnRight; -} // subSnikSnakTurnRight - -static int subSnikSnakFromBelow(int si, int bx) +static void subSnikSnakFromBelow(int si, int bx) { - static int subSnikSnakFromBelow; - - // int ax, ah, bl, dx, X, Y; int ax, bl; -#if 1 - subDrawSnikSnakFromBelow(si, bx); - bx = bx - 0xF; // get and increment sequence# -#else - bx = bx - 0xF; // get and increment sequence# // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - X = GetStretchX(si); - Y = GetStretchY(si + FieldWidth); - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X, Y - bx * TwoPixels, aniSnikSnakUp + bx); + subDrawSnikSnakFromBelow(si, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ -#endif + bx = bx - 0xF; // get and increment sequence# bl = LowByte(bx); if (bl == 7 && LowByte(PlayField16[si + FieldWidth]) != fiExplosion) @@ -408,7 +380,8 @@ static int subSnikSnakFromBelow(int si, int bx) { bl = bl + 0x10; MovHighByte(&PlayField16[si], bl); - return subSnikSnakFromBelow; + + return; } // loc_g_7813 PlayField16[si] = 0x11; // sequence#=8 -> arrived at the new field @@ -416,7 +389,8 @@ static int subSnikSnakFromBelow(int si, int bx) if (ax == 0 || LowByte(ax) == fiMurphy) // check for empty or murphy { MovHighByte(&PlayField16[si], 1); // start to turn left - return subSnikSnakFromBelow; + + return; } // loc_g_7826: and 'loc_g_7833: ax = PlayField16[si - FieldWidth]; // cannot turn left -> check above @@ -425,47 +399,37 @@ static int subSnikSnakFromBelow(int si, int bx) PlayField16[si] = 0x1BB; // mark as "sniksnak leaving" si = si - FieldWidth; // go up! PlayField16[si] = 0x1011; - return subSnikSnakFromBelow; + + return; } // loc_g_784A: if (LowByte(ax) == fiMurphy) // check for murphy above { ExplodeFieldSP(si); // Explode - return subSnikSnakFromBelow; + + return; } // loc_g_7855: ax = PlayField16[si + 1]; // check right field if (ax == 0 || LowByte(ax) == fiMurphy) // check for empty or murphy { MovHighByte(&PlayField16[si], 9); // start to turn right - return subSnikSnakFromBelow; + + return; } // loc_g_7862: and 'loc_g_786F: // else: no way to go, start turning around MovHighByte(&PlayField16[si], 1); +} - return subSnikSnakFromBelow; -} // subSnikSnakFromBelow - -static int subSnikSnakFromRight(int si, int bx) +static void subSnikSnakFromRight(int si, int bx) { - static int subSnikSnakFromRight; - - // int ax, ah, bl, dx, X, Y; int ax, bl; -#if 1 - subDrawSnikSnakFromRight(si, bx); - bx = bx - 0x17; // get and increment sequence# -#else - bx = bx - 0x17; // get and increment sequence# // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - X = GetStretchX(si + 1); - Y = GetStretchY(si); - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X - bx * TwoPixels, Y, aniSnikSnakLeft + bx); + subDrawSnikSnakFromRight(si, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ -#endif + bx = bx - 0x17; // get and increment sequence# bl = LowByte(bx); if (bl == 7 && LowByte(PlayField16[si + 1]) != fiExplosion) @@ -477,7 +441,8 @@ static int subSnikSnakFromRight(int si, int bx) { bl = bl + 0x18; MovHighByte(&PlayField16[si], bl); - return subSnikSnakFromRight; + + return; } // loc_g_78B9: PlayField16[si] = 0x11; // sequence#=8 -> arrived at the new field @@ -485,7 +450,8 @@ static int subSnikSnakFromRight(int si, int bx) if (ax == 0 || LowByte(ax) == fiMurphy) // empty or murphy? { MovHighByte(&PlayField16[si], 3); // yes -> turn left down - return subSnikSnakFromRight; + + return; } // loc_g_78CC: and 'loc_g_78D9: ax = PlayField16[si - 1]; // check left, etc ... see the comments on subSnikSnakFromBelow() @@ -494,46 +460,36 @@ static int subSnikSnakFromRight(int si, int bx) PlayField16[si] = 0x2BB; si = si - 1; // 1 field left PlayField16[si] = 0x1811; - return subSnikSnakFromRight; + + return; } // loc_g_78F0: if (LowByte(ax) == fiMurphy) { ExplodeFieldSP(si); // Explode - return subSnikSnakFromRight; + + return; } // loc_g_78FB: ax = PlayField16[si - FieldWidth]; // check above if (ax == 0 || LowByte(ax) == fiMurphy) { MovHighByte(&PlayField16[si], 0xF); - return subSnikSnakFromRight; + + return; } // loc_g_7908:loc_g_7915: MovHighByte(&PlayField16[si], 3); +} - return subSnikSnakFromRight; -} // subSnikSnakFromRight - -static int subSnikSnakFromAbove(int si, int bx) +static void subSnikSnakFromAbove(int si, int bx) { - static int subSnikSnakFromAbove; - - // int ax, ah, bl, dx, X, Y; int ax, bl; -#if 1 - subDrawSnikSnakFromAbove(si, bx); - bx = bx - 0x1F; // get and increment sequence# -#else - bx = bx - 0x1F; // get and increment sequence# // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - X = GetStretchX(si); - Y = GetStretchY(si - FieldWidth); - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X, Y + bx * TwoPixels, aniSnikSnakDown + bx); + subDrawSnikSnakFromAbove(si, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ -#endif + bx = bx - 0x1F; // get and increment sequence# bl = LowByte(bx); if (bl == 7 && LowByte(PlayField16[si - FieldWidth]) != fiExplosion) @@ -545,7 +501,8 @@ static int subSnikSnakFromAbove(int si, int bx) { bl = bl + 0x20; MovHighByte(&PlayField16[si], bl); - return subSnikSnakFromAbove; + + return; } // loc_g_7813 PlayField16[si] = 0x11; // sequence#=8 -> arrived at the new field @@ -553,7 +510,8 @@ static int subSnikSnakFromAbove(int si, int bx) if (ax == 0 || LowByte(ax) == fiMurphy) { MovHighByte(&PlayField16[si], 5); - return subSnikSnakFromAbove; + + return; } // loc_g_7986: ax = PlayField16[si + FieldWidth]; // check below @@ -562,46 +520,36 @@ static int subSnikSnakFromAbove(int si, int bx) PlayField16[si] = 0x3BB; si = si + FieldWidth; // 1 field down PlayField16[si] = 0x2011; - return subSnikSnakFromAbove; + + return; } // loc_g_799D: if (LowByte(ax) == fiMurphy) { ExplodeFieldSP(si); // Explode - return subSnikSnakFromAbove; + + return; } // loc_g_79A8: ax = PlayField16[si - 1]; // check left if (ax == 0 || LowByte(ax) == fiMurphy) { MovHighByte(&PlayField16[si], 0xD); - return subSnikSnakFromAbove; + + return; } // loc_g_79C2: MovHighByte(&PlayField16[si], 5); +} - return subSnikSnakFromAbove; -} // subSnikSnakFromAbove - -static int subSnikSnakFromLeft(int si, int bx) +static void subSnikSnakFromLeft(int si, int bx) { - static int subSnikSnakFromLeft; - - // int ax, ah, bl, dx, X, Y; int ax, bl; -#if 1 - subDrawSnikSnakFromLeft(si, bx); - bx = bx - 0x27; // get and increment sequence# -#else - bx = bx - 0x27; // get and increment sequence# // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - X = GetStretchX(si - 1); - Y = GetStretchY(si); - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X + bx * TwoPixels, Y, aniSnikSnakRight + bx); + subDrawSnikSnakFromLeft(si, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ -#endif + bx = bx - 0x27; // get and increment sequence# bl = LowByte(bx); if (bl == 7 && LowByte(PlayField16[si - 1]) != fiExplosion) @@ -613,7 +561,8 @@ static int subSnikSnakFromLeft(int si, int bx) { bl = bl + 0x28; MovHighByte(&PlayField16[si], bl); - return subSnikSnakFromLeft; + + return; } // loc_g_78B9: PlayField16[si] = 0x11; // sequence#=8 -> arrived at the new field @@ -621,7 +570,8 @@ static int subSnikSnakFromLeft(int si, int bx) if (ax == 0 || LowByte(ax) == fiMurphy) { MovHighByte(&PlayField16[si], 7); - return subSnikSnakFromLeft; + + return; } // loc_g_7A2D: ax = PlayField16[si + 1]; // check right(straight on) @@ -630,155 +580,98 @@ static int subSnikSnakFromLeft(int si, int bx) PlayField16[si] = 0x4BB; si = si + 1; // 1 field right PlayField16[si] = 0x2811; - return subSnikSnakFromLeft; + + return; } // loc_g_7A44: if (LowByte(ax) == fiMurphy) { ExplodeFieldSP(si); // Explode - return subSnikSnakFromLeft; + + return; } // loc_g_7A4F: ax = PlayField16[si + FieldWidth]; // check below if (ax == 0 || LowByte(ax) == fiMurphy) { MovHighByte(&PlayField16[si], 0xB); - return subSnikSnakFromLeft; + + return; } // loc_g_7A69: MovHighByte(&PlayField16[si], 7); +} - return subSnikSnakFromLeft; -} // subSnikSnakFromLeft - -static int subDrawSnikSnakTurnLeft(int si, int bx) +static void subDrawSnikSnakTurnLeft(int si, int bx) { - static int subDrawSnikSnakTurnLeft; - -#if 1 - // int pos = bx / 2; int pos = ((bx + 7) % 8) / 2; - GfxGraphic[GetX(si)][GetY(si)] = aniSnikSnakTurningLeft[pos]; -#else - int X, Y; - // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - X = GetStretchX(si); - Y = GetStretchY(si); - StretchedSprites.BltEx(X, Y, aniFramesSnikSnak[bx]); + GfxGraphic[GetX(si)][GetY(si)] = aniSnikSnakTurningLeft[pos]; // +++++++++++++++++++++++++++++++++++++++++++++++++++++ -#endif - - return subDrawSnikSnakTurnLeft; } -static int subDrawSnikSnakTurnRight(int si, int bx) +static void subDrawSnikSnakTurnRight(int si, int bx) { - static int subDrawSnikSnakTurnRight; - -#if 1 - // int pos = (bx - 8) / 2; int pos = ((bx - 1) % 8) / 2; - GfxGraphic[GetX(si)][GetY(si)] = aniSnikSnakTurningRight[pos]; -#else - int X, Y; - // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - X = GetStretchX(si); - Y = GetStretchY(si); - StretchedSprites.BltEx(X, Y, aniFramesSnikSnak[0x10 - bx]); + GfxGraphic[GetX(si)][GetY(si)] = aniSnikSnakTurningRight[pos]; // +++++++++++++++++++++++++++++++++++++++++++++++++++++ -#endif - - return subDrawSnikSnakTurnRight; } -static int subDrawSnikSnakFromBelow(int si, int bx) +static void subDrawSnikSnakFromBelow(int si, int bx) { - static int subDrawSnikSnakFromBelow; - int X, Y; bx = bx - 0xF; // get and anti-increment sequence# + // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si); Y = GetStretchY(si + FieldWidth); -#if 1 - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X, Y - bx * TwoPixels, aniSnikSnakUp, bx); -#else - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X, Y - bx * TwoPixels, aniSnikSnakUp + bx); -#endif + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X, Y - bx * TwoPixels, aniSnikSnakUp, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - - return subDrawSnikSnakFromBelow; } -static int subDrawSnikSnakFromRight(int si, int bx) +static void subDrawSnikSnakFromRight(int si, int bx) { - static int subDrawSnikSnakFromRight; - int X, Y; bx = bx - 0x17; // get and increment sequence# + // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si + 1); Y = GetStretchY(si); -#if 1 - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X - bx * TwoPixels, Y, aniSnikSnakLeft, bx); -#else - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X - bx * TwoPixels, Y, aniSnikSnakLeft + bx); -#endif + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X - bx * TwoPixels, Y, aniSnikSnakLeft, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - - return subDrawSnikSnakFromRight; } -static int subDrawSnikSnakFromAbove(int si, int bx) +static void subDrawSnikSnakFromAbove(int si, int bx) { - static int subDrawSnikSnakFromAbove; - int X, Y; bx = bx - 0x1F; // get and increment sequence# + // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si); Y = GetStretchY(si - FieldWidth); -#if 1 - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X, Y + bx * TwoPixels, aniSnikSnakDown, bx); -#else - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X, Y + bx * TwoPixels, aniSnikSnakDown + bx); -#endif + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X, Y + bx * TwoPixels, aniSnikSnakDown, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - - return subDrawSnikSnakFromAbove; } -static int subDrawSnikSnakFromLeft(int si, int bx) +static void subDrawSnikSnakFromLeft(int si, int bx) { - static int subDrawSnikSnakFromLeft; - int X, Y; bx = bx - 0x27; // get and increment sequence# + // +++++++++++++++++++++++++++++++++++++++++++++++++++++ X = GetStretchX(si - 1); Y = GetStretchY(si); -#if 1 - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X + bx * TwoPixels, Y, aniSnikSnakRight, bx); -#else - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X + bx * TwoPixels, Y, aniSnikSnakRight + bx); -#endif + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X + bx * TwoPixels, Y, aniSnikSnakRight, bx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ - - return subDrawSnikSnakFromLeft; } diff --git a/src/game_sp/SnikSnaks.h b/src/game_sp/SnikSnaks.h index ddebccfe..fd5f9ffe 100644 --- a/src/game_sp/SnikSnaks.h +++ b/src/game_sp/SnikSnaks.h @@ -5,14 +5,10 @@ #ifndef SNIKSNAKS_H #define SNIKSNAKS_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" -extern int subAnimateSnikSnaks(int si); -extern int subDrawAnimatedSnikSnaks(int si); + +extern void subAnimateSnikSnaks(int); +extern void subDrawAnimatedSnikSnaks(int); #endif /* SNIKSNAKS_H */ diff --git a/src/game_sp/Sound.c b/src/game_sp/Sound.c index 1284e58c..4a79925e 100644 --- a/src/game_sp/Sound.c +++ b/src/game_sp/Sound.c @@ -4,209 +4,6 @@ #include "Sound.h" -// static char *VB_Name = "modSound"; - -// --- Option Explicit - -int MusicOnFlag; -int FXOnFlag; - -#if 0 - -DirectSoundBuffer ZonkFX[1 + 1]; -DirectSoundBuffer InfotronFX[1 + 1]; -DirectSoundBuffer BugFX[1 + 1]; -DirectSoundBuffer ExplosionFX[1 + 1]; -DirectSoundBuffer PushFX; -DirectSoundBuffer ExitFX; -DirectSoundBuffer BaseFX; - -#endif - -void LoadSoundFX() -{ - -#if 0 - - DSBUFFERDESC bufferDesc; - WAVEFORMATEX waveFormat; - char *FName; - int i; - - bufferDesc.lFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_STATIC; - waveFormat.nFormatTag = WAVE_FORMAT_PCM; - waveFormat.nChannels = 1; - waveFormat.lSamplesPerSec = 8000; - waveFormat.nBitsPerSample = 8; - waveFormat.nBlockAlign = waveFormat.nBitsPerSample / 8 * waveFormat.nChannels; - waveFormat.lAvgBytesPerSec = waveFormat.lSamplesPerSec * waveFormat.nBlockAlign; - FName = CAT(App.Path, "/Sound/"); - for (i = 0; i <= 1; i++) - { - ZonkFX[i] = DSound.CreateSoundBufferFromFile(CAT(FName, "Zonk.wav"), bufferDesc, waveFormat); - InfotronFX[i] = DSound.CreateSoundBufferFromFile(CAT(FName, "Infotron.wav"), bufferDesc, waveFormat); - BugFX[i] = DSound.CreateSoundBufferFromFile(CAT(FName, "Bug.wav"), bufferDesc, waveFormat); - ExplosionFX[i] = DSound.CreateSoundBufferFromFile(CAT(FName, "Explosion.wav"), bufferDesc, waveFormat); - } - - BaseFX = DSound.CreateSoundBufferFromFile(CAT(FName, "Base.wav"), bufferDesc, waveFormat); - ExitFX = DSound.CreateSoundBufferFromFile(CAT(FName, "Exit.wav"), bufferDesc, waveFormat); - PushFX = DSound.CreateSoundBufferFromFile(CAT(FName, "Push.wav"), bufferDesc, waveFormat); - // FXOnFlag = 0 - -#endif - -} - -void subSoundFXZonk() -{ -#if 0 - - int i; - - if (FXOnFlag == 0) - return; - - for (i = 0; i <= 1; i++) - { - if (! IS_NOTHING(&ZonkFX[i], sizeof(ZonkFX[i]))) - { - if (ZonkFX[i].GetStatus() != DSBSTATUS_PLAYING) - { - ZonkFX[i].Play DSBPLAY_DEFAULT; - break; - } - } - } - -#endif -} - -void subSoundFXBug() -{ -#if 0 - - int i; - - if (FXOnFlag == 0) - return; - - for (i = 0; i <= 1; i++) - { - if (! IS_NOTHING(&BugFX[i], sizeof(BugFX[i]))) - { - if (BugFX[i].GetStatus() != DSBSTATUS_PLAYING) - { - BugFX[i].Play DSBPLAY_DEFAULT; - break; - } - } - } - -#endif -} - -void subSoundFXInfotron() -{ -#if 0 - - int i; - - if (FXOnFlag == 0) - return; - - for (i = 0; i <= 1; i++) - { - if (! IS_NOTHING(&InfotronFX[i], sizeof(InfotronFX[i]))) - { - if (InfotronFX[i].GetStatus() != DSBSTATUS_PLAYING) - { - InfotronFX[i].Play DSBPLAY_DEFAULT; - break; - } - } - } - -#endif -} - -void subSoundFXExplosion() -{ -#if 0 - - int i; - - if (FXOnFlag == 0) - return; - - for (i = 0; i <= 1; i++) - { - if (! IS_NOTHING(&ExplosionFX[i], sizeof(ExplosionFX[i]))) - { - if (ExplosionFX[i].GetStatus() != DSBSTATUS_PLAYING) - { - ExplosionFX[i].Play DSBPLAY_DEFAULT; - break; - } - } - } - -#endif -} - -void subSoundFXBase() -{ -#if 0 - - if (FXOnFlag == 0) - return; - - if (IS_NOTHING(&BaseFX, sizeof(BaseFX))) - return; - - if (BaseFX.GetStatus() != DSBSTATUS_PLAYING) - { - BaseFX.Play DSBPLAY_DEFAULT; - } - -#endif -} - -void subSoundFXPush() -{ -#if 0 - - if (FXOnFlag == 0) - return; - - if (IS_NOTHING(&PushFX, sizeof(PushFX))) - return; - - if (PushFX.GetStatus() != DSBSTATUS_PLAYING) - { - PushFX.Play DSBPLAY_DEFAULT; - } - -#endif -} - -void subSoundFXExit() -{ -#if 0 - - if (FXOnFlag == 0) - return; - - if (IS_NOTHING(&ExitFX, sizeof(ExitFX))) - return; - - if (ExitFX.GetStatus() != DSBSTATUS_PLAYING) - { - ExitFX.Play DSBPLAY_DEFAULT; - } - -#endif -} void subSoundFX(int si, int element, int action) { @@ -215,7 +12,3 @@ void subSoundFX(int si, int element, int action) PlayLevelSound_SP(x, y, element, action); } - -void subMusicInit() -{ -} diff --git a/src/game_sp/Sound.h b/src/game_sp/Sound.h index 445a4348..f4ca0f4b 100644 --- a/src/game_sp/Sound.h +++ b/src/game_sp/Sound.h @@ -5,26 +5,9 @@ #ifndef GAME_SP_SOUND_H #define GAME_SP_SOUND_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" -extern void LoadSoundFX(); -extern void subMusicInit(); -extern void subSoundFXBase(); -extern void subSoundFXBug(); -extern void subSoundFXExit(); -extern void subSoundFXExplosion(); -extern void subSoundFXInfotron(); -extern void subSoundFXPush(); -extern void subSoundFXZonk(); extern void subSoundFX(int, int, int); -extern int FXOnFlag; -extern int MusicOnFlag; - #endif /* GAME_SP_SOUND_H */ diff --git a/src/game_sp/TickCountObject.c b/src/game_sp/TickCountObject.c deleted file mode 100644 index fae698ce..00000000 --- a/src/game_sp/TickCountObject.c +++ /dev/null @@ -1,190 +0,0 @@ -// ---------------------------------------------------------------------------- -// TickCountObject.c -// ---------------------------------------------------------------------------- - -#include "TickCountObject.h" - -// --- VERSION 1.0 CLASS -// --- BEGIN -// --- MultiUse = -1 'True // True -// --- Persistable = 0 'NotPersistable // NotPersistable -// --- DataBindingBehavior = 0 'vbNone // vbNone -// --- DataSourceBehavior = 0 'vbNone // vbNone -// --- MTSTransactionMode = 0 'NotAnMTSObject // NotAnMTSObject -// --- END - -// static char *VB_Name = "TickCountObject"; -// static boolean VB_GlobalNameSpace = False; -// static boolean VB_Creatable = True; -// static boolean VB_PredeclaredId = False; -// static boolean VB_Exposed = False; -// --- Option Explicit - -#define LongMin (-(double)2147483648UL) // the "#" sign is a bug of the VB environment AutoFormat function but causes no real problems; don't worry 'bout it! -#define LongMax (2147483647UL) - -#if 0 - -long MyGetTickCount(); -long QueryPerformanceCounter(currency lpPerformanceCount); -long QueryPerformanceFrequency(currency lpFrequency); - -#endif - -boolean DelayLoopActive; - -boolean MPause, bHighPerf; -currency PFreq; // LARGE_INTEGER -double sFactor, msFactor, usFactor; - -#if 0 - -boolean TickCountObject_Get_Active() -{ - boolean Active; - - Active = DelayLoopActive; - - return Active; -} - -boolean TickCountObject_Get_Pause() -{ - boolean Pause; - - Pause = MPause; - - return Pause; -} - -void TickCountObject_Let_Pause(boolean NewVal) -{ - MPause = NewVal; -} - -currency TickCountObject_Get_TickNow() -{ - currency TickNow; - - if (bHighPerf) - { - QueryPerformanceCounter(TickNow); - } - else - { - TickNow = MyGetTickCount(); - } - - return TickNow; -} - -long TickCountObject_TickDiffS(currency TickStart) -{ - long TickDiffS; - - currency NewTick, TD; - - if (bHighPerf) - { - QueryPerformanceCounter(NewTick); - TD = (NewTick - TickStart); - TickDiffS = sFactor * TD; - } - else - { - NewTick = MyGetTickCount(); - if (NewTick < TickStart) - { - // Overflow occured and needs to be handled - TickDiffS = (LongMax - TickStart) + (NewTick - LongMin) + 1; - } - else - { - TickDiffS = NewTick - TickStart; - } - - TickDiffS = (int)(TickDiffS / 1000); - } - - return TickDiffS; -} - -long TickCountObject_TickDiffMS(currency TickStart) -{ - long TickDiffMS; - - currency NewTick, TD; - - if (bHighPerf) - { - QueryPerformanceCounter(NewTick); - TD = (NewTick - TickStart); - TickDiffMS = msFactor * TD; - } - else - { - NewTick = MyGetTickCount(); - if (NewTick < TickStart) - { - // Overflow occured and needs to be handled - TickDiffMS = (LongMax - TickStart) + (NewTick - LongMin) + 1; - } - else - { - TickDiffMS = NewTick - TickStart; - } - } - - return TickDiffMS; -} - -currency TickCountObject_TickDiffUS(currency TickStart) -{ - currency TickDiffUS; - - currency NewTick, TD; - - if (bHighPerf) - { - QueryPerformanceCounter(NewTick); - TD = (NewTick - TickStart); - TickDiffUS = usFactor * TD; - } - else - { - NewTick = MyGetTickCount(); - if (NewTick < TickStart) - { - // Overflow occured and needs to be handled - TickDiffUS = ((LongMax - TickStart) + (NewTick - LongMin) + 1) * (currency)1000; - } - else - { - TickDiffUS = (NewTick - TickStart) * (currency)1000; - } - } - - return TickDiffUS; -} - -#endif - -#if 0 - -static void Class_Initialize() -{ - long L; - - bHighPerf = (0 != QueryPerformanceFrequency(PFreq)); - if (bHighPerf) - { - sFactor = (double)1 / PFreq; - msFactor = (double)1000 / PFreq; - usFactor = (double)1000000 / PFreq; - } - - DelayLoopActive = False; - TickCountObject_Let_Pause(False); -} - -#endif diff --git a/src/game_sp/TickCountObject.h b/src/game_sp/TickCountObject.h deleted file mode 100644 index fc88b88b..00000000 --- a/src/game_sp/TickCountObject.h +++ /dev/null @@ -1,23 +0,0 @@ -// ---------------------------------------------------------------------------- -// TickCountObject.h -// ---------------------------------------------------------------------------- - -#ifndef TICKCOUNTOBJECT_H -#define TICKCOUNTOBJECT_H - -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - -#include "global.h" - -extern boolean TickCountObject_Get_Active(); -extern boolean TickCountObject_Get_Pause(); -extern currency TickCountObject_Get_TickNow(); -extern void TickCountObject_Let_Pause(boolean NewVal); -extern long TickCountObject_TickDiffMS(currency TickStart); -extern long TickCountObject_TickDiffS(currency TickStart); -extern currency TickCountObject_TickDiffUS(currency TickStart); - -#endif /* TICKCOUNTOBJECT_H */ diff --git a/src/game_sp/TopMost.c b/src/game_sp/TopMost.c deleted file mode 100644 index 82b7cf50..00000000 --- a/src/game_sp/TopMost.c +++ /dev/null @@ -1,54 +0,0 @@ -// ---------------------------------------------------------------------------- -// TopMost.c -// ---------------------------------------------------------------------------- - -#include "TopMost.h" - -#if 0 - -// static char *VB_Name = "TopMost_Module"; -// --- Option Explicit -// --- const int SWP_FRAMECHANGED = 0x20; -// --- const int SWP_HIDEWINDOW = 0x80; -// --- const int SWP_NOACTIVATE = 0x10; -// --- const int SWP_NOCOPYBITS = 0x100; -// --- const int SWP_NOMOVE = 0x2; -// --- const int SWP_NOOWNERZORDER = 0x200; -// --- const int SWP_NOREDRAW = 0x8; -// --- const int SWP_NOSIZE = 0x1; -// --- const int SWP_NOZORDER = 0x4; -// --- const int SWP_SHOWWINDOW = 0x40; -// --- const int SWP_DRAWFRAME = SWP_FRAMECHANGED; -// --- const int SWP_NOREPOSITION = SWP_NOOWNERZORDER; - -// --- const int HWND_BOTTOM = 1; -// --- const int HWND_BROADCAST = 0xFFFF; -// --- const int HWND_DESKTOP = 0; -// --- const int HWND_NOTOPMOST = - 2; -// --- const int HWND_TOP = 0; -// --- const int HWND_TOPMOST = - 1; - -int SetWindowPos(long h, long hb, int X, int Y, int cx, int cy, int f); - -void TopMost(Object obj) -{ - int i; - - i = SetWindowPos(obj.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE); -} - -void UnTopMost(Object obj) -{ - int i; - - i = SetWindowPos(obj.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE); -} - -void HideWindow(long hWnd) -{ - int i; - - i = SetWindowPos(hWnd, HWND_BOTTOM, 100, 100, 200, 200, SWP_HIDEWINDOW); -} - -#endif diff --git a/src/game_sp/TopMost.h b/src/game_sp/TopMost.h deleted file mode 100644 index 4eb6f24d..00000000 --- a/src/game_sp/TopMost.h +++ /dev/null @@ -1,42 +0,0 @@ -// ---------------------------------------------------------------------------- -// TopMost.h -// ---------------------------------------------------------------------------- - -#ifndef TOPMOST_H -#define TOPMOST_H - -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - -#include "global.h" - -#if 0 - -#define HWND_BOTTOM (1) -#define HWND_BROADCAST (0xFFFF) -#define HWND_DESKTOP (0) -#define HWND_NOTOPMOST (- 2) -#define HWND_TOP (0) -#define HWND_TOPMOST (- 1) -#define SWP_DRAWFRAME (SWP_FRAMECHANGED) -#define SWP_FRAMECHANGED (0x20) -#define SWP_HIDEWINDOW (0x80) -#define SWP_NOACTIVATE (0x10) -#define SWP_NOCOPYBITS (0x100) -#define SWP_NOMOVE (0x2) -#define SWP_NOOWNERZORDER (0x200) -#define SWP_NOREDRAW (0x8) -#define SWP_NOREPOSITION (SWP_NOOWNERZORDER) -#define SWP_NOSIZE (0x1) -#define SWP_NOZORDER (0x4) -#define SWP_SHOWWINDOW (0x40) - -extern void HideWindow(long hWnd); -extern void TopMost(Object obj); -extern void UnTopMost(Object obj); - -#endif - -#endif /* TOPMOST_H */ diff --git a/src/game_sp/Zonk.c b/src/game_sp/Zonk.c index b14af7ea..8656bdc8 100644 --- a/src/game_sp/Zonk.c +++ b/src/game_sp/Zonk.c @@ -131,14 +131,10 @@ loc_g_0DE8: // zonk comes falling from above X = GetStretchX(si); Y = GetStretchY(si - FieldWidth); dx = bl & 0x7; -#if 1 - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X, Y + TwoPixels * (dx + 1), aniZonk, dx); -#else - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X, Y + TwoPixels * (dx + 1), fiZonk); -#endif + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X, Y + TwoPixels * (dx + 1), aniZonk, dx); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ + bl = HighByte(PlayField16[si]) + 1; if (bl == 0x16) { @@ -272,14 +268,10 @@ loc_g_0F83: // zonk comes rolling from right to left X = GetStretchX(si + 1); Y = GetStretchY(si); dx = (bl & 0x7) + 1; -#if 1 - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X - (TwoPixels * dx), Y, aniZonkRollLeft, dx - 1); -#else - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X - (TwoPixels * dx), Y, aniFramesZonkRollLeft[dx - 1]); -#endif + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X - (TwoPixels * dx), Y, aniZonkRollLeft, dx - 1); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ + bl = HighByte(PlayField16[si]) + 1; // get and increment sequence# if (bl == 0x24) PlayField16[si + 1] = 0xAAAA; @@ -309,14 +301,10 @@ loc_g_0FE8: // zonk comes rolling from left to right X = GetStretchX(si - 1); Y = GetStretchY(si); dx = (bl & 0x7) + 1; -#if 1 - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X + (TwoPixels * dx), Y, aniZonkRollRight, dx - 1); -#else - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X + (TwoPixels * dx), Y, aniFramesZonkRollRight[dx - 1]); -#endif + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X + (TwoPixels * dx), Y, aniZonkRollRight, dx - 1); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ + bl = HighByte(PlayField16[si]) + 1; if (bl == 0x34) PlayField16[si - 1] = 0xAAAA; @@ -366,14 +354,10 @@ loc_g_107B: // zonk rolls left X = GetStretchX(si); Y = GetStretchY(si); dx = (bl & 0xF) + 1; -#if 1 - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X - (TwoPixels * dx), Y, aniZonkRollLeft, dx - 1); -#else - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X - (TwoPixels * dx), Y, aniFramesZonkRollLeft[dx - 1]); -#endif + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X - (TwoPixels * dx), Y, aniZonkRollLeft, dx - 1); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ + bl = HighByte(PlayField16[si]) + 1; // retrieve and increment sequence# if (bl < 0x52) { @@ -408,14 +392,10 @@ loc_g_10E9: // zonk rolls right X = GetStretchX(si); Y = GetStretchY(si); dx = (bl & 0x7) + 1; -#if 1 - StretchedSprites.BltImg(X, Y, aniSpace, 0); - StretchedSprites.BltImg(X + (TwoPixels * dx), Y, aniZonkRollRight, dx - 1); -#else - StretchedSprites.BltEx(X, Y, 0); - StretchedSprites.BltEx(X + (TwoPixels * dx), Y, aniFramesZonkRollRight[dx - 1]); -#endif + DDSpriteBuffer_BltImg(X, Y, aniSpace, 0); + DDSpriteBuffer_BltImg(X + (TwoPixels * dx), Y, aniZonkRollRight, dx - 1); // +++++++++++++++++++++++++++++++++++++++++++++++++++++ + bl = HighByte(PlayField16[si]) + 1; if (bl < 0x62) { diff --git a/src/game_sp/Zonk.h b/src/game_sp/Zonk.h index 7e6022f8..9bd3f770 100644 --- a/src/game_sp/Zonk.h +++ b/src/game_sp/Zonk.h @@ -5,11 +5,6 @@ #ifndef ZONK_H #define ZONK_H -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "global.h" extern int subAnimateZonks(int si); diff --git a/src/game_sp/file.c b/src/game_sp/file.c index f7b833c1..a998cfdf 100644 --- a/src/game_sp/file.c +++ b/src/game_sp/file.c @@ -248,10 +248,6 @@ void copyInternalEngineVars_SP() AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 * FieldWidth); TerminalState = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); - DemoPointer = FieldMax + 1; - DemoOffset = DemoPointer; - DemoKeyRepeatCounter = 0; - GravityFlag = LInfo.InitialGravity; FreezeZonks = LInfo.InitialFreezeZonks; diff --git a/src/game_sp/global.h b/src/game_sp/global.h index 027f2863..b459a837 100644 --- a/src/game_sp/global.h +++ b/src/game_sp/global.h @@ -7,11 +7,12 @@ #include "main_sp.h" +#include "vb_lib.h" + #include "ASM.h" #include "BugsTerminals.h" #include "DDScrollBuffer.h" #include "DDSpriteBuffer.h" -#include "Demo.h" #include "Display.h" #include "DoGameStuff.h" #include "Electrons.h" @@ -25,14 +26,8 @@ #include "MainGameLoop.h" #include "Murphy.h" #include "OrangeDisk.h" -#include "PathTools.h" -#include "SettingsObject.h" #include "SnikSnaks.h" #include "Sound.h" -#include "TickCountObject.h" -#include "TopMost.h" #include "Zonk.h" -#include "modAnimations.h" -#include "modMPX.h" #endif /* GAME_SP_GLOBAL_H */ diff --git a/src/game_sp/init.c b/src/game_sp/init.c index f79e20b0..a1312cac 100644 --- a/src/game_sp/init.c +++ b/src/game_sp/init.c @@ -7,30 +7,13 @@ Bitmap *screenBitmap; struct EngineSnapshotInfo_SP engine_snapshot_sp; -static void init_struct_functions() -{ - Stage.Blt = &DDScrollBuffer_Blt; - Stage.ScrollTo = &DDScrollBuffer_ScrollTo; - Stage.ScrollTowards = &DDScrollBuffer_ScrollTowards; - Stage.SoftScrollTo = &DDScrollBuffer_SoftScrollTo; - - // StretchedSprites.BltEx = &DDSpriteBuffer_BltEx; - StretchedSprites.BltImg = &DDSpriteBuffer_BltImg; -} - static void init_global_values() { - menBorder.Checked = False; - menPanel.Checked = True; - menAutoScroll.Checked = True; - - MainForm.picPane.Width = picPane.Width = SCR_FIELDX * TILEX; - MainForm.picPane.Height = picPane.Height = SCR_FIELDY * TILEY; + menBorder = False; } void sp_open_all() { - init_struct_functions(); init_global_values(); Form_Load(); @@ -49,10 +32,6 @@ unsigned int InitEngineRandom_SP(long seed) { if (seed == NEW_RANDOMIZE) { -#if 0 - printf("::: init.c: InitEngineRandom_SP(): subRandomize()\n"); -#endif - subRandomize(); seed = (long)RandomSeed; @@ -60,10 +39,6 @@ unsigned int InitEngineRandom_SP(long seed) RandomSeed = (short)seed; -#if 0 - printf("::: init.c: InitEngineRandom_SP(): RandomSeed == %d\n", RandomSeed); -#endif - return (unsigned int) seed; } @@ -140,8 +115,6 @@ void SaveEngineSnapshotValues_SP() SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScratchGravity)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(GravityFlag)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(SnikSnaksElectronsFrozen)); - SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(UpdateTimeFlag)); - SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(UpdatedFlag)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(YellowDisksExploded)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(YawnSleepCounter)); diff --git a/src/game_sp/main.c b/src/game_sp/main.c index a5ca525e..42f5f753 100644 --- a/src/game_sp/main.c +++ b/src/game_sp/main.c @@ -26,7 +26,7 @@ void InitGameEngine_SP() game_sp.red_disk_count = 0; game_sp.score = 0; - menBorder.Checked = setup.sp_show_border_elements; + menBorder = setup.sp_show_border_elements; for (x = 0; x < SP_MAX_PLAYFIELD_WIDTH; x++) { diff --git a/src/game_sp/modAnimations.c b/src/game_sp/modAnimations.c deleted file mode 100644 index 7cd0123a..00000000 --- a/src/game_sp/modAnimations.c +++ /dev/null @@ -1,78 +0,0 @@ -// ---------------------------------------------------------------------------- -// modAnimations.c -// ---------------------------------------------------------------------------- - -#include "modAnimations.h" - -// static char *VB_Name = "modAnimations"; -// --- Option Explicit - -// ::: #ifndef HAS_SpecialPortType -// ::: typedef struct -// ::: { -// ::: int PortLocation; // = 2*(x+(y*60)) -// ::: byte Gravity; // 1 = turn on, anything else (0) = turn off -// ::: byte FreezeZonks; // 2 = turn on, anything else (0) = turn off (1=off!) -// ::: byte FreezeEnemies; // 1 = turn on, anything else (0) = turn off -// ::: byte UnUsed; -// ::: } SpecialPortType; -// ::: #define HAS_SpecialPortType -// ::: #endif - -// ::: #ifndef HAS_LevelInfoType -// ::: typedef struct -// ::: { -// ::: byte UnUsed[4 + 1]; -// ::: byte InitialGravity; // 1=on, anything else (0) = off -// ::: byte Version; // SpeedFixVersion XOR &H20 -// ::: char LevelTitle[23]; -// ::: byte InitialFreezeZonks; // 2=on, anything else (0) = off. (1=off too!) -// ::: byte InfotronsNeeded; - -// ::: // Number of Infotrons needed. 0 means that Supaplex will count the total -// ::: // amount of Infotrons in the level, and use the low byte of that number. -// ::: // (A multiple of 256 Infotrons will then result in 0-to-eat, etc.!) -// ::: byte SpecialPortCount; // Maximum 10 allowed! -// ::: SpecialPortType SpecialPort[10 + 1]; -// ::: byte SpeedByte; // = Speed XOR Highbyte(RandomSeed) -// ::: byte CheckSumByte; // = CheckSum XOR SpeedByte -// ::: int DemoRandomSeed; -// ::: } LevelInfoType; -// ::: #define HAS_LevelInfoType -// ::: #endif - -DDSpriteBuffer NormalSprites; -DDSpriteBuffer StretchedSprites; -DDScrollBuffer Stage; - -byte LData[59 + 1][23 + 1]; -LevelInfoType LInfo; - -#if 1 -float Stretch = 1; // , StretchWidth%, TwoPixels! -#else -float Stretch; // , StretchWidth%, TwoPixels! -#endif - -int ScrollMinX, ScrollMaxX, ScrollMinY, ScrollMaxY; -int ScrollX, ScrollY; -// --- const long ScrollDelta = 1&; - -// Public FieldWidth&, FieldHeight& -boolean EndFlag; -long PauseMode; - -TickCountObject Clock; -long MurphyX, MurphyY; - -void GoPlay() -{ - // Call subFetchAndInitLevelB - EndFlag = False; - -#if 1 - subMainGameLoop_Init(); -#else - subMainGameLoop(); -#endif -} diff --git a/src/game_sp/modAnimations.h b/src/game_sp/modAnimations.h deleted file mode 100644 index 38325dc0..00000000 --- a/src/game_sp/modAnimations.h +++ /dev/null @@ -1,72 +0,0 @@ -// ---------------------------------------------------------------------------- -// modAnimations.h -// ---------------------------------------------------------------------------- - -#ifndef MODANIMATIONS_H -#define MODANIMATIONS_H - -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - -#include "global.h" - -#ifndef HAS_SpecialPortType -typedef struct -{ -#if 1 - short PortLocation; // = 2*(x+(y*60)) -#else - int PortLocation; // = 2*(x+(y*60)) -#endif - byte Gravity; // 1 = turn on, anything else (0) = turn off - byte FreezeZonks; // 2 = turn on, anything else (0) = turn off (1=off!) - byte FreezeEnemies; // 1 = turn on, anything else (0) = turn off - byte UnUsed; -} SpecialPortType; -#define HAS_SpecialPortType -#endif - -#ifndef HAS_LevelInfoType -typedef struct -{ - byte UnUsed[4]; - byte InitialGravity; // 1=on, anything else (0) = off - byte Version; // SpeedFixVersion XOR &H20 - char LevelTitle[23]; - byte InitialFreezeZonks; // 2=on, anything else (0) = off. (1=off too!) - byte InfotronsNeeded; - - // Number of Infotrons needed. 0 means that Supaplex will count the total - // amount of Infotrons in the level, and use the low byte of that number. - // (A multiple of 256 Infotrons will then result in 0-to-eat, etc.!) - byte SpecialPortCount; // Maximum 10 allowed! - SpecialPortType SpecialPort[10]; - byte SpeedByte; // = Speed XOR Highbyte(RandomSeed) - byte CheckSumByte; // = CheckSum XOR SpeedByte -#if 1 - short DemoRandomSeed; -#else - int DemoRandomSeed; -#endif -} LevelInfoType; -#define HAS_LevelInfoType -#endif - -#define ScrollDelta ((long)1) - -extern void GoPlay(); - -extern DDScrollBuffer Stage; -extern DDSpriteBuffer NormalSprites; -extern DDSpriteBuffer StretchedSprites; -extern LevelInfoType LInfo; -extern boolean EndFlag; -extern byte LData[59 + 1][23 + 1]; -extern float Stretch; -extern int ScrollMinX, ScrollMaxX, ScrollMinY, ScrollMaxY; -extern int ScrollX, ScrollY; -extern long PauseMode; - -#endif /* MODANIMATIONS_H */ diff --git a/src/game_sp/modMPX.c b/src/game_sp/modMPX.c deleted file mode 100644 index b2c26024..00000000 --- a/src/game_sp/modMPX.c +++ /dev/null @@ -1,455 +0,0 @@ -// ---------------------------------------------------------------------------- -// modMPX.c -// ---------------------------------------------------------------------------- - -#include "modMPX.h" - -void ReadMPX(); -#if 0 -static void SaveMPX(char *Path); -static void SaveSP(char *Path); -#endif - -// static char *VB_Name = "modMPX"; -// --- Option Explicit - -char *gSignature; -boolean bSignatureAvailable; - -const char MPX_ID[4] = "MPX "; - -// ::: #ifndef HAS_LevelDescriptor -// ::: typedef struct -// ::: { -// ::: int Width; -// ::: int Height; -// ::: long OffSet; -// ::: long Size; -// ::: } LevelDescriptor; -// ::: #define HAS_LevelDescriptor -// ::: #endif - -int MPXVersion; -int LevelCount; -boolean DemoAvailable; -LevelDescriptor *LDesc; -// int OFile; -FILE *OFile; - -boolean MpxOpen(char *Path) -{ - boolean MpxOpen; - - // int i; - // byte T; - char readID[4]; - - MpxOpen = False; - - // --- On Error GoTo OpenMPXEH - // OFile = FreeFile(); - OFile = fopen(CurPath, "rb"); - FILE_GET(OFile, -1, &readID, sizeof(readID)); - if (readID != MPX_ID) - goto OpenMPXEH; - - FILE_GET(OFile, -1, &MPXVersion, sizeof(MPXVersion)); - FILE_GET(OFile, -1, &LevelCount, sizeof(LevelCount)); - LDesc = REDIM_1D(sizeof(LevelDescriptor), 0, LevelCount + 1 - 1); - FILE_GET(OFile, -1, &LDesc, sizeof(LDesc)); - MpxOpen = True; - return MpxOpen; - -OpenMPXEH: - fclose(OFile); - OFile = 0; - - return MpxOpen; -} - -boolean MpxLoadLInfo(int i) -{ - boolean MpxLoadLInfo; - - long Off; - - MpxLoadLInfo = False; - // if (OFile < 1) - if (OFile == 0) - return MpxLoadLInfo; - - Off = LDesc[i].OffSet; - Off = Off + LDesc[i].Width * LDesc[i].Height; - - // --- On Error GoTo MpxLoadLInfoEH - FILE_GET(OFile, Off, &LInfo, sizeof(LInfo)); - MpxLoadLInfo = True; - return MpxLoadLInfo; - - // MpxLoadLInfoEH: - fclose(OFile); - OFile = 0; - - return MpxLoadLInfo; -} - -void MpxClose() -{ - if (0 < OFile) - { - fclose(OFile); - OFile = 0; - } -} - -void ReadMPX() -{ - // int FNum, i; - FILE *FNum; - int i; - // byte T; - char readID[4]; - - Trace("modMPX", "--> ReadMPX"); - - // --- On Error GoTo ReadMPXEH - // FNum = FreeFile(); - Trace("modMPX", "open file"); - FNum = fopen(CurPath, "rb"); - FILE_GET(FNum, -1, &readID, sizeof(readID)); - if (readID != MPX_ID) - goto ReadMPXEH; - - FILE_GET(FNum, -1, &MPXVersion, sizeof(MPXVersion)); - if (MPXVersion != 1) - goto ReadMPXEH; - - FILE_GET(FNum, -1, &LevelCount, sizeof(LevelCount)); - if (LevelCount < 1) - goto ReadMPXEH; - - LDesc = REDIM_1D(sizeof(LevelDescriptor), 0, LevelCount + 1 - 1); - Trace("modMPX", "--> read LevelDescriptor"); - FILE_GET(FNum, -1, &LDesc, sizeof(LDesc)); - FieldWidth = LDesc[LevelNumber].Width; - FieldHeight = LDesc[LevelNumber].Height; - HeaderSize = 96; - FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1; - LevelMax = (FieldWidth * FieldHeight) - 1; - FileMax = LDesc[LevelNumber].Size - 1; - if (FileMax < FieldMax) - FileMax = FieldMax; - - Trace("modMPX", "ReDim PlayField8"); - PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax + 1 - 1); - DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); - i = LDesc[LevelNumber].OffSet; -#if 1 - FILE_GET(FNum, i, PlayField8, FileMax + 1); -#else - FILE_GET(FNum, i, &PlayField8, sizeof(PlayField8)); -#endif - i = i + LevelMax + 1; - FILE_GET(FNum, i, &LInfo, sizeof(LInfo)); // store level info in an extra structure - fclose(FNum); - // --- On Error GoTo 0 - - Trace("modMPX", "file closed"); - if (FieldMax < FileMax) - DemoAvailable = True; - - Trace("modMPX", "read signature"); - ReadSignature(); - Trace("modMPX", "ReDim PlayField16"); - PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax); - for (i = 0; i <= FieldMax; i++) - { - PlayField16[i] = PlayField8[i]; - DisPlayField[i] = PlayField8[i]; - PlayField8[i] = 0; - } - - AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 *FieldWidth); - AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 *FieldWidth); - TerminalState = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); - GravityFlag = LInfo.InitialGravity; - FreezeZonks = LInfo.InitialFreezeZonks; - DemoPointer = FieldMax + 1; - DemoOffset = DemoPointer; - DemoKeyRepeatCounter = 0; - if (DemoFlag != 0) - { - // Debug.Print "ReadMPX: " & Hex(LInfo.DemoRandomSeed) - RandomSeed = LInfo.DemoRandomSeed; - DemoFlag = 1; - } - else - { - subRandomize(); - } - - MainForm.SetDisplayRegion(); - LevelLoaded = True; - if (CurPath != TmpPath) - Let_ModifiedFlag(False); - - Trace("modMPX", "--> ReadMPX"); - return; - -ReadMPXEH: - // Close(); - fclose(FNum); - ReportError("modMPX", CAT("Error reading MPX file ", CurPath)); - Trace("modMPX", "Error reading MPX file"); - Trace("modMPX", "--> ReadMPX"); -} - -#if 0 - -static void SaveMPX(char *Path) -{ - // int FNum, i; - FILE *FNum; - int i; - // byte T; - byte FF; - - FF = 0xFF; - LevelNumber = 1; - LevelCount = 1; - MPXVersion = 1; - if ((FileMax < FieldMax) || ! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer))) - FileMax = FieldMax; - - LDesc = REDIM_1D(sizeof(LevelDescriptor), 0, LevelCount + 1 - 1); - { - LDesc[LevelNumber].Width = FieldWidth; - LDesc[LevelNumber].Height = FieldHeight; - LDesc[LevelNumber].OffSet = 4 + 2 * strlen(INT_TO_STR(LevelCount)) + - LevelCount * sizeof(LDesc[1]) + 1; - LDesc[LevelNumber].Size = FileMax + 1; - if (! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer))) - { - LDesc[LevelNumber].Size = LDesc[LevelNumber].Size + DemoBuffer.Size + 2; - if (0 < strlen(MySignature)) - LDesc[LevelNumber].Size = LDesc[LevelNumber].Size + strlen(MySignature) + 1; - } - - } - - // UnEdAll(); - - // --- On Error GoTo SaveMPXEH - // FNum = FreeFile(); - if (FileExists(Path)) - MayKill(Path); - - FNum = fopen(Path, "wb"); - FILE_PUT(FNum, -1, &MPX_ID, sizeof(MPX_ID)); - FILE_PUT(FNum, -1, &MPXVersion, sizeof(MPXVersion)); - FILE_PUT(FNum, -1, &LevelCount, sizeof(LevelCount)); - FILE_PUT(FNum, -1, &LDesc, sizeof(LDesc)); - i = LDesc[LevelNumber].OffSet; - FILE_PUT(FNum, i, &PlayField8, sizeof(PlayField8)); - FILE_PUT(FNum, i, &DisPlayField, sizeof(DisPlayField)); - i = i + LevelMax + 1; - FILE_PUT(FNum, i, &LInfo, sizeof(LInfo)); // store level info - if (! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer))) // demo was recorded - { - // Debug.Print "SaveMPX: " & Hex(LInfo.DemoRandomSeed) - FILE_PUT(FNum, -1, &FirstDemoByte, sizeof(FirstDemoByte)); - if (! DemoBuffer.Serialize(FNum)) - goto SaveMPXEH; - - FILE_PUT(FNum, -1, &FF, sizeof(FF)); - if (0 < strlen(MySignature)) - { - FILE_PUT(FNum, -1, &MySignature, sizeof(MySignature)); - FILE_PUT(FNum, -1, &FF, sizeof(FF)); - } - } - - fclose(FNum); - // --- On Error GoTo 0 - - CurPath = Path; - - // EdAll(); - - if (Path != TmpPath) - Let_ModifiedFlag(False); - - return; - -SaveMPXEH: - // Close(); - fclose(FNum); -} - -#endif - -#if 0 - -static void SaveSP(char *Path) -{ - // int FNum, i; - FILE *FNum; - int i; - // byte T; - - LevelNumber = 1; - LevelCount = 1; - if (! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer))) - LInfo.CheckSumByte = DemoBuffer.CheckSumByte; - - if ((FileMax < FieldMax) || ! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer))) - FileMax = FieldMax; - - // UnEdAll(); - - // --- On Error GoTo SaveSPEH - // FNum = FreeFile(); - FNum = fopen(Path, "wb"); - FILE_PUT(FNum, 1, &PlayField8, sizeof(PlayField8)); - FILE_PUT(FNum, 1, &DisPlayField, sizeof(DisPlayField)); - i = LevelMax + 2; - FILE_PUT(FNum, i, &LInfo, sizeof(LInfo)); // store level info - if (! IS_NOTHING(&DemoBuffer, sizeof(DemoBuffer))) // demo was recorded - { - // Debug.Print "SaveMPX: " & Hex(LInfo.DemoRandomSeed) - // If Not DemoBuffer.Serialize(FNum) Then GoTo SaveSPEH - - // Debug.Assert(False); - } - - fclose(FNum); - // --- On Error GoTo 0 - - CurPath = Path; - - // EdAll(); - - if (Path != TmpPath) - Let_ModifiedFlag(False); - - return; - - // SaveSPEH: - // Close(); -} - -#endif - -void CreateLevel(int LWidth, int LHeight) -{ - long Tmp, i; - // byte T; - - CurPath = "Untitled"; - OrigPath = CurPath; - LevelNumber = 1; - FieldWidth = LWidth; - FieldHeight = LHeight; - HeaderSize = 96; - FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1; - LevelMax = (FieldWidth * FieldHeight) - 1; - FileMax = FieldMax; - PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax + 1 - 1); - DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); - Tmp = FieldWidth * (FieldHeight - 1); - for (i = 0; i <= FieldWidth - 1; i++) - { - PlayField8[i] = fiHardWare; - PlayField8[Tmp + i] = fiHardWare; - } - - Tmp = Tmp; - for (i = FieldWidth; i <= Tmp; i += FieldWidth) - { - PlayField8[i] = fiHardWare; - PlayField8[i - 1] = fiHardWare; - } - - { - LInfo.DemoRandomSeed = 0; - LInfo.InfotronsNeeded = 0; - LInfo.InitialFreezeZonks = 0; - LInfo.InitialGravity = 0; - strcpy(LInfo.LevelTitle, "------ New Level ------");; - LInfo.SpecialPortCount = 0; - LInfo.Version = 0x74; // immitate speedfix version 5.4 - } - PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax); - for (i = 0; i <= FieldMax; i++) - { - PlayField16[i] = PlayField8[i]; - DisPlayField[i] = PlayField8[i]; - PlayField8[i] = 0; - } - - AnimationPosTable = REDIM_1D(sizeof(int), 0, LevelMax - 2 *FieldWidth); - AnimationSubTable = REDIM_1D(sizeof(byte), 0, LevelMax - 2 *FieldWidth); - TerminalState = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); - GravityFlag = LInfo.InitialGravity; - FreezeZonks = LInfo.InitialFreezeZonks; - RandomSeed = LInfo.DemoRandomSeed; - DemoAvailable = False; - SET_TO_NOTHING(&DemoBuffer, sizeof(DemoBuffer)); - LevelLoaded = True; - Let_ModifiedFlag(True); -} - -void ReadSignature() -{ - long i, iMin, iMax; - - Trace("modMPX", "--> ReadSignature"); - bSignatureAvailable = False; - gSignature = ""; - - // ##################################################### ReRecording-Test - if ((DemoFlag == 1) && (RecordDemoFlag == 1)) - { - FirstDemoByte = PlayField8[DemoPointer]; - MySignature = gSignature; - } - - // ##################################################### ReRecording-Test - - // gSignature = String(511, "A"): bSignatureAvailable = False: Exit Sub 'test - if (! (FieldMax < FileMax)) - return; - - // !!! Debug.Assert PlayField8(FileMax) = &HFF - Trace("modMPX", "settin iMin/Max"); - iMin = FileMax - 512; - if (iMin < (FieldMax + 2)) - iMin = FieldMax + 2; - - iMax = FileMax - 1; - Trace("modMPX", " For i == iMax To iMin Step -1"); - for (i = iMax; i <= iMin; i += -1) - { - if (PlayField8[i] == 0xFF) - break; - } - - if (i < iMin) - return; - - for (i = i + 1; i <= iMax; i++) - { - gSignature = CAT(gSignature, (char)(PlayField8[i])); - } - - // ##################################################### ReRecording-Test - if ((DemoFlag == 1) && (RecordDemoFlag == 1)) - MySignature = gSignature; - - // ##################################################### ReRecording-Test - - if (iMin <= iMax) - bSignatureAvailable = True; - - Trace("modMPX", "<-- ReadSignature"); -} diff --git a/src/game_sp/modMPX.h b/src/game_sp/modMPX.h deleted file mode 100644 index bd707e21..00000000 --- a/src/game_sp/modMPX.h +++ /dev/null @@ -1,40 +0,0 @@ -// ---------------------------------------------------------------------------- -// modMPX.h -// ---------------------------------------------------------------------------- - -#ifndef MODMPX_H -#define MODMPX_H - -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - -#include "global.h" - -#ifndef HAS_LevelDescriptor -typedef struct -{ - int Width; - int Height; - long OffSet; - long Size; -} LevelDescriptor; -#define HAS_LevelDescriptor -#endif - -extern void CreateLevel(int LWidth, int LHeight); -extern void MpxClose(); -extern boolean MpxLoadLInfo(int i); -extern boolean MpxOpen(char *Path); -extern void ReadSignature(); - -extern void ReadMPX(); - -extern LevelDescriptor *LDesc; -extern boolean DemoAvailable; -extern boolean bSignatureAvailable; -extern char *gSignature; -extern int LevelCount; - -#endif /* MODMPX_H */ diff --git a/src/game_sp/vb_defs.h b/src/game_sp/vb_defs.h deleted file mode 100644 index b25d1570..00000000 --- a/src/game_sp/vb_defs.h +++ /dev/null @@ -1,87 +0,0 @@ -// ---------------------------------------------------------------------------- -// vb_defs.h -// ---------------------------------------------------------------------------- - -#ifndef VB_DEFS_H -#define VB_DEFS_H - -#define Win16 1 - -#ifndef False -#define False 0 -#define True (!False) -#endif - -#ifndef NULL -#define NULL ((void *)0) -#endif - -/* these are just dummy values to prevent the compiler from complaining */ -#define VALUE_START_VB 100 -#define VALUE_START_VB_KEY 200 -#define VALUE_START_DD 300 -#define VALUE_START_DD_ERR 400 -#define VALUE_START_DS 500 - -#define vbPicTypeBitmap (VALUE_START_VB + 1) -#define vbSrcCopy (VALUE_START_VB + 2) -#define vbTwips (VALUE_START_VB + 3) -#define vbPixels (VALUE_START_VB + 4) -#define vbPRORPortrait (VALUE_START_VB + 5) -#define vbPRORLandscape (VALUE_START_VB + 6) -#define vbDirectory (VALUE_START_VB + 7) - -#define vbKeySpace (VALUE_START_VB_KEY + 1) -#define vbKeyLeft (VALUE_START_VB_KEY + 2) -#define vbKeyRight (VALUE_START_VB_KEY + 3) -#define vbKeyUp (VALUE_START_VB_KEY + 4) -#define vbKeyDown (VALUE_START_VB_KEY + 5) -#define vbKeyEscape (VALUE_START_VB_KEY + 6) -#define vbKeyR (VALUE_START_VB_KEY + 7) -#define vbKeyReturn (VALUE_START_VB_KEY + 8) -#define vbKeyShift (VALUE_START_VB_KEY + 9) - -#define DD_OK (VALUE_START_DD + 0) - -#define DDSD_CAPS (VALUE_START_DD + 1) -#define DDSD_WIDTH (VALUE_START_DD + 2) -#define DDSD_HEIGHT (VALUE_START_DD + 3) -#define DDSCL_NORMAL (VALUE_START_DD + 4) -#define DDBLT_WAIT (VALUE_START_DD + 5) -#define DDSCAPS_VIDEOMEMORY (VALUE_START_DD + 6) -#define DDSCAPS_OFFSCREENPLAIN (VALUE_START_DD + 7) -#define DDSCAPS_PRIMARYSURFACE (VALUE_START_DD + 8) - -#define DDERR_GENERIC (VALUE_START_DD_ERR + 1) -#define DDERR_INVALIDCLIPLIST (VALUE_START_DD_ERR + 2) -#define DDERR_INVALIDOBJECT (VALUE_START_DD_ERR + 3) -#define DDERR_INVALIDPARAMS (VALUE_START_DD_ERR + 4) -#define DDERR_INVALIDRECT (VALUE_START_DD_ERR + 5) -#define DDERR_NOALPHAHW (VALUE_START_DD_ERR + 6) -#define DDERR_NOBLTHW (VALUE_START_DD_ERR + 7) -#define DDERR_NOCLIPLIST (VALUE_START_DD_ERR + 8) -#define DDERR_NODDROPSHW (VALUE_START_DD_ERR + 9) -#define DDERR_NOMIRRORHW (VALUE_START_DD_ERR + 10) -#define DDERR_NORASTEROPHW (VALUE_START_DD_ERR + 11) -#define DDERR_NOROTATIONHW (VALUE_START_DD_ERR + 12) -#define DDERR_NOSTRETCHHW (VALUE_START_DD_ERR + 13) -#define DDERR_NOZBUFFERHW (VALUE_START_DD_ERR + 14) -#define DDERR_SURFACEBUSY (VALUE_START_DD_ERR + 15) -#define DDERR_SURFACELOST (VALUE_START_DD_ERR + 16) -#define DDERR_UNSUPPORTED (VALUE_START_DD_ERR + 17) -#define DDERR_WASSTILLDRAWING (VALUE_START_DD_ERR + 18) - -#if 0 - -#define DSSCL_PRIORITY (VALUE_START_DS + 1) -#define DSBCAPS_CTRLFREQUENCY (VALUE_START_DS + 2) -#define DSBCAPS_CTRLPAN (VALUE_START_DS + 3) -#define DSBCAPS_CTRLVOLUME (VALUE_START_DS + 4) -#define DSBCAPS_STATIC (VALUE_START_DS + 5) -#define WAVE_FORMAT_PCM (VALUE_START_DS + 6) -#define DSBSTATUS_PLAYING (VALUE_START_DS + 7) -#define DSBPLAY_DEFAULT (VALUE_START_DS + 8) - -#endif - -#endif /* VB_DEFS_H */ diff --git a/src/game_sp/vb_lib.c b/src/game_sp/vb_lib.c index f9372a1a..f48ca389 100644 --- a/src/game_sp/vb_lib.c +++ b/src/game_sp/vb_lib.c @@ -2,20 +2,13 @@ // vb_lib.c // ---------------------------------------------------------------------------- -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - #include "main_sp.h" -#include +#include "vb_lib.h" /* helper functions for constructs not supported by C */ -#if 1 - void *REDIM_1D(int data_size, int first_data_pos, int last_data_pos) { /* for a buffer of n elements, first_data_pos is 0 and last_data_pos is n-1 */ @@ -28,195 +21,7 @@ void *REDIM_1D(int data_size, int first_data_pos, int last_data_pos) return (checked_calloc(buffer_size) - buffer_start); } -#else - -void *REDIM_1D(int a, int b, int c) -{ - return checked_calloc(a * (c - b + 1)); -} - -#endif - -void *REDIM_2D(int a, int b, int c, int d, int e) -{ - return 0; -} - -boolean IS_NOTHING(void *a, int b) -{ - return 0; -} - -void SET_TO_NOTHING(void *a, int b) -{ - return; -} - -void MESSAGE_BOX(char *a) -{ - return; -} - - -char *CAT(const char *a, ...) -{ - return 0; -} - -char *GET_PATH(char *a, ...) -{ - return 0; -} - -char *INT_TO_STR(int a) -{ - return 0; -} - - -boolean STRING_IS_LIKE(char *a, char *b) -{ - if (*b == '*') // something like "*.sp" - { - return (strSuffix(a, &b[1])); - } - else - { - // more sophisticated patterns currently not supported - - return 0; - } -} - - -void FILE_GET(FILE *file, int offset, void *buffer, int num_bytes) -{ - if (offset != -1) - fseek(file, offset - 1, SEEK_SET); - - while (num_bytes--) - *(byte *)buffer++ = fgetc(file); -} - -int FILE_PUT(FILE *a, int b, void *c, int d) -{ - return 0; -} - - -/* this is just a workaround -- handle array definitions later */ -void *Array(int a, ...) -{ - return 0; -} - - -/* VB functions that do not return "int" (and would cause compiler errors) */ -double Val(char *a) -{ - return 0; -} - -char *Left(char *a, int b) -{ - return 0; -} - -char *left(char *a, int b) -{ - return 0; -} - -char *Right(char *a, int b) -{ - return 0; -} - -char *right(char *a, int b) -{ - return 0; -} - -char *StrReverse(char *a) -{ - return 0; -} - -int InStr(int a, char *b, char *c) -{ - return 0; -} - -char *Dir(char *a) -{ - return 0; -} - -char *Dir_Without_Args() -{ - return 0; -} - -void Kill(char *a) -{ - return; -} - -char *Chr(int a) -{ - return 0; -} - -char *String(int a, char *b) -{ - return 0; -} - -void MkDir(char *a) -{ - return; -} - -char *Hex(int a) -{ - return 0; -} - - -int FileLen(char *a) -{ - struct stat buffer; - - if (stat(a, &buffer) == 0) - { - return buffer.st_size; - } - else - { - return 0; - } -} - long MyGetTickCount() { return random_linux_libc(RANDOM_SIMPLE); } - -int GetAttr(char *a) -{ - return 0; -} - -void SaveSetting(const char * a, const char *b, char *c, int d) -{ - return; -} - -#if 0 - -long GetTempPath(long a, char *b) -{ - return 0; -} - -#endif diff --git a/src/game_sp/vb_lib.h b/src/game_sp/vb_lib.h index 51af0f02..e3325749 100644 --- a/src/game_sp/vb_lib.h +++ b/src/game_sp/vb_lib.h @@ -11,53 +11,7 @@ /* helper functions for constructs not supported by C */ extern void *REDIM_1D(int, int, int); -extern void *REDIM_2D(int, int, int, int, int); - -extern boolean IS_NOTHING(void *, int); - -extern void SET_TO_NOTHING(void *, int); - -extern void MESSAGE_BOX(char *); - -extern char *CAT(const char *, ...); -extern char *GET_PATH(char *, ...); -extern char *INT_TO_STR(int); - -extern boolean STRING_IS_LIKE(char *, char *); - -extern void FILE_GET(FILE *, int, void *, int); -extern int FILE_PUT(FILE *, int, void *, int); - -/* this is just a workaround -- handle array definitions later */ -extern void *Array(int, ...); - -/* VB functions that do not return "int" (and would cause compiler errors) */ -extern double Val(char *); -extern char *Left(char *, int); -extern char *left(char *, int); -extern char *Right(char *, int); -extern char *right(char *, int); -extern char *StrReverse(char *); -extern int InStr(int, char *, char *); -extern char *Dir(char *); -extern char *Dir_Without_Args(); -extern void Kill(char *); -extern char *Chr(int); -extern char *String(int, char *); -extern void MkDir(char *); -extern char *SlashLess(char *); -extern char *Hex(int); - -extern int FileLen(char *); extern long MyGetTickCount(); -extern int GetAttr(char *); - -extern void SaveSetting(const char *, const char *, char *, int); - -#if 0 -extern long GetTempPath(long, char *); -#endif - #endif /* VB_LIB_H */ diff --git a/src/game_sp/vb_types.h b/src/game_sp/vb_types.h deleted file mode 100644 index 030e179e..00000000 --- a/src/game_sp/vb_types.h +++ /dev/null @@ -1,305 +0,0 @@ -// ---------------------------------------------------------------------------- -// vb_types.h -// ---------------------------------------------------------------------------- - -#ifndef VB_TYPES_H -#define VB_TYPES_H - -#include "../libgame/types.h" - - -#if 0 -typedef unsigned char boolean; -#endif - -typedef double currency; - -#if 0 -#if !defined(PLATFORM_WIN32) -typedef unsigned char byte; -#endif -#endif - -typedef int Variant; - -typedef struct -{ - int hWnd; -} Object; - -#ifndef HAS_RECT -typedef struct -{ - int left; - int top; - int right; - int bottom; -} MyRECT; -#define HAS_RECT -#endif - -typedef struct -{ - char *Path; -} vb_App; - -typedef struct -{ - void (*Assert)(boolean); - void (*Print)(char *); -} vb_Debug; - -typedef struct -{ - int Number; - void (*Raise)(int, char *, char *); -} vb_Err; - -typedef struct -{ - int Width; - int Height; - - int ScaleWidth; - int ScaleHeight; - int ScaleMode; - - int Orientation; - - int TwipsPerPixelX; - int TwipsPerPixelY; - - int hWnd; - - int (*ScaleX)(int, int, int); - int (*ScaleY)(int, int, int); -} vb_Generic_Device; - -typedef vb_Generic_Device vb_Screen; - -typedef vb_Generic_Device Form; -typedef vb_Generic_Device Picture; -typedef vb_Generic_Device IPicture; -typedef vb_Generic_Device Printer; - -typedef struct -{ - int lCaps; -} vb_Caps; - -typedef struct -{ - int LWidth; - int LHeight; - int lFlags; - vb_Caps ddsCaps; -} DDSURFACEDESC2; - -typedef struct -{ - void (*SetHWnd)(long); -} DirectDrawClipper; - -typedef struct -{ - boolean (*isLost)(void); - void (*GetSurfaceDesc)(DDSURFACEDESC2); - void (*SetClipper)(DirectDrawClipper); - // long (*Blt)(MyRECT, DirectDrawSurface7, MyRECT, int); - long (*Blt)(MyRECT, void *, MyRECT, int); - void (*BltColorFill)(MyRECT, int); -} DirectDrawSurface7; - -typedef struct -{ - DirectDrawSurface7 (*CreateSurface)(DDSURFACEDESC2); - DirectDrawSurface7 (*CreateSurfaceFromFile)(char *, DDSURFACEDESC2); - void (*SetCooperativeLevel)(int, int); - DirectDrawClipper (*CreateClipper)(int); - void (*RestoreAllSurfaces)(void); -} DirectDraw7; - -typedef struct -{ - int lFlags; -} DSBUFFERDESC; - -#if 0 - -typedef struct -{ - int nFormatTag; - int nChannels; - int lSamplesPerSec; - int nBitsPerSample; - int nBlockAlign; - int lAvgBytesPerSec; -} WAVEFORMATEX; - -typedef struct -{ - int (*GetStatus)(void); - void (*Play)(int); -} DirectSoundBuffer; - -typedef struct -{ - void (*SetCooperativeLevel)(long, int); - DirectSoundBuffer (*CreateSoundBufferFromFile)(char *, DSBUFFERDESC, WAVEFORMATEX); -} DirectSound; - -typedef struct -{ - DirectDraw7 (*DirectDrawCreate)(char *); - DirectSound (*DirectSoundCreate)(char *); - void (*GetWindowRect)(long, MyRECT); -} DirectX7; - -#endif - -typedef struct -{ - int Left; - int Top; - void (*RefreshMarker)(void); -} MarkerObject; - -typedef struct -{ - void (*DelayMS)(long, boolean); - double (*TickDiffUS)(double); - double (*TickNow)(); -} TickCountObject; - -typedef struct -{ - int Caption; - void (*Refresh)(void); -} MainForm_lblCount; - -typedef struct -{ - boolean Checked; - boolean Enabled; -} MainForm_men; - -typedef struct -{ - int Width; - int Height; - void (*Line)(int, int, int, int, int, int); -} MainForm_picPane; - -typedef struct -{ - MainForm_lblCount lblInfoCount; - MainForm_lblCount lblRedDiskCount; - void (*DisplayLevel)(void); - void (*DrawField)(int, int); - MainForm_men menGravOn; - MainForm_men menZonkOn; - MainForm_men menEnOn; - MainForm_men menGravOff; - MainForm_men menZonkOff; - MainForm_men menEnOff; - MainForm_men menRemSP; - MainForm_men menSP; - char *Caption; - boolean PanelVisible; - void (*ShowKey)(int); - void (*SaveSnapshot)(int); - void (*menStop_Click)(void); - MainForm_picPane picPane; - char *lblFrameCount; - void (*SetDisplayRegion)(void); -} MainFormObject; - -typedef struct -{ - int DestXOff; - int DestYOff; - void *Surface; - - void (*Cls)(); - void (*Blt)(); - void (*ScrollTo)(int, int); - void (*ScrollTowards)(int, int, double); - void (*SoftScrollTo)(int, int, long, int); - -} DDScrollBuffer; - -typedef struct -{ - int DestXOff; - int DestYOff; - void *DestinationSurface; - void *Surface; - - void (*Cls)(); - // void (*BltEx)(int, int, int); - void (*BltImg)(int, int, int, int); -} DDSpriteBuffer; - -typedef struct -{ - void (*CreateAtSize)(long, long, long); - void (*Let_Palette)(long, long); - void (*Let_ColorIndex)(long, long, long); -} BitMapObject; - -struct DemoBufferObject -{ - int Size; - byte CheckSumByte; - void (*SetSubBuffer)(struct DemoBufferObject *); - void (*AddDemoKey)(int); - boolean (*Serialize)(FILE *); -}; -typedef struct DemoBufferObject DemoBufferObject; - -typedef struct -{ - int (*Read)(char *ValName, int Default); - void (*Save)(char *ValName, int Val); -} SettingsObject; - -typedef struct -{ - int left; - int top; - int ListIndex; - char (*List)(int); -} cmbFileObject; - -typedef struct -{ - int Width; - int Height; - boolean Visible; - void (*Move)(int, int, int); -} shpProgressObject; - -typedef struct -{ - int left; - int Top; - int Width; - int Height; -} lblFrameCountObject; - -typedef struct -{ - boolean Checked; -} menBorderObject; - -typedef struct -{ - boolean Checked; -} menPanelObject; - -typedef struct -{ - boolean Checked; -} menAutoScrollObject; - -#endif /* VB_TYPES_H */ diff --git a/src/game_sp/vb_vars.c b/src/game_sp/vb_vars.c deleted file mode 100644 index 437ba023..00000000 --- a/src/game_sp/vb_vars.c +++ /dev/null @@ -1,20 +0,0 @@ -// ---------------------------------------------------------------------------- -// vb_vars.c -// ---------------------------------------------------------------------------- - -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - -vb_App App; -vb_Err Err; -MainFormObject MainForm; -lblFrameCountObject lblFrameCount; -cmbFileObject cmbFile; -shpProgressObject shpProgress; -menBorderObject menBorder; -menPanelObject menPanel; -menAutoScrollObject menAutoScroll; - -MainForm_picPane picPane; diff --git a/src/game_sp/vb_vars.h b/src/game_sp/vb_vars.h deleted file mode 100644 index 95690680..00000000 --- a/src/game_sp/vb_vars.h +++ /dev/null @@ -1,27 +0,0 @@ -// ---------------------------------------------------------------------------- -// vb_vars.h -// ---------------------------------------------------------------------------- - -#ifndef VB_VARS_H -#define VB_VARS_H - -extern vb_Screen Screen; -extern vb_Debug Debug; -extern vb_Err Err; -extern vb_App App; - -extern DemoBufferObject VB_OBJECT_SELF; - -extern MainFormObject MainForm; -extern cmbFileObject cmbFile; -extern shpProgressObject shpProgress; -extern lblFrameCountObject lblFrameCount; -extern menBorderObject menBorder; -extern menPanelObject menPanel; -extern menAutoScrollObject menAutoScroll; - -extern MainForm_picPane picPane; - -extern int hWnd; - -#endif /* VB_VARS_H */ -- 2.34.1