From 35b995abd3183999201d9581f7674de1475dc169 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 17 Mar 2010 00:54:20 +0100 Subject: [PATCH] rnd-20100317-1-src * continued code cleanup of native Supaplex game engine --- ChangeLog | 3 + src/conftime.h | 2 +- src/game_sp/DDScrollBuffer.c | 38 +--- src/game_sp/DDScrollBuffer.h | 1 - src/game_sp/DDSpriteBuffer.c | 14 +- src/game_sp/DDSpriteBuffer.h | 1 - src/game_sp/Demo.c | 7 - src/game_sp/Demo.h | 12 -- src/game_sp/Display.c | 7 +- src/game_sp/Display.h | 5 +- src/game_sp/Globals.c | 106 +--------- src/game_sp/Globals.h | 23 +- src/game_sp/InitGameConditions.c | 41 ++-- src/game_sp/MainForm.c | 174 +++++---------- src/game_sp/MainGameLoop.c | 10 +- src/game_sp/MainGameLoop.h | 2 +- src/game_sp/Murphy.c | 351 +------------------------------ src/game_sp/Murphy.h | 14 +- src/game_sp/file.c | 85 +------- src/game_sp/init.c | 11 - 20 files changed, 119 insertions(+), 788 deletions(-) delete mode 100644 src/game_sp/Demo.c delete mode 100644 src/game_sp/Demo.h diff --git a/ChangeLog b/ChangeLog index 7b43d771..bbe4d3ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-03-16 + * continued code cleanup of native Supaplex game engine + 2010-03-15 * continued code cleanup of native Supaplex game engine diff --git a/src/conftime.h b/src/conftime.h index 57960484..38aa374c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-03-16 01:16" +#define COMPILE_DATE_STRING "2010-03-17 00:53" diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index 816127b4..48710ace 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -7,10 +7,8 @@ #include -long mWidth, mHeight; long mScrollX, mScrollY; long mScrollX_last, mScrollY_last; -long mDestXOff, mDestYOff; long ScreenBuffer[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; @@ -280,22 +278,13 @@ void BackToFront_SP(void) scrolling_last = scrolling; } -void DDScrollBuffer_Blt() -{ - BackToFront_SP(); -} - void DDScrollBuffer_ScrollTo(int X, int Y) { if (NoDisplayFlag) return; - X = X / Stretch; - Y = Y / Stretch; - mScrollX = X; - mScrollY = Y; - ScrollX = mScrollX; - ScrollY = mScrollY; + ScrollX = mScrollX = X; + ScrollY = mScrollY = Y; ScrollPlayfieldIfNeeded(); } @@ -307,8 +296,6 @@ void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) if (NoDisplayFlag) return; - X = X / Stretch; - Y = Y / Stretch; dx = X - mScrollX; dY = Y - mScrollY; @@ -321,10 +308,8 @@ void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) else r = 1; - mScrollX = mScrollX + dx * r; - mScrollY = mScrollY + dY * r; - ScrollX = mScrollX; - ScrollY = mScrollY; + ScrollX = mScrollX = mScrollX + dx * r; + ScrollY = mScrollY = mScrollY + dY * r; ScrollPlayfieldIfNeeded(); } @@ -344,8 +329,7 @@ void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) return; AlreadyRunning = True; - X = X / Stretch; - Y = Y / Stretch; + dx = X - mScrollX; dY = Y - mScrollY; maxD = (Abs(dx) < Abs(dY) ? Abs(dY) : Abs(dx)); @@ -364,16 +348,12 @@ void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) for (T = (double)tStep; T <= (double)1; T += tStep) { - mScrollX = oldX + T * dx; - mScrollY = oldY + T * dY; - ScrollX = mScrollX; - ScrollY = mScrollY; + ScrollX = mScrollX = oldX + T * dx; + ScrollY = mScrollY = oldY + T * dY; } - mScrollX = X; - mScrollY = Y; - ScrollX = mScrollX; - ScrollY = mScrollY; + ScrollX = mScrollX = X; + ScrollY = mScrollY = Y; AlreadyRunning = False; diff --git a/src/game_sp/DDScrollBuffer.h b/src/game_sp/DDScrollBuffer.h index b3ac17e5..78c6e563 100644 --- a/src/game_sp/DDScrollBuffer.h +++ b/src/game_sp/DDScrollBuffer.h @@ -20,7 +20,6 @@ extern void InitScrollPlayfield(); extern void UpdatePlayfield(); extern void RestorePlayfield(); -extern void DDScrollBuffer_Blt(); extern void DDScrollBuffer_ScrollTo(int X, int Y); extern void DDScrollBuffer_ScrollTowards(int X, int Y, double Step); extern void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS); diff --git a/src/game_sp/DDSpriteBuffer.c b/src/game_sp/DDSpriteBuffer.c index ac5287db..863aac39 100644 --- a/src/game_sp/DDSpriteBuffer.c +++ b/src/game_sp/DDSpriteBuffer.c @@ -5,18 +5,6 @@ #include "DDSpriteBuffer.h" -long mXSpriteCount, mYSpriteCount; -long mSpriteWidth, mSpriteHeight; -long mDestXOff, mDestYOff; - -void DDSpriteBuffer_Init() -{ - mSpriteWidth = TILEX; - mSpriteHeight = TILEY; - mXSpriteCount = 16; - mYSpriteCount = 16; -} - static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY) { int scx = (mScrollX_last < 0 ? 0 : mScrollX_last); @@ -37,7 +25,7 @@ static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY) return; BlitBitmap(bitmap, screenBitmap, SpriteX, SpriteY, - mSpriteWidth, mSpriteHeight, sx, sy); + TILEX, TILEY, sx, sy); } void DDSpriteBuffer_BltImg(int pX, int pY, int graphic, int sync_frame) diff --git a/src/game_sp/DDSpriteBuffer.h b/src/game_sp/DDSpriteBuffer.h index c9e8747a..9872f576 100644 --- a/src/game_sp/DDSpriteBuffer.h +++ b/src/game_sp/DDSpriteBuffer.h @@ -8,7 +8,6 @@ #include "global.h" -extern void DDSpriteBuffer_Init(); extern void DDSpriteBuffer_BltImg(int pX, int pY, int graphic, int sync_frame); #endif /* DDSPRITEBUFFER_H */ diff --git a/src/game_sp/Demo.c b/src/game_sp/Demo.c deleted file mode 100644 index c9ed3917..00000000 --- a/src/game_sp/Demo.c +++ /dev/null @@ -1,7 +0,0 @@ -// ---------------------------------------------------------------------------- -// Demo.c -// ---------------------------------------------------------------------------- - -#include "Demo.h" - - diff --git a/src/game_sp/Demo.h b/src/game_sp/Demo.h deleted file mode 100644 index 339a17dd..00000000 --- a/src/game_sp/Demo.h +++ /dev/null @@ -1,12 +0,0 @@ -// ---------------------------------------------------------------------------- -// Demo.h -// ---------------------------------------------------------------------------- - -#ifndef DEMO_H -#define DEMO_H - -#include "global.h" - - - -#endif /* DEMO_H */ diff --git a/src/game_sp/Display.c b/src/game_sp/Display.c index 156b828d..8cd55484 100644 --- a/src/game_sp/Display.c +++ b/src/game_sp/Display.c @@ -7,12 +7,11 @@ int ScreenScrollXPos, ScreenScrollYPos; -int ShowPanel; int ExplosionShake; boolean NoDisplayFlag; -long DisplayMinX, DisplayMaxX, DisplayWidth; -long DisplayMinY, DisplayMaxY, DisplayHeight; +long DisplayMinX, DisplayMaxX; +long DisplayMinY, DisplayMaxY; void subDisplayLevel() @@ -50,7 +49,7 @@ void ScrollTowards(int X, int Y) Y = Max(Y, ScrollMinY); Y = Min(Y, ScrollMaxY); - DDScrollBuffer_ScrollTowards(X, Y, 2 * Stretch * ZoomFactor); + DDScrollBuffer_ScrollTowards(X, Y, 2 * ZoomFactor); } void SoftScrollTo(int X, int Y, long TimeMS, int FPS) diff --git a/src/game_sp/Display.h b/src/game_sp/Display.h index a6bd3683..2fbc4a2a 100644 --- a/src/game_sp/Display.h +++ b/src/game_sp/Display.h @@ -10,12 +10,11 @@ extern int ScreenScrollXPos, ScreenScrollYPos; -extern int ShowPanel; extern int ExplosionShake; extern boolean NoDisplayFlag; -extern long DisplayMinX, DisplayMaxX, DisplayWidth; -extern long DisplayMinY, DisplayMaxY, DisplayHeight; +extern long DisplayMinX, DisplayMaxX; +extern long DisplayMinY, DisplayMaxY; extern void subDisplayLevel(); extern void ScrollTo(int, int); diff --git a/src/game_sp/Globals.c b/src/game_sp/Globals.c index 82d3a014..91a5296e 100644 --- a/src/game_sp/Globals.c +++ b/src/game_sp/Globals.c @@ -5,25 +5,20 @@ #include "Globals.h" -void ReadLevel(); - -int LevelNumber; boolean LevelLoaded; boolean DemoAvailable; boolean menBorder; -int FieldWidth; // = 60 -int FieldHeight; // = 24 -int HeaderSize; // = 96 +int FieldWidth; // standard size = 60 +int FieldHeight; // standard size = 24 +int HeaderSize; // standard size = 96 int FieldMax, LevelMax; long FileMax; int *PlayField16; byte *PlayField8; byte *DisPlayField; -// Public DisplayMin%, DisplayMax%, DisplayWidth%, DisplayHeight% - int TimerVar; #if 1 short RandomSeed; @@ -35,99 +30,9 @@ 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 -// --- const int fiBase = 2; // &H02 base -// --- const int fiMurphy = 3; // &H03 Murphy -// --- const int fiInfotron = 4; // &H04 infotron -// --- const int fiRAM = 5; // &H05 small RAM chip -// --- const int fiHardWare = 6; // &H06 hardware (square, standard pyramid shape) -// --- const int fiExit = 7; // &H07 exit -// --- const int fiOrangeDisk = 8; // &H08 brown/orange utility disk -// --- const int fiPortRight = 9; // &H09 port 1 left to right -// --- const int fiPortDown = 10; // &H0A port 1 up to down -// --- const int fiPortLeft = 11; // &H0B port 1 right to left -// --- const int fiPortUp = 12; // &H0C port 1 down to up -// --- const int fiSpPortRight = 13; // &H0D port 2 left to right (gravity change) -// --- const int fiSpPortDown = 14; // &H0E port 2 up to down (gravity change) -// --- const int fiSpPortLeft = 15; // &H0F port 2 right to left (gravity change) -// --- const int fiSpPortUp = 16; // &H10 port 2 down to up (gravity change) -// --- const int fiSnikSnak = 17; // &H11 snik snak -// --- const int fiYellowDisk = 18; // &H12 yellow utility disk -// --- const int fiTerminal = 19; // &H13 terminal -// --- const int fiRedDisk = 20; // &H14 red utility disk -// --- const int fiPortUpAndDown = 21; // &H15 vertical port -// --- const int fiPortLeftAndRight = 22; // &H16 horizontal port -// --- const int fiPortAllDirections = 23; // &H17 horizontal + vertical port -// --- const int fiElectron = 24; // &H18 electron -// --- const int fiBug = 25; // &H19 bug -// --- const int fiRAMLeft = 26; // &H1A horizontal RAM chip, left (pin 1) -// --- const int fiRAMRight = 27; // &H1B horizontal RAM chip, right -// --- const int fiHWFirst = 28; // &H1C hardware (radial blue circular cap + coloured shapes) - -// Public Const fiHW1% = 29 ' 29 = 1D hardware (green signal lamp) -// Public Const fiHW2% = 30 ' 30 = 1E hardware (blue signal lamp) -// Public Const fiHW3% = 31 ' 31 = 1F hardware (red signal lamp) -// Public Const fiHW4% = 32 ' 32 = 20 hardware (yellow/black diagonal stripes) -// Public Const fiHW5% = 33 ' 33 = 21 hardware (yellow resistor + blue + red shapes) -// Public Const fiHW6% = 34 ' 34 = 22 hardware (horizontal red capacitor + smd shape) -// Public Const fiHW7% = 35 ' 35 = 23 hardware (red + yellow + blue horizontal resistors) -// Public Const fiHW8% = 36 ' 36 = 24 hardware (3 red vertical resistors) -// --- const int fiHWLast = 37; // 37 = 25 hardware (3 yellow horizontal resistors) -// --- const int fiRAMTop = 38; // 38 = 26 vertical RAM chip, top (pin 1) -// --- const int fiRAMBottom = 39; // 39 = 27 vertical RAM chip, bottom - -// Specials to experiment with ... -// --- const int fiWallSpace = 40; // 40 = 28 invisible wall (can explode, zonks don't roll off) -// --- const int fiHWTrash1 = 41; // 41 = 29 hardware trash -// --- const int fiHWTrash2 = 42; // 42 = 2A hardware trash -// --- const int fiHWMurphy = 43; // 43 = 2B hardware inverted Murphy ... (maybe nice for use?) - -// --- const int fiExplosion = 0x1F; - -// --- const int keyNone = 0; -// --- const int keyUp = 1; -// --- const int keyLeft = 2; -// --- const int keyDown = 3; -// --- const int keyRight = 4; -// --- const int keySpaceUp = 5; -// --- const int keySpaceLeft = 6; -// --- const int keySpaceDown = 7; -// --- const int keySpaceRight = 8; -// --- const int keySpace = 9; - -#if 0 -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 }; -int aniFramesInfotronRollRight[] = { 206, 205, 204, 203, 202, 201, 200, 4 }; -int aniFramesInfotronRollLeft[] = { 200, 201, 202, 203, 204, 205, 206, 4 }; -int aniFramesSnikSnak[] = { 121, 122, 123, 124, 125, 126, 127, 120, 121 }; -int aniFramesElectron[] = { 144, 145, 146, 147, 148, 149, 150, 151, 144 }; -int aniFramesExplosion[] = { 3, 103, 104, 105, 106, 107, 108, 109, 0 }; -int aniFramesTouchBase[] = { 80, 81, 82, 83, 84, 85, 86, 0, -1 }; -int aniFramesTouchInfotron[] = { 87, 88, 89, 91, 92, 93, 0, -1 }; // Only seven frames!!!! -int aniFramesTouchRedDisk[] = { 96, 97, 98, 99, 100, 101, 102, 0, -1 }; -int aniFramesMurphyExit[] = { 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 }; -int aniFramesMurphyEatLeft[] = { 176, 177, 178, 179, 180, 181, 182, 183, -1 }; -int aniFramesMurphyEatRight[] = { 184, 185, 186, 187, 188, 189, 190, 191, -1 }; -int aniFramesMurphyEatUpLeft[] = { 183, 182, 181, 180, 179, 178, 177, 176, -1 }; -int aniFramesMurphyEatUpRight[] = { 191, 190, 189, 188, 187, 186, 185, 184, -1 }; - // aniFramesMurphyEatRightRedDisk = { 184, 184, 185, 186, 187, 188, 189, 190, 191, -1) '9 frames! -int aniFramesEatInfotronLeft[] = { 209, 211, 213, 215, 217, 219, 221, 223, -1 }; -int aniFramesEatInfotronRight[] = { 224, 226, 228, 230, 232, 234, 236, 238, -1 }; -int aniFramesSplitUpDown[] = { 3, 3, 3, 3, 3, 3, 3, 3, -1 }; -int aniFramesYellowDisk[] = { 18, 18, 18, 18, 18, 18, 18, 18, -1 }; -int aniFramesOrangeDisk[] = { 8, 8, 8, 8, 8, 8, 8, 8, -1 }; -int aniFramesRedDisk[] = { 20, -1 }; -#endif - int fiGraphic[] = { aniSpace, @@ -240,6 +145,7 @@ void InitGlobals() FieldMax = (FieldWidth * FieldHeight) + HeaderSize - 1; LevelMax = (FieldWidth * FieldHeight) - 1; bPlaying = False; + menBorder = False; } int GetSI(int X, int Y) @@ -267,7 +173,7 @@ int GetStretchY(int si) return StretchWidth * (si / FieldWidth); } -void ReadLevel() +void PrepareLevel() { copyInternalEngineVars_SP(); @@ -276,8 +182,6 @@ void ReadLevel() SetScrollEdges(); #endif - LevelNumber = level_nr; - LevelLoaded = True; } diff --git a/src/game_sp/Globals.h b/src/game_sp/Globals.h index 194f1b9d..330b5470 100644 --- a/src/game_sp/Globals.h +++ b/src/game_sp/Globals.h @@ -18,6 +18,7 @@ #define ZoomFactor (2) #define BaseWidth (ZoomFactor * 16) #define StretchWidth (ZoomFactor * 16) +#define TileSize (ZoomFactor * 16) #define TwoPixels (ZoomFactor * 2) @@ -68,12 +69,12 @@ #define fiRAMTop (38) #define fiRAMBottom (39) #define fiWallSpace (40) -#define fiHWTrash1 (41) -#define fiHWTrash2 (42) -#define fiHWMurphy (43) #define fiExplosion (0x1F) +#define fiFirst (0) +#define fiLast (40) + // ---------------------------------------------------------------------------- // graphics and animations (used at runtime to display the elements) @@ -142,7 +143,6 @@ #define aniMurphyYawn IMG_SP_MURPHY_BORING_1 #define aniPushLeft IMG_SP_MURPHY_PUSHING_LEFT #define aniPushRight IMG_SP_MURPHY_PUSHING_RIGHT -#define aniPushUpDown IMG_SP_MURPHY_PUSHING_RIGHT #define aniBugActivating IMG_SP_BUGGY_BASE_ACTIVATING #define aniBugDeactivating IMG_SP_BUGGY_BASE_ACTIVATING @@ -200,17 +200,6 @@ #define imgFrameVertical IMG_SP_FRAME_VERTICAL -extern int aniFramesBug[], aniFramesZonkRollRight[], aniFramesZonkRollLeft[]; -extern int aniFramesEatInfotronLeft[], aniFramesEatInfotronRight[]; -extern int aniFramesInfotronRollRight[], aniFramesInfotronRollLeft[]; -extern int aniFramesMurphyEatLeft[], aniFramesMurphyEatRight[]; -extern int aniFramesMurphyEatUpLeft[], aniFramesMurphyEatUpRight[], aniFramesSplitUpDown[]; -extern int aniFramesMurphyExit[]; -extern int aniFramesSnikSnak[], aniFramesElectron[], aniFramesExplosion[]; -extern int aniFramesTouchBase[], aniFramesTouchInfotron[], aniFramesTouchRedDisk[]; -extern int aniFramesYellowDisk[], aniFramesOrangeDisk[], aniFramesRedDisk[]; - - // ---------------------------------------------------------------------------- // input keys // ---------------------------------------------------------------------------- @@ -284,7 +273,7 @@ extern int GetX(int si); extern int GetY(int si); extern void InitGlobals(); -extern void ReadLevel(); +extern void PrepareLevel(); extern int getSequenceLength(int sequence); extern boolean isSnappingSequence(int sequence); @@ -313,14 +302,12 @@ extern int FieldMax, LevelMax; extern int FieldWidth; extern int FreezeZonks; extern int HeaderSize; -extern int LevelNumber; extern int TimerVar; extern short RandomSeed; extern long FileMax; extern LevelInfoType LInfo; -extern float Stretch; extern int ScrollMinX, ScrollMaxX, ScrollMinY, ScrollMaxY; extern int ScrollX, ScrollY; diff --git a/src/game_sp/InitGameConditions.c b/src/game_sp/InitGameConditions.c index 73c6ec11..dd210b1c 100644 --- a/src/game_sp/InitGameConditions.c +++ b/src/game_sp/InitGameConditions.c @@ -27,7 +27,6 @@ void subInitGameConditions() TimerVar = 0; - EnterRepeatCounter = 0; // restart Enter repeat counter SnikSnaksElectronsFrozen = 0; // Snik-Snaks and Electrons move! SplitMoveFlag = 0; // Reset Split-through-ports @@ -45,7 +44,7 @@ void InitMurphyPos() { int si; - for (si = 0; si <= LevelMax - 1; si++) + for (si = 0; si < LevelMax; si++) if (PlayField16[si] == fiMurphy) break; @@ -56,18 +55,12 @@ void InitMurphyPos() void InitMurphyPosB(int si) { - MurphyYPos = GetStretchY(si) / Stretch; - MurphyXPos = GetStretchX(si) / Stretch; - - MurphyScreenXPos = GetStretchX(si); // Murphy's screen x-position - MurphyScreenYPos = GetStretchY(si); // Murphy's screen y-position + MurphyScreenXPos = MurphyXPos = GetStretchX(si); // Murphy's screen x-position + MurphyScreenYPos = MurphyYPos = GetStretchY(si); // Murphy's screen y-position // To Do: draw Murphy in location ax DDSpriteBuffer_BltImg(MurphyScreenXPos, MurphyScreenYPos, aniMurphy, 0); - MurphyScreenXPos = MurphyScreenXPos / Stretch; - MurphyScreenYPos = MurphyScreenYPos / Stretch; - subCalculateScreenScrollPos(); // calculate screen start addrs if (AutoScrollFlag) @@ -238,32 +231,28 @@ void subFetchAndInitLevelB() void subFetchAndInitLevelA() { - GameBusyFlag = 0; // restore scissors too - - subFetchAndInitLevel(); // Fetch and initialize a level + GameBusyFlag = 0; // restore scissors too + subFetchAndInitLevel(); // fetch and initialize a level + GameBusyFlag = 1; // no free screen write - GameBusyFlag = 1; // no free screen write - - DemoKeyCode = 0; // delete last demo key! + DemoKeyCode = 0; // delete last demo key! } void subFetchAndInitLevel() { int InfoCountInLevel; - ReadLevel(); // Read LEVELS.DAT - - GameBusyFlag = -GameBusyFlag; // make <>1 - - InfoCountInLevel = subConvertToEasySymbols(); // Convert to easy symbols + PrepareLevel(); // initialize level data - GameBusyFlag = -GameBusyFlag; // restore + GameBusyFlag = -GameBusyFlag; // make != 1 + InfoCountInLevel = subConvertToEasySymbols(); // convert to easy symbols + GameBusyFlag = -GameBusyFlag; // restore - subDisplayLevel(); // Paint (Init) game field + subDisplayLevel(); // paint (init) game field - ResetInfotronsNeeded(InfoCountInLevel); // and reset Infotron count + ResetInfotronsNeeded(InfoCountInLevel); // and reset Infotron count - subInitGameConditions(); // Init game conditions (vars) + subInitGameConditions(); // init game conditions (vars) - InitMurphyPos(); // Locate Murphy + screen pos + InitMurphyPos(); // locate Murphy + screen pos } diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index f169bac3..d4c3545e 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -6,15 +6,12 @@ static void DrawFrame(int Delta); -static void ReStretch(float NewStretch); -static void picViewPort_Resize(); +static void ReStretch(); void DrawField(int X, int Y); void DrawFieldAnimated(int X, int Y); void DrawFieldNoAnimated(int X, int Y); -boolean Loaded; - void DrawFrameIfNeeded() { DrawFrame(0); @@ -30,9 +27,6 @@ void DisplayLevel() { int X, Y; - if (! Loaded) - return; - if (! LevelLoaded) return; @@ -44,60 +38,31 @@ void DisplayLevel() SetDisplayRegion(); #endif - DrawFrame(0); - - /* !!! CHECK THIS !!! */ -#if 1 - if (! menBorder) - DrawFrame(1); -#endif + DrawFrameIfNeeded(); if (bPlaying) { -#if 0 - printf("::: MainForm.c: DisplayLevel(): [%ld, %ld, %ld, %ld] [%d, %d]...\n", - DisplayMinX, DisplayMinY, DisplayMaxX, DisplayMaxY, - FieldWidth, FieldHeight); -#endif - for (Y = DisplayMinY; Y <= DisplayMaxY; Y++) - { for (X = DisplayMinX; X <= DisplayMaxX; X++) - { DrawFieldNoAnimated(X, Y); - } - } for (Y = DisplayMinY; Y <= DisplayMaxY; Y++) - { for (X = DisplayMinX; X <= DisplayMaxX; X++) - { DrawFieldAnimated(X, Y); - } - } - } else { for (Y = DisplayMinY; Y <= DisplayMaxY; Y++) - { for (X = DisplayMinX; X <= DisplayMaxX; X++) - { DrawField(X, Y); - } - } } } void Form_Load() { - Loaded = False; - InitGlobals(); - Loaded = True; - - ReStretch(Stretch); + ReStretch(); } static void DrawFrame(int Delta) @@ -108,10 +73,12 @@ static void DrawFrame(int 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); @@ -152,11 +119,9 @@ void SetDisplayRegion() if (! menBorder) { DisplayMinX = 1; - DisplayMaxX = FieldWidth - 2; - DisplayWidth = FieldWidth; DisplayMinY = 1; + DisplayMaxX = FieldWidth - 2; DisplayMaxY = FieldHeight - 2; - DisplayHeight = FieldHeight; if (LevelLoaded) DrawFrame(1); @@ -164,11 +129,9 @@ void SetDisplayRegion() else { DisplayMinX = 0; - DisplayMaxX = FieldWidth - 1; - DisplayWidth = FieldWidth + 2; DisplayMinY = 0; + DisplayMaxX = FieldWidth - 1; DisplayMaxY = FieldHeight - 1; - DisplayHeight = FieldHeight + 2; if (LevelLoaded) RestoreFrame(); @@ -181,7 +144,7 @@ void menPlay_Click() subFetchAndInitLevelB(); - ReStretch(Stretch); + ReStretch(); subMainGameLoop_Init(); @@ -194,27 +157,16 @@ void menPlay_Click() subFetchAndInitLevel(); } -static void ReStretch(float NewStretch) +static void ReStretch() { - long BW2, LW, LH; - - if (! Loaded) + if (LevelLoaded) { - Stretch = NewStretch; - - return; - } + SetDisplayRegion(); - Stretch = NewStretch; + SetScrollEdges(); - BW2 = StretchWidth / 2; - LW = (FieldWidth + 2) * BaseWidth; // StretchWidth - LH = (FieldHeight + 2) * BaseWidth; // StretchWidth + ScrollTo(ScrollX, ScrollY); - if (Loaded && LevelLoaded) - { - SetDisplayRegion(); - picViewPort_Resize(); DisplayLevel(); } @@ -225,48 +177,39 @@ static void ReStretch(float NewStretch) void SetScrollEdges() { - ScrollMinX = (int)(DisplayMinX - 0.5) * Stretch * BaseWidth; - ScrollMinY = (int)(DisplayMinY - 0.5) * Stretch * BaseWidth; - ScrollMaxX = (int)(DisplayMaxX + 1.5) * Stretch * BaseWidth - SXSIZE; - ScrollMaxY = (int)(DisplayMaxY + 1.5) * Stretch * BaseWidth - SYSIZE; + ScrollMinX = (int)(DisplayMinX - 0.5) * BaseWidth; + ScrollMinY = (int)(DisplayMinY - 0.5) * BaseWidth; + ScrollMaxX = (int)(DisplayMaxX + 1.5) * BaseWidth - SXSIZE; + ScrollMaxY = (int)(DisplayMaxY + 1.5) * BaseWidth - SYSIZE; } void DrawField(int X, int Y) { - int Tmp, tsi; + int tsi = GetSI(X, Y); + int Tmp = LowByte(PlayField16[tsi]); - tsi = GetSI(X, Y); - Tmp = LowByte(PlayField16[tsi]); - if (Tmp > 40) - Tmp = 0; + if (Tmp < fiFirst || Tmp > fiLast) + Tmp = fiSpace; - if (Tmp == fiRAM || Tmp == fiHardWare) + if (Tmp == fiRAM || + Tmp == fiHardWare || + Tmp == fiBug || + Tmp == fiWallSpace) Tmp = DisPlayField[tsi]; - if (Tmp == fiBug || Tmp == 40) - Tmp = DisPlayField[tsi]; - -#if 1 - if (Tmp >= 0 && Tmp <= 40) - { - subCopyImageToScreen(tsi, fiGraphic[Tmp]); + subCopyImageToScreen(tsi, fiGraphic[Tmp]); -#if 1 - if (Tmp != fiSpace && Tmp != fiSnikSnak && Tmp != fiElectron) - GfxGraphic[X][Y] = fiGraphic[Tmp]; -#endif - } -#else - DDSpriteBuffer_BltEx(StretchWidth * X, StretchWidth * Y, Tmp); -#endif + if (Tmp != fiSpace && + Tmp != fiSnikSnak && + Tmp != fiElectron) + GfxGraphic[X][Y] = fiGraphic[Tmp]; } void DrawFieldAnimated(int X, int Y) { - int Tmp, tsi; + int tsi = GetSI(X, Y); + int Tmp = LowByte(PlayField16[tsi]); - tsi = GetSI(X, Y); - Tmp = LowByte(PlayField16[tsi]); switch (Tmp) { case fiSnikSnak: @@ -278,23 +221,15 @@ void DrawFieldAnimated(int X, int Y) break; default: - // If 40 < Tmp Then Tmp = 0 - // If Tmp = fiRAM Or Tmp = fiHardWare Then Tmp = DisPlayField(tsi) - // If Tmp = fiBug Or Tmp = 40 Then Tmp = DisPlayField(tsi) - // If EditFlag Then - // If fiOrangeDisk < Tmp And Tmp < fiSnikSnak Then Tmp = DisPlayField(tsi) - // End If - // DDSpriteBuffer_BltEx StretchWidth * X, StretchWidth * Y, Tmp break; } } void DrawFieldNoAnimated(int X, int Y) { - int Tmp, tsi; + int tsi = GetSI(X, Y); + int Tmp = LowByte(PlayField16[tsi]); - tsi = GetSI(X, Y); - Tmp = LowByte(PlayField16[tsi]); switch (Tmp) { case fiSnikSnak: @@ -306,29 +241,25 @@ void DrawFieldNoAnimated(int X, int Y) break; default: - if (Tmp > 40) - Tmp = 0; - - if (Tmp == fiRAM || Tmp == fiHardWare) - Tmp = DisPlayField[tsi]; +#if 1 + DrawField(X, Y); +#else + if (Tmp < fiFirst || Tmp > fiLast) + Tmp = fiSpace; - if (Tmp == fiBug || Tmp == 40) - Tmp = DisPlayField[tsi]; + if (Tmp == fiRAM || + Tmp == fiHardWare || + Tmp == fiBug || + Tmp == fiWallSpace) + Tmp = DisPlayField[tsi]; -#if 1 - if (Tmp >= 0 && Tmp <= 40) - { - subCopyImageToScreen(tsi, fiGraphic[Tmp]); + subCopyImageToScreen(tsi, fiGraphic[Tmp]); -#if 1 - if (Tmp != fiSpace && Tmp != fiSnikSnak && Tmp != fiElectron) - GfxGraphic[X][Y] = fiGraphic[Tmp]; -#endif - } -#else - DDSpriteBuffer_BltEx(StretchWidth * X, StretchWidth * Y, Tmp); + if (Tmp != fiSpace && + Tmp != fiSnikSnak && + Tmp != fiElectron) + GfxGraphic[X][Y] = fiGraphic[Tmp]; #endif - break; } } @@ -337,10 +268,3 @@ void DrawImage(int X, int Y, int graphic) { DDSpriteBuffer_BltImg(StretchWidth * X, StretchWidth * Y, graphic, 0); } - -static void picViewPort_Resize() -{ - SetScrollEdges(); - - ScrollTo(ScrollX, ScrollY); -} diff --git a/src/game_sp/MainGameLoop.c b/src/game_sp/MainGameLoop.c index a82c8732..145c0436 100644 --- a/src/game_sp/MainGameLoop.c +++ b/src/game_sp/MainGameLoop.c @@ -6,7 +6,7 @@ boolean bPlaying; -int LeadOutCounter, EnterRepeatCounter; +int LeadOutCounter; int ExitToMenuFlag; boolean AutoScrollFlag; @@ -98,7 +98,7 @@ locExitMainGameLoop: void subCalculateScreenScrollPos() { - int ax, Ay; + int ax, ay; #if 1 int jump_pos = TILEX / 2; @@ -124,9 +124,9 @@ void subCalculateScreenScrollPos() { ax = SXSIZE / 2; - Ay = SYSIZE / 2; + ay = SYSIZE / 2; } - ScreenScrollXPos = Stretch * (MurphyScreenXPos + TILEX / 2) - ax; - ScreenScrollYPos = Stretch * (MurphyScreenYPos + TILEY / 2) - Ay; + ScreenScrollXPos = (MurphyScreenXPos + TILEX / 2) - ax; + ScreenScrollYPos = (MurphyScreenYPos + TILEY / 2) - ay; } diff --git a/src/game_sp/MainGameLoop.h b/src/game_sp/MainGameLoop.h index ee7c4de4..3ce85d27 100644 --- a/src/game_sp/MainGameLoop.h +++ b/src/game_sp/MainGameLoop.h @@ -11,7 +11,7 @@ extern boolean AutoScrollFlag; extern boolean bPlaying; extern int ExitToMenuFlag; -extern int LeadOutCounter, EnterRepeatCounter; +extern int LeadOutCounter; extern void subMainGameLoop_Init(); extern void subMainGameLoop_Main(byte, boolean); diff --git a/src/game_sp/Murphy.c b/src/game_sp/Murphy.c index 2d939a31..85e6e112 100644 --- a/src/game_sp/Murphy.c +++ b/src/game_sp/Murphy.c @@ -32,10 +32,7 @@ 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 dx1 = 0; // 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 static int SeqPos = 0; // index into dx() @@ -88,10 +85,6 @@ void subAnimateMurphy(int *si) if (bl != 0) // a key was pressed! goto locKeyPressed5FCF; -#if 0 - printf("::: Murphy.c: !!! %d [%d]\n", DemoKeyCode, GravityFlag); -#endif - RedDiskReleaseFlag = 1; if (ScratchGravity != 0) // gravity pulls & space below?'-> force Space up to down { @@ -669,11 +662,7 @@ 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; @@ -683,11 +672,7 @@ 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; @@ -698,11 +683,7 @@ loc_g_6312: // ========================================================================== loc_g_6341: -#if 0 - dx = aniFramesMurphyEatLeft; -#else dx1 = aniMurphyMoveLeft; -#endif PlayField16[*si - 1] = 0x203; PlayField16[*si] = 0x300; *si = *si - 1; @@ -713,11 +694,7 @@ 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; @@ -728,11 +705,7 @@ loc_g_6364: // ========================================================================== loc_g_6399: -#if 0 - dx = aniFramesMurphyEatRight; -#else dx1 = aniMurphyMoveRight; -#endif PlayField16[*si + 1] = 0x403; PlayField16[*si] = 0x300; *si = *si + 1; @@ -756,17 +729,9 @@ loc_g_63C2: // ========================================================================== loc_g_63D3: -#if 1 subSoundFX(*si, fiBase, actDigging); -#else - 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; @@ -790,17 +755,9 @@ loc_g_640B: // ========================================================================== loc_g_641C: -#if 1 subSoundFX(*si, fiBase, actDigging); -#else - subSoundFXBase(); -#endif -#if 0 - dx = aniFramesMurphyEatLeft; -#else dx1 = aniMurphyDigLeft; -#endif PlayField16[*si - 1] = 0x203; PlayField16[*si] = 0x300; *si = *si - 1; @@ -824,17 +781,9 @@ loc_g_6448: // ========================================================================== loc_g_6459: -#if 1 subSoundFX(*si, fiBase, actDigging); -#else - 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; @@ -858,17 +807,9 @@ loc_g_6491: // ========================================================================== loc_g_64A2: -#if 1 subSoundFX(*si, fiBase, actDigging); -#else - subSoundFXBase(); -#endif -#if 0 - dx = aniFramesMurphyEatRight; -#else dx1 = aniMurphyDigRight; -#endif PlayField16[*si + 1] = 0x803; PlayField16[*si] = 0x300; *si = *si + 1; @@ -893,17 +834,9 @@ loc_g_64CE: loc_g_64DF: subCopyImageToScreen(*si, aniMurphyTouchUp); -#if 1 subSoundFX(*si, fiBase, actDigging); -#else - subSoundFXBase(); -#endif -#if 0 - dx = aniFramesTouchBase; -#else dx1 = aniTouchBase; -#endif dxPos = *si - FieldWidth; MovHighByte(&PlayField16[*si], 0x10); goto loc_StopNoSplit; @@ -927,17 +860,9 @@ loc_g_650C: loc_g_651D: subCopyImageToScreen(*si, aniMurphyTouchLeft); -#if 1 subSoundFX(*si, fiBase, actDigging); -#else - subSoundFXBase(); -#endif -#if 0 - dx = aniFramesTouchBase; -#else dx1 = aniTouchBase; -#endif dxPos = *si - 1; MovHighByte(&PlayField16[*si], 0x11); goto loc_StopNoSplit; @@ -961,17 +886,9 @@ loc_g_654A: loc_g_655B: subCopyImageToScreen(*si, aniMurphyTouchDown); -#if 1 subSoundFX(*si, fiBase, actDigging); -#else - subSoundFXBase(); -#endif -#if 0 - dx = aniFramesTouchBase; -#else dx1 = aniTouchBase; -#endif dxPos = *si + FieldWidth; MovHighByte(&PlayField16[*si], 0x12); goto loc_StopNoSplit; @@ -995,17 +912,9 @@ loc_g_6588: loc_g_6599: subCopyImageToScreen(*si, aniMurphyTouchRight); -#if 1 subSoundFX(*si, fiBase, actDigging); -#else - subSoundFXBase(); -#endif -#if 0 - dx = aniFramesTouchBase; -#else dx1 = aniTouchBase; -#endif dxPos = *si + 1; MovHighByte(&PlayField16[*si], 0x13); goto loc_StopNoSplit; @@ -1015,17 +924,9 @@ loc_g_6599: // ========================================================================== loc_g_65C6: -#if 1 subSoundFX(*si, fiInfotron, actCollecting); -#else - 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; @@ -1036,17 +937,9 @@ loc_g_65C6: // ========================================================================== loc_g_65FE: -#if 1 subSoundFX(*si, fiInfotron, actCollecting); -#else - subSoundFXInfotron(); -#endif -#if 0 - dx = aniFramesEatInfotronLeft; -#else dx1 = aniEatInfotronLeft; -#endif #if 0 dx2 = fiInfotron; dx2Step = -1; @@ -1062,17 +955,9 @@ loc_g_65FE: // ========================================================================== loc_g_662A: -#if 1 subSoundFX(*si, fiInfotron, actCollecting); -#else - 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; @@ -1083,17 +968,9 @@ loc_g_662A: // ========================================================================== loc_g_6662: -#if 1 subSoundFX(*si, fiInfotron, actCollecting); -#else - subSoundFXInfotron(); -#endif -#if 0 - dx = aniFramesEatInfotronRight; -#else dx1 = aniEatInfotronRight; -#endif #if 0 dx2 = fiInfotron; dx2Step = 1; @@ -1110,17 +987,9 @@ loc_g_6662: loc_g_668E: subCopyImageToScreen(*si, aniMurphyTouchUp); -#if 1 subSoundFX(*si, fiInfotron, actCollecting); -#else - subSoundFXInfotron(); -#endif -#if 0 - dx = aniFramesTouchInfotron; -#else dx1 = aniTouchInfotron; -#endif MovHighByte(&PlayField16[*si], 0x14); MovHighByte(&PlayField16[*si - FieldWidth], 0xFF); goto loc_StopNoSplit; @@ -1131,17 +1000,9 @@ loc_g_668E: loc_g_66C0: subCopyImageToScreen(*si, aniMurphyTouchLeft); -#if 1 subSoundFX(*si, fiInfotron, actCollecting); -#else - subSoundFXInfotron(); -#endif -#if 0 - dx = aniFramesTouchInfotron; -#else dx1 = aniTouchInfotron; -#endif MovHighByte(&PlayField16[*si], 0x15); MovHighByte(&PlayField16[*si - 1], 0xFF); goto loc_StopNoSplit; @@ -1152,17 +1013,9 @@ loc_g_66C0: loc_g_66F2: subCopyImageToScreen(*si, aniMurphyTouchDown); -#if 1 subSoundFX(*si, fiInfotron, actCollecting); -#else - subSoundFXInfotron(); -#endif -#if 0 - dx = aniFramesTouchInfotron; -#else dx1 = aniTouchInfotron; -#endif MovHighByte(&PlayField16[*si], 0x16); MovHighByte(&PlayField16[*si + FieldWidth], 0xFF); goto loc_StopNoSplit; @@ -1173,17 +1026,9 @@ loc_g_66F2: loc_g_6724: subCopyImageToScreen(*si, aniMurphyTouchRight); -#if 1 subSoundFX(*si, fiInfotron, actCollecting); -#else - subSoundFXInfotron(); -#endif -#if 0 - dx = aniFramesTouchInfotron; -#else dx1 = aniTouchInfotron; -#endif MovHighByte(&PlayField16[*si], 0x17); MovHighByte(&PlayField16[*si + 1], 0xFF); goto loc_StopNoSplit; @@ -1203,25 +1048,17 @@ loc_g_6756: #if 1 if (!game_sp.LevelSolved) - printf("::: Murphy.c: !!!!!!!!!! LEVEL %d SOLVED !!!!!!!!!!\n",LevelNumber); + printf("::: Murphy.c: !!!!!!!!!! LEVEL %d SOLVED !!!!!!!!!!\n", level_nr); #endif #if 1 game_sp.LevelSolved = TRUE; #endif -#if 1 subSoundFX(*si, fiExit, actPassing); -#else - subSoundFXExit(); -#endif LeadOutCounter = 0x40; // quit: start lead-out -#if 0 - dx = aniFramesMurphyExit; -#else dx1 = aniMurphyExit; -#endif MovHighByte(&PlayField16[*si], 0xD); goto loc_StopNoSplit; @@ -1236,11 +1073,7 @@ 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; @@ -1262,11 +1095,7 @@ 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; @@ -1398,11 +1227,7 @@ 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; @@ -1416,11 +1241,7 @@ 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; @@ -1434,11 +1255,7 @@ 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; @@ -1452,11 +1269,7 @@ 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; @@ -1471,11 +1284,7 @@ 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; @@ -1485,11 +1294,7 @@ 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; @@ -1500,11 +1305,7 @@ 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; @@ -1514,12 +1315,8 @@ loc_g_69F7: // ========================================================================== loc_g_6A1F: -#if 0 - // dx = aniFramesMurphyEatRightRedDisk 'this sequence is 9 steps long! - dx = aniFramesMurphyEatRight; -#else + // dx = aniMurphyEatRightRedDisk 'this sequence is 9 steps long! dx1 = aniMurphyEatRight; -#endif // -------------------------------------------------------------------------- // BugFix // Table data_h_145A, pointed to by table data_h_105E, has a severe bug: @@ -1548,11 +1345,7 @@ 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; @@ -1562,11 +1355,7 @@ 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; @@ -1576,11 +1365,7 @@ 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; @@ -1590,11 +1375,7 @@ loc_g_6A80: // ========================================================================== loc_g_6A9C: -#if 0 - dx = aniFramesTouchRedDisk; -#else dx1 = aniTouchRedDisk; -#endif MovHighByte(&PlayField16[*si], 0x23); MovHighByte(&PlayField16[*si + 1], 3); @@ -1611,25 +1392,12 @@ loc_g_6AB8: return; PlayField16[*si - 2 * FieldWidth] = 0x1200; -#if 0 - subCopyImageToScreen(*si, aniPushRight); -#endif -#if 0 - dx = aniFramesYellowDisk; -#else dx1 = aniYellowDisk; -#endif dxPos = *si - FieldWidth; -#if 1 dx2 = (MurphyVarFaceLeft == 0 ? aniPushRight : aniPushLeft); -#else - dx2 = aniPushUpDown; -#endif dx2Step = FieldWidth; PlayField16[*si] = 0x2403; -#if 1 subCopyImageToScreen(*si, dx2); -#endif goto loc_MoveNoSplit; // ========================================================================== @@ -1642,11 +1410,7 @@ 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; @@ -1662,25 +1426,12 @@ loc_g_6B2A: return; PlayField16[*si + 2 * FieldWidth] = 0x1200; -#if 0 - subCopyImageToScreen(*si, aniPushRight); -#endif -#if 0 - dx = aniFramesYellowDisk; -#else dx1 = aniYellowDisk; -#endif dxPos = *si + FieldWidth; -#if 1 dx2 = (MurphyVarFaceLeft == 0 ? aniPushRight : aniPushLeft); -#else - dx2 = aniPushUpDown; -#endif dx2Step = -FieldWidth; PlayField16[*si] = 0x2703; -#if 1 subCopyImageToScreen(*si, dx2); -#endif goto loc_MoveNoSplit; // ========================================================================== @@ -1693,11 +1444,7 @@ 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; @@ -1714,11 +1461,7 @@ 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; @@ -1738,11 +1481,7 @@ 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; @@ -1775,7 +1514,6 @@ locProceedMovingMurphy: // proceed moving murphy MovingPictureSequencePhase = ax; // store for later if (ax == 0) // Sound effects -#if 1 { switch (HighByte(PlayField16[*si])) { @@ -1800,9 +1538,6 @@ locProceedMovingMurphy: // proceed moving murphy break; } } -#else - subSoundFXPush(); -#endif bl = HighByte(PlayField16[*si]); if (bl == 0xE) // Push Zonk to left @@ -1887,11 +1622,7 @@ loc_g_6C8F: StretchedSprites.BltEx(X, Y, dx[Tmp]); #endif -#if 1 if (!(dx2 < 0)) -#else - if (! dx2 < 0) -#endif { tPos = dxPos + dx2Step; X = GetStretchX(tPos); @@ -2386,12 +2117,8 @@ loc_g_716E: } else if (MovingPictureSequencePhase == 0x20) { -#if 1 // anxious murphy, dropping red disk subCopyImageToScreen(*si, aniMurphyDropping); -#else - subCopyFieldToScreen(*si, 43); // anxious murphy -#endif RedDiskReleasePhase = 1; } @@ -2669,11 +2396,7 @@ loc_g_747F: RedDiskReleasePhase = 2; RedDiskCount = RedDiskCount - 1; -#if 1 subSoundFX(*si, fiRedDisk, actDropping); -#else - subSoundFXPush(); // Sound effects -#endif } // subAnimateMurphy // ========================================================================== @@ -2770,76 +2493,24 @@ loc_g_753F: // The 10-port data base is at data_h_0D28, 10 entries of 6 bytes each: // (hi),(lo),(gravity),(freeze zonks),(freeze enemies),(unused) // ========================================================================== -int subSpPortTest(int si) -{ - int subSpPortTest; - - int i, cx, bx; -#if 1 - cx = LInfo.SpecialPortCount; // number of special ports +void subSpPortTest(int si) +{ + int i; - for (i = 0; i < cx; i++) + for (i = 0; i < LInfo.SpecialPortCount; i++) { -#if 1 - /* this assumes that PortLocation is stored as big endian */ - bx = LInfo.SpecialPort[i].PortLocation; -#else - /* this assumes that PortLocation is stored as little endian */ - bx = HighByte(LInfo.SpecialPort[i].PortLocation); - MovHighByte(&bx, LowByte(LInfo.SpecialPort[i].PortLocation)); -#endif - - if (bx / 2 == si) + if (LInfo.SpecialPort[i].PortLocation / 2 == si) { - GravityFlag = LInfo.SpecialPort[i].Gravity; - FreezeZonks = LInfo.SpecialPort[i].FreezeZonks; + GravityFlag = LInfo.SpecialPort[i].Gravity; + FreezeZonks = LInfo.SpecialPort[i].FreezeZonks; SnikSnaksElectronsFrozen = LInfo.SpecialPort[i].FreezeEnemies; - // RandomTime = RandomTime Xor RandomSeed 'is RandomTime used at all? no! - break; } } - -#else - - cx = LInfo.SpecialPortCount; // number of special ports - for (i = 1; i <= cx; i++) - { - { - bx = HighByte(LInfo.SpecialPort[i].PortLocation); - MovHighByte(&bx, LowByte(LInfo.SpecialPort[i].PortLocation)); - if (bx / 2 == si) - { - GravityFlag = LInfo.SpecialPort[i].Gravity; - FreezeZonks = LInfo.SpecialPort[i].FreezeZonks; - SnikSnaksElectronsFrozen = LInfo.SpecialPort[i].FreezeEnemies; - // RandomTime = RandomTime Xor RandomSeed 'is RandomTime used at all? no! - i = cx + 1; - } - } - } -#endif - - return subSpPortTest; -} // subSpPortTest - -#if 0 - -void subCopyFieldToScreen(int si, int fi) -{ - int X, Y; - - // +++++++++++++++++++++++++++++++++++++++++ - X = GetStretchX(si); - Y = GetStretchY(si); - StretchedSprites.BltEx(X, Y, fi); - // +++++++++++++++++++++++++++++++++++++++++ } -#endif - void subCopyAnimToScreen(int si, int graphic, int sync_frame) { int X, Y; @@ -2917,4 +2588,4 @@ loc_g_15E8: // zonk/infotron above right MovHighByte(&PlayField16[si - FieldWidth + 1], 0x50); // make roll left PlayField16[si - FieldWidth] = 0x8888; } -} // subAdjustZonksInfotronsAboveMurphy +} diff --git a/src/game_sp/Murphy.h b/src/game_sp/Murphy.h index ece70c44..e0d51a35 100644 --- a/src/game_sp/Murphy.h +++ b/src/game_sp/Murphy.h @@ -7,12 +7,12 @@ #include "global.h" -extern void subAdjustZonksInfotronsAboveMurphy(int si); -extern void subAnimateMurphy(int *si); -extern void subCopyFieldToScreen(int si, int fi); -extern void subCopyImageToScreen(int si, int graphic); -extern void subCopyAnimToScreen(int si, int graphic, int sync_frame); -extern void subExplodeSnikSnaksBelow(int si); -extern int subSpPortTest(int si); +extern void subAdjustZonksInfotronsAboveMurphy(int); +extern void subAnimateMurphy(int *); +extern void subCopyFieldToScreen(int, int); +extern void subCopyImageToScreen(int, int); +extern void subCopyAnimToScreen(int, int, int); +extern void subExplodeSnikSnaksBelow(int); +extern void subSpPortTest(int); #endif /* MURPHY_H */ diff --git a/src/game_sp/file.c b/src/game_sp/file.c index a998cfdf..8497704b 100644 --- a/src/game_sp/file.c +++ b/src/game_sp/file.c @@ -112,10 +112,8 @@ void copyInternalEngineVars_SP() int count; int i, x, y; -#if 1 for (i = 0; preceding_playfield_memory[i] != NULL; i++) preceding_buffer_size += 8; /* eight 16-bit integer values */ -#endif /* needed for engine snapshots */ game_sp.preceding_buffer_size = preceding_buffer_size; @@ -131,23 +129,10 @@ void copyInternalEngineVars_SP() FileMax = FieldMax + native_sp_level.demo.length; - PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax + 1 - 1); - DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax + 1 - 1); -#if 1 + PlayField8 = REDIM_1D(sizeof(byte), 0, FileMax); + DisPlayField = REDIM_1D(sizeof(byte), 0, FieldMax); PlayField16 = REDIM_1D(sizeof(int), -preceding_buffer_size, FieldMax); -#else - PlayField16 = REDIM_1D(sizeof(int), -FieldWidth, FieldMax); -#endif - -#if 1 -#if 0 - /* fill preceding playfield buffer zone with (indestructible) "hardware" */ - for (i = -FieldWidth; i < 0; i++) - PlayField16[i] = 0x20; -#endif - -#if 1 count = 0; for (i = 0; preceding_playfield_memory[i] != NULL; i++) { @@ -176,7 +161,6 @@ void copyInternalEngineVars_SP() s++; } } -#endif count = 0; for (y = 0; y < native_sp_level.height; y++) @@ -194,46 +178,6 @@ void copyInternalEngineVars_SP() PlayField8[i] = 0; } -#if 0 - { - static int x = 0; - - if (x == 1) - { - printf("++++++++"); - printf("----------\n"); - for (i = 0; i < preceding_buffer_size + FieldMax; i++) - { - int x = PlayField16[-preceding_buffer_size + i]; - - printf("%c%c", x & 0xff, x >> 8); - } - printf("----------\n"); - exit(0); - } - - x++; - } -#endif - -#else - - for (i = 0; y = 0; y < native_sp_level.height; y++) - { - for (x = 0; x < native_sp_level.width; x++) - { - PlayField8[i] = native_sp_level.playfield[x][y]; - - PlayField16[i] = PlayField8[i]; - DisPlayField[i] = PlayField8[i]; - PlayField8[i] = 0; - - i++; - } - } - -#endif - if (native_sp_level.demo.is_available) { DemoAvailable = True; @@ -254,13 +198,7 @@ void copyInternalEngineVars_SP() #if 1 /* this is set by main game tape code to native random generator directly */ #else - -#if 1 - printf("::: file.c: copyInternalEngineVars_SP(): RandomSeed = LInfo.DemoRandomSeed\n"); -#endif - RandomSeed = LInfo.DemoRandomSeed; - #endif LevelLoaded = True; @@ -308,10 +246,6 @@ static void LoadNativeLevelFromFileStream_SP(FILE *file, int width, int height, /* number of special ("gravity") port entries below (maximum 10 allowed) */ header->SpecialPortCount = getFile8Bit(file); -#if 0 - printf("::: num_special_ports == %d\n", header->SpecialPortCount); -#endif - /* database of properties of up to 10 special ports (6 bytes per port) */ for (i = 0; i < SP_MAX_SPECIAL_PORTS; i++) { @@ -324,16 +258,6 @@ static void LoadNativeLevelFromFileStream_SP(FILE *file, int width, int height, which is 2 bytes per tile) */ port->PortLocation = getFile16BitBE(file); /* yes, big endian */ -#if 0 - { - int port_x = (port->PortLocation / 2) % SP_PLAYFIELD_WIDTH; - int port_y = (port->PortLocation / 2) / SP_PLAYFIELD_WIDTH; - - printf("::: %d: port_location == %d => (%d, %d)\n", - i, port->PortLocation, port_x, port_y); - } -#endif - /* change gravity: 1 == "turn on", anything else (0) == "turn off" */ port->Gravity = getFile8Bit(file); @@ -354,11 +278,6 @@ static void LoadNativeLevelFromFileStream_SP(FILE *file, int width, int height, /* random seed used for recorded demos */ header->DemoRandomSeed = getFile16BitLE(file); /* yes, little endian */ - // header->DemoRandomSeed = getFile16BitBE(file); /* !!! TEST ONLY !!! */ - -#if 0 - printf("::: file.c: DemoRandomSeed == %d\n", header->DemoRandomSeed); -#endif /* auto-determine number of infotrons if it was stored as "0" -- see above */ if (header->InfotronsNeeded == 0) diff --git a/src/game_sp/init.c b/src/game_sp/init.c index a1312cac..32a832c2 100644 --- a/src/game_sp/init.c +++ b/src/game_sp/init.c @@ -7,21 +7,12 @@ Bitmap *screenBitmap; struct EngineSnapshotInfo_SP engine_snapshot_sp; -static void init_global_values() -{ - menBorder = False; -} - void sp_open_all() { - init_global_values(); - Form_Load(); screenBitmap = CreateBitmap(MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY, DEFAULT_DEPTH); - - DDSpriteBuffer_Init(); } void sp_close_all() @@ -93,8 +84,6 @@ void SaveEngineSnapshotValues_SP() SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayMinY)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayMaxX)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayMaxY)); - SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayWidth)); - SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayHeight)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(InfotronsNeeded)); SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(KillMurphyFlag)); -- 2.34.1