X-Git-Url: https://sfsrealm.hopto.org/projects/?a=blobdiff_plain;f=drawgrp%2Fdrawgrp.cpp;h=8d617368347469bfb7ba4c143c131dcb36879600;hb=f7234247672bf3a40fdc28e0935daf4951aafef8;hp=630fcf1e603754051ab41519468dc721e5f489cf;hpb=561c0942c0bb8e6dcfcc3616a5b89123cadd9ce1;p=grpapi.git diff --git a/drawgrp/drawgrp.cpp b/drawgrp/drawgrp.cpp index 630fcf1..8d61736 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,61 +59,97 @@ 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 - hGrp = LoadGrp("game\\icons.grp"); + 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 = (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