// r_sky.c #include "quakedef.h" #include "r_local.h" #include "d_local.h" int iskyspeed = 4; int iskyspeed2 = 1; float skyspeed, skyspeed2; float skytime; byte *r_skysource; int r_skymade; int r_skydirect; // not used? // TODO: clean up these routines byte bottomsky[128*131]; byte bottommask[128*131]; byte newsky[128*256]; // newsky and topsky both pack in here, 128 bytes // of newsky on the left of each scan, 128 bytes // of topsky on the right, because the low-level // drawers need 256-byte scan widths /* ============= R_InitSky A sky texture is 256*128, with the right side being a masked overlay ============== */ void R_InitSky (texture_t *mt) { int i, j; byte *src; src = (byte *)mt + mt->offsets[0]; for (i=0 ; i<128 ; i++) { for (j=0 ; j<128 ; j++) { newsky[(i*256) + j + 128] = src[i*256 + j + 128]; } } for (i=0 ; i<128 ; i++) { for (j=0 ; j<131 ; j++) { if (src[i*256 + (j & 0x7F)]) { bottomsky[(i*131) + j] = src[i*256 + (j & 0x7F)]; bottommask[(i*131) + j] = 0; } else { bottomsky[(i*131) + j] = 0; bottommask[(i*131) + j] = 0xff; } } } r_skysource = newsky; } /* ================= R_MakeSky ================= */ void R_MakeSky (void) { int x, y; int ofs, baseofs; int xshift, yshift; unsigned *pnewsky; static int xlast = -1, ylast = -1; xshift = skytime*skyspeed; yshift = skytime*skyspeed; if ((xshift == xlast) && (yshift == ylast)) return; xlast = xshift; ylast = yshift; pnewsky = (unsigned *)&newsky[0]; for (y=0 ; y