X-Git-Url: https://sfsrealm.hopto.org/projects/gitweb.cgi?a=blobdiff_plain;f=drawgrp%2Fdrawgrp.cpp;h=f4467934718743d7cb4ffe3b311ce579ce00c99e;hb=0df810495ce1e922f22278469a15014e9b5de5aa;hp=9adc3512852fb2f15cf5df202aaa501b3c96625b;hpb=14362b19599627313cd243bdbc404dc2087d4422;p=grpapi.git diff --git a/drawgrp/drawgrp.cpp b/drawgrp/drawgrp.cpp index 9adc351..f446793 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,36 @@ 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 + 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,8 +59,9 @@ int main(int argc, char* argv[]) memcpy(buffer,"Patch_rt.mpq",13); SFileOpenArchive(buffer,3000,0,&hMPQ3); } + BufferInfo BI; LoadPalette("tileset\\Jungle.wpe",dwPalette); - HANDLE hGrp; + HANDLE hGrp, hGrp2; if (argc>1) hGrp = LoadGrp(argv[1]); else @@ -40,21 +69,96 @@ int main(int argc, char* argv[]) 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