⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v_video.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 3 页
字号:
            source = (byte *)column + 3;            dest   = desttop + column->topdelta*dupy*vid.width;            count  = column->length*dupy;            ofs = 0;            while (count--)            {                *dest = source[ofs>>FRACBITS];                dest += vid.width;                ofs += rowfrac;            }            column = (column_t *)( (byte *)column + column->length + 4 );        }    }}// Same as V_DrawScaledPatch, but x-mirrored - just for f_finale.c//void V_DrawScaledPatchFlipped ( int           x,                                int           y,                                int           scrn,    // hacked flags in it...                                patch_t*      patch ){    int         count;    int         col;    column_t*   column;    byte*       desttop;    byte*       dest;    byte*       source;    int         w;    int         dupx,dupy;    int         ofs;    int         colfrac,rowfrac;    // draw an hardware converted patch    #ifdef HWRENDER    if ( rendermode != render_soft) {        HWR_DrawPatch ((GlidePatch_t*)patch, x, y);        return;    }    #endif    dupx = vid.dupx;    dupy = vid.dupy;    y -= SHORT(patch->topoffset);    x -= SHORT(patch->leftoffset);    col = 0;    colfrac  = FixedDiv (FRACUNIT, dupx<<FRACBITS);    rowfrac  = FixedDiv (FRACUNIT, dupy<<FRACBITS);    desttop = screens[scrn&0xFF];    if (scrn&V_NOSCALESTART)        desttop += (y*vid.width) + x;    else        desttop += (y*dupy*vid.width) + (x*dupx) + scaledofs;    w = SHORT(patch->width)<<FRACBITS;    for (col=w-colfrac; col>=0; col-=colfrac, desttop++)    {        column = (column_t *)((byte *)patch + LONG(patch->columnofs[col>>FRACBITS]));        while (column->topdelta != 0xff )        {            source = (byte *)column + 3;            dest   = desttop + column->topdelta*dupy*vid.width;            count  = column->length*dupy;            ofs = 0;            while (count--)            {                *dest = source[ofs>>FRACBITS];                dest += vid.width;                ofs += rowfrac;            }            column = (column_t *)( (byte *)column + column->length + 4 );        }    }}//added:16-02-98: now used for crosshair////  This draws a patch over a background with translucency...SCALED//  DOESNT SCALE THE STARTING COORDS!!//void V_DrawTranslucentPatch ( int           x,                              int           y,                              int           scrn, // hacked flag on it                              patch_t*      patch ){    int         count;    int         col;    column_t*   column;    byte*       desttop;    byte*       dest;    byte*       source;    int         w;    int         dupx,dupy;    int         ofs;    int         colfrac,rowfrac;    // draw an hardware converted patch    #ifdef HWRENDER    if ( rendermode != render_soft) {        HWR_DrawPatch ((GlidePatch_t*)patch, x, y);        return;    }    #endif    dupx = vid.dupx;    dupy = vid.dupy;    y -= SHORT(patch->topoffset)*dupy;    x -= SHORT(patch->leftoffset)*dupx;    if (!(scrn&0xffff))        V_MarkRect (x, y, SHORT(patch->width)*dupx, SHORT(patch->height)*dupy);    col = 0;    colfrac  = FixedDiv (FRACUNIT, dupx<<FRACBITS);    rowfrac  = FixedDiv (FRACUNIT, dupy<<FRACBITS);    desttop = screens[scrn&0xffff];    if (scrn&V_SCALESTART)        desttop += (y*dupy*vid.width) + (x*dupx) + scaledofs;    else        desttop += (y*vid.width) + x;            w = SHORT(patch->width)<<FRACBITS;    for ( ; col<w ; col+=colfrac, desttop++)    {        column = (column_t *)((byte *)patch + LONG(patch->columnofs[col>>FRACBITS]));        while (column->topdelta != 0xff )        {            source = (byte *)column + 3;            dest   = desttop + column->topdelta*dupy*vid.width;            count  = column->length*dupy;            ofs = 0;            while (count--)            {                *dest = *( transtables + ((source[ofs>>FRACBITS]<<8)&0xFF00) + (*dest&0xFF) );                dest += vid.width;                ofs += rowfrac;            }            column = (column_t *)( (byte *)column + column->length + 4 );        }    }}//// V_DrawPatch// Masks a column based masked pic to the screen. NO SCALING!!!//void V_DrawPatch ( int           x,                   int           y,                   int           scrn,                   patch_t*      patch ){    int         count;    int         col;    column_t*   column;    byte*       desttop;    byte*       dest;    byte*       source;    int         w;    // draw an hardware converted patch#ifdef HWRENDER    if ( rendermode != render_soft) {        HWR_DrawPatch ((GlidePatch_t*)patch, x, y);        return;    }#endif    y -= SHORT(patch->topoffset);    x -= SHORT(patch->leftoffset);#ifdef RANGECHECK    if (x<0        ||x+SHORT(patch->width) >vid.width        || y<0        || y+SHORT(patch->height)>vid.height        || (unsigned)scrn>4)    {      fprintf( stderr, "Patch at %d,%d exceeds LFB\n", x,y );      // No I_Error abort - what is up with TNT.WAD?      fprintf( stderr, "V_DrawPatch: bad patch (ignored)\n");      return;    }#endif    if (!scrn)        V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height));    col = 0;    desttop = screens[scrn]+y*vid.width+x;    w = SHORT(patch->width);    for ( ; col<w ; x++, col++, desttop++)    {        column = (column_t *)((byte *)patch + LONG(patch->columnofs[col]));        // step through the posts in a column        while (column->topdelta != 0xff )        {            source = (byte *)column + 3;            dest = desttop + column->topdelta*vid.width;            count = column->length;            while (count--)            {                *dest = *source++;                dest += vid.width;            }            column = (column_t *)( (byte *)column + column->length + 4 );        }    }}//// V_DrawPatchFlipped// Masks a column based masked pic to the screen.// Flips horizontally, e.g. to mirror face.//voidV_DrawPatchFlipped( int           x,  int           y,  int           scrn,  patch_t*      patch ){    int         count;    int         col;    column_t*   column;    byte*       desttop;    byte*       dest;    byte*       source;    int         w;    // draw an hardware converted patch    #ifdef HWRENDER    if ( rendermode != render_soft) {        HWR_DrawPatch ((GlidePatch_t*)patch, x, y);        return;    }    #endif    y -= SHORT(patch->topoffset);    x -= SHORT(patch->leftoffset);#ifdef RANGECHECK    if (x<0        ||x+SHORT(patch->width) >vid.width        || y<0        || y+SHORT(patch->height)>vid.height        || (unsigned)scrn>4)    {      fprintf( stderr, "Patch origin %d,%d exceeds LFB\n", x,y );      I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped");    }#endif    if (!scrn)        V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height));    col = 0;    desttop = screens[scrn]+y*vid.width+x;    w = SHORT(patch->width);    for ( ; col<w ; x++, col++, desttop++)    {        column = (column_t *)((byte *)patch + LONG(patch->columnofs[w-1-col]));        // step through the posts in a column        while (column->topdelta != 0xff )        {            source = (byte *)column + 3;            dest = desttop + column->topdelta*vid.width;            count = column->length;            while (count--)            {                *dest = *source++;                dest += vid.width;            }            column = (column_t *)(  (byte *)column + column->length                                    + 4 );        }    }}//// V_DrawBlock// Draw a linear block of pixels into the view buffer.//void V_DrawBlock ( int           x,                   int           y,                   int           scrn,                   int           width,                   int           height,                   byte*         src ){    byte*       dest;#ifdef RANGECHECK    if (x<0        ||x+width >vid.width        || y<0        || y+height>vid.height        || (unsigned)scrn>4 )    {        I_Error ("Bad V_DrawBlock");    }#endif    //V_MarkRect (x, y, width, height);    dest = screens[scrn] + y*vid.width + x;    while (height--)    {        memcpy (dest, src, width);        src += width;        dest += vid.width;    }}//// V_GetBlock// Gets a linear block of pixels from the view buffer.//voidV_GetBlock( int           x,  int           y,  int           scrn,  int           width,  int           height,  byte*         dest ){    byte*         src;    if (rendermode!=render_soft)        I_Error ("V_GetBlock: called in non-software mode");#ifdef RANGECHECK    if (x<0        ||x+width >vid.width        || y<0        || y+height>vid.height        || (unsigned)scrn>4 )    {        I_Error ("Bad V_GetBlock");    }#endif    src = screens[scrn] + y*vid.width+x;    while (height--)    {        memcpy (dest, src, width);        src += vid.width;        dest += width;    }}static void V_BlitScalePic(int x1, int y1, int scrn, pic_t *pic);//  Draw a linear pic, scaled, TOTALLY CRAP CODE!!! OPTIMISE AND ASM!!//  CURRENTLY USED FOR StatusBarOverlay, scale pic but not starting coords//void V_DrawScalePic ( int           x1,                      int           y1,                      int           scrn,     // hack flag                      int           lumpnum ){#ifdef HWRENDER    if (rendermode!=render_soft)    {        HWR_DrawPic(x1, y1, lumpnum);        return;    }#endif    V_BlitScalePic(x1, y1, scrn, W_CacheLumpNum(lumpnum,PU_CACHE));}static void V_BlitScalePic(int x1, int y1, int scrn, pic_t *pic){    int         dupx,dupy;    int         x,y;    byte        *src, *dest;    int         width,height;    width = SHORT(pic->width);    height= SHORT(pic->height);    scrn&=0xffff;    if (pic->mode != 0)    {        CONS_Printf("pic mode %d not supported in Software\n",pic->mode);        return;    }    dest = screens[scrn] + max(0,y1*vid.width) + max(0,x1);    // y cliping to the screen    if( y1+height*vid.dupy>=vid.width )        height = (vid.width-y1)/vid.dupy-1;    // WARING no x clipping (not needed for the moment)    for (y=max(0,-y1/vid.dupy) ; y<height ; y++)    {        for(dupy=vid.dupy;dupy;dupy--)                {            src = pic->data + y*width;            for (x=0 ; x<width ; x++)            {                for(dupx=vid.dupx;dupx;dupx--)                    *dest++ = *src;                src++;            }            dest += vid.width-vid.dupx*width;        }    }}void V_DrawRawScreen(int x1, int y1, int lumpnum, int width, int height){#ifdef HWRENDER    if (rendermode!=render_soft)    {        // save size somewhere and mark lump as a raw pic !        GlidePatch_t *grpatch = &(wadfiles[lumpnum>>16]->hwrcache[lumpnum & 0xffff]);        grpatch->width = width;        grpatch->height = height;        grpatch->mipmap.flags |= TF_RAWASPIC;        HWR_DrawPic(x1, y1, lumpnum);        return;    }#endif    V_BlitScalePic(x1, y1, 0, W_CacheRawAsPic(lumpnum, width, height, PU_CACHE));}////  Fills a box of pixels with a single color, NOTE: scaled to screen size////added:05-02-98:void V_DrawFill (int x, int y, int w, int h, int c){    byte      *dest;    int       u, v;    int       dupx,dupy;#ifdef HWRENDER    if (rendermode!=render_soft)    {        HWR_DrawFill(x, y, w, h, c);        return;    }#endif    dupx = vid.dupx;    dupy = vid.dupy;    dest = screens[0] + y*dupy*vid.width + x*dupx + scaledofs;    w *= dupx;    h *= dupy;    for (v=0 ; v<h ; v++, dest += vid.width)        for (u=0 ; u<w ; u++)            dest[u] = c;}////  Fills a box of pixels using a flat texture as a pattern,//  scaled to screen size.////added:06-02-98:void V_DrawFlatFill (int x, int y, int w, int h, int flatnum){    byte      *dest;    int       u, v;    int       dupx,dupy;    fixed_t   dx,dy,xfrac,yfrac;    byte      *src;    byte      *flat;#ifdef HWRENDER    if (rendermode != render_soft)    {        HWR_DrawFlatFill(x,y,w,h,flatnum);        return;    }#endif    flat = W_CacheLumpNum (flatnum, PU_CACHE);    dupx = vid.dupx;    dupy = vid.dupy;    dest = screens[0] + y*dupy*vid.width + x*dupx + scaledofs;    w *= dupx;    h *= dupy;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -