+
+ cam_theta = fmod(cam_theta, 360.0f);
+ if(cam_theta < 0) cam_theta += 360.0f;
+
+ if(cam_phi < 0) cam_phi = 0;
+}
+
+static void backdrop(void)
+{
+ static const int colzen[] = {98, 64, 192};
+ static const int colhor[] = {128, 80, 64};
+ int i, j, hory, start[3], end[3], col[3];
+ uint16_t *fbptr, pcol;
+ int cidx, offs = -10;
+ int startidx;
+
+ startidx = cround64(cam_theta * (float)BGOFFS_SIZE) / 360;
+
+ hory = (fb_height - 2 * fb_height * cround64(cam_phi) / VFOV) / 2;
+ if(hory > fb_height) hory = fb_height;
+
+ if(hory > 0) {
+ fbptr = fb_pixels + (hory - 1) * fb_width;
+ cidx = offs;
+ i = 0;
+ while(fbptr >= fb_pixels) {
+ pcol = bgcol[cidx < 0 ? 0 : (cidx >= BGCOL_SIZE ? BGCOL_SIZE - 1 : cidx)];
+ for(j=0; j<fb_width; j++) {
+ if(cidx < bgoffs[(startidx + j) & (BGOFFS_SIZE - 1)]) {
+ fbptr[j] = mountcol;
+ } else {
+ fbptr[j] = pcol;
+ }
+ }
+ fbptr -= fb_width;
+ cidx++;
+ }
+ cidx = offs;
+ } else {
+ cidx = offs - hory;
+ hory = 0;
+ }
+
+ fbptr = fb_pixels + hory * fb_width;
+ for(i=hory; i<fb_height; i++) {
+ pcol = bgcol_mir[cidx < 0 ? 0 : (cidx >= BGCOL_SIZE ? BGCOL_SIZE - 1 : cidx)];
+ for(j=0; j<fb_width; j++) {
+ if(cidx < bgoffs[(startidx + j) & (BGOFFS_SIZE - 1)]) {
+ *fbptr++ = mountcol_mir;
+ } else {
+ *fbptr++ = pcol;
+ }
+ }
+ cidx++;
+ }