home *** CD-ROM | disk | FTP | other *** search
- /*
- * General video routines
- *
- * Patrice Mandin
- */
-
- #include "doomstat.h"
- #include "i_system.h"
- #include "v_video.h"
- #include "i_video.h"
- #include "i_zoom.h"
-
- #include "m_argv.h"
- #include "d_main.h"
- #include "m_swap.h"
-
- #include "doomdef.h"
- #include "r_draw.h"
- #include "am_map.h"
- #include "f_wipe.h"
- #include "f_finale.h"
- #include "r_main.h"
-
- extern byte *orig_colormaps;
-
- int fbnum=0;
- int bpp;
- int pixel_size;
- lighttable_t truecolor_palette[256];
- boolean pixelinv=false; /* byte swap TC pixels ? */
- boolean zoomscreen=false; /* Zoom to fill screen */
- int videomode=-1; /* Video mode number selected */
- int videowidth,videoheight; /* Size of destination screen */
-
- boolean dblbuffer=false; /* Double buffer ? */
-
- /* Display functions */
- void (*R_DrawColumn)();
- void (*R_DrawColumnLow)();
- void (*R_DrawFuzzColumn)();
- void (*R_DrawFuzzColumnLow)();
- void (*R_DrawTranslatedColumn)();
- void (*R_DrawTranslatedColumnLow)();
- void (*R_DrawSpan)();
- void (*R_DrawSpanLow)();
- void (*AM_DrawFline)();
- void (*V_DrawPatch)();
- void (*V_DrawPatchFlipped)();
- int (*wipe_doMelt)();
- void (*F_DrawPatchCol)();
-
- extern unsigned long fuzzmask; /* for fuzz effect in 15/16 bit mode */
-
- extern patch_t *ext_shortnum[10];
-
- void I_FinishUpdate (void)
- {
- static int lasttic;
- static int tics=999;
- int i;
- int c,d,u;
-
- /* draws little dots on the bottom of the screen */
- if (devparm)
- {
- if (tics>999)
- tics=999;
-
- c=tics / 100;
- d=(tics-c*100) / 10;
- u=(tics-c*100-d*10);
-
- if (ext_shortnum[c])
- {
- V_DrawPatch(320-12,0,0,ext_shortnum[c]);
- V_DrawPatch(320-8,0,0,ext_shortnum[d]);
- V_DrawPatch(320-4,0,0,ext_shortnum[u]);
- }
- }
-
- I_VidUpdate();
-
- i = I_GetTime();
- tics = i - lasttic;
- lasttic = i;
- }
-
- void I_ReadScreen (byte* scr)
- {
- memcpy (scr, screens[0], SCREENWIDTH*SCREENHEIGHT*pixel_size);
- }
-
- void I_SetPalette (byte* palette)
- {
- int i;
- lighttable_t tc=0;
- byte *palette1=palette;
-
- switch(pixel_size)
- {
- case 1:
- I_SetPalette256(palette);
- break;
- case 2:
- case 3:
- case 4:
- for(i = 0; i < 256; i++)
- {
- int r1,v1,b1;
- int c,y,r,v,b;
-
- c=orig_colormaps[i]*3;
-
- r1=gammatable[usegamma][palette[c]];
- v1=gammatable[usegamma][palette[c+1]];
- b1=gammatable[usegamma][palette[c+2]];
-
- for(y=0;y<NUMCOLORMAPS;y++)
- {
- r=r1-(y*r1)/(NUMCOLORMAPS-1);
- v=v1-(y*v1)/(NUMCOLORMAPS-1);
- b=b1-(y*b1)/(NUMCOLORMAPS-1);
- switch (bpp)
- {
- case 15:
- tc = ((r>>3)<<10)|((v>>3)<<5)|(b>>3);
- if (pixelinv)
- tc = SwapSHORT(tc);
- tc |= tc << 16;
- break;
- case 16:
- tc = ((r>>3)<<11)|((v>>2)<<5)|(b>>3);
- if (pixelinv)
- tc = SwapSHORT(tc);
- tc |= tc << 16;
- break;
- case 24:
- case 32:
- if (pixelinv)
- tc=(b<<16)|(v<<8)|r;
- else
- tc=(r<<16)|(v<<8)|b;
- break;
- }
- colormaps[y*256+i]=tc;
- }
-
- /* Invulnerabilite */
-
- colormaps[NUMCOLORMAPS*256+i]=colormaps[orig_colormaps[32*256+i]];
-
- /* Noir */
-
- colormaps[(NUMCOLORMAPS+1)*256+i]=0;
-
- /* Palettes normales */
-
- r=gammatable[usegamma][*palette1++];
- v=gammatable[usegamma][*palette1++];
- b=gammatable[usegamma][*palette1++];
-
- switch (bpp)
- {
- case 15:
- tc = ((r>>3)<<10)|((v>>3)<<5)|(b>>3);
- if (pixelinv)
- tc = SwapSHORT(tc);
- tc |= tc << 16;
- break;
- case 16:
- tc = ((r>>3)<<11)|((v>>2)<<5)|(b>>3);
- if (pixelinv)
- tc = SwapSHORT(tc);
- tc |= tc << 16;
- break;
- case 24:
- case 32:
- if (pixelinv)
- tc=(b<<16)|(v<<8)|r;
- else
- tc=(r<<16)|(v<<8)|b;
- break;
- }
- truecolor_palette[i]=tc;
- }
- break;
- }
- }
-
- void I_InitGraphics_null(void)
- {
- bpp=8;
-
- switch (bpp)
- {
- case 8:
- R_DrawColumn=R_DrawColumn8;
- R_DrawColumnLow=R_DrawColumnLow8;
- R_DrawFuzzColumn=R_DrawFuzzColumn8;
- R_DrawFuzzColumnLow=R_DrawFuzzColumnLow8;
- R_DrawTranslatedColumn=R_DrawTranslatedColumn8;
- R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow8;
- R_DrawSpan=R_DrawSpan8;
- R_DrawSpanLow=R_DrawSpanLow8;
- AM_DrawFline=AM_drawFline8;
- wipe_doMelt=wipe_doMelt8;
- V_DrawPatch=V_DrawPatch8;
- V_DrawPatchFlipped=V_DrawPatchFlipped8;
- F_DrawPatchCol=F_DrawPatchCol8;
- I_Zoom=I_Zoom8;
- pixel_size=1;
- break;
- case 15:
- R_DrawColumn=R_DrawColumn16;
- R_DrawColumnLow=R_DrawColumnLow16;
- R_DrawFuzzColumn=R_DrawFuzzColumn16;
- R_DrawFuzzColumnLow=R_DrawFuzzColumnLow16;
- R_DrawTranslatedColumn=R_DrawTranslatedColumn16;
- R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow16;
- R_DrawSpan=R_DrawSpan16;
- R_DrawSpanLow=R_DrawSpanLow16;
- AM_DrawFline=AM_drawFline16;
- wipe_doMelt=wipe_doMelt16;
- V_DrawPatch=V_DrawPatch16;
- V_DrawPatchFlipped=V_DrawPatchFlipped16;
- F_DrawPatchCol=F_DrawPatchCol16;
- I_Zoom=I_Zoom16;
- pixel_size=2;
- fuzzmask=0x3DEF3DEF;
- break;
- case 16:
- R_DrawColumn=R_DrawColumn16;
- R_DrawColumnLow=R_DrawColumnLow16;
- R_DrawFuzzColumn=R_DrawFuzzColumn16;
- R_DrawFuzzColumnLow=R_DrawFuzzColumnLow16;
- R_DrawTranslatedColumn=R_DrawTranslatedColumn16;
- R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow16;
- R_DrawSpan=R_DrawSpan16;
- R_DrawSpanLow=R_DrawSpanLow16;
- AM_DrawFline=AM_drawFline16;
- wipe_doMelt=wipe_doMelt16;
- V_DrawPatch=V_DrawPatch16;
- V_DrawPatchFlipped=V_DrawPatchFlipped16;
- F_DrawPatchCol=F_DrawPatchCol16;
- I_Zoom=I_Zoom16;
- pixel_size=2;
- fuzzmask=0x7BEF7BEF;
- break;
- case 24:
- R_DrawColumn=R_DrawColumn24;
- R_DrawColumnLow=R_DrawColumnLow24;
- R_DrawFuzzColumn=R_DrawFuzzColumn24;
- R_DrawFuzzColumnLow=R_DrawFuzzColumnLow24;
- R_DrawTranslatedColumn=R_DrawTranslatedColumn24;
- R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow24;
- R_DrawSpan=R_DrawSpan24;
- R_DrawSpanLow=R_DrawSpanLow24;
- AM_DrawFline=AM_drawFline24;
- wipe_doMelt=wipe_doMelt24;
- V_DrawPatch=V_DrawPatch24;
- V_DrawPatchFlipped=V_DrawPatchFlipped24;
- F_DrawPatchCol=F_DrawPatchCol24;
- I_Zoom=I_Zoom24;
- pixel_size=3;
- break;
- case 32:
- R_DrawColumn=R_DrawColumn32;
- R_DrawColumnLow=R_DrawColumnLow32;
- R_DrawFuzzColumn=R_DrawFuzzColumn32;
- R_DrawFuzzColumnLow=R_DrawFuzzColumnLow32;
- R_DrawTranslatedColumn=R_DrawTranslatedColumn32;
- R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow32;
- R_DrawSpan=R_DrawSpan32;
- R_DrawSpanLow=R_DrawSpanLow32;
- AM_DrawFline=AM_drawFline32;
- wipe_doMelt=wipe_doMelt32;
- V_DrawPatch=V_DrawPatch32;
- V_DrawPatchFlipped=V_DrawPatchFlipped32;
- F_DrawPatchCol=F_DrawPatchCol32;
- I_Zoom=I_Zoom32;
- pixel_size=4;
- fuzzmask=0x007F7F7F;
- break;
- }
- }
-