From d45b35552f4ca1ada1266fb7e8b6968d878019a6 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 15 Mar 2010 01:24:15 +0100 Subject: [PATCH] rnd-20100315-1-src * started code cleanup of native Supaplex game engine --- ChangeLog | 3 + src/conftime.h | 2 +- src/engines.h | 1 - src/game_sp/ASM.c | 111 +----- src/game_sp/ASM.h | 18 +- src/game_sp/BitMapObject.c | 601 ------------------------------ src/game_sp/BitMapObject.h | 72 ---- src/game_sp/BugsTerminals.c | 269 ++------------ src/game_sp/BugsTerminals.h | 9 +- src/game_sp/Capture.c | 543 --------------------------- src/game_sp/Capture.h | 151 -------- src/game_sp/DDScrollBuffer.c | 690 ----------------------------------- src/game_sp/DDScrollBuffer.h | 11 +- src/game_sp/DDSpriteBuffer.c | 422 +-------------------- src/game_sp/DDSpriteBuffer.h | 14 +- src/game_sp/Infotrons.c | 6 +- src/game_sp/MainForm.c | 6 - src/game_sp/Makefile | 4 - src/game_sp/Murphy.c | 2 +- src/game_sp/Zonk.c | 4 +- src/game_sp/global.h | 2 - src/game_sp/init.c | 19 +- src/game_sp/main.c | 42 --- src/tools.c | 5 - 24 files changed, 84 insertions(+), 2923 deletions(-) delete mode 100644 src/game_sp/BitMapObject.c delete mode 100644 src/game_sp/BitMapObject.h delete mode 100644 src/game_sp/Capture.c delete mode 100644 src/game_sp/Capture.h diff --git a/ChangeLog b/ChangeLog index 777cbb85..8967bdd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-03-14 + * started code cleanup of native Supaplex game engine + 2010-03-13 * integrated playing sound effects into native Supaplex game engine diff --git a/src/conftime.h b/src/conftime.h index 78990a15..e58f87ed 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-03-13 15:52" +#define COMPILE_DATE_STRING "2010-03-15 01:21" diff --git a/src/engines.h b/src/engines.h index 0bdb824a..42d64b54 100644 --- a/src/engines.h +++ b/src/engines.h @@ -50,7 +50,6 @@ extern void SetBitmaps_SP(Bitmap **); void getGraphicSource_SP(struct GraphicInfo_SP *, int, int, int, int); int getGraphicInfo_Delay(int); -boolean isRandomAnimation_SP(int); boolean isNextAnimationFrame_SP(int, int); diff --git a/src/game_sp/ASM.c b/src/game_sp/ASM.c index d31edfae..ae2de3ee 100644 --- a/src/game_sp/ASM.c +++ b/src/game_sp/ASM.c @@ -5,119 +5,32 @@ #include "ASM.h" -void Mov(int *Var, int Val) +void MovLowByte(int *p, int i) { - *Var = Val; + *p = (*p & 0xff00) | (i & 0xff); } -void MovLowByte(int *Var, int Val) +void MovHighByte(int *p, int i) { - *Var = (*Var & 0xFF00) | (Val & 0xFF); + *p = (*p & 0xff) | ((i << 8) & 0xff00); } -void MovHighByte(int *Var, int Val) +int LowByte(int i) { - int Tmp; - - Tmp = Val & 0x7F; - Tmp = 0x100 * Tmp; - - if ((Val & 0x80) != 0) - Tmp = Tmp | 0x8000; - - *Var = (*Var & 0xFF) | Tmp; + return (i & 0xff); } -int LowByte(int Var) +int HighByte(int i) { - int LowByte; - - LowByte = (Var & 0xFF); - - return LowByte; + return ((i >> 8) & 0xff); } -int HighByte(int Var) +int SgnHighByte(int i) { - int HighByte; - - if (Var & 0x8000) - HighByte = ((Var & 0x7FFF) / 0x100) | 0x80; - else - HighByte = Var / 0x100; - - return HighByte; + return (signed char)HighByte(i); } -int SgnHighByte(int Var) // extends the signum to 16 bit +int ByteToInt(byte b) { -#if 1 - short SgnHighByte; -#else - int SgnHighByte; -#endif - - if (Var & 0x8000) - SgnHighByte = ((Var & 0x7FFF) / 0x100) | 0xFF80; - else - SgnHighByte = Var / 0x100; - - return SgnHighByte; -} - -int SHL(int *Var, int Count) -{ - int SHL; - - int i; - - for (i = 1; i <= Count; i++) - { - *Var = *Var & 0x7FFF; - - if ((*Var & 0x4000) != 0) - *Var = (2 * (*Var & 0x3FFF)) | 0x8000; - else - *Var = 2 * *Var; - } - - return SHL; -} - -int SHR(int *Var, int Count) -{ - int SHR; - - int i; - - if (*Var & 0x8000) - *Var = ((*Var & 0x7FFF) / 2) | 0x4000; - else - *Var = *Var / 2; - - for (i = 2; i <= Count; i++) - *Var = *Var / 2; - - return SHR; -} - -int ByteToInt(byte B) -{ - int ByteToInt; - - if ((B & 0x80) == 0x80) - ByteToInt = -(0xFF - B + 1); - else - ByteToInt = B; - - return ByteToInt; -} - -byte IntToByte(int i) -{ - byte IntToByte; - - IntToByte = (byte)(i & 0xFF); - - return IntToByte; + return (signed char)b; } diff --git a/src/game_sp/ASM.h b/src/game_sp/ASM.h index f1e4e4ac..ae23113d 100644 --- a/src/game_sp/ASM.h +++ b/src/game_sp/ASM.h @@ -13,17 +13,11 @@ #include "global.h" -#define ByteMask (0xFF) - -extern void Mov(int *Var, int Val); -extern void MovLowByte(int *Var, int Val); -extern void MovHighByte(int *Var, int Val); -extern int LowByte(int Var); -extern int HighByte(int Var); -extern int SgnHighByte(int Var); -extern int SHL(int *Var, int Count); -extern int SHR(int *Var, int Count); -extern int ByteToInt(byte B); -extern byte IntToByte(int i); +extern void MovLowByte(int *, int); +extern void MovHighByte(int *, int); +extern int LowByte(int); +extern int HighByte(int); +extern int SgnHighByte(int); +extern int ByteToInt(byte); #endif /* ASM_H */ diff --git a/src/game_sp/BitMapObject.c b/src/game_sp/BitMapObject.c deleted file mode 100644 index 5e267682..00000000 --- a/src/game_sp/BitMapObject.c +++ /dev/null @@ -1,601 +0,0 @@ -// ---------------------------------------------------------------------------- -// BitMapObject.c -// ---------------------------------------------------------------------------- - -#include "BitMapObject.h" - -// static void ConvertToVBPalette(); -static long Get_ByteWidth(); -static long Get_LineLength(); -static void ReDimArrays(); - -// --- 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 = "BitMapObject"; -// static boolean VB_GlobalNameSpace = False; -// static boolean VB_Creatable = True; -// static boolean VB_PredeclaredId = False; -// static boolean VB_Exposed = False; - -// --- Option Explicit - -// info von http://web.usxchange.net/elmo/bmp.htm - -// A BMP file consists of the four following parts: -// -// 1.BITMAPFILEHEADER -// 2.BITMAPINFOHEADER -// 3.A color table of RGBQUAD structures (1, 4 & 8 bit only) -// 4.An array of bytes for the actual image data - -// 1.BITMAPFILEHEADER -// 1.bfType -// Declared an unsigned integer. But, this is just to reserve space for 2 bytes. -// The 2 bytes must be the 2 characters BM to indicate a BitMap file. -// 2.bfSize -// Total size of file in bytes. -// 3.bfReserved1 -// Always zero (ignore). -// 4.bfReserved2 -// Always zero (ignore). -// 5.bfOffBits -// Specifies the byte offset from the BITMAPFILEHEADER structure to the actual bitmap data in the file. -// ::: #ifndef HAS_BitmapFileHeaderType -// ::: typedef struct // { /* bmfh */ -// ::: { -// ::: byte bfTypeB; -// ::: byte bfTypeM; -// ::: long bfSize; -// ::: int bfReserved1; -// ::: int bfReserved2; -// ::: long bfOffBits; -// ::: } BitmapFileHeaderType; -// ::: #define HAS_BitmapFileHeaderType -// ::: #endif - -// 2.BITMAPINFOHEADER -// 1.biSize -// Size of BITMAPINFOHEADER structure (should always be 40). -// 2.biWidth -// Width of image in pixels. -// 3.biHeight -// Height of image in pixels. -// 4.biPlanes -// Always one (ignore). -// 5.biBitCount -// Specifies the number of bits per pixel. This value must be 1, 4, 8, or 24. -// 6.biCompression -// Specifies the type of compression. -// 1.BI_RGB No compression. -// 2.BI_RLE8 8 bit RLE -// 3.BI_RLE4 4 bit RLE -// 7.biSizeImage -// Specifies the size, in bytes, of the image data. May be zero if the bitmap is in the BI_RGB format. -// 8.biXPelsPerMeter -// Ignore. -// 9.biYPelsPerMeter -// Ignore. -// 10.biClrUsed -// Specifies the number of color indices in the color table. Zero indicaes the bitmap uses the maximum number of colors corresponding to the value of the -// biBitCount member e.g. 8 bit -> 256 colors. -// -// The maximum number of colors = 2N. Where N = biBitCount. 2N is the same as 1 << N. The same as you can get powers of 10 by shifting the decimal point -// in a decimal number, only it is binary. -// 11.biClrImportant -// Ignore. -// ::: #ifndef HAS_BitmapInfoHeaderType -// ::: typedef struct // { /* bmih */ -// ::: { -// ::: long biSize; -// ::: long biWidth; -// ::: long biHeight; -// ::: int biPlanes; -// ::: int biBitCount; -// ::: long biCompression; -// ::: long biSizeImage; -// ::: long biXPelsPerMeter; -// ::: long biYPelsPerMeter; -// ::: long biClrUsed; -// ::: long biClrImportant; -// ::: } BitmapInfoHeaderType; -// ::: #define HAS_BitmapInfoHeaderType -// ::: #endif - -// 3.A color table of RGBQUAD structures (1, 4 & 8 bit only) -// RGBQUAD structure is self explanatory. -// ::: #ifndef HAS_RGBQUADType -// ::: typedef struct // { /* rgbq */ -// ::: { -// ::: byte rgbBlue; -// ::: byte rgbGreen; -// ::: byte rgbRed; -// ::: byte rgbReserved; -// ::: } RGBQUADType; -// ::: #define HAS_RGBQUADType -// ::: #endif - -RGBQUADType *ColorTable; -long *VBPalette; - -// 4.An array of bytes for the actual image data -// Bits per pixel & compression determined by biBitCount & biCompression. - -byte *ImageDataBytes; - -// ###################################################################################################### - -BitmapFileHeaderType BMFH; -BitmapInfoHeaderType BMIH; - -static long Get_LineLength() -{ - static long LineLength; - - LineLength = 4 * (((Get_ByteWidth() - 1) / 4) + 1); - - return LineLength; -} - -static long Get_ByteWidth() -{ - static long ByteWidth; - - ByteWidth = BMIH.biWidth * BMIH.biBitCount / 8; - - return ByteWidth; -} - -void BitMapObject_CreateAtSize(long XPixels, long YPixels, long BitsPerPixel) -{ - { - BMIH.biWidth = XPixels; - BMIH.biHeight = YPixels; - BMIH.biSize = 40; - BMIH.biBitCount = BitsPerPixel; - BMIH.biClrUsed = (1 << BMIH.biBitCount); - BMIH.biPlanes = 1; - BMIH.biClrImportant = BMIH.biClrUsed; - BMIH.biCompression = 0; - } - { - BMFH.bfTypeB = 0x42; // B' - BMFH.bfTypeM = 0x4D; // M' - } - ReDimArrays(); -} - -#if 0 - -void BitMapObject_CreateFromFile(char *Path) -{ - long FNum; - - FNum = FreeFile(); - if (! FileExists(Path)) - return; - - if (FileLen(Path) < (Len(BMFH) + Len(BMIH))) - return; - - FNum = fopen(Path, "rb"); - FILE_GET(FNum, -1, &BMFH, sizeof(BMFH)); - FILE_GET(FNum, -1, &BMIH, sizeof(BMIH)); - ReDimArrays(); - { - if (BMIH.biCompression != 0) - { - Err.Raise(600, "BitMapObject", "Cannot read compressed BMP files"); - fclose(FNum); - return; - } - - if (BMIH.biBitCount < 9) - { - FILE_GET(FNum, -1, &ColorTable, sizeof(ColorTable)); - } - - } - FILE_GET(FNum, 1 + BMFH.bfOffBits, &ImageDataBytes, sizeof(ImageDataBytes)); - fclose(FNum); - if (BMIH.biBitCount < 9) - ConvertToVBPalette(); -} - -void BitMapObject_SaveToFile(char *Path) -{ - FILE *FNum; - - BMFH.bfOffBits = Len(BMFH) + Len(BMIH); - if (BMIH.biBitCount < 9) - BMFH.bfOffBits = BMFH.bfOffBits + ((1 << BMIH.biBitCount)) * Len(ColorTable[0]); - - BMIH.biSizeImage = Get_LineLength() * BMIH.biHeight; - BMFH.bfSize = BMFH.bfOffBits + BMIH.biSizeImage; - // FNum = FreeFile(); - FNum = fopen(Path, "wb"); - FILE_PUT(FNum, -1, &BMFH, sizeof(BMFH)); - FILE_PUT(FNum, -1, &BMIH, sizeof(BMIH)); - if (BMIH.biBitCount < 9) - { - FILE_PUT(FNum, -1, &ColorTable, sizeof(ColorTable)); - } - - FILE_PUT(FNum, -1, &ImageDataBytes, sizeof(ImageDataBytes)); - fclose(FNum); -} - -static void ConvertToVBPalette() -{ - long ColMax, i; - - ColMax = UBound(ColorTable); - for (i = 0; i <= ColMax; i++) - { - { - VBPalette[i] = RGB(ColorTable[i].rgbRed, ColorTable[i].rgbGreen, ColorTable[i].rgbBlue); - } - } -} - -#endif - -static void ReDimArrays() -{ - { - if (BMIH.biBitCount < 9) - { - BMIH.biClrUsed = (1 << BMIH.biBitCount); - ColorTable = REDIM_1D(sizeof(RGBQUADType), 0, BMIH.biClrUsed - 1); - VBPalette = REDIM_1D(sizeof(long), 0, BMIH.biClrUsed - 1); - } - - if (0 < Get_LineLength() && 0 < BMIH.biHeight) - { - ImageDataBytes = REDIM_2D(sizeof(byte), 0, Get_LineLength() - 1, 0, BMIH.biHeight - 1); - } - - } -} - -long BitMapObject_Get_Palette(long Index) -{ - long Palette; - - Palette = VBPalette[Index]; - - return Palette; -} - -void BitMapObject_Let_Palette(long Index, long NewVal) -{ - VBPalette[Index] = NewVal & 0xFFFFFF; - { - ColorTable[Index].rgbRed = (NewVal & 0xFF) / 0x1; - ColorTable[Index].rgbGreen = (NewVal & 0xFF00) / 0x100; - ColorTable[Index].rgbBlue = (NewVal & 0xFF0000) / 0x10000; - } -} - -long BitMapObject_Get_ColorsUsed() -{ - long ColorsUsed; - - if (BMIH.biBitCount < 9) - { - ColorsUsed = (1 << BMIH.biBitCount); - } - else - { - ColorsUsed = 0; - } - - return ColorsUsed; -} - -#if 0 - -long BitMapObject_Get_ColorIndex(long X, long Y) -{ - long ColorIndex; - - long ColIndex, NewX, BitPos, nY; - - if (8 < BMIH.biBitCount) - { - Err.Raise(600, "BitmapObject", "I have ! Palette in this ColorDepthMode"); - ColorIndex = -1; - return ColorIndex; - } - - nY = BMIH.biHeight - 1 - Y; - switch (BMIH.biBitCount) - { - case 1: - ColIndex = ImageDataBytes[X / 8, nY]; - BitPos = 7 - (X % 8); - NewX = (1 << BitPos); - if ((NewX && ColIndex) == 0) - { - ColorIndex = 0; - } - else - { - ColorIndex = 1; - } - - break; - - case 4: - ColIndex = ImageDataBytes[X / 2, nY]; - if ((X % 2) == 0) - { - ColorIndex = (ColIndex & 0xF0) / 0x10; - } - else - { - ColorIndex = (ColIndex & 0xF); - } - - break; - - case 8: - ColorIndex = ImageDataBytes[X, nY]; - break; - - default: - Err.Raise(600, "BitmapObject", "Invalid bpx value"); - break; - } - - return ColorIndex; -} - -void BitMapObject_Let_ColorIndex(long X, long Y, long ColorIndex) -{ - long ColIndex, ByteVal, NewX, BitPos, nY; - - if (8 < BMIH.biBitCount) - { - Err.Raise(600, "BitmapObject", "I have ! Palette in this ColorDepthMode"); - return; - } - - nY = BMIH.biHeight - 1 - Y; - switch (BMIH.biBitCount) - { - case 1: - ByteVal = ImageDataBytes[X / 8, nY]; - BitPos = 7 - (X % 8); - NewX = (1 << BitPos); - ColIndex = ColorIndex * NewX; - if (ColIndex == 0) - { - ByteVal = (ByteVal & (! NewX)); - } - else - { - ByteVal = (ByteVal | NewX); - } - - ImageDataBytes[X / 8, nY] = ByteVal; - break; - - case 4: - ByteVal = ImageDataBytes[X / 2, nY]; - if ((X % 2) == 0) - { - ByteVal = (ByteVal & 0xF) + ColorIndex * 0x10; - } - else - { - ByteVal = (ByteVal & 0xF0) + ColorIndex; - } - - ImageDataBytes[X / 2, nY] = ByteVal; - break; - - case 8: - ImageDataBytes[X, nY] = ColorIndex; - break; - - case 24: - Err.Raise(600, "BitmapObject", "Invalid bpx value"); - break; - } -} - -long BitMapObject_Get_Point(long X, long Y) -{ - long Point; - - long ColIndex, NewX, BitPos, nY; - - nY = BMIH.biHeight - 1 - Y; - switch (BMIH.biBitCount) - { - case 1: - ColIndex = ImageDataBytes[X / 8, nY]; - BitPos = 7 - (X % 8); - NewX = (1 << BitPos); - if ((NewX && ColIndex) == 0) - { - ColIndex = 0; - } - else - { - ColIndex = 1; - } - - Point = VBPalette[ColIndex]; - break; - - case 4: - ColIndex = ImageDataBytes[X / 2, nY]; - if ((X % 2) == 0) - { - ColIndex = (ColIndex & 0xF0) / 0x10; - } - else - { - ColIndex = (ColIndex & 0xF); - } - - Point = VBPalette[ColIndex]; - break; - - case 8: - ColIndex = ImageDataBytes[X, nY]; - Point = VBPalette[ColIndex]; - break; - - case 24: - NewX = 3 * X; - Point = ImageDataBytes[NewX, nY] * 0x10000; - Point = Point + ImageDataBytes[NewX + 1, nY] * 0x100; - Point = Point + ImageDataBytes[NewX + 2, nY]; - break; - - default: - Err.Raise(600, "BitmapObject", "Invalid bpx value"); - break; - } - - return Point; -} - -void BitMapObject_Let_Point(long X, long Y, long NewColor) -{ - long ColIndex, ByteVal, NewX, BitPos, nY; - - nY = BMIH.biHeight - 1 - Y; - switch (BMIH.biBitCount) - { - case 1: - ColIndex = GetPaletteIndex(NewColor); - ByteVal = ImageDataBytes[X / 8][nY]; - BitPos = 7 - (X % 8); - NewX = (1 << BitPos); - ColIndex = ColIndex * NewX; - if (ColIndex == 0) - { - ByteVal = (ByteVal & (! NewX)); - } - else - { - ByteVal = (ByteVal | NewX); - } - - ImageDataBytes[X / 8][nY] = ByteVal; - break; - - case 4: - ColIndex = GetPaletteIndex(NewColor); - ByteVal = ImageDataBytes[X / 2][nY]; - if ((X % 2) == 0) - { - ByteVal = (ByteVal & 0xF) + ColIndex * 0x10; - } - else - { - ByteVal = (ByteVal & 0xF0) + ColIndex; - } - - ImageDataBytes[X / 2][nY] = ByteVal; - break; - - case 8: - ImageDataBytes[X][nY] = GetPaletteIndex(NewColor); - break; - - case 24: - NewX = 3 * X; - ImageDataBytes[NewX][nY] = (NewColor & 0xFF0000) / 0x10000; // B - ImageDataBytes[NewX + 1][nY] = (NewColor & 0xFF00) / 0x100; // G - ImageDataBytes[NewX + 2][nY] = (NewColor & 0xFF); // R - break; - - default: - Err.Raise(600, "BitmapObject", "Invalid bpx value"); - break; - } -} - -int BitMapObject_GetPaletteIndex(long Color) -{ - int GetPaletteIndex; - - long i, ColMax; - - ColMax = UBound(VBPalette); - for (i = 0; i <= ColMax; i++) - { - if (VBPalette[i] == Color) - break; - } - - if (ColMax < i) // Error - Color not in Palette! - i = -1; - - GetPaletteIndex = i; - - return GetPaletteIndex; -} - -#endif - -long BitMapObject_Get_Width() -{ - long Width; - - Width = BMIH.biWidth; - - return Width; -} - -long BitMapObject_Get_Height() -{ - long Height; - - Height = BMIH.biHeight; - - return Height; -} - -#if 0 - -BitMapObject BitMapObject_GetStretchCopy(float StretchVal) -{ - BitMapObject GetStretchCopy; - - long nWidth, nHeight, iX, iY; - - // GetStretchCopy = New BitMapObject; // (handle this later, if needed) - nWidth = StretchVal * BMIH.biWidth; - nHeight = StretchVal * BMIH.biHeight; - GetStretchCopy.CreateAtSize(nWidth, nHeight, CLng(BMIH.biBitCount)); - nWidth = nWidth - 1; - nHeight = nHeight - 1; - for (iX = 0; iX <= BMIH.biClrUsed - 1; iX++) - { - GetStretchCopy.Let_Palette(iX, Palette(iX)); - } - - for (iY = 0; iY <= nHeight; iY++) - { - for (iX = 0; iX <= nWidth; iX++) - { - GetStretchCopy.Let_ColorIndex(iX, iY, ColorIndex((int)(iX / StretchVal), (int)(iY / StretchVal))); - } - } - - return GetStretchCopy; -} - -#endif diff --git a/src/game_sp/BitMapObject.h b/src/game_sp/BitMapObject.h deleted file mode 100644 index 64c10d94..00000000 --- a/src/game_sp/BitMapObject.h +++ /dev/null @@ -1,72 +0,0 @@ -// ---------------------------------------------------------------------------- -// BitMapObject.h -// ---------------------------------------------------------------------------- - -#ifndef BITMAPOBJECT_H -#define BITMAPOBJECT_H - -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - -#include "global.h" - -#ifndef HAS_BitmapFileHeaderType -typedef struct // { /* bmfh */ -{ - byte bfTypeB; - byte bfTypeM; - long bfSize; - int bfReserved1; - int bfReserved2; - long bfOffBits; -} BitmapFileHeaderType; -#define HAS_BitmapFileHeaderType -#endif - -#ifndef HAS_BitmapInfoHeaderType -typedef struct // { /* bmih */ -{ - long biSize; - long biWidth; - long biHeight; - int biPlanes; - int biBitCount; - long biCompression; - long biSizeImage; - long biXPelsPerMeter; - long biYPelsPerMeter; - long biClrUsed; - long biClrImportant; -} BitmapInfoHeaderType; -#define HAS_BitmapInfoHeaderType -#endif - -#ifndef HAS_RGBQUADType -typedef struct // { /* rgbq */ -{ - byte rgbBlue; - byte rgbGreen; - byte rgbRed; - byte rgbReserved; -} RGBQUADType; -#define HAS_RGBQUADType -#endif - -extern void BitMapObject_CreateAtSize(long XPixels, long YPixels, long BitsPerPixel); -extern void BitMapObject_CreateFromFile(char *Path); -extern int BitMapObject_GetPaletteIndex(long Color); -extern BitMapObject BitMapObject_GetStretchCopy(float StretchVal); -extern long BitMapObject_Get_ColorIndex(long X, long Y); -extern long BitMapObject_Get_ColorsUsed(); -extern long BitMapObject_Get_Height(); -extern long BitMapObject_Get_Palette(long Index); -extern long BitMapObject_Get_Point(long X, long Y); -extern long BitMapObject_Get_Width(); -extern void BitMapObject_Let_ColorIndex(long X, long Y, long ColorIndex); -extern void BitMapObject_Let_Palette(long Index, long NewVal); -extern void BitMapObject_Let_Point(long X, long Y, long NewColor); -extern void BitMapObject_SaveToFile(char *Path); - -#endif /* BITMAPOBJECT_H */ diff --git a/src/game_sp/BugsTerminals.c b/src/game_sp/BugsTerminals.c index b7f7862d..ec4be1ea 100644 --- a/src/game_sp/BugsTerminals.c +++ b/src/game_sp/BugsTerminals.c @@ -4,179 +4,75 @@ #include "BugsTerminals.h" -// static char *VB_Name = "modBugTerminal"; - -// --- Option Explicit - -long MyGetTickCount(); byte *TerminalState; int TerminalMaxCycles; -#if 0 -#define aniTerminal (0x80) -#endif // ========================================================================== // SUBROUTINE // Animate bugs // ========================================================================== -int subAnimateBugs(int si) +void subAnimateBugs(int si) { - int subAnimateBugs; - - // int ax, bx, cx, dx, di; - // int ah, bh, ch, dh, al, bl, cl, dl; - // int cx; -#if 0 - int graphic, sync_frame; -#endif int bl; if (fiBug != LowByte(PlayField16[si])) - return subAnimateBugs; + return; -#if 0 - if (0 != (TimerVar & 3)) - return subAnimateBugs; -#endif + bl = SgnHighByte(PlayField16[si]); // get and increment sequence number - bl = SgnHighByte(PlayField16[si]); // get and increment sequence# - -#if 1 if ((TimerVar & 3) == 0) { bl = bl + 1; if (bl >= 0xE) { - bl = subGetRandomNumber(); // generate new random number + bl = subGetRandomNumber(); // generate new random number bl = -((bl & 0x3F) + 0x20); } - MovHighByte(&PlayField16[si], bl); // save sequence# + MovHighByte(&PlayField16[si], bl); // save sequence number } -#else - bl = bl + 1; - if (bl >= 0xE) - { - bl = subGetRandomNumber(); // generate new random number - bl = -((bl & 0x3F) + 0x20); - } - - MovHighByte(&PlayField16[si], bl); // save sequence# -#endif - if (bl < 0) // bug sleeps / is inactive - return subAnimateBugs; -#if 1 - if ((TimerVar & 3) != 0) - goto markDisplay; -#endif + if (bl < 0) // bug sleeps / is inactive + return; // now the bug is active! Beware Murphy! - if ((ByteMask & PlayField16[si - FieldWidth - 1]) == fiMurphy) - goto markPlaySound; - - if ((ByteMask & PlayField16[si - FieldWidth]) == fiMurphy) - goto markPlaySound; - - if ((ByteMask & PlayField16[si - FieldWidth + 1]) == fiMurphy) - goto markPlaySound; - - if ((ByteMask & PlayField16[si - 1]) == fiMurphy) - goto markPlaySound; - - if ((ByteMask & PlayField16[si + 1]) == fiMurphy) - goto markPlaySound; - - if ((ByteMask & PlayField16[si + FieldWidth - 1]) == fiMurphy) - goto markPlaySound; - - if ((ByteMask & PlayField16[si + FieldWidth]) == fiMurphy) - goto markPlaySound; + if ((TimerVar & 3) == 0 && + (LowByte(PlayField16[si - FieldWidth - 1]) == fiMurphy || + LowByte(PlayField16[si - FieldWidth]) == fiMurphy || + LowByte(PlayField16[si - FieldWidth + 1]) == fiMurphy || + LowByte(PlayField16[si - 1]) == fiMurphy || + LowByte(PlayField16[si + 1]) == fiMurphy || + LowByte(PlayField16[si + FieldWidth - 1]) == fiMurphy || + LowByte(PlayField16[si + FieldWidth]) == fiMurphy || + LowByte(PlayField16[si + FieldWidth + 1]) == fiMurphy)) + subSoundFX(si, fiBug, actActive); // play dangerous sound - if ((ByteMask & PlayField16[si + FieldWidth + 1]) == fiMurphy) - goto markPlaySound; - - goto markDisplay; - -markPlaySound: -#if 1 - subSoundFX(si, fiBug, actActive); // play dangerous sound -#else - subSoundFXBug(); // play dangerous sound -#endif - -markDisplay: // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#if 1 - -#if 1 - -#if 0 - graphic = (bl == 0 ? aniBugActivating : - bl == 12 ? aniBugDeactivating : - bl == 13 ? aniBug : aniBugActive); - sync_frame = (bl >= 1 && bl <= 11 ? (bl - 1) * 4 : 0) + (TimerVar & 3); -#endif - - // printf("::: %d [%d]\n", sync_frame, gfx.anim_random_frame); - -#if 0 - /* a general random frame treatment would be needed for _all_ animations */ - /* (DONE) */ - if (isRandomAnimation_SP(graphic) && - !isNextAnimationFrame_SP(graphic, sync_frame)) - return subAnimateBugs; -#endif - -#if 1 - GfxGraphic[GetX(si)][GetY(si)] = (bl == 0 ? aniBugActivating : bl == 12 ? aniBugDeactivating : bl == 13 ? aniBug : aniBugActive); - -#else - subCopyAnimToScreen(si, graphic, sync_frame); -#endif - -#else - subCopyFieldToScreen(si, aniFramesBug[bl]); -#endif - -#else - cx = aniFramesBug[bl]; - StretchedSprites.BltEx(GetStretchX(si), GetStretchY(si), cx); -#endif // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +} - return subAnimateBugs; -} // subAnimateBugs // ========================================================================== // SUBROUTINE // Animate terminals // ========================================================================== -int subAnimateTerminals(int si) -{ - int subAnimateTerminals; - // int bl, ax, al, X, Y; -#if 1 +void subAnimateTerminals(int si) +{ short bl; -#else - int bl, al, X, Y; -#endif -#if 1 int lx = GetX(si); int ly = GetY(si); int graphic; -#endif if (LowByte(PlayField16[si]) != fiTerminal) - return subAnimateTerminals; + return; /* use native frame handling (undo frame incrementation in main loop) */ if (game.use_native_sp_graphics_engine) @@ -192,105 +88,46 @@ int subAnimateTerminals(int si) { MovHighByte(&PlayField16[si], bl); -#if 1 - if (game.use_native_sp_graphics_engine) - return subAnimateTerminals; -#else - return subAnimateTerminals; -#endif + return; } /* calculate new random animation delay */ bl = -(subGetRandomNumber() & TerminalMaxCycles); // generate new random number - MovHighByte(&PlayField16[si], bl); // save new sequence# + MovHighByte(&PlayField16[si], bl); // save new sequence number /* check terminal state (active or inactive) */ bl = TerminalState[si] + 1; if (bl == 8) - { bl = 0; - } else if (15 < bl) - { bl = 8; - } TerminalState[si] = bl; // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -#if 1 graphic = (bl < 8 ? aniTerminal : aniTerminalActive); if (game.use_native_sp_graphics_engine) GfxFrame[lx][ly] += getGraphicInfo_Delay(graphic); -#if 1 - -#if 1 - - GfxGraphic[GetX(si)][GetY(si)] = (bl < 8 ? aniTerminal : aniTerminalActive); - -#else - subCopyAnimToScreen(si, graphic, GfxFrame[lx][ly]); -#endif - -#else - X = GetStretchX(si); - Y = GetStretchY(si); - StretchedSprites.BltImg(X, Y, graphic, GfxFrame[lx][ly]); -#endif - -#else - - al = aniTerminal + bl; + GfxGraphic[lx][ly] = (bl < 8 ? aniTerminal : aniTerminalActive); -#if 1 - subCopyFieldToScreen(si, al); -#else - X = GetStretchX(si); - Y = GetStretchY(si); - StretchedSprites.BltEx(X, Y, al); -#endif - -#endif // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +} - return subAnimateTerminals; -} // subAnimateElectrons // ========================================================================== // SUBROUTINE // Randomize random number generator // ========================================================================== -int subRandomize() +void subRandomize() { - int subRandomize; - - long Tick, Tmp; - - Tick = MyGetTickCount(); - Tmp = ((Tick ^ (long)(Tick / (1 << 16))) & 0xFFFF); - RandomSeed = 0x7FFF & Tmp; - if ((Tmp & 0x8000) != 0) - RandomSeed = RandomSeed | 0x8000; - -#if 0 - { - int i; - - for (i = 0; i < 10; i++) - printf("::: TEST random number: %d\n", subGetRandomNumber()); - } -#endif - -#if 0 - printf("::: BugsTerminals.c: ========== subRandomize()\n"); -#endif + long Tick = MyGetTickCount(); - return subRandomize; -} // subRandomize + RandomSeed = (Tick ^ (Tick >> 16)) & 0xFFFF; +} // ========================================================================== @@ -300,37 +137,9 @@ int subRandomize() int subGetRandomNumber() { - int subGetRandomNumber; - - long Tmp, RSeed; -#if 0 - long Tst; -#endif - - RSeed = (long)(0x7FFF & RandomSeed); - if (0x8000 == (RandomSeed & 0x8000)) - RSeed = RSeed | 0x8000; - -#if 0 - /* !!! TEST !!! */ - Tmp = 0xFFFF & (((0x5E5 * RSeed) & 0xFFFF) + 0x31); -#else - Tmp = 0xFFFF & (((0x5E5 * RandomSeed) & 0xFFFF) + 0x31); -#endif - -#if 0 - Tst = 0xFFFF & (((0x5E5 * RSeed) & 0xFFFF) + 0x31); - printf("::: BugsTerminals.c: subGetRandomNumber(): %d [%ld] [%ld, %ld]\n", - RandomSeed, RSeed, Tmp, Tst); - if (Tmp != Tst) - printf("::: !!!!!!!!!!\n"); -#endif - - RandomSeed = 0x7FFF & Tmp; - if ((Tmp & 0x8000) != 0) - RandomSeed = RandomSeed | 0x8000; - - subGetRandomNumber = Tmp / 2; + RandomSeed = (RandomSeed * 0x5E5 + 0x31) & 0xFFFF; + + return (RandomSeed >> 1); // Mov ax, randomseed // Mov bx, &H5E5 @@ -338,16 +147,4 @@ int subGetRandomNumber() // Add ax, &H31 // Mov randomseed, ax // shr ax,1 - -#if 0 - printf("::: BugsTerminals.c: ---------- subGetRandomNumber(): %d\n", - subGetRandomNumber); -#endif - -#if 0 - printf("::: BugsTerminals.c: subGetRandomNumber(): %d [%ld, %d]\n", - subGetRandomNumber, Tmp, RandomSeed); -#endif - - return subGetRandomNumber; -} // subGetRandomNumber +} diff --git a/src/game_sp/BugsTerminals.h b/src/game_sp/BugsTerminals.h index 4ec01cd4..1bd00886 100644 --- a/src/game_sp/BugsTerminals.h +++ b/src/game_sp/BugsTerminals.h @@ -12,12 +12,13 @@ #include "global.h" -extern int subAnimateBugs(int si); -extern int subAnimateTerminals(int si); -extern int subGetRandomNumber(); -extern int subRandomize(); extern byte *TerminalState; extern int TerminalMaxCycles; +extern void subAnimateBugs(int si); +extern void subAnimateTerminals(int si); +extern void subRandomize(); +extern int subGetRandomNumber(); + #endif /* BUGSTERMINALS_H */ diff --git a/src/game_sp/Capture.c b/src/game_sp/Capture.c deleted file mode 100644 index 5a71fd0e..00000000 --- a/src/game_sp/Capture.c +++ /dev/null @@ -1,543 +0,0 @@ -// ---------------------------------------------------------------------------- -// Capture.c -// ---------------------------------------------------------------------------- - -#include "Capture.h" - -#if 0 - -// static char *VB_Name = "CaptureModule"; - -// -------------------------------------------------------------------- -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -// Visual Basic 4.0 16/32 Capture Routines -// -// This module contains several routines for capturing windows into a -// picture. All the routines work on both 16 and 32 bit Windows -// platforms. -// The routines also have palette support. -// -// CreateBitmapPicture - Creates a picture object from a bitmap and -// palette. -// CaptureWindow - Captures any window given a window handle. -// CaptureActiveWindow - Captures the active window on the desktop. -// CaptureForm - Captures the entire form. -// CaptureClient - Captures the client area of a form. -// CaptureScreen - Captures the entire screen. -// PrintPictureToFitPage - prints any picture as big as possible on -// the page. -// -// NOTES -// - No error trapping is included in these routines. -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -// --- Option Explicit -// --- Option Base 0 - -// ::: #ifndef HAS_PALETTEENTRY -// ::: typedef struct -// ::: { -// ::: byte peRed; -// ::: byte peGreen; -// ::: byte peBlue; -// ::: byte peFlags; -// ::: } PALETTEENTRY; -// ::: #define HAS_PALETTEENTRY -// ::: #endif - -// ::: #ifndef HAS_LOGPALETTE -// ::: typedef struct -// ::: { -// ::: int palVersion; -// ::: int palNumEntries; -// ::: PALETTEENTRY palPalEntry[255]; // Enough for 256 colors. -// ::: } LOGPALETTE; -// ::: #define HAS_LOGPALETTE -// ::: #endif - -// ::: #ifndef HAS_GUID -// ::: typedef struct -// ::: { -// ::: long Data1; -// ::: int Data2; -// ::: int Data3; -// ::: byte Data4[7]; -// ::: } GUID; -// ::: #define HAS_GUID -// ::: #endif - -#if Win32 - -#define RASTERCAPS (38) -#define RC_PALETTE (0x100) -#define SIZEPALETTE (104) - -// ::: #ifndef HAS_RECT -// ::: typedef struct -// ::: { -// ::: long left; -// ::: long top; -// ::: long right; -// ::: long bottom; -// ::: } RECT; -// ::: #define HAS_RECT -// ::: #endif - -long CreateCompatibleDC(long hDC); -long CreateCompatibleBitmap(long hDC, long nWidth, long nHeight); -long GetDeviceCaps(long hDC, long iCapabilitiy); -long GetSystemPaletteEntries(long hDC, long wStartIndex, long wNumEntries, PALETTEENTRY lpPaletteEntries); -long CreatePalette(LOGPALETTE lpLogPalette); -long SelectObject(long hDC, long hObject); -long BitBlt(long hDCDest, long XDest, long YDest, long nWidth, long nHeight, long hDCSrc, long XSrc, long YSrc, long dwRop); -long DeleteDC(long hDC); -long GetForegroundWindow(); -long SelectPalette(long hDC, long hPalette, long bForceBackground); -long RealizePalette(long hDC); -long GetWindowDC(long hWnd); -long GetDC(long hWnd); -#if 0 -long GetWindowRect(long hWnd, RECT lpRect); -#endif -long ReleaseDC(long hWnd, long hDC); -long GetDesktopWindow(); - -// ::: #ifndef HAS_PicBmp -// ::: typedef struct -// ::: { -// ::: long Size; -// ::: long Type; -// ::: long hBmp; -// ::: long hPal; -// ::: long Reserved; -// ::: } PicBmp; -// ::: #define HAS_PicBmp -// ::: #endif - -long OleCreatePictureIndirect(PicBmp PicDesc, GUID RefIID, long fPictureOwnsHandle, IPicture IPic); - -#elif Win16 - -#define RASTERCAPS (38) -#define RC_PALETTE (0x100) -#define SIZEPALETTE (104) - -// ::: #ifndef HAS_RECT -// ::: typedef struct -// ::: { -// ::: int left; -// ::: int top; -// ::: int right; -// ::: int bottom; -// ::: } RECT; -// ::: #define HAS_RECT -// ::: #endif - -int CreateCompatibleDC(int hDC); -int CreateCompatibleBitmap(int hDC, int nWidth, int nHeight); -int GetDeviceCaps(int hDC, int iCapabilitiy); -int GetSystemPaletteEntries(int hDC, int wStartIndex, int wNumEntries, PALETTEENTRY lpPaletteEntries); -int CreatePalette(LOGPALETTE lpLogPalette); -int SelectObject(int hDC, int hObject); -int BitBlt(int hDCDest, int XDest, int YDest, int nWidth, int nHeight, int hDCSrc, int XSrc, int YSrc, long dwRop); -int DeleteDC(int hDC); -int GetForegroundWindow(); -int SelectPalette(int hDC, int hPalette, int bForceBackground); -int RealizePalette(int hDC); -int GetWindowDC(int hWnd); -int GetDC(int hWnd); -#if 0 -int GetWindowRect(int hWnd, RECT lpRect); -#endif -int ReleaseDC(int hWnd, int hDC); -int GetDesktopWindow(); - -// ::: #ifndef HAS_PicBmp -// ::: typedef struct -// ::: { -// ::: int Size; -// ::: int Type; -// ::: int hBmp; -// ::: int hPal; -// ::: int Reserved; -// ::: } PicBmp; -// ::: #define HAS_PicBmp -// ::: #endif - -int OleCreatePictureIndirect(PicBmp PictDesc, GUID RefIID, int fPictureOwnsHandle, IPicture IPic); - -#endif - -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -// CreateBitmapPicture -// - Creates a bitmap type Picture object from a bitmap and -// palette. -// -// hBmp -// - Handle to a bitmap. -// -// hPal -// - Handle to a Palette. -// - Can be null if the bitmap doesn't use a palette. -// -// Returns -// - Returns a Picture object containing the bitmap. -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -#if Win32 -Picture CreateBitmapPicture(long hBmp, long hPal) -{ - Picture CreateBitmapPicture; - - long r; - -#elif Win16 -Picture CreateBitmapPicture(int hBmp, int hPal) -{ - Picture CreateBitmapPicture; - - int r; - -#endif - PicBmp pic; - - // IPicture requires a reference to "Standard OLE Types." - IPicture IPic; - GUID IID_IDispatch; - - // Fill in with IDispatch Interface ID. - { - IID_IDispatch.Data1 = 0x20400; - IID_IDispatch.Data4[0] = 0xC0; - IID_IDispatch.Data4[7] = 0x46; - } - - // Fill Pic with necessary parts. - { - pic.Size = sizeof(pic); // Length of structure. - pic.Type = vbPicTypeBitmap; // Type of Picture (bitmap). - pic.hBmp = hBmp; // Handle to bitmap. - pic.hPal = hPal; // Handle to palette (may be null). - } - - // Create Picture object. - r = OleCreatePictureIndirect(pic, IID_IDispatch, 1, IPic); - - // Return the new Picture object. - CreateBitmapPicture = IPic; - - return CreateBitmapPicture; -} - -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -// CaptureWindow -// - Captures any portion of a window. -// -// hWndSrc -// - Handle to the window to be captured. -// -// Client -// - If True CaptureWindow captures from the client area of the -// window. -// - If False CaptureWindow captures from the entire window. -// -// LeftSrc, TopSrc, WidthSrc, HeightSrc -// - Specify the portion of the window to capture. -// - Dimensions need to be specified in pixels. -// -// Returns -// - Returns a Picture object containing a bitmap of the specified -// portion of the window that was captured. -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// ''''' -// -#if Win32 -Picture CaptureWindow(long hWndSrc, boolean Client, long LeftSrc, long TopSrc, long WidthSrc, long HeightSrc) -{ - Picture CaptureWindow; - - long hDCMemory; - long hBmp; - long hBmpPrev; - long r; - long hDCSrc; - long hPal; - long hPalPrev; - long RasterCapsScrn; - long HasPaletteScrn; - long PaletteSizeScrn; - -#elif Win16 -Picture CaptureWindow(int hWndSrc, boolean Client, int LeftSrc, int TopSrc, long WidthSrc, long HeightSrc) -{ - Picture CaptureWindow; - - int hDCMemory; - int hBmp; - int hBmpPrev; - int r; - int hDCSrc; - int hPal; - int hPalPrev; - int RasterCapsScrn; - int HasPaletteScrn; - int PaletteSizeScrn; - -#endif - LOGPALETTE LogPal; - - // Depending on the value of Client get the proper device context. - if (Client) - { - hDCSrc = GetDC(hWndSrc); // Get device context for client area. - } - else - { - hDCSrc = GetWindowDC(hWndSrc); // Get device context for entire - // window. - } - - // Create a memory device context for the copy process. - hDCMemory = CreateCompatibleDC(hDCSrc); - // Create a bitmap and place it in the memory DC. - hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc); - hBmpPrev = SelectObject(hDCMemory, hBmp); - - // Get screen properties. - RasterCapsScrn = GetDeviceCaps(hDCSrc, RASTERCAPS); // Raster - // capabilities. - HasPaletteScrn = RasterCapsScrn & RC_PALETTE; // Palette - // support. - PaletteSizeScrn = GetDeviceCaps(hDCSrc, SIZEPALETTE); // Size of - // palette. - - // If the screen has a palette make a copy and realize it. - if (HasPaletteScrn && (PaletteSizeScrn == 256)) - { - // Create a copy of the system palette. - LogPal.palVersion = 0x300; - LogPal.palNumEntries = 256; - r = GetSystemPaletteEntries(hDCSrc, 0, 256, LogPal.palPalEntry[0]); - hPal = CreatePalette(LogPal); - // Select the new palette into the memory DC and realize it. - hPalPrev = SelectPalette(hDCMemory, hPal, 0); - r = RealizePalette(hDCMemory); - } - - // Copy the on-screen image into the memory DC. - r = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy); - - // Remove the new copy of the on-screen image. - hBmp = SelectObject(hDCMemory, hBmpPrev); - - // If the screen has a palette get back the palette that was - // selected in previously. - if (HasPaletteScrn && (PaletteSizeScrn == 256)) - { - hPal = SelectPalette(hDCMemory, hPalPrev, 0); - } - - // Release the device context resources back to the system. - r = DeleteDC(hDCMemory); - r = ReleaseDC(hWndSrc, hDCSrc); - - // Call CreateBitmapPicture to create a picture object from the - // bitmap and palette handles. Then return the resulting picture - // object. - - CaptureWindow = CreateBitmapPicture(hBmp, hPal); - - return CaptureWindow; -} - -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -// CaptureScreen -// - Captures the entire screen. -// -// Returns -// - Returns a Picture object containing a bitmap of the screen. -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -Picture CaptureScreen() -{ - Picture CaptureScreen; - -#if Win32 - long hWndScreen; - -#elif Win16 - int hWndScreen; - -#endif - - // Get a handle to the desktop window. - hWndScreen = GetDesktopWindow(); - - // Call CaptureWindow to capture the entire desktop give the handle - // and return the resulting Picture object. - - CaptureScreen = CaptureWindow(hWndScreen, False, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY); - - return CaptureScreen; -} - -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -// CaptureForm -// - Captures an entire form including title bar and border. -// -// frmSrc -// - The Form object to capture. -// -// Returns -// - Returns a Picture object containing a bitmap of the entire -// form. -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -Picture CaptureForm(Form frmSrc) -{ - Picture CaptureForm; - - // Call CaptureWindow to capture the entire form given its window - // handle and then return the resulting Picture object. - CaptureForm = CaptureWindow(frmSrc.hWnd, False, 0, 0, frmSrc.ScaleX(frmSrc.Width, vbTwips, vbPixels), frmSrc.ScaleY(frmSrc.Height, vbTwips, vbPixels)); - - return CaptureForm; -} - -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -// CaptureClient -// - Captures the client area of a form. -// -// frmSrc -// - The Form object to capture. -// -// Returns -// - Returns a Picture object containing a bitmap of the form's -// client area. -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -Picture CaptureClient(Form frmSrc) -{ - Picture CaptureClient; - - // Call CaptureWindow to capture the client area of the form given - // its window handle and return the resulting Picture object. - CaptureClient = CaptureWindow(frmSrc.hWnd, True, 0, 0, frmSrc.ScaleX(frmSrc.ScaleWidth, frmSrc.ScaleMode, vbPixels), frmSrc.ScaleY(frmSrc.ScaleHeight, frmSrc.ScaleMode, vbPixels)); - - return CaptureClient; -} - -#if 0 - -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -// CaptureActiveWindow -// - Captures the currently active window on the screen. -// -// Returns -// - Returns a Picture object containing a bitmap of the active -// window. -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -Picture CaptureActiveWindow() -{ - Picture CaptureActiveWindow; - -#if Win32 - long hWndActive; - long r; - -#elif Win16 - int hWndActive; - int r; - -#endif - RECT RectActive; - - // Get a handle to the active/foreground window. - hWndActive = GetForegroundWindow(); - - // Get the dimensions of the window. - r = GetWindowRect(hWndActive, RectActive); - - // Call CaptureWindow to capture the active window given its - // handle and return the Resulting Picture object. - CaptureActiveWindow = CaptureWindow(hWndActive, False, 0, 0, RectActive.right - RectActive.left, RectActive.bottom - RectActive.top); - - return CaptureActiveWindow; -} - -#endif - -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -// -// PrintPictureToFitPage -// - Prints a Picture object as big as possible. -// -// Prn -// - Destination Printer object. -// -// Pic -// - Source Picture object. -// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -// -void PrintPictureToFitPage(Printer Prn, Picture pic) -{ - #define vbHiMetric (8) - double PicRatio; - double PrnWidth; - double PrnHeight; - double PrnRatio; - double PrnPicWidth; - double PrnPicHeight; - - // Determine if picture should be printed in landscape or portrait - // and set the orientation. - if (pic.Height >= pic.Width) - { - Prn.Orientation = vbPRORPortrait; // Taller than wide. - } - else - { - Prn.Orientation = vbPRORLandscape; // Wider than tall. - } - - // Calculate device independent Width-to-Height ratio for picture. - PicRatio = pic.Width / pic.Height; - - // Calculate the dimentions of the printable area in HiMetric. - PrnWidth = Prn.ScaleX(Prn.ScaleWidth, Prn.ScaleMode, vbHiMetric); - PrnHeight = Prn.ScaleY(Prn.ScaleHeight, Prn.ScaleMode, vbHiMetric); - // Calculate device independent Width to Height ratio for printer. - PrnRatio = PrnWidth / PrnHeight; - - // Scale the output to the printable area. - if (PicRatio >= PrnRatio) - { - // Scale picture to fit full width of printable area. - PrnPicWidth = Prn.ScaleX(PrnWidth, vbHiMetric, Prn.ScaleMode); - PrnPicHeight = Prn.ScaleY(PrnWidth / PicRatio, vbHiMetric, Prn.ScaleMode); - } - else - { - // Scale picture to fit full height of printable area. - PrnPicHeight = Prn.ScaleY(PrnHeight, vbHiMetric, Prn.ScaleMode); - PrnPicWidth = Prn.ScaleX(PrnHeight * PicRatio, vbHiMetric, Prn.ScaleMode); - } - - // Print the picture using the PaintPicture method. -#if 0 - Prn.PaintPicture(pic, 0, 0, PrnPicWidth, PrnPicHeight); -#endif -} - -// -------------------------------------------------------------------- - -#endif diff --git a/src/game_sp/Capture.h b/src/game_sp/Capture.h deleted file mode 100644 index 427a9b9c..00000000 --- a/src/game_sp/Capture.h +++ /dev/null @@ -1,151 +0,0 @@ -// ---------------------------------------------------------------------------- -// Capture.h -// ---------------------------------------------------------------------------- - -#ifndef CAPTURE_H -#define CAPTURE_H - -#include "vb_types.h" -#include "vb_defs.h" -#include "vb_vars.h" -#include "vb_lib.h" - -#include "global.h" - -#if 0 - -#ifndef HAS_PALETTEENTRY -typedef struct -{ - byte peRed; - byte peGreen; - byte peBlue; - byte peFlags; -} PALETTEENTRY; -#define HAS_PALETTEENTRY -#endif - -#ifndef HAS_LOGPALETTE -typedef struct -{ - int palVersion; - int palNumEntries; - PALETTEENTRY palPalEntry[255]; // Enough for 256 colors. -} LOGPALETTE; -#define HAS_LOGPALETTE -#endif - -#ifndef HAS_GUID -typedef struct -{ - long Data1; - int Data2; - int Data3; - byte Data4[7]; -} GUID; -#define HAS_GUID -#endif - -#if Win32 - -#ifndef HAS_RECT -typedef struct -{ - long left; - long top; - long right; - long bottom; -} RECT; -#define HAS_RECT -#endif - -#ifndef HAS_PicBmp -typedef struct -{ - long Size; - long Type; - long hBmp; - long hPal; - long Reserved; -} PicBmp; -#define HAS_PicBmp -#endif - -#elif Win16 - -#ifndef HAS_RECT -typedef struct -{ - int left; - int top; - int right; - int bottom; -} RECT; -#define HAS_RECT -#endif - -#ifndef HAS_PicBmp -typedef struct -{ - int Size; - int Type; - int hBmp; - int hPal; - int Reserved; -} PicBmp; -#define HAS_PicBmp -#endif - -#endif - -#if Win32 - - - -#elif Win16 - - - -#endif - -#if Win32 - - - -#elif Win16 - - - -#endif - -#if Win32 - - - -#elif Win16 - - - -#endif - -#if Win32 - - - -#elif Win16 - - - -#endif - -extern Picture CaptureActiveWindow(); -extern Picture CaptureClient(Form frmSrc); -extern Picture CaptureForm(Form frmSrc); -extern Picture CaptureScreen(); -extern Picture CaptureWindow(int hWndSrc, boolean Client, int LeftSrc, int TopSrc, long WidthSrc, long HeightSrc); -extern Picture CreateBitmapPicture(int hBmp, int hPal); -extern void PrintPictureToFitPage(Printer Prn, Picture pic); - -#endif - -#endif /* CAPTURE_H */ diff --git a/src/game_sp/DDScrollBuffer.c b/src/game_sp/DDScrollBuffer.c index de5b237e..0f1191ce 100644 --- a/src/game_sp/DDScrollBuffer.c +++ b/src/game_sp/DDScrollBuffer.c @@ -7,27 +7,6 @@ #include -// --- 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 = "DDScrollBuffer"; -// static boolean VB_GlobalNameSpace = False; -// static boolean VB_Creatable = True; -// static boolean VB_PredeclaredId = False; -// static boolean VB_Exposed = False; - -// --- Option Explicit - -// needs reference to: DirectX7 for Visual Basic Type Library - -DirectDrawSurface7 Buffer; -DirectDrawSurface7 mPrimary; long mWidth, mHeight; long mhWnd; long mScrollX, mScrollY; @@ -37,7 +16,6 @@ long mDestXOff, mDestYOff; long ScreenBuffer[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; -int TEST_flag = 0; void RestorePlayfield() { @@ -101,30 +79,13 @@ static void ScrollPlayfield(int dx, int dy) (PlayField8[tsi] << 16) | (DisPlayField[tsi] << 24)); -#if 0 -#if 1 - printf("::: [%d] %d [%d, %d] [%d]\n", dx, sx, x, y, buf_xsize); -#else - if (sx == 0 || sx == MAX_BUF_XSIZE - 1) - printf("::: %d, %d\n", dx, sx); -#endif -#endif - if ((dx == -1 && x == x2) || (dx == +1 && x == x1) || (dy == -1 && y == y2) || (dy == +1 && y == y1)) { -#if 0 - printf("::: %d, %d\n", sx, sy); -#endif - - TEST_flag = 1; - DrawFieldNoAnimated(x, y); DrawFieldAnimated(x, y); - - TEST_flag = 0; } ScreenBuffer[sx][sy] = id; @@ -151,8 +112,6 @@ static void ScrollPlayfieldIfNeededExt(boolean reset) return; } -#if 1 - /* check if scrolling the playfield requires redrawing the viewport bitmap */ if ((mScrollX != mScrollX_last || mScrollY != mScrollY_last) && @@ -168,32 +127,7 @@ static void ScrollPlayfieldIfNeededExt(boolean reset) mScrollY_last -= dy * TILEY; ScrollPlayfield(dx, dy); - -#if 0 - printf("::: %ld, %ld\n", mScrollX, mScrollY); -#endif - } - -#else - - /* check if scrolling the playfield reached the destination tile position */ - if ((mScrollX != mScrollX_last || mScrollY != mScrollY_last) && - mScrollX % TILEX == 0 && mScrollY % TILEY == 0) - { - int dx = (mScrollX < mScrollX_last ? 1 : mScrollX > mScrollX_last ? -1 : 0); - int dy = (mScrollY < mScrollY_last ? 1 : mScrollY > mScrollY_last ? -1 : 0); - - mScrollX_last = mScrollX; - mScrollY_last = mScrollY; - - ScrollPlayfield(dx, dy); - -#if 0 - printf("::: %ld, %ld\n", mScrollX, mScrollY); -#endif } - -#endif } static void ScrollPlayfieldIfNeeded() @@ -280,205 +214,14 @@ void UpdatePlayfield(boolean force_redraw) #endif } -void UpdatePlayfield_TMP() -{ - int x1 = mScrollX_last / TILEX - 2; - int y1 = mScrollY_last / TILEY - 2; - int x2 = mScrollX_last / TILEX + (SCR_FIELDX - 1) + 2; - int y2 = mScrollY_last / TILEY + (SCR_FIELDY - 1) + 2; - int x, y; - - for (y = DisplayMinY; y <= DisplayMaxY; y++) - { - for (x = DisplayMinX; x <= DisplayMaxX; x++) - { - if (x >= x1 && x <= x2 && y >= y1 && y <= y2) - { - int sx = x - x1; - int sy = y - y1; - int tsi = GetSI(x, y); - long id = ((PlayField16[tsi]) | - (PlayField8[tsi] << 16) | - (DisPlayField[tsi] << 24)); - boolean redraw_screen_tile = (ScreenBuffer[sx][sy] != id); - -#if 0 - if (LowByte(PlayField16[tsi]) == fiMurphy) - continue; -#endif - - if (redraw_screen_tile) - { -#if 0 - DrawFieldNoAnimated(x, y); - DrawFieldAnimated(x, y); -#endif - - ScreenBuffer[sx][sy] = id; - - redraw[sx][sy] = TRUE; - redraw_tiles++; - } - } - } - } -} - -void OLD_UpdatePlayfield() -{ - int x, y; - int left = mScrollX / TILEX; - int top = mScrollY / TILEY; - - for (y = top; y < top + MAX_BUF_YSIZE; y++) - { - for (x = left; x < left + MAX_BUF_XSIZE; x++) - { - int sx = x % MAX_BUF_XSIZE; - int sy = y % MAX_BUF_YSIZE; - int tsi = GetSI(x, y); - long id = ((PlayField16[tsi]) | - (PlayField8[tsi] << 16) | - (DisPlayField[tsi] << 24)); - boolean redraw_screen_tile = (ScreenBuffer[sx][sy] != id); - - if (redraw_screen_tile) - { - DrawFieldNoAnimated(x, y); - DrawFieldAnimated(x, y); - - ScreenBuffer[sx][sy] = id; - - redraw[sx][sy] = TRUE; - redraw_tiles++; - } - } - } -} - -void DDScrollBuffer_Let_DestXOff(long NewVal) -{ - mDestXOff = NewVal; -} - -long DDScrollBuffer_Get_DestXOff() -{ - long DestXOff; - - DestXOff = mDestXOff; - - return DestXOff; -} - -void DDScrollBuffer_Let_DestYOff(long NewVal) -{ - mDestYOff = NewVal; -} - -long DDScrollBuffer_Get_DestYOff() -{ - long DestYOff; - - DestYOff = mDestYOff; - - return DestYOff; -} - -DirectDrawSurface7 DDScrollBuffer_Get_Surface() -{ - DirectDrawSurface7 Surface; - - Surface = Buffer; - - return Surface; -} - -long DDScrollBuffer_Get_Width() -{ - long Width; - - Width = mWidth; - - return Width; -} - -int DDScrollBuffer_Get_Height() -{ - int Height; - - Height = mHeight; - - return Height; -} - -#if 0 - -long DDScrollBuffer_CreateAtSize(long Width, long Height, long hWndViewPort) -{ - long CreateAtSize; - - DDSURFACEDESC2 SD; - - CreateAtSize = 0; - mhWnd = hWndViewPort; - // Create ScrollBuffer: - { - SD.lFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - SD.ddsCaps.lCaps = DDSCAPS_VIDEOMEMORY; - // SD.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN - SD.LWidth = Width; - SD.LHeight = Height; - } - - // --- On Error Resume Next - Buffer = DDraw.CreateSurface(SD); - if (Err.Number != 0) - return CreateAtSize; - - // --- On Error GoTo 0 - - mWidth = Width; - mHeight = Height; - mScrollX = 0; - mScrollY = 0; - CreateAtSize = -1; - - return CreateAtSize; -} - -void DDScrollBuffer_Cls(int BackColor) -{ - RECT EmptyRect; - - if (NoDisplayFlag) - return; - - Buffer.BltColorFill(EmptyRect, BackColor); -} - -#endif - /* copy the entire screen to the window at the scroll position */ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) { -#if 0 - int px = 2 * TILEX + mScrollX % TILEX; - int py = 2 * TILEY + mScrollY % TILEY; -#else int px = 2 * TILEX + (mScrollX - mScrollX_last) % TILEX; int py = 2 * TILEY + (mScrollY - mScrollY_last) % TILEY; -#endif int sx, sy, sxsize, sysize; -#if 0 - if (mScrollX % TILEX != (mScrollX - mScrollX_last) % TILEX || - mScrollY % TILEY != (mScrollY - mScrollY_last) % TILEY) - printf("::: %ld, %ld / %ld, %ld\n", - mScrollX, mScrollY, mScrollX_last, mScrollY_last); -#endif - -#if 1 int xsize = SXSIZE; int ysize = SYSIZE; int full_xsize = (FieldWidth - (menBorder.Checked ? 0 : 1)) * TILEX; @@ -488,117 +231,16 @@ void BlitScreenToBitmap_SP(Bitmap *target_bitmap) 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); -#endif - -#if 0 - { - static int mScrollX_tmp = -1; - static int mScrollY_tmp = -1; - if (mScrollX != mScrollX_tmp || mScrollY != mScrollY_tmp) - { - printf("::: %ld, %ld\n", mScrollX, mScrollY); - - mScrollX_tmp = mScrollX; - mScrollY_tmp = mScrollY; - } - } -#endif - -#if 0 - { - static boolean x = 0; - - if (x == 0) - { - printf("::: %d, %d (%d, %d) (%d, %d) [%ld, %ld] [%ld, %ld] \n", - sx, sy, xsize, ysize, full_xsize, full_ysize, - mScrollX, mScrollY, mScrollX_last, mScrollY_last); - - x = 1; - } - } -#endif - -#if 1 if (!menBorder.Checked) { px += TILEX / 2; py += TILEY / 2; } -#endif - -#if 0 - if (mScrollX >= 0 && mScrollX <= 16) - { - px -= mScrollX; - } -#if 0 - else if (mScrollX >= 352 && mScrollX <= 368) - { - px -= mScrollX; - } -#endif - else if (mScrollX >= 16) // && mScrollX <= 352) - { - px -= TILEX / 2; - } -#endif - -#if 0 - /* !!! TEST ONLY !!! */ - px = py = 0; - sx = sy = SX; -#endif BlitBitmap(screenBitmap, target_bitmap, px, py, sxsize, sysize, sx, sy); } -void OLD_BlitScreenToBitmap_SP(Bitmap *target_bitmap) -{ - int x = mScrollX % (MAX_BUF_XSIZE * TILEX); - int y = mScrollY % (MAX_BUF_YSIZE * TILEY); - - if (x < 2 * TILEX && y < 2 * TILEY) - { - BlitBitmap(screenBitmap, target_bitmap, x, y, - SCR_FIELDX * TILEX, SCR_FIELDY * TILEY, SX, SY); - } - else if (x < 2 * TILEX && y >= 2 * TILEY) - { - BlitBitmap(screenBitmap, target_bitmap, x, y, - SCR_FIELDX * TILEX, MAX_BUF_YSIZE * TILEY - y, - SX, SY); - BlitBitmap(screenBitmap, target_bitmap, x, 0, - SCR_FIELDX * TILEX, y - 2 * TILEY, - SX, SY + MAX_BUF_YSIZE * TILEY - y); - } - else if (x >= 2 * TILEX && y < 2 * TILEY) - { - BlitBitmap(screenBitmap, target_bitmap, x, y, - MAX_BUF_XSIZE * TILEX - x, SCR_FIELDY * TILEY, - SX, SY); - BlitBitmap(screenBitmap, target_bitmap, 0, y, - x - 2 * TILEX, SCR_FIELDY * TILEY, - SX + MAX_BUF_XSIZE * TILEX - x, SY); - } - else - { - BlitBitmap(screenBitmap, target_bitmap, x, y, - MAX_BUF_XSIZE * TILEX - x, MAX_BUF_YSIZE * TILEY - y, - SX, SY); - BlitBitmap(screenBitmap, target_bitmap, 0, y, - x - 2 * TILEX, MAX_BUF_YSIZE * TILEY - y, - SX + MAX_BUF_XSIZE * TILEX - x, SY); - BlitBitmap(screenBitmap, target_bitmap, x, 0, - MAX_BUF_XSIZE * TILEX - x, y - 2 * TILEY, - SX, SY + MAX_BUF_YSIZE * TILEY - y); - BlitBitmap(screenBitmap, target_bitmap, 0, 0, - x - 2 * TILEX, y - 2 * TILEY, - SX + MAX_BUF_XSIZE * TILEX - x, SY + MAX_BUF_YSIZE * TILEY - y); - } -} - void BackToFront_SP(void) { static boolean scrolling_last = FALSE; @@ -612,15 +254,7 @@ void BackToFront_SP(void) if (1 || redraw_tiles > REDRAWTILES_THRESHOLD || scrolling || scrolling_last) { -#if 1 BlitScreenToBitmap_SP(window); -#else - /* blit all (up to four) parts of the scroll buffer to the backbuffer */ - BlitScreenToBitmap_SP(backbuffer); - - /* blit the completely updated backbuffer to the window (in one blit) */ - BlitBitmap(backbuffer, window, SX, SY, SXSIZE, SYSIZE, SX, SY); -#endif } else { @@ -649,260 +283,9 @@ void BackToFront_SP(void) scrolling_last = scrolling; } - -void DDScrollBuffer_Blt_Ext(Bitmap *target_bitmap) -{ - MyRECT DR, SR; -#if 1 - long tX, tY; -#else - long tX, tY, L; -#endif - int sX, sY; - // RECT ERect; - // long Restore; - - if (NoDisplayFlag) - return; - -#if 1 - DR.left = 0; - DR.top = 0; - DR.right = SCR_FIELDX * TILEX; - DR.bottom = SCR_FIELDY * TILEY; -#else - // --- On Error GoTo BltEH - DirectX.GetWindowRect(mhWnd, DR); - // --- On Error GoTo 0 -#endif - - { - tX = (DR.right - DR.left) / Stretch; - tY = (DR.bottom - DR.top) / Stretch; - } - - { - SR.left = mScrollX + mDestXOff; - SR.top = mScrollY + mDestYOff; - - SR.right = SR.left + tX; - SR.bottom = SR.top + tY; - - // If mWidth < SR.right Then - // SR.right = mWidth - // DR.right = DR.left + Stretch * (SR.right - SR.left) - // End If - // If mHeight < SR.bottom Then - // SR.bottom = mHeight - // DR.bottom = DR.top + Stretch * (SR.bottom - SR.top) - // End If - // If (mScrollX + mDestXOff) < 0 Then - // SR.left = 0 - // DR.left = DR.left - Stretch * (mScrollX + mDestXOff) - // End If - // If (mScrollY + mDestYOff) < 0 Then - // SR.top = 0 - // DR.top = DR.top - Stretch * (mScrollY + mDestYOff) - // End If - } - -#if 1 - SR.left = (SR.left < 0 ? 0 : SR.left); - SR.top = (SR.top < 0 ? 0 : SR.top); -#endif - -#if 1 - { - int full_xsize = (FieldWidth - (menBorder.Checked ? 0 : 1)) * TILEX; - int full_ysize = (FieldHeight - (menBorder.Checked ? 0 : 1)) * TILEY; - int sxsize = SCR_FIELDX * TILEX; - int sysize = SCR_FIELDY * TILEY; - - tX = (full_xsize < sxsize ? full_xsize : tX); - tY = (full_ysize < sysize ? full_ysize : tY); - sX = SX + (full_xsize < sxsize ? (sxsize - full_xsize) / 2 : 0); - sY = SY + (full_ysize < sysize ? (sysize - full_ysize) / 2 : 0); - } -#endif - -#if 1 - if (!menBorder.Checked) - { - SR.left += TILEX / 2; - SR.top += TILEY / 2; - } -#endif - -#if 1 - -#if 1 - printf("::: DDScrollBuffer.c: DDScrollBuffer_Blt(): blit from %d, %d [%ld, %ld] [%ld, %ld] [%ld, %ld]\n", - SR.left, SR.top, mScrollX, mScrollY, mDestXOff, mDestYOff, tX, tY); -#endif - -#if 0 - /* !!! quick and dirty -- FIX THIS !!! */ - if (tape.playing && tape.fast_forward && - target_bitmap == window && - (FrameCounter % 2) != 0) - printf("::: FrameCounter == %d\n", FrameCounter); -#endif - -#if 1 - SyncDisplay(); -#endif - -#if 1 - BlitBitmap(screenBitmap, target_bitmap, - SR.left, SR.top, tX, tY, sX, sY); -#else - BlitBitmap(screenBitmap, target_bitmap, - SR.left, SR.top, - SCR_FIELDX * TILEX, SCR_FIELDY * TILEY, SX, SY); -#endif - -#if 1 - FlushDisplay(); -#endif - - return; - -#endif - - // DDraw.WaitForVerticalBlank DDWAITVB_BLOCKBEGIN, 0 - if (IS_NOTHING(&Buffer, sizeof(Buffer))) - return; - -#if 0 - if (IS_NOTHING(&PrimarySurface, sizeof(PrimarySurface))) - return; -#endif - -#if 0 - - L = PrimarySurface.Blt(DR, &Buffer, SR, DDBLT_WAIT); - if (L != DD_OK) - { - switch (L) - { -#if 0 - case DDERR_GENERIC: - Debug.Assert(False); - break; - - case DDERR_INVALIDCLIPLIST: - Debug.Assert(False); - break; - - case DDERR_INVALIDOBJECT: - Debug.Assert(False); - break; - - case DDERR_INVALIDPARAMS: - Debug.Assert(False); - break; - - case DDERR_INVALIDRECT: - Debug.Assert(False); - break; - - case DDERR_NOALPHAHW: - Debug.Assert(False); - break; - - case DDERR_NOBLTHW: - Debug.Assert(False); - break; - - case DDERR_NOCLIPLIST: - Debug.Assert(False); - break; - - case DDERR_NODDROPSHW: - Debug.Assert(False); - break; - - case DDERR_NOMIRRORHW: - Debug.Assert(False); - break; - - case DDERR_NORASTEROPHW: - Debug.Assert(False); - break; - - case DDERR_NOROTATIONHW: - Debug.Assert(False); - break; - - case DDERR_NOSTRETCHHW: - Debug.Assert(False); - break; - - case DDERR_NOZBUFFERHW: - Debug.Assert(False); - break; - - case DDERR_SURFACEBUSY: - Debug.Assert(False); - break; -#endif - -#if 0 - case DDERR_SURFACELOST: - DDraw.RestoreAllSurfaces(); - if (! PrimarySurface.isLost()) - { - subDisplayLevel(); - // Blt(); - } - - // RestorePrimarySurface - // ClipToWindow 0 - break; -#endif - -#if 0 - case DDERR_UNSUPPORTED: - Debug.Assert(False); - break; - - case DDERR_WASSTILLDRAWING: - Debug.Assert(False); - break; - - default: - Debug.Assert(False); - break; -#endif - } - } - -#endif - -#if 0 - // Buffer.UpdateOverlay SR, PrimarySurface, DR, DDOVER_SHOW - if (EditFlag) - FMark.RefreshMarker(); -#endif - - // BltEH: -} - void DDScrollBuffer_Blt() { -#if 1 - -#if 1 BackToFront_SP(); -#else - /* !!! TEST ONLY !!! */ - BlitBitmap(screenBitmap, window, - 0, 0, SCR_FIELDX * TILEX, SCR_FIELDY * TILEY, SX, SY); -#endif - -#else - DDScrollBuffer_Blt_Ext(window); -#endif } void DDScrollBuffer_ScrollTo(int X, int Y) @@ -917,11 +300,6 @@ void DDScrollBuffer_ScrollTo(int X, int Y) ScrollX = mScrollX; ScrollY = mScrollY; -#if 0 - printf("::: DDScrollBuffer.c: DDScrollBuffer_ScrollTo(): mScroll: %ld, %ld [%d, %d]\n", - mScrollX, mScrollY, X, Y); -#endif - #if 1 ScrollPlayfieldIfNeeded(); #endif @@ -934,11 +312,6 @@ void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) if (NoDisplayFlag) return; -#if 0 - printf("::: DDScrollBuffer.c: DDScrollBuffer_ScrollTowards(): (1) mScroll: %ld, %ld [%d, %d, %f, %f]\n", - mScrollX, mScrollY, X, Y, Step, Stretch); -#endif - X = X / Stretch; Y = Y / Stretch; dx = X - mScrollX; @@ -957,11 +330,6 @@ void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) ScrollX = mScrollX; ScrollY = mScrollY; -#if 0 - printf("::: DDScrollBuffer.c: DDScrollBuffer_ScrollTowards(): (2) mScroll: %ld, %ld [%d, %d, %f]\n", - mScrollX, mScrollY, X, Y, Step); -#endif - #if 1 ScrollPlayfieldIfNeeded(); #endif @@ -970,22 +338,11 @@ void DDScrollBuffer_ScrollTowards(int X, int Y, double Step) void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) { double dx, dY; -#if 0 - TickCountObject Tick; -#endif long dT, StepCount; double T, tStep; long oldX, oldY, maxD; static boolean AlreadyRunning = False; -#if 0 - printf(":a: %d, %d [%d, %d] [%d, %d] [%d, %d]\n", - mScrollX, mScrollY, - mScrollX_last, mScrollY_last, - ScreenScrollXPos, ScreenScrollYPos, - ScrollX, ScrollY); -#endif - if (NoDisplayFlag) return; @@ -1018,71 +375,24 @@ void DDScrollBuffer_SoftScrollTo(int X, int Y, long TimeMS, int FPS) if (UserDragFlag) goto SoftScrollEH; - // If Claim Then Exit For - -#if 0 - Tick.DelayMS(dT, False); -#endif - mScrollX = oldX + T * dx; mScrollY = oldY + T * dY; ScrollX = mScrollX; ScrollY = mScrollY; - -#if 0 - Blt(); -#endif } -#if 0 - printf(":x: %d, %d [%d, %d] [%d, %d] [%d, %d]\n", - mScrollX, mScrollY, - mScrollX_last, mScrollY_last, - ScreenScrollXPos, ScreenScrollYPos, - ScrollX, ScrollY); -#endif - if (UserDragFlag) goto SoftScrollEH; -#if 0 - Tick.DelayMS(dT, False); -#endif - mScrollX = X; mScrollY = Y; ScrollX = mScrollX; ScrollY = mScrollY; -#if 0 - Blt(); -#endif - SoftScrollEH: AlreadyRunning = False; -#if 0 - printf("::: DDScrollBuffer.c: DDScrollBuffer_SoftScrollTo(): mScroll: %ld, %ld\n", - mScrollX, mScrollY); -#endif - -#if 0 - printf(":y: %d, %d [%d, %d] [%d, %d] [%d, %d]\n", - mScrollX, mScrollY, - mScrollX_last, mScrollY_last, - ScreenScrollXPos, ScreenScrollYPos, - ScrollX, ScrollY); -#endif - #if 1 ScrollPlayfieldIfNeeded(); #endif - -#if 0 - printf(":z: %d, %d [%d, %d] [%d, %d] [%d, %d]\n", - mScrollX, mScrollY, - mScrollX_last, mScrollY_last, - ScreenScrollXPos, ScreenScrollYPos, - ScrollX, ScrollY); -#endif } diff --git a/src/game_sp/DDScrollBuffer.h b/src/game_sp/DDScrollBuffer.h index aaaf63ab..3224d72a 100644 --- a/src/game_sp/DDScrollBuffer.h +++ b/src/game_sp/DDScrollBuffer.h @@ -12,6 +12,7 @@ #include "global.h" + extern long mScrollX, mScrollY; extern long mScrollX_last, mScrollY_last; @@ -24,17 +25,7 @@ extern void InitScrollPlayfield(); extern void UpdatePlayfield(); extern void RestorePlayfield(); -extern void DDScrollBuffer_Blt_Ext(Bitmap *); extern void DDScrollBuffer_Blt(); -extern void DDScrollBuffer_Cls(int BackColor); -extern long DDScrollBuffer_CreateAtSize(long Width, long Height, long hWndViewPort); -extern long DDScrollBuffer_Get_DestXOff(); -extern long DDScrollBuffer_Get_DestYOff(); -extern int DDScrollBuffer_Get_Height(); -extern DirectDrawSurface7 DDScrollBuffer_Get_Surface(); -extern long DDScrollBuffer_Get_Width(); -extern void DDScrollBuffer_Let_DestXOff(long NewVal); -extern void DDScrollBuffer_Let_DestYOff(long NewVal); 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 36d271f1..39f04e76 100644 --- a/src/game_sp/DDSpriteBuffer.c +++ b/src/game_sp/DDSpriteBuffer.c @@ -4,188 +4,22 @@ #include "DDSpriteBuffer.h" -static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY); -// --- 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 = "DDSpriteBuffer"; -// static boolean VB_GlobalNameSpace = False; -// static boolean VB_Creatable = True; -// static boolean VB_PredeclaredId = False; -// static boolean VB_Exposed = False; -// --- Option Explicit - -// needs reference to: DirectX7 for Visual Basic Type Library - -DirectDrawSurface7 Buffer; -DirectDrawSurface7 mDest; long mXSpriteCount, mYSpriteCount; long mSpriteWidth, mSpriteHeight; long mDestXOff, mDestYOff; -void DDSpriteBuffer_Let_DestXOff(long NewVal) -{ - mDestXOff = NewVal; -} - -long DDSpriteBuffer_Get_DestXOff() -{ - long DestXOff; - - DestXOff = mDestXOff; - - return DestXOff; -} - -void DDSpriteBuffer_Let_DestYOff(long NewVal) -{ - mDestYOff = NewVal; -} - -long DDSpriteBuffer_Get_DestYOff() -{ - long DestYOff; - - DestYOff = mDestYOff; - - return DestYOff; -} - -int DDSpriteBuffer_Set_DestinationSurface(DirectDrawSurface7 DSurface) -{ - int DestinationSurface; - - mDest = DSurface; - - return DestinationSurface; -} - -DirectDrawSurface7 DDSpriteBuffer_Get_Surface() -{ - DirectDrawSurface7 Surface; - - Surface = Buffer; - - return Surface; -} - -long DDSpriteBuffer_Get_Width() -{ - long Width; - - Width = mSpriteWidth * mXSpriteCount; - - return Width; -} - -int DDSpriteBuffer_Get_Height() -{ - int Height; - - Height = mSpriteHeight * mYSpriteCount; - - return Height; -} - -boolean DDSpriteBuffer_CreateFromFile(char *Path, long xSprites, long ySprites) +void DDSpriteBuffer_Init() { - boolean CreateFromFile; - - DDSURFACEDESC2 SD; - - { - SD.lFlags = DDSD_CAPS; // Or DDSD_WIDTH Or DDSD_HEIGHT - SD.ddsCaps.lCaps = DDSCAPS_VIDEOMEMORY; // DDSCAPS_SYSTEMMEMORY 'DDSCAPS_OFFSCREENPLAIN - } - - // --- On Error GoTo CreateFromFileEH -#if 1 - SD.LWidth = 16 * TILEX; - SD.LHeight = 16 * TILEY; -#else - Buffer = DDraw.CreateSurfaceFromFile(Path, SD); -#endif - // --- On Error GoTo 0 - -#if 0 - Buffer.GetSurfaceDesc(SD); -#endif - - mSpriteWidth = SD.LWidth / xSprites; - mSpriteHeight = SD.LHeight / ySprites; - mXSpriteCount = xSprites; - mYSpriteCount = ySprites; - - CreateFromFile = True; - return CreateFromFile; - - // CreateFromFileEH: - CreateFromFile = False; - - return CreateFromFile; + mSpriteWidth = TILEX; + mSpriteHeight = TILEY; + mXSpriteCount = 16; + mYSpriteCount = 16; } -#if 0 - -boolean DDSpriteBuffer_CreateAtSize(long Width, long Height, long xSprites, long ySprites) -{ - boolean CreateAtSize; - - DDSURFACEDESC2 SD; - - { - SD.lFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - SD.ddsCaps.lCaps = DDSCAPS_VIDEOMEMORY; - // SD.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN - SD.LWidth = Width; - SD.LHeight = Height; - } - - // --- On Error GoTo CreateAtSizeEH - Buffer = DDraw.CreateSurface(SD); - // --- On Error GoTo 0 - - mSpriteWidth = Width / xSprites; - mSpriteHeight = Height / ySprites; - mXSpriteCount = xSprites; - mYSpriteCount = ySprites; - CreateAtSize = True; - return CreateAtSize; - - // CreateAtSizeEH: - CreateAtSize = False; - - return CreateAtSize; -} - -#endif - -#if 0 - -void DDSpriteBuffer_Cls(int BackColor) -{ - RECT EmptyRect; - - Buffer.BltColorFill(EmptyRect, BackColor); -} - -#endif - static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY) { MyRECT DR, SR; -#if 0 - long Tmp; -#endif - -#if 1 int scx = (mScrollX_last < 0 ? 0 : mScrollX_last); int scy = (mScrollY_last < 0 ? 0 : mScrollY_last); @@ -197,216 +31,29 @@ static void Blt(int pX, int pY, Bitmap *bitmap, int SpriteX, int SpriteY) int sx = pX - sx1; int sy = pY - sy1; -#else - - int sx1 = mScrollX - TILEX; - int sy1 = mScrollY - TILEY; - int sx2 = mScrollX + SXSIZE + TILEX; - int sy2 = mScrollY + SYSIZE + TILEY; - int x1 = sx1 / TILEX; - int y1 = sy1 / TILEY; - -#if 0 - int x2 = sx2 / TILEX; - int y2 = sy2 / TILEY; -#endif - - int sx = pX - x1 * TILEX; - int sy = pY - y1 * TILEY; - -#endif - -#if 0 - printf(":1: DDSpriteBuffer.c: Blt(): %d, %d [%ld, %ld]\n", - pX, pY, mScrollX, mScrollY); -#endif - if (NoDisplayFlag) return; -#if 0 - if (TEST_flag) - { - if (pX < sx1 || pX > sx2 || pY < sy1 || pY > sy2) - printf("::: DDSpriteBuffer.c: Blt(): %d, %d [%d..%d, %d..%d] (%ld, %ld) (%ld, %ld) [SKIPPED]\n", - pX, pY, sx1, sx2, sy1, sy2, mScrollX, mScrollY, mScrollX_last, mScrollY_last); - else - printf("::: DDSpriteBuffer.c: Blt(): %d, %d [%d..%d, %d..%d] (%ld, %ld) (%ld, %ld)\n", - pX, pY, sx1, sx2, sy1, sy2, mScrollX, mScrollY, mScrollX_last, mScrollY_last); - } -#endif - /* do not draw fields that are outside the visible screen area */ if (pX < sx1 || pX > sx2 || pY < sy1 || pY > sy2) return; -#if 0 - printf(":2: DDSpriteBuffer.c: Blt(): %d, %d [%ld, %ld]\n", - pX, pY, mScrollX, mScrollY); -#endif - - { - DR.left = pX + mDestXOff; - DR.top = pY + mDestYOff; - DR.right = pX + mSpriteWidth + mDestXOff; - DR.bottom = pY + mSpriteHeight + mDestYOff; - } - { -#if 1 - SR.left = SpriteX; - SR.top = SpriteY; -#else - SR.left = mSpriteWidth * (SpriteX - 1); - SR.top = mSpriteHeight * (SpriteY - 1); -#endif - SR.right = SR.left + mSpriteWidth; - SR.bottom = SR.top + mSpriteHeight; - } - -#if 0 - printf("::: DDSpriteBuffer.c: Blt(): %d, %d\n", DR.left, DR.top); -#endif + DR.left = pX + mDestXOff; + DR.top = pY + mDestYOff; + DR.right = pX + mSpriteWidth + mDestXOff; + DR.bottom = pY + mSpriteHeight + mDestYOff; -#if 0 - printf("::: DDSpriteBuffer.c: Blt(): %d, %d\n", sx, sy); -#endif + SR.left = SpriteX; + SR.top = SpriteY; + SR.right = SR.left + mSpriteWidth; + SR.bottom = SR.top + mSpriteHeight; -#if 0 - if (pX == 0 * StretchWidth && pY == 0 * StretchWidth) - printf("::: TEST: drawing topleft corner ...\n"); - if (pX == 59 * StretchWidth && pY == 23 * StretchWidth) - printf("::: TEST: drawing bottomright corner ...\n"); -#endif - -#if 1 - -#if 1 BlitBitmap(bitmap, screenBitmap, SR.left, SR.top, mSpriteWidth, mSpriteHeight, sx, sy); -#else - BlitBitmap(sp_objects, screenBitmap, - SR.left, SR.top, - mSpriteWidth, mSpriteHeight, - DR.left, DR.top); -#endif - -#else - Tmp = mDest.Blt(DR, &Buffer, SR, DDBLT_WAIT); -#endif } -#if 0 - -static void OLD_Blt(int pX, int pY, int SpriteX, int SpriteY) -{ - RECT DR, SR; -#if 0 - long Tmp; -#endif - -#if 1 - int left = mScrollX; - int top = mScrollY; -#else - int left = mScrollX / TILEX; - int top = mScrollY / TILEY; -#endif - - int sx = pX % (MAX_BUF_XSIZE * TILEX); - int sy = pY % (MAX_BUF_YSIZE * TILEY); - -#if 0 - printf("::: DDSpriteBuffer.c: Blt(): %d, %d [%ld, %ld] [%d, %d]\n", - pX, pY, mScrollX, mScrollY, left, top); -#endif - - if (NoDisplayFlag) - return; - - /* do not draw fields that are outside the visible screen area */ - if (pX < left || pX >= left + MAX_BUF_XSIZE * TILEX || - pY < top || pY >= top + MAX_BUF_YSIZE * TILEY) - return; - - { - DR.left = pX + mDestXOff; - DR.top = pY + mDestYOff; - DR.right = pX + mSpriteWidth + mDestXOff; - DR.bottom = pY + mSpriteHeight + mDestYOff; - } - { - SR.left = mSpriteWidth * (SpriteX - 1); - SR.top = mSpriteHeight * (SpriteY - 1); - SR.right = SR.left + mSpriteWidth; - SR.bottom = SR.top + mSpriteHeight; - } - -#if 0 - printf("::: DDSpriteBuffer.c: Blt(): %d, %d\n", DR.left, DR.top); -#endif - -#if 0 - if (pX == 0 * StretchWidth && pY == 0 * StretchWidth) - printf("::: TEST: drawing topleft corner ...\n"); - if (pX == 59 * StretchWidth && pY == 23 * StretchWidth) - printf("::: TEST: drawing bottomright corner ...\n"); -#endif - -#if 1 - -#if 1 - BlitBitmap(sp_objects, screenBitmap, - SR.left, SR.top, - mSpriteWidth, mSpriteHeight, - sx, sy); -#else - BlitBitmap(sp_objects, screenBitmap, - SR.left, SR.top, - mSpriteWidth, mSpriteHeight, - DR.left, DR.top); -#endif - -#else - Tmp = mDest.Blt(DR, &Buffer, SR, DDBLT_WAIT); -#endif -} - -#endif - -#if 0 - -void DDSpriteBuffer_BltEx(int pX, int pY, int SpritePos) -{ - int XPos, YPos; - - if (NoDisplayFlag) - return; - -#if 1 - XPos = mSpriteWidth * (SpritePos % mXSpriteCount); - YPos = mSpriteHeight * (SpritePos / mXSpriteCount); -#else - XPos = (SpritePos % mXSpriteCount) + 1; - YPos = (SpritePos / mXSpriteCount) + 1; -#endif - -#if 0 - printf("::: BltEx: %d, %d, %d, %d\n", pX, pY, XPos, YPos); -#endif - -#if 0 - if (TEST_flag) - printf("::: DDSpriteBuffer_BltEx(): %d, %d [%d]\n", - pX, pY, SpritePos); -#endif - - Blt(pX, pY, sp_objects, XPos, YPos); -} - -#endif - void DDSpriteBuffer_BltImg(int pX, int pY, int graphic, int sync_frame) { struct GraphicInfo_SP g; @@ -416,48 +63,5 @@ void DDSpriteBuffer_BltImg(int pX, int pY, int graphic, int sync_frame) getGraphicSource_SP(&g, graphic, sync_frame, -1, -1); -#if 0 - printf("::: BltImg: %d, %d, %d, %d\n", pX, pY, g.src_x, g.src_y); -#endif - Blt(pX, pY, g.bitmap, g.src_x, g.src_y); } - -// Public Function GetStretchCopy(Stretch!) As DDSpriteBuffer -// Dim SR As RECT, DR As RECT, Y%, X%, pX%, pY%, Tmp& -// // Set GetStretchCopy = New DDSpriteBuffer // (handle this later, if needed) -// If Not GetStretchCopy.CreateAtSize(Stretch * Width, Stretch * Height, mXSpriteCount, mYSpriteCount) Then -// Set GetStretchCopy = Nothing -// Else -// For Y = 0 To mYSpriteCount - 1 -// pY = Y * Stretch * mSpriteHeight -// For X = 0 To mXSpriteCount - 1 -// pX = X * Stretch * mSpriteWidth -// With DR -// .left = pX -// .top = pY -// .right = pX + mSpriteWidth * Stretch -// .bottom = pY + mSpriteHeight * Stretch -// End With -// With SR -// .left = mSpriteWidth * X -// .top = mSpriteHeight * Y -// .right = .left + mSpriteWidth -// .bottom = .top + mSpriteHeight -// End With -// Tmp = GetStretchCopy.Surface.Blt(DR, Buffer, SR, DDBLT_WAIT) -// Next X -// Next Y -// 'GetStretchCopy.Surface.Blt DR, Buffer, DR, DDBLT_WAIT -// End If -// End Function - -#if 0 - -static void Class_Initialize() -{ - mDestXOff = 0; - mDestYOff = 0; -} - -#endif diff --git a/src/game_sp/DDSpriteBuffer.h b/src/game_sp/DDSpriteBuffer.h index 54b2df2c..5840a175 100644 --- a/src/game_sp/DDSpriteBuffer.h +++ b/src/game_sp/DDSpriteBuffer.h @@ -12,18 +12,8 @@ #include "global.h" -extern void DDSpriteBuffer_BltEx(int pX, int pY, int SpritePos); + +extern void DDSpriteBuffer_Init(); extern void DDSpriteBuffer_BltImg(int pX, int pY, int graphic, int sync_frame); -extern void DDSpriteBuffer_Cls(int BackColor); -extern boolean DDSpriteBuffer_CreateAtSize(long Width, long Height, long xSprites, long ySprites); -extern boolean DDSpriteBuffer_CreateFromFile(char *Path, long xSprites, long ySprites); -extern long DDSpriteBuffer_Get_DestXOff(); -extern long DDSpriteBuffer_Get_DestYOff(); -extern int DDSpriteBuffer_Get_Height(); -extern DirectDrawSurface7 DDSpriteBuffer_Get_Surface(); -extern long DDSpriteBuffer_Get_Width(); -extern void DDSpriteBuffer_Let_DestXOff(long NewVal); -extern void DDSpriteBuffer_Let_DestYOff(long NewVal); -extern int DDSpriteBuffer_Set_DestinationSurface(DirectDrawSurface7 DSurface); #endif /* DDSPRITEBUFFER_H */ diff --git a/src/game_sp/Infotrons.c b/src/game_sp/Infotrons.c index 49d23c5c..c804191f 100644 --- a/src/game_sp/Infotrons.c +++ b/src/game_sp/Infotrons.c @@ -213,7 +213,8 @@ loc_g_133A: // test if infotron may roll left goto loc_g_11BD; MovHighByte(&PlayField16[si], 0x50); // infotron rolls left - Mov(&PlayField16[si - 1], 0x8888); + PlayField16[si - 1] = 0x8888; + return subAnimateInfotrons; loc_g_1350: // test if infotron may roll right @@ -221,7 +222,8 @@ loc_g_1350: // test if infotron may roll right return subAnimateInfotrons; MovHighByte(&PlayField16[si], 0x60); // infotron rolls right - Mov(&PlayField16[si + 1], 0x8888); + PlayField16[si + 1] = 0x8888; + return subAnimateInfotrons; loc_g_1364: // Murphy dies, but not in any case diff --git a/src/game_sp/MainForm.c b/src/game_sp/MainForm.c index f44177c7..731cd0fb 100644 --- a/src/game_sp/MainForm.c +++ b/src/game_sp/MainForm.c @@ -3290,12 +3290,6 @@ void DrawFieldNoAnimated(int X, int Y) Tmp = DisPlayField[tsi]; } -#if 0 - if (TEST_flag) - printf("::: MainForm.c: DrawFieldNoAnimated(): %d, %d [%d]\n", - X, Y, Tmp); -#endif - #if 1 if (Tmp >= 0 && Tmp <= 40) { diff --git a/src/game_sp/Makefile b/src/game_sp/Makefile index 4679486b..03424b38 100644 --- a/src/game_sp/Makefile +++ b/src/game_sp/Makefile @@ -19,9 +19,7 @@ SRCS = init.c \ vb_vars.c \ \ ASM.c \ - BitMapObject.c \ BugsTerminals.c \ - Capture.c \ DDScrollBuffer.c \ DDSpriteBuffer.c \ Demo.c \ @@ -64,9 +62,7 @@ OBJS = init.o \ vb_vars.o \ \ ASM.o \ - BitMapObject.o \ BugsTerminals.o \ - Capture.o \ DDScrollBuffer.o \ DDSpriteBuffer.o \ Demo.o \ diff --git a/src/game_sp/Murphy.c b/src/game_sp/Murphy.c index ae4fd764..33421783 100644 --- a/src/game_sp/Murphy.c +++ b/src/game_sp/Murphy.c @@ -686,7 +686,7 @@ loc_g_62E2: dx = aniFramesRedDisk; dx1 = aniRedDisk; MovLowByte(&RedDiskReleasePhase, 1); - Mov(&RedDiskReleaseMurphyPos, *si); // remember Murphy's location + RedDiskReleaseMurphyPos = *si; // remember Murphy's location goto loc_Split; // ========================================================================== diff --git a/src/game_sp/Zonk.c b/src/game_sp/Zonk.c index f047a610..b14af7ea 100644 --- a/src/game_sp/Zonk.c +++ b/src/game_sp/Zonk.c @@ -216,7 +216,7 @@ loc_g_0EEA: // test if zonk may roll left goto loc_g_0D4C; MovHighByte(&PlayField16[si], 0x50); // zonk rolls left - Mov(&PlayField16[si - 1], 0x8888); // mark as zonk accessing? + PlayField16[si - 1] = 0x8888; // mark as zonk accessing? return subAnimateZonks; loc_g_0F00: // test if zonk may roll right @@ -224,7 +224,7 @@ loc_g_0F00: // test if zonk may roll right return subAnimateZonks; MovHighByte(&PlayField16[si], 0x60); // zonk rolls right - Mov(&PlayField16[si + 1], 0x8888); // mark as zonk accessing? + PlayField16[si + 1] = 0x8888; // mark as zonk accessing? return subAnimateZonks; loc_g_0F14: // Murphy dies, but not in any case diff --git a/src/game_sp/global.h b/src/game_sp/global.h index 73a8282b..4829b2f0 100644 --- a/src/game_sp/global.h +++ b/src/game_sp/global.h @@ -8,9 +8,7 @@ #include "main_sp.h" #include "ASM.h" -#include "BitMapObject.h" #include "BugsTerminals.h" -#include "Capture.h" #include "DDScrollBuffer.h" #include "DDSpriteBuffer.h" #include "Demo.h" diff --git a/src/game_sp/init.c b/src/game_sp/init.c index 8ac8804e..f79e20b0 100644 --- a/src/game_sp/init.c +++ b/src/game_sp/init.c @@ -3,11 +3,6 @@ #include "global.h" -#if 0 -Bitmap *sp_objects; - -#endif - Bitmap *screenBitmap; struct EngineSnapshotInfo_SP engine_snapshot_sp; @@ -40,22 +35,10 @@ void sp_open_all() Form_Load(); -#if 0 - SetBitmaps_SP(&sp_objects); -#endif - -#if 0 - /* too small for oversized levels, but too big for graphics performance */ - /* (the whole playfield is drawn/updated, not only visible/scrolled area) */ - /* !!! FIX THIS !!! */ - screenBitmap = CreateBitmap(60 * TILEX, 24 * TILEY, - DEFAULT_DEPTH); -#else screenBitmap = CreateBitmap(MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY, DEFAULT_DEPTH); -#endif - DDSpriteBuffer_CreateFromFile("[NONE]", 16, 16); + DDSpriteBuffer_Init(); } void sp_close_all() diff --git a/src/game_sp/main.c b/src/game_sp/main.c index 299a63b5..a5ca525e 100644 --- a/src/game_sp/main.c +++ b/src/game_sp/main.c @@ -6,7 +6,6 @@ struct GameInfo_SP game_sp; struct LevelInfo_SP native_sp_level; - int GfxElementLast[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT]; int GfxGraphicLast[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT]; int GfxGraphic[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT]; @@ -42,34 +41,11 @@ void InitGameEngine_SP() InitScrollPlayfield(); -#if 0 - printf(":A: %d, %d [%d, %d]\n", - mScrollX, mScrollY, mScrollX_last, mScrollY_last); -#endif - -#if 1 menPlay_Click(); -#else - menPlayDemo_Click(); -#endif - -#if 0 - printf(":B: %d, %d [%d, %d]\n", - mScrollX, mScrollY, mScrollX_last, mScrollY_last); -#endif -} - -#if 0 -void BlitScreenToBitmap_SP(Bitmap *target_bitmap) -{ - DDScrollBuffer_Blt_Ext(target_bitmap); } -#endif void RedrawPlayfield_SP(boolean force_redraw) { - // subDisplayLevel(); - if (force_redraw) RestorePlayfield(); @@ -80,28 +56,10 @@ void RedrawPlayfield_SP(boolean force_redraw) void DrawGameDoorValues_SP() { -#if 1 - game_sp.time_played = TimerVar / setup.game_frame_delay; game_sp.infotrons_still_needed = InfotronsNeeded; game_sp.red_disk_count = RedDiskCount; game_sp.score = 0; // (currently no score in Supaplex engine) - -#else - - int infotrons_still_needed = InfotronsNeeded; - int red_disks = RedDiskCount; - int no_score_in_supaplex = 0; -#if 1 - int level_time_played = TimerVar / setup.game_frame_delay; -#else - int level_time_played = TimerVar / 35; /* !!! CHECK THIS !!! */ -#endif - int no_keys_in_supaplex = 0; - - DrawAllGameValues(infotrons_still_needed, red_disks, no_score_in_supaplex, - level_time_played, no_keys_in_supaplex); -#endif } void GameActions_SP(byte action[MAX_PLAYERS], boolean warp_mode) diff --git a/src/tools.c b/src/tools.c index c6cd967a..42e82254 100644 --- a/src/tools.c +++ b/src/tools.c @@ -7789,11 +7789,6 @@ void getGraphicSource_SP(struct GraphicInfo_SP *g_sp, getGraphicSource(graphic, frame, &g_sp->bitmap, &g_sp->src_x, &g_sp->src_y); } -boolean isRandomAnimation_SP(int graphic) -{ - return (ANIM_MODE(graphic) == ANIM_RANDOM); -} - boolean isNextAnimationFrame_SP(int graphic, int sync_frame) { return (IS_NEXT_FRAME(sync_frame, graphic)); -- 2.34.1