1 #include "version.h" 2 3 #ifdef USE_PARALLAX 4 5 #include "wl_def.h" 6 7 #ifdef USE_FEATUREFLAGS 8 9 // The lower left tile of every map determines the start texture of the parallax sky. GetParallaxStartTexture()10static int GetParallaxStartTexture() 11 { 12 int startTex = ffDataBottomLeft; 13 assert(startTex >= 0 && startTex < PMSpriteStart); 14 return startTex; 15 } 16 17 #else 18 GetParallaxStartTexture()19static int GetParallaxStartTexture() 20 { 21 int startTex; 22 switch(gamestate.episode * 10 + mapon) 23 { 24 case 0: startTex = 20; break; 25 default: startTex = 0; break; 26 } 27 assert(startTex >= 0 && startTex < PMSpriteStart); 28 return startTex; 29 } 30 31 #endif 32 DrawParallax(byte * vbuf,unsigned vbufPitch)33void DrawParallax(byte *vbuf, unsigned vbufPitch) 34 { 35 int startpage = GetParallaxStartTexture(); 36 int midangle = player->angle * (FINEANGLES / ANGLES); 37 int skyheight = viewheight >> 1; 38 int curtex = -1; 39 byte *skytex; 40 41 startpage += USE_PARALLAX - 1; 42 43 for(int x = 0; x < viewwidth; x++) 44 { 45 int curang = pixelangle[x] + midangle; 46 if(curang < 0) curang += FINEANGLES; 47 else if(curang >= FINEANGLES) curang -= FINEANGLES; 48 int xtex = curang * USE_PARALLAX * TEXTURESIZE / FINEANGLES; 49 int newtex = xtex >> TEXTURESHIFT; 50 if(newtex != curtex) 51 { 52 curtex = newtex; 53 skytex = PM_GetTexture(startpage - curtex); 54 } 55 int texoffs = TEXTUREMASK - ((xtex & (TEXTURESIZE - 1)) << TEXTURESHIFT); 56 int yend = skyheight - (wallheight[x] >> 3); 57 if(yend <= 0) continue; 58 59 for(int y = 0, offs = x; y < yend; y++, offs += vbufPitch) 60 vbuf[offs] = skytex[texoffs + (y * TEXTURESIZE) / skyheight]; 61 } 62 } 63 64 #endif 65