X-Git-Url: https://sfsrealm.hopto.org/projects/?a=blobdiff_plain;f=drawgrp%2Fdrawgrp.cpp;h=9b5e286f6e4556791e0120ac936517e2fc9dcac3;hb=c483a082ba5c516a59a3ae91e3efee095f0f59a3;hp=d342525a30e7ff1bc4e2a21b7099d86fe5d622ce;hpb=afcd1861b390cdcd023cf6e7dfe28c44ba6e2cca;p=grpapi.git diff --git a/drawgrp/drawgrp.cpp b/drawgrp/drawgrp.cpp index d342525..9b5e286 100644 --- a/drawgrp/drawgrp.cpp +++ b/drawgrp/drawgrp.cpp @@ -1,6 +1,8 @@ // drawgrp.cpp : Defines the entry point for the console application. // +#define _CRT_RAND_S +#include #include "stdafx.h" @@ -20,17 +22,24 @@ int main(int argc, char* argv[]) struct BufferInfo { WORD nWidth; WORD nHeight; - LPDWORD pBuffer; + signed short *pBuffer; + WORD nFrame; }; COLORREF WINAPI ReadPixelFromBuffer(BufferInfo *pBI, int X, int Y) { - return pBI->pBuffer[(Y * pBI->nWidth) + X]; + 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) { - pBI->pBuffer[(Y * pBI->nWidth) + X] = clrColor; + if (pBI->nFrame == 0xFFFF) + pBI->pBuffer[(Y * pBI->nWidth) + X] = (signed short)clrColor; + else + pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X] = (signed short)clrColor; } int main(int argc, char* argv[]) @@ -49,11 +58,9 @@ int main(int argc, char* argv[]) memcpy(buffer,"Patch_rt.mpq",13); SFileOpenArchive(buffer,3000,0,&hMPQ3); } - SetFunctionGetPixel((GETPIXELPROC)ReadPixelFromBuffer); - SetFunctionSetPixel((SETPIXELPROC)WritePixelToBuffer); BufferInfo BI; LoadPalette("tileset\\Jungle.wpe",dwPalette); - HANDLE hGrp; + HANDLE hGrp, hGrp2; if (argc>1) hGrp = LoadGrp(argv[1]); else @@ -63,32 +70,58 @@ int main(int argc, char* argv[]) if (GetGrpInfo(hGrp,&GrpInfo)==0) {GrpInfo.nFrames=0;GrpInfo.wMaxWidth=0;GrpInfo.wMaxHeight=0;} BI.nWidth = GrpInfo.wMaxWidth; BI.nHeight = GrpInfo.wMaxHeight; - BI.pBuffer = (DWORD *)malloc(BI.nWidth * BI.nHeight * sizeof(DWORD)); + BI.pBuffer = (signed short *)malloc(GrpInfo.nFrames * BI.nWidth * BI.nHeight * sizeof(short)); WORD i,x,y; - DWORD j; - for (i = 0; i < BI.nWidth * BI.nHeight; i++) - BI.pBuffer[i] = 0xFFFFFFFF; + 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