X-Git-Url: https://sfsrealm.hopto.org/projects/?a=blobdiff_plain;f=drawgrp%2Fdrawgrp.cpp;h=06af64f5f3936aefad6a010e4ae507606f713d05;hb=58a8b78cdc107c2e6136f562e9453723c7322949;hp=4de2c4cdaed92342a6821ee7d36eb7efda169d11;hpb=ca356bb15e8bce53881ea299626c01d73ab23907;p=grpapi.git diff --git a/drawgrp/drawgrp.cpp b/drawgrp/drawgrp.cpp index 4de2c4c..06af64f 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" @@ -20,17 +23,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 +59,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,31 +71,69 @@ 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