Current News Archived News Search News Discussion Forum Old Forum Install Programs More Downloads... Troubleshooting Source Code Format Specs. Misc. Information Non-SF Stuff Links Small banner for links to this site: |
diff --git a/drawgrp/drawgrp.cpp b/drawgrp/drawgrp.cpp
--- a/drawgrp/drawgrp.cpp
+++ b/drawgrp/drawgrp.cpp
return RetVal;\r
}*/\r
\r
+struct BufferInfo {\r
+ WORD nWidth;\r
+ WORD nHeight;\r
+ LPDWORD pBuffer;\r
+};\r
+\r
+COLORREF WINAPI ReadPixelFromBuffer(BufferInfo *pBI, int X, int Y)\r
+{\r
+ return pBI->pBuffer[(Y * pBI->nWidth) + X];\r
+}\r
+\r
+void WINAPI WritePixelToBuffer(BufferInfo *pBI, int X, int Y, COLORREF clrColor)\r
+{\r
+ pBI->pBuffer[(Y * pBI->nWidth) + X] = clrColor;\r
+}\r
+\r
int main(int argc, char* argv[])\r
{\r
HANDLE hMPQ=0,hMPQ2=0,hMPQ3=0;\r
DWORD *dwPalette = (DWORD *)_alloca(1024);\r
memset(dwPalette,0,1024);\r
+ LoadStorm("SFMpq.dll");\r
+ SetMpqDll("SFMpq.dll");\r
if (SFileOpenArchive!=0) {\r
char *buffer = (char *)_alloca(13);\r
memcpy(buffer,"StarDat.mpq",12);\r
memcpy(buffer,"Patch_rt.mpq",13);\r
SFileOpenArchive(buffer,3000,0,&hMPQ3);\r
}\r
+ SetFunctionGetPixel((GETPIXELPROC)ReadPixelFromBuffer);\r
+ SetFunctionSetPixel((SETPIXELPROC)WritePixelToBuffer);\r
+ BufferInfo BI;\r
LoadPalette("tileset\\Jungle.wpe",dwPalette);\r
HANDLE hGrp;\r
if (argc>1)\r
HDC hDC = GetDC(0);\r
GRPHEADER GrpInfo;\r
if (GetGrpInfo(hGrp,&GrpInfo)==0) {GrpInfo.nFrames=0;GrpInfo.wMaxWidth=0;GrpInfo.wMaxHeight=0;}\r
+ BI.nWidth = GrpInfo.wMaxWidth;\r
+ BI.nHeight = GrpInfo.wMaxHeight;\r
+ BI.pBuffer = (DWORD *)malloc(BI.nWidth * BI.nHeight * sizeof(DWORD));\r
+ WORD i,x,y;\r
+ DWORD j;\r
+ for (i = 0; i < BI.nWidth * BI.nHeight; i++)\r
+ BI.pBuffer[i] = 0xFFFFFFFF;\r
//for (DWORD j=0;j<16;j++){\r
/*for (WORD i=0;i<GrpInfo.nFrames;i++) {\r
DrawGrp(hGrp,hDC,0,0,i,dwPalette,ALPHA_BLEND,0x401020);\r
}*/\r
- for (WORD i=8;i<400;i+=17) {\r
- for (DWORD j=0;j<8;j++)\r
- DrawGrp(hGrp,hDC,i,0,i % (17*8),dwPalette,ALPHA_BLEND,0x401020);\r
+ COLORREF clrPixel;\r
+ RECT rect;\r
+ for (i=13;i<400;i+=17) {\r
+ rect.left = rect.top = i;\r
+ rect.right = rect.left + BI.nWidth;\r
+ rect.bottom = rect.top + BI.nHeight;\r
+ for (x = 0; x < BI.nWidth * BI.nHeight; x++)\r
+ BI.pBuffer[x] = 0xFFFFFFFF;\r
+ for (j=0;j<32;j++) {\r
+// DrawGrp(hGrp,(HDC)&BI,i,0,i % (17*8),dwPalette,ALPHA_BLEND,0x401020);\r
+ DrawGrp(hGrp,(HDC)&BI,0,0,i % (17*8),dwPalette,0,0x401020);\r
+ for (x = 0; x < BI.nWidth; x++)\r
+ for (y = 0; y < BI.nHeight; y++) {\r
+ clrPixel = BI.pBuffer[(y * BI.nWidth) + x];\r
+ if (clrPixel != 0xFFFFFFFF) SetPixelV(hDC, i + x, i + y, clrPixel);\r
+ }\r
+ }\r
+ FillRect(hDC, &rect, (HBRUSH) (COLOR_WINDOW+1));\r
}\r
- for (i=8;i<400;i+=17) {\r
- for (DWORD j=0;j<8;j++)\r
- DrawGrp(hGrp,hDC,400-i,0,i % (17*8),dwPalette,HORIZONTAL_FLIP|ALPHA_BLEND,0x401020);\r
+ for (i=4;i<400;i+=17) {\r
+ rect.left = rect.top = 400-i;\r
+ rect.right = rect.left + BI.nWidth;\r
+ rect.bottom = rect.top + BI.nHeight;\r
+ for (x = 0; x < BI.nWidth * BI.nHeight; x++)\r
+ BI.pBuffer[x] = 0xFFFFFFFF;\r
+ for (j=0;j<32;j++) {\r
+// DrawGrp(hGrp,(HDC)&BI,400-i,0,i % (17*8),dwPalette,HORIZONTAL_FLIP|ALPHA_BLEND,0x401020);\r
+ DrawGrp(hGrp,(HDC)&BI,0,0,i % (17*8),dwPalette,HORIZONTAL_FLIP,0x401020);\r
+ for (x = 0; x < BI.nWidth; x++)\r
+ for (y = 0; y < BI.nHeight; y++) {\r
+ clrPixel = BI.pBuffer[(y * BI.nWidth) + x];\r
+ if (clrPixel != 0xFFFFFFFF) SetPixelV(hDC, 400-i + x, 400-i + y, clrPixel);\r
+ }\r
+ }\r
+ FillRect(hDC, &rect, (HBRUSH) (COLOR_WINDOW+1));\r
}\r
+ for (i = 0; i < BI.nWidth; i++)\r
+ for (j = 0; j < BI.nHeight; j++) {\r
+ clrPixel = BI.pBuffer[(j * BI.nWidth) + i];\r
+ if (clrPixel != 0xFFFFFFFF) SetPixelV(hDC, 400 + i, 300 + j, clrPixel);\r
+ }\r
//}\r
ReleaseDC(0,hDC);\r
+ free(BI.pBuffer);\r
DestroyGrp(hGrp);\r
if (SFileCloseArchive!=0) {\r
if (hMPQ3!=0) SFileCloseArchive(hMPQ3);\r
--- a/grpapi/grpapi_no-lib.cpp
+++ b/grpapi/grpapi_no-lib.cpp
funcDestroyGrp DestroyGrp = 0;\r
funcDrawGrp DrawGrp = 0;\r
funcGetGrpInfo GetGrpInfo = 0;\r
+funcSetFunctionGetPixel SetFunctionGetPixel = 0;\r
+funcSetFunctionSetPixel SetFunctionSetPixel = 0;\r
+funcSetMpqDll SetMpqDll = 0;\r
funcLoadGrpApi LoadGrpApi = 0;\r
funcFreeGrpApi FreeGrpApi = 0;\r
\r
DestroyGrp = (funcDestroyGrp)GetProcAddress(hGrpApi,"DestroyGrp");\r
DrawGrp = (funcDrawGrp)GetProcAddress(hGrpApi,"DrawGrp");\r
GetGrpInfo = (funcGetGrpInfo)GetProcAddress(hGrpApi,"GetGrpInfo");\r
+ SetFunctionGetPixel = (funcSetFunctionGetPixel)GetProcAddress(hGrpApi,"SetFunctionGetPixel");\r
+ SetFunctionSetPixel = (funcSetFunctionSetPixel)GetProcAddress(hGrpApi,"SetFunctionSetPixel");\r
+ SetMpqDll = (funcSetMpqDll)GetProcAddress(hGrpApi,"SetMpqDll");\r
LoadGrpApi = (funcLoadGrpApi)GetProcAddress(hGrpApi,"LoadGrpApi");\r
FreeGrpApi = (funcFreeGrpApi)GetProcAddress(hGrpApi,"FreeGrpApi");\r
}\r
DestroyGrp = 0;\r
DrawGrp = 0;\r
GetGrpInfo = 0;\r
+ SetFunctionGetPixel = 0;\r
+ SetFunctionSetPixel = 0;\r
+ SetMpqDll = 0;\r
LoadGrpApi = 0;\r
FreeGrpApi = 0;\r
\r
void FreeGrpApiLib()\r
{\r
}\r
-\r
diff --git a/grpapi/grpapi_no-lib.h b/grpapi/grpapi_no-lib.h
--- a/grpapi/grpapi_no-lib.h
+++ b/grpapi/grpapi_no-lib.h
extern funcDrawGrp DrawGrp;\r
extern funcGetGrpInfo GetGrpInfo;\r
\r
+typedef COLORREF (WINAPI* GETPIXELPROC)(\r
+ HDC hDC, // same value as hdcDest from DrawGrp,\r
+ // does not need to be used as an HDC,\r
+ // can be used for any other type of pointer\r
+ int X, // x-coordinate of pixel\r
+ int Y // y-coordinate of pixel\r
+);\r
+typedef void (WINAPI* SETPIXELPROC)(\r
+ HDC hDC, // same value as hdcDest from DrawGrp,\r
+ // does not need to be used as an HDC,\r
+ // can be used for any other type of pointer\r
+ int X, // x-coordinate of pixel\r
+ int Y, // y-coordinate of pixel\r
+ COLORREF clrColor // new pixel color\r
+);\r
+\r
+// Call these to have DrawGrp use custom functions for reading and drawing pixels\r
+// so that you can have it read from and write to a buffer, for example.\r
+typedef void (WINAPI* funcSetFunctionGetPixel)(GETPIXELPROC lpGetPixelProc);\r
+typedef void (WINAPI* funcSetFunctionSetPixel)(SETPIXELPROC lpSetPixelProc);\r
+extern funcSetFunctionGetPixel SetFunctionGetPixel;\r
+extern funcSetFunctionSetPixel SetFunctionSetPixel;\r
+\r
+// Call this to make a different Storm.dll-compatible MPQ library be used (like SFMPQ).\r
+typedef BOOL (WINAPI* funcSetMpqDll)(LPCSTR lpDllFileName);\r
+extern funcSetMpqDll SetMpqDll;\r
+\r
// These no longer need to be called\r
typedef BOOL (WINAPI* funcLoadGrpApi)();\r
typedef void (WINAPI* funcFreeGrpApi)();\r
|