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




CommitLineData
14362b19 1// drawgrp.cpp : Defines the entry point for the console application.\r
2//\r
3\r
4#include "stdafx.h"\r
5\r
6\r
7/*int qmain(int argc, char* argv[]);\r
8\r
9int main(int argc, char* argv[])\r
10{\r
11 HINSTANCE hStorm = LoadStorm("Storm.dll");\r
12 if (SFileDestroy!=0) SFileDestroy();\r
13 LoadGrpApi();\r
14 int RetVal = qmain(argc,argv);\r
15 FreeGrpApi();\r
16 if (hStorm!=0) FreeLibrary(hStorm);\r
17 return RetVal;\r
18}*/\r
19\r
7f7b4247 20struct BufferInfo {\r
21 WORD nWidth;\r
22 WORD nHeight;\r
23 LPDWORD pBuffer;\r
24};\r
25\r
26COLORREF WINAPI ReadPixelFromBuffer(BufferInfo *pBI, int X, int Y)\r
27{\r
28 return pBI->pBuffer[(Y * pBI->nWidth) + X];\r
29}\r
30\r
31void WINAPI WritePixelToBuffer(BufferInfo *pBI, int X, int Y, COLORREF clrColor)\r
32{\r
33 pBI->pBuffer[(Y * pBI->nWidth) + X] = clrColor;\r
34}\r
35\r
14362b19 36int main(int argc, char* argv[])\r
37{\r
38 HANDLE hMPQ=0,hMPQ2=0,hMPQ3=0;\r
39 DWORD *dwPalette = (DWORD *)_alloca(1024);\r
40 memset(dwPalette,0,1024);\r
7f7b4247 41 LoadStorm("SFMpq.dll");\r
42 SetMpqDll("SFMpq.dll");\r
14362b19 43 if (SFileOpenArchive!=0) {\r
44 char *buffer = (char *)_alloca(13);\r
45 memcpy(buffer,"StarDat.mpq",12);\r
46 if (SFileOpenArchive(buffer,1000,0,&hMPQ)==0) return 0;\r
47 memcpy(buffer,"BrooDat.mpq",12);\r
48 SFileOpenArchive(buffer,2000,0,&hMPQ2);\r
49 memcpy(buffer,"Patch_rt.mpq",13);\r
50 SFileOpenArchive(buffer,3000,0,&hMPQ3);\r
51 }\r
7f7b4247 52 SetFunctionGetPixel((GETPIXELPROC)ReadPixelFromBuffer);\r
53 SetFunctionSetPixel((SETPIXELPROC)WritePixelToBuffer);\r
54 BufferInfo BI;\r
14362b19 55 LoadPalette("tileset\\Jungle.wpe",dwPalette);\r
56 HANDLE hGrp;\r
57 if (argc>1)\r
58 hGrp = LoadGrp(argv[1]);\r
59 else\r
ca356bb1 60 hGrp = LoadGrp("unit\\zerg\\ultra.grp");\r
14362b19 61 HDC hDC = GetDC(0);\r
62 GRPHEADER GrpInfo;\r
63 if (GetGrpInfo(hGrp,&GrpInfo)==0) {GrpInfo.nFrames=0;GrpInfo.wMaxWidth=0;GrpInfo.wMaxHeight=0;}\r
7f7b4247 64 BI.nWidth = GrpInfo.wMaxWidth;\r
65 BI.nHeight = GrpInfo.wMaxHeight;\r
66 BI.pBuffer = (DWORD *)malloc(BI.nWidth * BI.nHeight * sizeof(DWORD));\r
67 WORD i,x,y;\r
68 DWORD j;\r
69 for (i = 0; i < BI.nWidth * BI.nHeight; i++)\r
70 BI.pBuffer[i] = 0xFFFFFFFF;\r
14362b19 71 //for (DWORD j=0;j<16;j++){\r
72 /*for (WORD i=0;i<GrpInfo.nFrames;i++) {\r
73 DrawGrp(hGrp,hDC,0,0,i,dwPalette,ALPHA_BLEND,0x401020);\r
74 }*/\r
7f7b4247 75 COLORREF clrPixel;\r
76 RECT rect;\r
ca356bb1 77 for (i=13;i<400;i+=17) {\r
7f7b4247 78 rect.left = rect.top = i;\r
79 rect.right = rect.left + BI.nWidth;\r
80 rect.bottom = rect.top + BI.nHeight;\r
81 for (x = 0; x < BI.nWidth * BI.nHeight; x++)\r
82 BI.pBuffer[x] = 0xFFFFFFFF;\r
83 for (j=0;j<32;j++) {\r
84// DrawGrp(hGrp,(HDC)&BI,i,0,i % (17*8),dwPalette,ALPHA_BLEND,0x401020);\r
85 DrawGrp(hGrp,(HDC)&BI,0,0,i % (17*8),dwPalette,0,0x401020);\r
86 for (x = 0; x < BI.nWidth; x++)\r
87 for (y = 0; y < BI.nHeight; y++) {\r
88 clrPixel = BI.pBuffer[(y * BI.nWidth) + x];\r
89 if (clrPixel != 0xFFFFFFFF) SetPixelV(hDC, i + x, i + y, clrPixel);\r
90 }\r
91 }\r
92 FillRect(hDC, &rect, (HBRUSH) (COLOR_WINDOW+1));\r
14362b19 93 }\r
ca356bb1 94 for (i=4;i<400;i+=17) {\r
7f7b4247 95 rect.left = rect.top = 400-i;\r
96 rect.right = rect.left + BI.nWidth;\r
97 rect.bottom = rect.top + BI.nHeight;\r
98 for (x = 0; x < BI.nWidth * BI.nHeight; x++)\r
99 BI.pBuffer[x] = 0xFFFFFFFF;\r
100 for (j=0;j<32;j++) {\r
101// DrawGrp(hGrp,(HDC)&BI,400-i,0,i % (17*8),dwPalette,HORIZONTAL_FLIP|ALPHA_BLEND,0x401020);\r
102 DrawGrp(hGrp,(HDC)&BI,0,0,i % (17*8),dwPalette,HORIZONTAL_FLIP,0x401020);\r
103 for (x = 0; x < BI.nWidth; x++)\r
104 for (y = 0; y < BI.nHeight; y++) {\r
105 clrPixel = BI.pBuffer[(y * BI.nWidth) + x];\r
106 if (clrPixel != 0xFFFFFFFF) SetPixelV(hDC, 400-i + x, 400-i + y, clrPixel);\r
107 }\r
108 }\r
109 FillRect(hDC, &rect, (HBRUSH) (COLOR_WINDOW+1));\r
14362b19 110 }\r
7f7b4247 111 for (i = 0; i < BI.nWidth; i++)\r
112 for (j = 0; j < BI.nHeight; j++) {\r
113 clrPixel = BI.pBuffer[(j * BI.nWidth) + i];\r
114 if (clrPixel != 0xFFFFFFFF) SetPixelV(hDC, 400 + i, 300 + j, clrPixel);\r
115 }\r
14362b19 116 //}\r
117 ReleaseDC(0,hDC);\r
7f7b4247 118 free(BI.pBuffer);\r
14362b19 119 DestroyGrp(hGrp);\r
120 if (SFileCloseArchive!=0) {\r
121 if (hMPQ3!=0) SFileCloseArchive(hMPQ3);\r
122 if (hMPQ2!=0) SFileCloseArchive(hMPQ2);\r
123 if (hMPQ!=0) SFileCloseArchive(hMPQ);\r
124 }\r
125 return 0;\r
126}\r
127\r