home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / pmdoom / src / i_video.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-17  |  6.8 KB  |  286 lines

  1. /*
  2.  *    General video routines
  3.  *
  4.  *    Patrice Mandin
  5.  */
  6.  
  7. #include "doomstat.h"
  8. #include "i_system.h"
  9. #include "v_video.h"
  10. #include "i_video.h"
  11. #include "i_zoom.h"
  12.  
  13. #include "m_argv.h"
  14. #include "d_main.h"
  15. #include "m_swap.h"
  16.  
  17. #include "doomdef.h"
  18. #include "r_draw.h"
  19. #include "am_map.h"
  20. #include "f_wipe.h"
  21. #include "f_finale.h"
  22. #include "r_main.h"
  23.  
  24. extern byte    *orig_colormaps;
  25.  
  26. int        fbnum=0;
  27. int        bpp;
  28. int        pixel_size;
  29. lighttable_t    truecolor_palette[256];
  30. boolean    pixelinv=false; /* byte swap TC pixels ? */
  31. boolean zoomscreen=false;    /* Zoom to fill screen */
  32. int     videomode=-1;        /* Video mode number selected */
  33. int        videowidth,videoheight;    /* Size of destination screen */
  34.  
  35. boolean dblbuffer=false;    /* Double buffer ? */
  36.  
  37. /* Display functions */
  38. void        (*R_DrawColumn)();
  39. void        (*R_DrawColumnLow)();
  40. void        (*R_DrawFuzzColumn)();
  41. void        (*R_DrawFuzzColumnLow)();
  42. void        (*R_DrawTranslatedColumn)();
  43. void        (*R_DrawTranslatedColumnLow)();
  44. void        (*R_DrawSpan)();
  45. void        (*R_DrawSpanLow)();
  46. void        (*AM_DrawFline)();
  47. void        (*V_DrawPatch)();
  48. void        (*V_DrawPatchFlipped)();
  49. int        (*wipe_doMelt)();
  50. void        (*F_DrawPatchCol)();
  51.  
  52. extern    unsigned long fuzzmask;    /* for fuzz effect in 15/16 bit mode */
  53.  
  54. extern patch_t    *ext_shortnum[10];
  55.  
  56. void I_FinishUpdate (void)
  57. {
  58.     static int    lasttic;
  59.     static int    tics=999;
  60.     int        i;
  61.     int c,d,u;
  62.  
  63.     /* draws little dots on the bottom of the screen */
  64.     if (devparm)
  65.     {
  66.         if (tics>999)
  67.             tics=999;
  68.  
  69.         c=tics / 100;
  70.         d=(tics-c*100) / 10;
  71.         u=(tics-c*100-d*10);
  72.  
  73.         if (ext_shortnum[c])
  74.         {
  75.             V_DrawPatch(320-12,0,0,ext_shortnum[c]);
  76.             V_DrawPatch(320-8,0,0,ext_shortnum[d]);
  77.             V_DrawPatch(320-4,0,0,ext_shortnum[u]);
  78.         }
  79.     }
  80.  
  81.     I_VidUpdate();
  82.  
  83.     i = I_GetTime();
  84.     tics = i - lasttic;
  85.     lasttic = i;
  86. }
  87.  
  88. void I_ReadScreen (byte* scr)
  89. {
  90.     memcpy (scr, screens[0], SCREENWIDTH*SCREENHEIGHT*pixel_size);
  91. }
  92.  
  93. void I_SetPalette (byte* palette)
  94. {
  95.     int                i;
  96.     lighttable_t    tc=0;
  97.     byte            *palette1=palette;
  98.  
  99.     switch(pixel_size)
  100.     {
  101.         case 1:
  102.             I_SetPalette256(palette);
  103.             break;
  104.         case 2:
  105.         case 3:
  106.         case 4:
  107.             for(i = 0; i < 256; i++)
  108.             {
  109.                 int        r1,v1,b1;
  110.                 int        c,y,r,v,b;
  111.  
  112.                 c=orig_colormaps[i]*3;
  113.  
  114.                 r1=gammatable[usegamma][palette[c]];
  115.                 v1=gammatable[usegamma][palette[c+1]];
  116.                 b1=gammatable[usegamma][palette[c+2]];    
  117.  
  118.                 for(y=0;y<NUMCOLORMAPS;y++)
  119.                 {
  120.                     r=r1-(y*r1)/(NUMCOLORMAPS-1);
  121.                     v=v1-(y*v1)/(NUMCOLORMAPS-1);
  122.                     b=b1-(y*b1)/(NUMCOLORMAPS-1);    
  123.                     switch (bpp)
  124.                     {
  125.                         case 15:
  126.                             tc = ((r>>3)<<10)|((v>>3)<<5)|(b>>3);
  127.                             if (pixelinv)
  128.                                 tc = SwapSHORT(tc);
  129.                             tc |= tc << 16;
  130.                             break;
  131.                         case 16:
  132.                             tc = ((r>>3)<<11)|((v>>2)<<5)|(b>>3);
  133.                             if (pixelinv)
  134.                                 tc = SwapSHORT(tc);
  135.                             tc |= tc << 16;
  136.                             break;
  137.                         case 24:
  138.                         case 32:
  139.                               if (pixelinv)
  140.                                 tc=(b<<16)|(v<<8)|r;
  141.                             else
  142.                                 tc=(r<<16)|(v<<8)|b;
  143.                             break;
  144.                     }
  145.                     colormaps[y*256+i]=tc;            
  146.                 }
  147.  
  148.                 /* Invulnerabilite */
  149.     
  150.                 colormaps[NUMCOLORMAPS*256+i]=colormaps[orig_colormaps[32*256+i]];
  151.  
  152.                 /* Noir */
  153.     
  154.                 colormaps[(NUMCOLORMAPS+1)*256+i]=0;
  155.  
  156.                 /* Palettes normales */
  157.  
  158.                 r=gammatable[usegamma][*palette1++];
  159.                 v=gammatable[usegamma][*palette1++];
  160.                 b=gammatable[usegamma][*palette1++];
  161.  
  162.                 switch (bpp)
  163.                 {
  164.                     case 15:
  165.                         tc = ((r>>3)<<10)|((v>>3)<<5)|(b>>3);
  166.                         if (pixelinv)
  167.                             tc = SwapSHORT(tc);
  168.                         tc |= tc << 16;
  169.                         break;
  170.                     case 16:
  171.                         tc = ((r>>3)<<11)|((v>>2)<<5)|(b>>3);
  172.                         if (pixelinv)
  173.                             tc = SwapSHORT(tc);
  174.                         tc |= tc << 16;
  175.                         break;
  176.                     case 24:
  177.                     case 32:
  178.                           if (pixelinv)
  179.                             tc=(b<<16)|(v<<8)|r;
  180.                         else
  181.                             tc=(r<<16)|(v<<8)|b;
  182.                         break;
  183.                 }
  184.                 truecolor_palette[i]=tc;
  185.             }
  186.             break;
  187.     }
  188. }
  189.  
  190. void I_InitGraphics_null(void)
  191. {
  192.     bpp=8;
  193.  
  194.     switch (bpp)
  195.     {
  196.         case 8:
  197.             R_DrawColumn=R_DrawColumn8;
  198.             R_DrawColumnLow=R_DrawColumnLow8;
  199.             R_DrawFuzzColumn=R_DrawFuzzColumn8;
  200.             R_DrawFuzzColumnLow=R_DrawFuzzColumnLow8;
  201.             R_DrawTranslatedColumn=R_DrawTranslatedColumn8;
  202.             R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow8;
  203.             R_DrawSpan=R_DrawSpan8;
  204.             R_DrawSpanLow=R_DrawSpanLow8;
  205.             AM_DrawFline=AM_drawFline8;
  206.             wipe_doMelt=wipe_doMelt8;
  207.             V_DrawPatch=V_DrawPatch8;
  208.             V_DrawPatchFlipped=V_DrawPatchFlipped8;
  209.             F_DrawPatchCol=F_DrawPatchCol8;
  210.             I_Zoom=I_Zoom8;
  211.             pixel_size=1;
  212.             break;
  213.         case 15:
  214.             R_DrawColumn=R_DrawColumn16;
  215.             R_DrawColumnLow=R_DrawColumnLow16;
  216.             R_DrawFuzzColumn=R_DrawFuzzColumn16;
  217.             R_DrawFuzzColumnLow=R_DrawFuzzColumnLow16;
  218.             R_DrawTranslatedColumn=R_DrawTranslatedColumn16;
  219.             R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow16;
  220.             R_DrawSpan=R_DrawSpan16;
  221.             R_DrawSpanLow=R_DrawSpanLow16;
  222.             AM_DrawFline=AM_drawFline16;
  223.             wipe_doMelt=wipe_doMelt16;
  224.             V_DrawPatch=V_DrawPatch16;
  225.             V_DrawPatchFlipped=V_DrawPatchFlipped16;
  226.             F_DrawPatchCol=F_DrawPatchCol16;
  227.             I_Zoom=I_Zoom16;
  228.             pixel_size=2;
  229.             fuzzmask=0x3DEF3DEF;
  230.             break;
  231.         case 16:
  232.             R_DrawColumn=R_DrawColumn16;
  233.             R_DrawColumnLow=R_DrawColumnLow16;
  234.             R_DrawFuzzColumn=R_DrawFuzzColumn16;
  235.             R_DrawFuzzColumnLow=R_DrawFuzzColumnLow16;
  236.             R_DrawTranslatedColumn=R_DrawTranslatedColumn16;
  237.             R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow16;
  238.             R_DrawSpan=R_DrawSpan16;
  239.             R_DrawSpanLow=R_DrawSpanLow16;
  240.             AM_DrawFline=AM_drawFline16;
  241.             wipe_doMelt=wipe_doMelt16;
  242.             V_DrawPatch=V_DrawPatch16;
  243.             V_DrawPatchFlipped=V_DrawPatchFlipped16;
  244.             F_DrawPatchCol=F_DrawPatchCol16;
  245.             I_Zoom=I_Zoom16;
  246.             pixel_size=2;
  247.             fuzzmask=0x7BEF7BEF;
  248.             break;
  249.         case 24:
  250.             R_DrawColumn=R_DrawColumn24;
  251.             R_DrawColumnLow=R_DrawColumnLow24;
  252.             R_DrawFuzzColumn=R_DrawFuzzColumn24;
  253.             R_DrawFuzzColumnLow=R_DrawFuzzColumnLow24;
  254.             R_DrawTranslatedColumn=R_DrawTranslatedColumn24;
  255.             R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow24;
  256.             R_DrawSpan=R_DrawSpan24;
  257.             R_DrawSpanLow=R_DrawSpanLow24;
  258.             AM_DrawFline=AM_drawFline24;
  259.             wipe_doMelt=wipe_doMelt24;
  260.             V_DrawPatch=V_DrawPatch24;
  261.             V_DrawPatchFlipped=V_DrawPatchFlipped24;
  262.             F_DrawPatchCol=F_DrawPatchCol24;
  263.             I_Zoom=I_Zoom24;
  264.             pixel_size=3;
  265.             break;
  266.         case 32:
  267.             R_DrawColumn=R_DrawColumn32;
  268.             R_DrawColumnLow=R_DrawColumnLow32;
  269.             R_DrawFuzzColumn=R_DrawFuzzColumn32;
  270.             R_DrawFuzzColumnLow=R_DrawFuzzColumnLow32;
  271.             R_DrawTranslatedColumn=R_DrawTranslatedColumn32;
  272.             R_DrawTranslatedColumnLow=R_DrawTranslatedColumnLow32;
  273.             R_DrawSpan=R_DrawSpan32;
  274.             R_DrawSpanLow=R_DrawSpanLow32;
  275.             AM_DrawFline=AM_drawFline32;
  276.             wipe_doMelt=wipe_doMelt32;
  277.             V_DrawPatch=V_DrawPatch32;
  278.             V_DrawPatchFlipped=V_DrawPatchFlipped32;
  279.             F_DrawPatchCol=F_DrawPatchCol32;
  280.             I_Zoom=I_Zoom32;
  281.             pixel_size=4;
  282.             fuzzmask=0x007F7F7F;
  283.             break;
  284.     }
  285. }
  286.