X-Git-Url: https://sfsrealm.hopto.org/projects/gitweb.cgi?a=blobdiff_plain;f=drawgrp%2Fdrawgrp.cpp;h=6dbb7eb39106a30ba8044105f657d90ea91b38c1;hb=f15b049dbe98d0083932932f2b70015ea2deb84a;hp=e2f41c80af2d5b2a97582ed2511ac5422b71bc5a;hpb=f497a4730685896b542330aaf1a3d41f73c9a19e;p=grpapi.git diff --git a/drawgrp/drawgrp.cpp b/drawgrp/drawgrp.cpp index e2f41c8..6dbb7eb 100644 --- a/drawgrp/drawgrp.cpp +++ b/drawgrp/drawgrp.cpp @@ -1,177 +1,184 @@ -// drawgrp.cpp : Defines the entry point for the console application. -// - -#define _CRT_RAND_S -#include -#include -#include "stdafx.h" - - -/*int qmain(int argc, char* argv[]); - -int main(int argc, char* argv[]) -{ - HINSTANCE hStorm = LoadStorm("Storm.dll"); - if (SFileDestroy!=0) SFileDestroy(); - LoadGrpApi(); - int RetVal = qmain(argc,argv); - FreeGrpApi(); - if (hStorm!=0) FreeLibrary(hStorm); - return RetVal; -}*/ - -struct BufferInfo { - WORD nWidth; - WORD nHeight; - signed short *pBuffer; - WORD nFrame; -}; - -COLORREF WINAPI ReadPixelFromBuffer(BufferInfo *pBI, int X, int Y) -{ - if (pBI->nFrame == 0xFFFF) - return pBI->pBuffer[(Y * pBI->nWidth) + X]; - else - return pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X]; -} - -void WINAPI WritePixelToBuffer(BufferInfo *pBI, int X, int Y, COLORREF clrColor) -{ - if (pBI->nFrame == 0xFFFF) - pBI->pBuffer[(Y * pBI->nWidth) + X] = (signed short)clrColor; - else - //if (clrColor < 1 || clrColor > 13) - // pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X] = (signed short)((BYTE)-clrColor); - //else - pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X] = (signed short)clrColor; -} - -int main(int argc, char* argv[]) -{ - HANDLE hMPQ=0,hMPQ2=0,hMPQ3=0; - DWORD *dwPalette = (DWORD *)_alloca(1024); - memset(dwPalette,0,1024); - LoadStorm("SFMpq.dll"); - SetMpqDll("SFMpq.dll"); - if (SFileOpenArchive!=0) { - char *buffer = (char *)_alloca(13); - memcpy(buffer,"StarDat.mpq",12); - if (SFileOpenArchive(buffer,1000,0,&hMPQ)==0) return 0; - memcpy(buffer,"BrooDat.mpq",12); - SFileOpenArchive(buffer,2000,0,&hMPQ2); - memcpy(buffer,"Patch_rt.mpq",13); - SFileOpenArchive(buffer,3000,0,&hMPQ3); - } - BufferInfo BI; - LoadPalette("tileset\\Jungle.wpe",dwPalette); - HANDLE hGrp, hGrp2; - if (argc>1) - hGrp = LoadGrp(argv[1]); - else - hGrp = LoadGrp("unit\\zerg\\ultra.grp"); - HDC hDC = GetDC(0); - GRPHEADER GrpInfo; - if (GetGrpInfo(hGrp,&GrpInfo)==0) {GrpInfo.nFrames=0;GrpInfo.wMaxWidth=0;GrpInfo.wMaxHeight=0;} - BI.nWidth = GrpInfo.wMaxWidth; - BI.nHeight = GrpInfo.wMaxHeight; - BI.pBuffer = (signed short *)malloc(GrpInfo.nFrames * BI.nWidth * BI.nHeight * sizeof(short)); - WORD i,x,y; - DWORD j, nGrpSize; - unsigned int u,v; - memset(BI.pBuffer, 0xFF, GrpInfo.nFrames * BI.nWidth * BI.nHeight * sizeof(short)); - //for (DWORD j=0;j<16;j++){ - /*for (WORD i=0;i +#include +#include "stdafx.h" + + +/*int qmain(int argc, char* argv[]); + +int main(int argc, char* argv[]) +{ + HINSTANCE hStorm = LoadStorm("Storm.dll"); + if (SFileDestroy!=0) SFileDestroy(); + LoadGrpApi(); + int RetVal = qmain(argc,argv); + FreeGrpApi(); + if (hStorm!=0) FreeLibrary(hStorm); + return RetVal; +}*/ + +struct BufferInfo { + WORD nWidth; + WORD nHeight; + signed short *pBuffer; + WORD nFrame; +}; + +COLORREF WINAPI ReadPixelFromBuffer(BufferInfo *pBI, int X, int Y) +{ + if (pBI->nFrame == 0xFFFF) + return pBI->pBuffer[(Y * pBI->nWidth) + X]; + else + return pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X]; +} + +void WINAPI WritePixelToBuffer(BufferInfo *pBI, int X, int Y, COLORREF clrColor) +{ + if (pBI->nFrame == 0xFFFF) + pBI->pBuffer[(Y * pBI->nWidth) + X] = (signed short)clrColor; + else + //if (clrColor < 1 || clrColor > 13) + // pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X] = (signed short)((BYTE)-clrColor); + //else + pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X] = (signed short)clrColor; +} + +int main(int argc, char* argv[]) +{ + HANDLE hMPQ=0,hMPQ2=0,hMPQ3=0; + DWORD *dwPalette = (DWORD *)_alloca(1024); + memset(dwPalette,0,1024); + LoadStorm("SFMpq.dll"); + SetMpqDll("SFMpq.dll"); + if (SFileOpenArchive!=0) { + char *buffer = (char *)_alloca(13); + memcpy(buffer,"StarDat.mpq",12); + if (SFileOpenArchive(buffer,1000,0,&hMPQ)==0) return 0; + memcpy(buffer,"BrooDat.mpq",12); + SFileOpenArchive(buffer,2000,0,&hMPQ2); + memcpy(buffer,"Patch_rt.mpq",13); + SFileOpenArchive(buffer,3000,0,&hMPQ3); + } + BufferInfo BI; + LoadPalette("tileset\\Platform.wpe",dwPalette); + HANDLE hGrp, hGrp2; + if (argc>1) + hGrp = LoadGrp(argv[1]); + else + hGrp = LoadGrp("unit\\zerg\\zergling.grp"); + HDC hDC = GetDC(0); + GRPHEADER GrpInfo; + if (GetGrpInfo(hGrp,&GrpInfo)==0) {GrpInfo.nFrames=0;GrpInfo.wMaxWidth=0;GrpInfo.wMaxHeight=0;} + BI.nWidth = GrpInfo.wMaxWidth; + BI.nHeight = GrpInfo.wMaxHeight; + //BI.nWidth = 255; + //BI.nHeight = 255; + BI.pBuffer = (signed short *)malloc(GrpInfo.nFrames * BI.nWidth * BI.nHeight * sizeof(short)); + WORD i,x,y; + DWORD j, nGrpSize; + unsigned int u,v; + memset(BI.pBuffer, 0xFF, GrpInfo.nFrames * BI.nWidth * BI.nHeight * sizeof(short)); + //for (DWORD j=0;j<16;j++){ + /*for (WORD i=0;i