home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / games / diyupdate3 / Unix / Diffs / i_video_c < prev   
Encoding:
Text File  |  1998-07-29  |  7.4 KB  |  280 lines

  1. 49c49
  2. < #include <errnos.h>
  3. ---
  4. > #include <errno.h>
  5. 53a54
  6. > #include "i_video.h"
  7. 59a61,63
  8. > #include "r_main.h"
  9. 63a68
  10. > #if (LD_PIXEL_DEPTH == 3)
  11. 64a70,82
  12. > #define USE_PIXEL_DEPTH        8
  13. > #else
  14. > #if (LD_PIXEL_DEPTH == 4)
  15. > #define USE_PIXEL_DEPTH        16
  16. > #elif (LD_PIXEL_DEPTH == 5)
  17. > #define USE_PIXEL_DEPTH        24
  18. > #else
  19. > #error "Unsupported pixel depth!"
  20. > #endif
  21. > boolean        PaletteChanged=false;
  22. > lighttable_t    translated_colourmaps[256*(NUMCOLORMAPS+1)];
  23. > unsigned long    light_multipliers[NUMCOLORMAPS];
  24. > #endif
  25. 93a112,113
  26. 151a172,182
  27. >       case XK_0:
  28. >       case XK_KP_0:    rc = '0';        break;
  29. >       case XK_KP_1:    rc = '1';        break;
  30. >       case XK_KP_2:    rc = '2';        break;
  31. >       case XK_KP_3:    rc = '3';        break;
  32. >       case XK_KP_4:    rc = '4';        break;
  33. >       case XK_KP_5:    rc = '5';        break;
  34. >       case XK_KP_6:    rc = '6';        break;
  35. >       case XK_KP_7:    rc = '7';        break;
  36. >       case XK_KP_8:    rc = '8';        break;
  37. 388c419
  38. <         olineptrs[i] = (unsigned int *) &image->data[i*X_width];
  39. ---
  40. >         olineptrs[i] = (unsigned int *) &image->data[i*X_width*sizeof(pixel_t)];
  41. 393a425
  42. > #if (LD_PIXEL_DEPTH == 3)
  43. 416a449,481
  44. > #elif (LD_PIXEL_DEPTH == 4)
  45. >         do
  46. >         {
  47. >         fouripixels = *ilineptr++;
  48. >         twoopixels = (fouripixels & 0xffff0000); twoopixels |= (twoopixels >> 16);
  49. >         twomoreopixels = (fouripixels & 0xffff); twomoreopixels |= (twomoreopixels << 16);
  50. > #ifdef __BIG_ENDIAN__
  51. >         *olineptrs[0]++ = twoopixels;
  52. >         *olineptrs[1]++ = twoopixels;
  53. >         *olineptrs[0]++ = twomoreopixels;
  54. >         *olineptrs[1]++ = twomoreopixels;
  55. > #else
  56. >         *olineptrs[0]++ = twomoreopixels;
  57. >         *olineptrs[1]++ = twomoreopixels;
  58. >         *olineptrs[0]++ = twoopixels;
  59. >         *olineptrs[1]++ = twoopixels;
  60. > #endif
  61. >         } while (x-=2);
  62. >         olineptrs[0] += X_width/2;
  63. >         olineptrs[1] += X_width/2;
  64. > #else
  65. >         do
  66. >         {
  67. >         fouripixels = *ilineptr++;
  68. >         *olineptrs[0]++ = fouripixels;
  69. >         *olineptrs[0]++ = fouripixels;
  70. >         *olineptrs[1]++ = fouripixels;
  71. >         *olineptrs[1]++ = fouripixels;
  72. >         }
  73. >         while (x--);
  74. >         olineptrs[0] += X_width;
  75. >         olineptrs[1] += X_width;
  76. > #endif
  77. 430c495
  78. <         olineptrs[i] = (unsigned int *) &image->data[i*X_width];
  79. ---
  80. >         olineptrs[i] = (unsigned int *) &image->data[i*X_width*sizeof(pixel_t)];
  81. 435a501
  82. > #if (LD_PIXEL_DEPTH == 3)
  83. 472a539,587
  84. > #elif (LD_PIXEL_DEPTH == 4)
  85. >         do
  86. >         {
  87. >         fouripixels = *ilineptr++;
  88. > #ifdef __BIG_ENDIAN__
  89. >         fouropixels[0] = (fouripixels & 0xffff0000);
  90. >         fouropixels[0] |= (fouropixels[0] >> 16);
  91. >         fouropixels[1] = fouripixels;
  92. >         fouropixels[2] = (fouripixels & 0xffff);
  93. >         fouropixels[2] |= (fouropixels[2] << 16);
  94. > #else
  95. >         fouropixels[0] = (fouripixels & 0xffff);
  96. >         fouropixels[1] = fouropixels[0];
  97. >         fouropixels[0] |= (fouropixels[0] << 16);
  98. >         fouropixels[2] = (fouripixels & 0xffff0000);
  99. >         fouropixels[1] |= fouropixels[2];
  100. >         fouropixels[2] |= (fouropixels[2] >> 16);
  101. > #endif
  102. >         *olineptrs[0]++ = fouropixels[0];
  103. >         *olineptrs[0]++ = fouropixels[1];
  104. >         *olineptrs[0]++ = fouropixels[2];
  105. >         *olineptrs[1]++ = fouropixels[0];
  106. >         *olineptrs[1]++ = fouropixels[1];
  107. >         *olineptrs[1]++ = fouropixels[2];
  108. >         *olineptrs[2]++ = fouropixels[0];
  109. >         *olineptrs[2]++ = fouropixels[1];
  110. >         *olineptrs[2]++ = fouropixels[2];
  111. >         } while (x-=2);
  112. >         olineptrs[0] += X_width;
  113. >         olineptrs[1] += X_width;
  114. >         olineptrs[2] += X_width;
  115. > #else
  116. >         do
  117. >         {
  118. >         fouripixels = *ilineptr++;
  119. >         *olineptrs[0]++ = fouripixels;
  120. >         *olineptrs[0]++ = fouripixels;
  121. >         *olineptrs[0]++ = fouripixels;
  122. >         *olineptrs[1]++ = fouripixels;
  123. >         *olineptrs[1]++ = fouripixels;
  124. >         *olineptrs[1]++ = fouripixels;
  125. >         *olineptrs[2]++ = fouripixels;
  126. >         *olineptrs[2]++ = fouripixels;
  127. >         *olineptrs[2]++ = fouripixels;
  128. >         } while (x--);
  129. >         olineptrs[0] += 2*X_width;
  130. >         olineptrs[1] += 2*X_width;
  131. >         olineptrs[2] += 2*X_width;
  132. > #endif
  133. 527c642
  134. < void I_ReadScreen (byte* scr)
  135. ---
  136. > void I_ReadScreen (pixel_t* scr)
  137. 529c644
  138. <     memcpy (scr, screens[0], SCREENWIDTH*SCREENHEIGHT);
  139. ---
  140. >     memcpy (scr, screens[0], SCREENWIDTH*SCREENHEIGHT*sizeof(pixel_t));
  141. 579a695,748
  142. > #if (LD_PIXEL_DEPTH > 3)
  143. > void I_TranslatePalette(byte *palette)
  144. > {
  145. >     unsigned char    gamma_palette[768];
  146. >     unsigned char*    pal;
  147. >     unsigned char*    gt;
  148. >     unsigned char*    invul;
  149. >     int            i, j;
  150. >     unsigned long*    gp;
  151. >     lighttable_t*    cmap;
  152. >     unsigned long    intensity;
  153. >     int            red, green, blue;
  154. >     gt = (unsigned char*)(gammatable[usegamma]); gp = (unsigned long*)gamma_palette;
  155. >     for (i=0; i<768/4; i++)
  156. >     {
  157. >     *gp++ =
  158. > #ifdef __BIG_ENDIAN__
  159. >     (gt[(unsigned char)(palette[0])] << 24) | (gt[(unsigned char)(palette[1])] << 16) |
  160. >     (gt[(unsigned char)(palette[2])] << 8)  | (gt[(unsigned char)(palette[3])]);
  161. > #else
  162. >     (gt[(unsigned char)(palette[0])]) | (gt[(unsigned char)(palette[1])] << 8) |
  163. >     (gt[(unsigned char)(palette[2])] << 16) | (gt[(unsigned char)(palette[3])] << 24);
  164. > #endif
  165. >     palette += 4;
  166. >     }
  167. >     cmap = translated_colourmaps;
  168. >     for (j=0; j<NUMCOLORMAPS; j++)
  169. >     {
  170. >     intensity = light_multipliers[j];
  171. >     for (i=0, pal=gamma_palette; i<256; i++, pal+=3)
  172. >     {
  173. >         red   = (intensity * pal[0]) >> 16;
  174. >         green = (intensity * pal[1]) >> 16;
  175. >         blue  = (intensity * pal[2]) >> 16;
  176. >         *cmap++ = BUILD_RGB_PIXEL(red, green, blue);
  177. >     }
  178. >     }
  179. >     invul = (unsigned char*)(colormaps + 32*256);
  180. >     for (i=0; i<256; i++)
  181. >     {
  182. >     pal = gamma_palette + 3*((unsigned char)(invul[i]));
  183. >     *cmap++ = BUILD_RGB_PIXEL(pal[0], pal[1], pal[2]);
  184. >     }
  185. > }
  186. > #endif
  187. 583a753
  188. > #if (LD_PIXEL_DEPTH == 3)
  189. 584a755,757
  190. > #else
  191. >     I_TranslatePalette(palette);
  192. > #endif
  193. 771,772c944,952
  194. <     if (!XMatchVisualInfo(X_display, X_screen, 8, PseudoColor, &X_visualinfo))
  195. <     I_Error("xdoom currently only supports 256-color PseudoColor screens");
  196. ---
  197. > #if (LD_PIXEL_DEPTH == 3)
  198. >     if (!XMatchVisualInfo(X_display, X_screen, USE_PIXEL_DEPTH, PseudoColor, &X_visualinfo))
  199. > #elif (LD_PIXEL_DEPTH == 4)
  200. >     if (!XMatchVisualInfo(X_display, X_screen, USE_PIXEL_DEPTH, TrueColor, &X_visualinfo))
  201. > #else
  202. >     if (!XMatchVisualInfo(X_display, X_screen, USE_PIXEL_DEPTH, TrueColor, &X_visualinfo))
  203. > #endif
  204. >     I_Error("Can't claim visual for pixel depth %d. Try another binary.", USE_PIXEL_DEPTH);
  205. 792a973
  206. > #if (LD_PIXEL_DEPTH == 3)
  207. 795a977,986
  208. >     attribs.colormap = X_cmap;
  209. > #else
  210. >     attribs.colormap = 0;
  211. >     /* Init the lighttable intensities */
  212. >     for (n=0; n<NUMCOLORMAPS; n++)
  213. >     {
  214. >     light_multipliers[n] = 0x10000 - (n * (0x10000 - 0x2000)) / (NUMCOLORMAPS - 1);
  215. >     }
  216. > #endif
  217. 805d995
  218. <     attribs.colormap = X_cmap;
  219. 814c1004
  220. <                     8, /* depth*/
  221. ---
  222. >                     USE_PIXEL_DEPTH, /* depth*/
  223. 861c1051
  224. <                     8,
  225. ---
  226. >                     USE_PIXEL_DEPTH,
  227. 900c1090
  228. <                     8,
  229. ---
  230. >                     USE_PIXEL_DEPTH,
  231. 903c1093
  232. <                     (char*)malloc(X_width * X_height),
  233. ---
  234. >                     (char*)malloc(X_width * X_height * sizeof(pixel_t)),
  235. 906c1096
  236. <                     X_width );
  237. ---
  238. >                     X_width * sizeof(pixel_t) );
  239. 911c1101
  240. <     screens[0] = (unsigned char *) (image->data);
  241. ---
  242. >     screens[0] = (pixel_t *) (image->data);
  243. 913c1103
  244. <     screens[0] = (unsigned char *) malloc (SCREENWIDTH * SCREENHEIGHT);
  245. ---
  246. >     screens[0] = (pixel_t *) malloc (SCREENWIDTH * SCREENHEIGHT * sizeof(pixel_t));
  247. 917a1108
  248. > #if (LD_PIXEL_DEPTH == 3)
  249. 1049a1241,1254
  250. > #else
  251. > void InitExpand(void) {;}
  252. > void InitExpand2(void) {;}
  253. > void
  254. > Expand4
  255. > ( unsigned*    lineptr,
  256. >   double*    xline )
  257. > {
  258. >     printf("-4 not supported!\n");
  259. > }
  260. > #endif
  261.