diff --git a/CAmbarCendamo.cpp b/CAmbarCendamo.cpp index a36348edc..f843d897c 100644 --- a/CAmbarCendamo.cpp +++ b/CAmbarCendamo.cpp @@ -391,6 +391,19 @@ void CAmbarCendamo::deh3m() int defAmount = bufor[i]; // liczba defow defAmount = readNormalNr(i); i+=4; + +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + int srmask = 0xff000000; + int sgmask = 0x00ff0000; + int sbmask = 0x0000ff00; + int samask = 0x000000ff; +#else + int srmask = 0x000000ff; + int sgmask = 0x0000ff00; + int sbmask = 0x00ff0000; + int samask = 0xff000000; +#endif + SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, srmask, sgmask, sbmask, samask); for (int idd = 0 ; iddopenDef(map.defy[idd].name.c_str(), "H3sprite.lod"); + map.defy[idd].handler = new CDefHandler(); + map.defy[idd].handler->openDef( std::string("newH3sprite\\")+map.defy[idd].name); for(int ff=0; ffourImages.size(); ++ff) //adding shadows and transparency { map.defy[idd].handler->ourImages[ff].bitmap = CSDL_Ext::alphaTransform(map.defy[idd].handler->ourImages[ff].bitmap); - }//*/ + SDL_Surface * bufs = CSDL_Ext::secondAlphaTransform(map.defy[idd].handler->ourImages[ff].bitmap, alphaTransSurf); + SDL_FreeSurface(map.defy[idd].handler->ourImages[ff].bitmap); + map.defy[idd].handler->ourImages[ff].bitmap = bufs; + } //end fo testing - only fragment/////////////////////////////////////////////////////// //teceDef(); } + SDL_FreeSurface(alphaTransSurf); THC std::cout<<"Wczytywanie defow: "<init(std::string("h3abp_bm.lod")); CDefHandler * tdef = new CDefHandler; - tdef->openDef(std::string("H3sprite.lod\\EDG.DEF")); - tdef->getSprite(0); + tdef->openDef(std::string("newh3sprite\\AVLSPTR3.DEF")); + //tdef->getSprite(0); //CLodHandler * bitmapLod = new CLodHandler; //bitmapLod->init(std::string("newH3bitmap.lod")); @@ -285,6 +285,9 @@ int _tmain(int argc, _TCHAR* argv[]) tconv->convert(); tconv->saveBMP(std::string("tesciczekConva.bmp")); + CSemiDefHandler * semek = new CSemiDefHandler; + semek->openDef(std::string("EDG.DEF"), std::string("H3sprite.lod")); + //////////////////////////////////////////////////////////////////////////////// lod testing end cgi->sspriteh = new CSemiLodHandler(); @@ -343,6 +346,7 @@ int _tmain(int argc, _TCHAR* argv[]) bool scrollingUp = false; bool scrollingDown = false; bool updateScreen = false; + unsigned char animVal=0; //for animations handling for(;;) // main loop { try @@ -456,7 +460,7 @@ int _tmain(int argc, _TCHAR* argv[]) if(updateScreen) { SDL_FillRect(ekran, NULL, SDL_MapRGB(ekran->format, 0, 0, 0)); - SDL_Surface * help = mh->terrainRect(xx,yy,25,19,zz); + SDL_Surface * help = mh->terrainRect(xx,yy,25,19,zz,animVal); SDL_BlitSurface(help,NULL,ekran,NULL); SDL_FreeSurface(help); SDL_UpdateRect(ekran, 0, 0, ekran->w, ekran->h); @@ -467,7 +471,10 @@ int _tmain(int argc, _TCHAR* argv[]) catch(...) { continue; } - SDL_Delay(25); //give time for other apps + updateScreen = true; + ++animVal; //for animations + + SDL_Delay(30); //give time for other apps } return 0; } diff --git a/SDL_Extensions.cpp b/SDL_Extensions.cpp index 485d9fa38..b9b2720b5 100644 --- a/SDL_Extensions.cpp +++ b/SDL_Extensions.cpp @@ -329,7 +329,7 @@ SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src) } SDL_SetColors(src, &shadow, yy, 1); } - if(cur.g == 255 && cur.b == 255) + if((cur.g == 255 && cur.b == 255) || (cur.r == 255 && cur.g == 0 && cur.b == 0)) { SDL_Color transp; transp.b = transp.g = transp.r = 0; @@ -345,7 +345,7 @@ SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src) SDL_Surface * CSDL_Ext::secondAlphaTransform(SDL_Surface * src, SDL_Surface * alpha) { - Uint32 pompom[192][192]; + Uint32 pompom[224][224]; for(int i=0; iw; ++i) { for(int j=0; jh; ++j) @@ -353,7 +353,7 @@ SDL_Surface * CSDL_Ext::secondAlphaTransform(SDL_Surface * src, SDL_Surface * al pompom[i][j] = 0xffffffff - (SDL_GetPixel(src, i, j, true) & 0xff000000); } } - Uint32 pompom2[192][192]; + Uint32 pompom2[224][224]; for(int i=0; iw; ++i) { for(int j=0; jh; ++j) diff --git a/map.h b/map.h index 2b34f108b..d052870a7 100644 --- a/map.h +++ b/map.h @@ -5,6 +5,7 @@ #include #include "global.h" #include "CSemiDefHandler.h" +#include "CDefHandler.h" enum ESortBy{name,playerAm,size,format, viccon,loscon}; struct Sresource @@ -56,7 +57,8 @@ struct DefInfo //information from def declaration { std::string name; int bytes [42]; - CSemiDefHandler * handler; + //CSemiDefHandler * handler; + CDefHandler * handler; }; struct Location { diff --git a/mapHandler.cpp b/mapHandler.cpp index ac6bcfc26..39e2f6254 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -17,18 +17,18 @@ void CMapHandler::init() CSDL_Ext::alphaTransform(partialHide->ourImages[i].bitmap); } - visibility.resize(reader->map.width+8); - for(int gg=0; ggmap.width+8; ++gg) + visibility.resize(reader->map.width+2*Woff); + for(int gg=0; ggmap.width+2*Woff; ++gg) { - visibility[gg].resize(reader->map.height+8); - for(int jj=0; jjmap.height+8; ++jj) + visibility[gg].resize(reader->map.height+2*Hoff); + for(int jj=0; jjmap.height+2*Hoff; ++jj) visibility[gg][jj] = true; } - undVisibility.resize(reader->map.width+8); - for(int gg=0; ggmap.width+8; ++gg) + undVisibility.resize(reader->map.width+2*Woff); + for(int gg=0; ggmap.width+2*Woff; ++gg) { - undVisibility[gg].resize(reader->map.height+8); - for(int jj=0; jjmap.height+8; ++jj) + undVisibility[gg].resize(reader->map.height+2*Woff); + for(int jj=0; jjmap.height+2*Woff; ++jj) undVisibility[gg][jj] = true; } @@ -44,8 +44,8 @@ void CMapHandler::init() visibility[6][9] = false; terrainBitmap = new SDL_Surface **[reader->map.width+8]; - for (int ii=0;iimap.width+8;ii++) - terrainBitmap[ii] = new SDL_Surface*[reader->map.height+8]; // allocate memory + for (int ii=0;iimap.width+2*Woff;ii++) + terrainBitmap[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory CSemiDefHandler * bord = CGameInfo::mainObj->sspriteh->giveDef("EDG.DEF"); for (int i=0; imap.width+8; i++) //jest po szerokości { @@ -241,7 +241,7 @@ void CMapHandler::init() } //end of if } -SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level) +SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, unsigned char anim) { #if SDL_BYTEORDER == SDL_BIG_ENDIAN int rmask = 0xff000000; @@ -280,27 +280,19 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level) } } ////terrain printed; printing objects - /* - for (int bx=0; bxobjh->objInstances.size(); ++gg) { - for (int by=0; byobjh->objInstances[gg].x >= x-3 && CGameInfo::mainObj->objh->objInstances[gg].x < dx+x-3 && CGameInfo::mainObj->objh->objInstances[gg].y >= y-3 && CGameInfo::mainObj->objh->objInstances[gg].y < dy+y-3 && CGameInfo::mainObj->objh->objInstances[gg].z == level) { - for(int gg=0; ggobjh->objInstances.size(); ++gg) - { - if(CGameInfo::mainObj->objh->objInstances[gg].x == bx+x-4 && CGameInfo::mainObj->objh->objInstances[gg].y == by+y-4 && CGameInfo::mainObj->objh->objInstances[gg].z == level) - { - SDL_Rect * sr = new SDL_Rect; - sr->h=sr->w=192; - sr->x = (bx)*32 - CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[0].bitmap->w + 32; - sr->y = (by)*32 - CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[0].bitmap->h + 32; - SDL_Surface * s2 = CSDL_Ext::secondAlphaTransform(CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[0].bitmap, su); - SDL_BlitSurface(s2, NULL, su, sr); - SDL_FreeSurface(s2); - delete sr; - } - } + SDL_Rect * sr = new SDL_Rect; + sr->w = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[0].bitmap->w; + sr->h = CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[0].bitmap->h; + sr->x = (CGameInfo::mainObj->objh->objInstances[gg].x-x+4)*32 - CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[0].bitmap->w + 32; + sr->y = (CGameInfo::mainObj->objh->objInstances[gg].y-y+4)*32 - CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[0].bitmap->h + 32; + SDL_BlitSurface(CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages[anim%CGameInfo::mainObj->ac->map.defy[CGameInfo::mainObj->objh->objInstances[gg].defNumber].handler->ourImages.size()].bitmap, NULL, su, sr); + delete sr; } - }//*/ + } ////objects printed, printing shadow for (int bx=0; bx