Annotation of quake1/d_sky.c, revision 1.1.1.1

1.1       root        1: // d_sky.c
                      2: 
                      3: #include "quakedef.h"
                      4: #include "r_local.h"
                      5: #include "d_local.h"
                      6: 
                      7: #define SKY_SPAN_SHIFT 5
                      8: #define SKY_SPAN_MAX   (1 << SKY_SPAN_SHIFT)
                      9: 
                     10: 
                     11: /*
                     12: =================
                     13: D_Sky_uv_To_st
                     14: =================
                     15: */
                     16: void D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t)
                     17: {
                     18:        float   wu, wv, temp;
                     19:        vec3_t  end;
                     20: 
                     21:        if (r_refdef.vrect.width >= r_refdef.vrect.height)
                     22:                temp = (float)r_refdef.vrect.width;
                     23:        else
                     24:                temp = (float)r_refdef.vrect.height;
                     25: 
                     26:        wu = 8192.0 * (float)(u-((int)vid.width>>1)) / temp;
                     27:        wv = 8192.0 * (float)(((int)vid.height>>1)-v) / temp;
                     28: 
                     29:        end[0] = 4096*vpn[0] + wu*vright[0] + wv*vup[0];
                     30:        end[1] = 4096*vpn[1] + wu*vright[1] + wv*vup[1];
                     31:        end[2] = 4096*vpn[2] + wu*vright[2] + wv*vup[2];
                     32:        end[2] *= 3;
                     33:        VectorNormalize (end);
                     34: 
                     35:        temp = skytime*skyspeed;        // TODO: add D_SetupFrame & set this there
                     36:        *s = (int)((temp + 6*(SKYSIZE/2-1)*end[0]) * 0x10000);
                     37:        *t = (int)((temp + 6*(SKYSIZE/2-1)*end[1]) * 0x10000);
                     38: }
                     39: 
                     40: 
                     41: /*
                     42: =================
                     43: D_DrawSkyScans8
                     44: =================
                     45: */
                     46: void D_DrawSkyScans8 (espan_t *pspan)
                     47: {
                     48:        int                             count, spancount, u, v;
                     49:        unsigned char   *pdest;
                     50:        fixed16_t               s, t, snext, tnext, sstep, tstep;
                     51:        int                             spancountminus1;
                     52: 
                     53:        sstep = 0;      // keep compiler happy
                     54:        tstep = 0;      // ditto
                     55: 
                     56:        do
                     57:        {
                     58:                pdest = (unsigned char *)((byte *)d_viewbuffer +
                     59:                                (screenwidth * pspan->v) + pspan->u);
                     60: 
                     61:                count = pspan->count;
                     62: 
                     63:        // calculate the initial s & t
                     64:                u = pspan->u;
                     65:                v = pspan->v;
                     66:                D_Sky_uv_To_st (u, v, &s, &t);
                     67: 
                     68:                do
                     69:                {
                     70:                        if (count >= SKY_SPAN_MAX)
                     71:                                spancount = SKY_SPAN_MAX;
                     72:                        else
                     73:                                spancount = count;
                     74: 
                     75:                        count -= spancount;
                     76: 
                     77:                        if (count)
                     78:                        {
                     79:                                u += spancount;
                     80: 
                     81:                        // calculate s and t at far end of span,
                     82:                        // calculate s and t steps across span by shifting
                     83:                                D_Sky_uv_To_st (u, v, &snext, &tnext);
                     84: 
                     85:                                sstep = (snext - s) >> SKY_SPAN_SHIFT;
                     86:                                tstep = (tnext - t) >> SKY_SPAN_SHIFT;
                     87:                        }
                     88:                        else
                     89:                        {
                     90:                        // calculate s and t at last pixel in span,
                     91:                        // calculate s and t steps across span by division
                     92:                                spancountminus1 = (float)(spancount - 1);
                     93: 
                     94:                                if (spancountminus1 > 0)
                     95:                                {
                     96:                                        u += spancountminus1;
                     97:                                        D_Sky_uv_To_st (u, v, &snext, &tnext);
                     98: 
                     99:                                        sstep = (snext - s) / spancountminus1;
                    100:                                        tstep = (tnext - t) / spancountminus1;
                    101:                                }
                    102:                        }
                    103: 
                    104:                        do
                    105:                        {
                    106:                                *pdest++ = r_skysource[((t & R_SKY_TMASK) >> 8) +
                    107:                                                ((s & R_SKY_SMASK) >> 16)];
                    108:                                s += sstep;
                    109:                                t += tstep;
                    110:                        } while (--spancount > 0);
                    111: 
                    112:                        s = snext;
                    113:                        t = tnext;
                    114: 
                    115:                } while (count > 0);
                    116: 
                    117:        } while ((pspan = pspan->pnext) != NULL);
                    118: }
                    119: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.