X-Git-Url: https://sfsrealm.hopto.org/projects/?a=blobdiff_plain;f=drawgrp%2Fdrawgrp.cpp;h=6ddab08a7d12bc188357c2b2f3aef4c7e9248caf;hb=6ac16fc3a1be03db0b4f50c3d5e6561e70ad8341;hp=9adc3512852fb2f15cf5df202aaa501b3c96625b;hpb=14362b19599627313cd243bdbc404dc2087d4422;p=grpapi.git diff --git a/drawgrp/drawgrp.cpp b/drawgrp/drawgrp.cpp index 9adc351..6ddab08 100644 --- a/drawgrp/drawgrp.cpp +++ b/drawgrp/drawgrp.cpp @@ -1,6 +1,9 @@ // drawgrp.cpp : Defines the entry point for the console application. // +#define _CRT_RAND_S +#include +#include #include "stdafx.h" @@ -17,11 +20,39 @@ int main(int argc, char* argv[]) 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); @@ -31,30 +62,117 @@ int main(int argc, char* argv[]) memcpy(buffer,"Patch_rt.mpq",13); SFileOpenArchive(buffer,3000,0,&hMPQ3); } - LoadPalette("tileset\\Jungle.wpe",dwPalette); - HANDLE hGrp; + BufferInfo BI; + LoadPalette("tileset\\Platform.wpe",dwPalette); + HANDLE hGrp, hGrp2; if (argc>1) hGrp = LoadGrp(argv[1]); else - hGrp = LoadGrp("unit\\zerg\\ultra.grp"); + 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