r_draw.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. /* Emacs style mode select -*- C++ -*-
  2. *-----------------------------------------------------------------------------
  3. *
  4. *
  5. * PrBoom: a Doom port merged with LxDoom and LSDLDoom
  6. * based on BOOM, a modified and improved DOOM engine
  7. * Copyright (C) 1999 by
  8. * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
  9. * Copyright (C) 1999-2000 by
  10. * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
  11. * Copyright 2005, 2006 by
  12. * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  27. * 02111-1307, USA.
  28. *
  29. * DESCRIPTION:
  30. * The actual span/column drawing functions.
  31. * Here find the main potential for optimization,
  32. * e.g. inline assembly, different algorithms.
  33. *
  34. *-----------------------------------------------------------------------------*/
  35. #include "doomstat.h"
  36. #include "w_wad.h"
  37. #include "r_main.h"
  38. #include "r_draw.h"
  39. #include "r_filter.h"
  40. #include "v_video.h"
  41. #include "st_stuff.h"
  42. #include "g_game.h"
  43. #include "am_map.h"
  44. #include "lprintf.h"
  45. //
  46. // All drawing to the view buffer is accomplished in this file.
  47. // The other refresh files only know about ccordinates,
  48. // not the architecture of the frame buffer.
  49. // Conveniently, the frame buffer is a linear one,
  50. // and we need only the base address,
  51. // and the total size == width*height*depth/8.,
  52. //
  53. byte *viewimage;
  54. int displaywidth;
  55. int displayheight;
  56. int viewwidth;
  57. int scaledviewwidth;
  58. int viewheight;
  59. int viewwindowx;
  60. int viewwindowy;
  61. // Color tables for different players,
  62. // translate a limited part to another
  63. // (color ramps used for suit colors).
  64. //
  65. // CPhipps - made const*'s
  66. const byte *tranmap; // translucency filter maps 256x256 // phares
  67. const byte *main_tranmap; // killough 4/11/98
  68. //
  69. // R_DrawColumn
  70. // Source is the top of the column to scale.
  71. //
  72. // SoM: OPTIMIZE for ANYRES
  73. typedef enum
  74. {
  75. COL_NONE,
  76. COL_OPAQUE,
  77. COL_TRANS,
  78. COL_FLEXTRANS,
  79. COL_FUZZ,
  80. COL_FLEXADD
  81. } columntype_e;
  82. static int temp_x = 0;
  83. static int tempyl[4], tempyh[4];
  84. static byte byte_tempbuf[MAX_SCREENHEIGHT * 4];
  85. static unsigned short short_tempbuf[MAX_SCREENHEIGHT * 4];
  86. static unsigned int int_tempbuf[MAX_SCREENHEIGHT * 4];
  87. static int startx = 0;
  88. static int temptype = COL_NONE;
  89. static int commontop, commonbot;
  90. static const byte *temptranmap = NULL;
  91. // SoM 7-28-04: Fix the fuzz problem.
  92. static const byte *tempfuzzmap;
  93. //
  94. // Spectre/Invisibility.
  95. //
  96. #define FUZZTABLE 50
  97. // proff 08/17/98: Changed for high-res
  98. //#define FUZZOFF (SCREENWIDTH)
  99. #define FUZZOFF 1
  100. static const int fuzzoffset_org[FUZZTABLE] = {
  101. FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,
  102. FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,
  103. FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,
  104. FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,
  105. FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,
  106. FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,
  107. FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF
  108. };
  109. static int fuzzoffset[FUZZTABLE];
  110. static int fuzzpos = 0;
  111. // render pipelines
  112. #define RDC_STANDARD 1
  113. #define RDC_TRANSLUCENT 2
  114. #define RDC_TRANSLATED 4
  115. #define RDC_FUZZ 8
  116. // no color mapping
  117. #define RDC_NOCOLMAP 16
  118. // filter modes
  119. #define RDC_DITHERZ 32
  120. #define RDC_BILINEAR 64
  121. #define RDC_ROUNDED 128
  122. draw_vars_t drawvars = {
  123. NULL, // byte_topleft
  124. NULL, // short_topleft
  125. NULL, // int_topleft
  126. 0, // byte_pitch
  127. 0, // short_pitch
  128. 0, // int_pitch
  129. RDRAW_FILTER_POINT, // filterwall
  130. RDRAW_FILTER_POINT, // filterfloor
  131. RDRAW_FILTER_POINT, // filtersprite
  132. RDRAW_FILTER_POINT, // filterz
  133. RDRAW_FILTER_POINT, // filterpatch
  134. RDRAW_MASKEDCOLUMNEDGE_SQUARE, // sprite_edges
  135. RDRAW_MASKEDCOLUMNEDGE_SQUARE, // patch_edges
  136. // 49152 = FRACUNIT * 0.75
  137. // 81920 = FRACUNIT * 1.25
  138. 49152 // mag_threshold
  139. };
  140. //
  141. // Error functions that will abort if R_FlushColumns tries to flush
  142. // columns without a column type.
  143. //
  144. static void R_FlushWholeError(void)
  145. {
  146. I_Error("R_FlushWholeColumns called without being initialized.\n");
  147. }
  148. static void R_FlushHTError(void)
  149. {
  150. I_Error("R_FlushHTColumns called without being initialized.\n");
  151. }
  152. static void R_QuadFlushError(void)
  153. {
  154. I_Error("R_FlushQuadColumn called without being initialized.\n");
  155. }
  156. static void (*R_FlushWholeColumns)(void) = R_FlushWholeError;
  157. static void (*R_FlushHTColumns)(void) = R_FlushHTError;
  158. static void (*R_FlushQuadColumn)(void) = R_QuadFlushError;
  159. static void R_FlushColumns(void)
  160. {
  161. if(temp_x != 4 || commontop >= commonbot)
  162. R_FlushWholeColumns();
  163. else
  164. {
  165. R_FlushHTColumns();
  166. R_FlushQuadColumn();
  167. }
  168. temp_x = 0;
  169. }
  170. //
  171. // R_ResetColumnBuffer
  172. //
  173. // haleyjd 09/13/04: new function to call from main rendering loop
  174. // which gets rid of the unnecessary reset of various variables during
  175. // column drawing.
  176. //
  177. void R_ResetColumnBuffer(void)
  178. {
  179. // haleyjd 10/06/05: this must not be done if temp_x == 0!
  180. if(temp_x)
  181. R_FlushColumns();
  182. temptype = COL_NONE;
  183. R_FlushWholeColumns = R_FlushWholeError;
  184. R_FlushHTColumns = R_FlushHTError;
  185. R_FlushQuadColumn = R_QuadFlushError;
  186. }
  187. #define R_DRAWCOLUMN_PIPELINE RDC_STANDARD
  188. #define R_DRAWCOLUMN_PIPELINE_BITS 8
  189. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole8
  190. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT8
  191. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad8
  192. #include "r_drawflush.inl"
  193. #define R_DRAWCOLUMN_PIPELINE RDC_TRANSLUCENT
  194. #define R_DRAWCOLUMN_PIPELINE_BITS 8
  195. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL8
  196. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL8
  197. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL8
  198. #include "r_drawflush.inl"
  199. #define R_DRAWCOLUMN_PIPELINE RDC_FUZZ
  200. #define R_DRAWCOLUMN_PIPELINE_BITS 8
  201. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz8
  202. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz8
  203. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz8
  204. #include "r_drawflush.inl"
  205. #define R_DRAWCOLUMN_PIPELINE RDC_STANDARD
  206. #define R_DRAWCOLUMN_PIPELINE_BITS 15
  207. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole15
  208. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT15
  209. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad15
  210. #include "r_drawflush.inl"
  211. #define R_DRAWCOLUMN_PIPELINE RDC_TRANSLUCENT
  212. #define R_DRAWCOLUMN_PIPELINE_BITS 15
  213. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL15
  214. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL15
  215. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL15
  216. #include "r_drawflush.inl"
  217. #define R_DRAWCOLUMN_PIPELINE RDC_FUZZ
  218. #define R_DRAWCOLUMN_PIPELINE_BITS 15
  219. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz15
  220. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz15
  221. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz15
  222. #include "r_drawflush.inl"
  223. #define R_DRAWCOLUMN_PIPELINE RDC_STANDARD
  224. #define R_DRAWCOLUMN_PIPELINE_BITS 16
  225. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole16
  226. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT16
  227. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad16
  228. #include "r_drawflush.inl"
  229. #define R_DRAWCOLUMN_PIPELINE RDC_TRANSLUCENT
  230. #define R_DRAWCOLUMN_PIPELINE_BITS 16
  231. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL16
  232. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL16
  233. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL16
  234. #include "r_drawflush.inl"
  235. #define R_DRAWCOLUMN_PIPELINE RDC_FUZZ
  236. #define R_DRAWCOLUMN_PIPELINE_BITS 16
  237. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz16
  238. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz16
  239. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz16
  240. #include "r_drawflush.inl"
  241. #define R_DRAWCOLUMN_PIPELINE RDC_STANDARD
  242. #define R_DRAWCOLUMN_PIPELINE_BITS 32
  243. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole32
  244. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT32
  245. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad32
  246. #include "r_drawflush.inl"
  247. #define R_DRAWCOLUMN_PIPELINE RDC_TRANSLUCENT
  248. #define R_DRAWCOLUMN_PIPELINE_BITS 32
  249. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL32
  250. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL32
  251. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL32
  252. #include "r_drawflush.inl"
  253. #define R_DRAWCOLUMN_PIPELINE RDC_FUZZ
  254. #define R_DRAWCOLUMN_PIPELINE_BITS 32
  255. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz32
  256. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz32
  257. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz32
  258. #include "r_drawflush.inl"
  259. //
  260. // R_DrawColumn
  261. //
  262. //
  263. // A column is a vertical slice/span from a wall texture that,
  264. // given the DOOM style restrictions on the view orientation,
  265. // will always have constant z depth.
  266. // Thus a special case loop for very fast rendering can
  267. // be used. It has also been used with Wolfenstein 3D.
  268. //
  269. byte *translationtables;
  270. #define R_DRAWCOLUMN_PIPELINE_TYPE RDC_PIPELINE_STANDARD
  271. #define R_DRAWCOLUMN_PIPELINE_BASE RDC_STANDARD
  272. #define R_DRAWCOLUMN_PIPELINE_BITS 8
  273. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawColumn8 ## postfix
  274. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole8
  275. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT8
  276. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad8
  277. #include "r_drawcolpipeline.inl"
  278. #define R_DRAWCOLUMN_PIPELINE_BITS 15
  279. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawColumn15 ## postfix
  280. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole15
  281. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT15
  282. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad15
  283. #include "r_drawcolpipeline.inl"
  284. #define R_DRAWCOLUMN_PIPELINE_BITS 16
  285. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawColumn16 ## postfix
  286. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole16
  287. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT16
  288. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad16
  289. #include "r_drawcolpipeline.inl"
  290. #define R_DRAWCOLUMN_PIPELINE_BITS 32
  291. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawColumn32 ## postfix
  292. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole32
  293. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT32
  294. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad32
  295. #include "r_drawcolpipeline.inl"
  296. #undef R_DRAWCOLUMN_PIPELINE_BASE
  297. #undef R_DRAWCOLUMN_PIPELINE_TYPE
  298. // Here is the version of R_DrawColumn that deals with translucent // phares
  299. // textures and sprites. It's identical to R_DrawColumn except // |
  300. // for the spot where the color index is stuffed into *dest. At // V
  301. // that point, the existing color index and the new color index
  302. // are mapped through the TRANMAP lump filters to get a new color
  303. // index whose RGB values are the average of the existing and new
  304. // colors.
  305. //
  306. // Since we're concerned about performance, the 'translucent or
  307. // opaque' decision is made outside this routine, not down where the
  308. // actual code differences are.
  309. #define R_DRAWCOLUMN_PIPELINE_TYPE RDC_PIPELINE_TRANSLUCENT
  310. #define R_DRAWCOLUMN_PIPELINE_BASE RDC_TRANSLUCENT
  311. #define R_DRAWCOLUMN_PIPELINE_BITS 8
  312. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTLColumn8 ## postfix
  313. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL8
  314. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL8
  315. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL8
  316. #include "r_drawcolpipeline.inl"
  317. #define R_DRAWCOLUMN_PIPELINE_BITS 15
  318. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTLColumn15 ## postfix
  319. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL15
  320. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL15
  321. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL15
  322. #include "r_drawcolpipeline.inl"
  323. #define R_DRAWCOLUMN_PIPELINE_BITS 16
  324. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTLColumn16 ## postfix
  325. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL16
  326. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL16
  327. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL16
  328. #include "r_drawcolpipeline.inl"
  329. #define R_DRAWCOLUMN_PIPELINE_BITS 32
  330. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTLColumn32 ## postfix
  331. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL32
  332. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL32
  333. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL32
  334. #include "r_drawcolpipeline.inl"
  335. #undef R_DRAWCOLUMN_PIPELINE_BASE
  336. #undef R_DRAWCOLUMN_PIPELINE_TYPE
  337. //
  338. // R_DrawTranslatedColumn
  339. // Used to draw player sprites
  340. // with the green colorramp mapped to others.
  341. // Could be used with different translation
  342. // tables, e.g. the lighter colored version
  343. // of the BaronOfHell, the HellKnight, uses
  344. // identical sprites, kinda brightened up.
  345. //
  346. #define R_DRAWCOLUMN_PIPELINE_TYPE RDC_PIPELINE_TRANSLATED
  347. #define R_DRAWCOLUMN_PIPELINE_BASE RDC_TRANSLATED
  348. #define R_DRAWCOLUMN_PIPELINE_BITS 8
  349. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTranslatedColumn8 ## postfix
  350. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole8
  351. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT8
  352. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad8
  353. #include "r_drawcolpipeline.inl"
  354. #define R_DRAWCOLUMN_PIPELINE_BITS 15
  355. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTranslatedColumn15 ## postfix
  356. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole15
  357. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT15
  358. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad15
  359. #include "r_drawcolpipeline.inl"
  360. #define R_DRAWCOLUMN_PIPELINE_BITS 16
  361. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTranslatedColumn16 ## postfix
  362. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole16
  363. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT16
  364. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad16
  365. #include "r_drawcolpipeline.inl"
  366. #define R_DRAWCOLUMN_PIPELINE_BITS 32
  367. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTranslatedColumn32 ## postfix
  368. #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole32
  369. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT32
  370. #define R_FLUSHQUAD_FUNCNAME R_FlushQuad32
  371. #include "r_drawcolpipeline.inl"
  372. #undef R_DRAWCOLUMN_PIPELINE_BASE
  373. #undef R_DRAWCOLUMN_PIPELINE_TYPE
  374. //
  375. // Framebuffer postprocessing.
  376. // Creates a fuzzy image by copying pixels
  377. // from adjacent ones to left and right.
  378. // Used with an all black colormap, this
  379. // could create the SHADOW effect,
  380. // i.e. spectres and invisible players.
  381. //
  382. #define R_DRAWCOLUMN_PIPELINE_TYPE RDC_PIPELINE_FUZZ
  383. #define R_DRAWCOLUMN_PIPELINE_BASE RDC_FUZZ
  384. #define R_DRAWCOLUMN_PIPELINE_BITS 8
  385. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawFuzzColumn8 ## postfix
  386. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz8
  387. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz8
  388. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz8
  389. #include "r_drawcolpipeline.inl"
  390. #define R_DRAWCOLUMN_PIPELINE_BITS 15
  391. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawFuzzColumn15 ## postfix
  392. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz15
  393. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz15
  394. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz15
  395. #include "r_drawcolpipeline.inl"
  396. #define R_DRAWCOLUMN_PIPELINE_BITS 16
  397. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawFuzzColumn16 ## postfix
  398. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz16
  399. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz16
  400. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz16
  401. #include "r_drawcolpipeline.inl"
  402. #define R_DRAWCOLUMN_PIPELINE_BITS 32
  403. #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawFuzzColumn32 ## postfix
  404. #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz32
  405. #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz32
  406. #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz32
  407. #include "r_drawcolpipeline.inl"
  408. #undef R_DRAWCOLUMN_PIPELINE_BASE
  409. #undef R_DRAWCOLUMN_PIPELINE_TYPE
  410. static R_DrawColumn_f drawcolumnfuncs[VID_MODEMAX][RDRAW_FILTER_MAXFILTERS][RDRAW_FILTER_MAXFILTERS][RDC_PIPELINE_MAXPIPELINES] = {
  411. {
  412. {
  413. {NULL, NULL, NULL, NULL,},
  414. {R_DrawColumn8_PointUV,
  415. R_DrawTLColumn8_PointUV,
  416. R_DrawTranslatedColumn8_PointUV,
  417. R_DrawFuzzColumn8_PointUV,},
  418. {R_DrawColumn8_LinearUV,
  419. R_DrawTLColumn8_LinearUV,
  420. R_DrawTranslatedColumn8_LinearUV,
  421. R_DrawFuzzColumn8_LinearUV,},
  422. {R_DrawColumn8_RoundedUV,
  423. R_DrawTLColumn8_RoundedUV,
  424. R_DrawTranslatedColumn8_RoundedUV,
  425. R_DrawFuzzColumn8_RoundedUV,},
  426. },
  427. {
  428. {NULL, NULL, NULL, NULL,},
  429. {R_DrawColumn8_PointUV_PointZ,
  430. R_DrawTLColumn8_PointUV_PointZ,
  431. R_DrawTranslatedColumn8_PointUV_PointZ,
  432. R_DrawFuzzColumn8_PointUV_PointZ,},
  433. {R_DrawColumn8_LinearUV_PointZ,
  434. R_DrawTLColumn8_LinearUV_PointZ,
  435. R_DrawTranslatedColumn8_LinearUV_PointZ,
  436. R_DrawFuzzColumn8_LinearUV_PointZ,},
  437. {R_DrawColumn8_RoundedUV_PointZ,
  438. R_DrawTLColumn8_RoundedUV_PointZ,
  439. R_DrawTranslatedColumn8_RoundedUV_PointZ,
  440. R_DrawFuzzColumn8_RoundedUV_PointZ,},
  441. },
  442. {
  443. {NULL, NULL, NULL, NULL,},
  444. {R_DrawColumn8_PointUV_LinearZ,
  445. R_DrawTLColumn8_PointUV_LinearZ,
  446. R_DrawTranslatedColumn8_PointUV_LinearZ,
  447. R_DrawFuzzColumn8_PointUV_LinearZ,},
  448. {R_DrawColumn8_LinearUV_LinearZ,
  449. R_DrawTLColumn8_LinearUV_LinearZ,
  450. R_DrawTranslatedColumn8_LinearUV_LinearZ,
  451. R_DrawFuzzColumn8_LinearUV_LinearZ,},
  452. {R_DrawColumn8_RoundedUV_LinearZ,
  453. R_DrawTLColumn8_RoundedUV_LinearZ,
  454. R_DrawTranslatedColumn8_RoundedUV_LinearZ,
  455. R_DrawFuzzColumn8_RoundedUV_LinearZ,},
  456. },
  457. },
  458. {
  459. {
  460. {NULL, NULL, NULL, NULL,},
  461. {R_DrawColumn15_PointUV,
  462. R_DrawTLColumn15_PointUV,
  463. R_DrawTranslatedColumn15_PointUV,
  464. R_DrawFuzzColumn15_PointUV,},
  465. {R_DrawColumn15_LinearUV,
  466. R_DrawTLColumn15_LinearUV,
  467. R_DrawTranslatedColumn15_LinearUV,
  468. R_DrawFuzzColumn15_LinearUV,},
  469. {R_DrawColumn15_RoundedUV,
  470. R_DrawTLColumn15_RoundedUV,
  471. R_DrawTranslatedColumn15_RoundedUV,
  472. R_DrawFuzzColumn15_RoundedUV,},
  473. },
  474. {
  475. {NULL, NULL, NULL, NULL,},
  476. {R_DrawColumn15_PointUV_PointZ,
  477. R_DrawTLColumn15_PointUV_PointZ,
  478. R_DrawTranslatedColumn15_PointUV_PointZ,
  479. R_DrawFuzzColumn15_PointUV_PointZ,},
  480. {R_DrawColumn15_LinearUV_PointZ,
  481. R_DrawTLColumn15_LinearUV_PointZ,
  482. R_DrawTranslatedColumn15_LinearUV_PointZ,
  483. R_DrawFuzzColumn15_LinearUV_PointZ,},
  484. {R_DrawColumn15_RoundedUV_PointZ,
  485. R_DrawTLColumn15_RoundedUV_PointZ,
  486. R_DrawTranslatedColumn15_RoundedUV_PointZ,
  487. R_DrawFuzzColumn15_RoundedUV_PointZ,},
  488. },
  489. {
  490. {NULL, NULL, NULL, NULL,},
  491. {R_DrawColumn15_PointUV_LinearZ,
  492. R_DrawTLColumn15_PointUV_LinearZ,
  493. R_DrawTranslatedColumn15_PointUV_LinearZ,
  494. R_DrawFuzzColumn15_PointUV_LinearZ,},
  495. {R_DrawColumn15_LinearUV_LinearZ,
  496. R_DrawTLColumn15_LinearUV_LinearZ,
  497. R_DrawTranslatedColumn15_LinearUV_LinearZ,
  498. R_DrawFuzzColumn15_LinearUV_LinearZ,},
  499. {R_DrawColumn15_RoundedUV_LinearZ,
  500. R_DrawTLColumn15_RoundedUV_LinearZ,
  501. R_DrawTranslatedColumn15_RoundedUV_LinearZ,
  502. R_DrawFuzzColumn15_RoundedUV_LinearZ,},
  503. },
  504. },
  505. {
  506. {
  507. {NULL, NULL, NULL, NULL,},
  508. {R_DrawColumn16_PointUV,
  509. R_DrawTLColumn16_PointUV,
  510. R_DrawTranslatedColumn16_PointUV,
  511. R_DrawFuzzColumn16_PointUV,},
  512. {R_DrawColumn16_LinearUV,
  513. R_DrawTLColumn16_LinearUV,
  514. R_DrawTranslatedColumn16_LinearUV,
  515. R_DrawFuzzColumn16_LinearUV,},
  516. {R_DrawColumn16_RoundedUV,
  517. R_DrawTLColumn16_RoundedUV,
  518. R_DrawTranslatedColumn16_RoundedUV,
  519. R_DrawFuzzColumn16_RoundedUV,},
  520. },
  521. {
  522. {NULL, NULL, NULL, NULL,},
  523. {R_DrawColumn16_PointUV_PointZ,
  524. R_DrawTLColumn16_PointUV_PointZ,
  525. R_DrawTranslatedColumn16_PointUV_PointZ,
  526. R_DrawFuzzColumn16_PointUV_PointZ,},
  527. {R_DrawColumn16_LinearUV_PointZ,
  528. R_DrawTLColumn16_LinearUV_PointZ,
  529. R_DrawTranslatedColumn16_LinearUV_PointZ,
  530. R_DrawFuzzColumn16_LinearUV_PointZ,},
  531. {R_DrawColumn16_RoundedUV_PointZ,
  532. R_DrawTLColumn16_RoundedUV_PointZ,
  533. R_DrawTranslatedColumn16_RoundedUV_PointZ,
  534. R_DrawFuzzColumn16_RoundedUV_PointZ,},
  535. },
  536. {
  537. {NULL, NULL, NULL, NULL,},
  538. {R_DrawColumn16_PointUV_LinearZ,
  539. R_DrawTLColumn16_PointUV_LinearZ,
  540. R_DrawTranslatedColumn16_PointUV_LinearZ,
  541. R_DrawFuzzColumn16_PointUV_LinearZ,},
  542. {R_DrawColumn16_LinearUV_LinearZ,
  543. R_DrawTLColumn16_LinearUV_LinearZ,
  544. R_DrawTranslatedColumn16_LinearUV_LinearZ,
  545. R_DrawFuzzColumn16_LinearUV_LinearZ,},
  546. {R_DrawColumn16_RoundedUV_LinearZ,
  547. R_DrawTLColumn16_RoundedUV_LinearZ,
  548. R_DrawTranslatedColumn16_RoundedUV_LinearZ,
  549. R_DrawFuzzColumn16_RoundedUV_LinearZ,},
  550. },
  551. },
  552. {
  553. {
  554. {NULL, NULL, NULL, NULL,},
  555. {R_DrawColumn32_PointUV,
  556. R_DrawTLColumn32_PointUV,
  557. R_DrawTranslatedColumn32_PointUV,
  558. R_DrawFuzzColumn32_PointUV,},
  559. {R_DrawColumn32_LinearUV,
  560. R_DrawTLColumn32_LinearUV,
  561. R_DrawTranslatedColumn32_LinearUV,
  562. R_DrawFuzzColumn32_LinearUV,},
  563. {R_DrawColumn32_RoundedUV,
  564. R_DrawTLColumn32_RoundedUV,
  565. R_DrawTranslatedColumn32_RoundedUV,
  566. R_DrawFuzzColumn32_RoundedUV,},
  567. },
  568. {
  569. {NULL, NULL, NULL, NULL,},
  570. {R_DrawColumn32_PointUV_PointZ,
  571. R_DrawTLColumn32_PointUV_PointZ,
  572. R_DrawTranslatedColumn32_PointUV_PointZ,
  573. R_DrawFuzzColumn32_PointUV_PointZ,},
  574. {R_DrawColumn32_LinearUV_PointZ,
  575. R_DrawTLColumn32_LinearUV_PointZ,
  576. R_DrawTranslatedColumn32_LinearUV_PointZ,
  577. R_DrawFuzzColumn32_LinearUV_PointZ,},
  578. {R_DrawColumn32_RoundedUV_PointZ,
  579. R_DrawTLColumn32_RoundedUV_PointZ,
  580. R_DrawTranslatedColumn32_RoundedUV_PointZ,
  581. R_DrawFuzzColumn32_RoundedUV_PointZ,},
  582. },
  583. {
  584. {NULL, NULL, NULL, NULL,},
  585. {R_DrawColumn32_PointUV_LinearZ,
  586. R_DrawTLColumn32_PointUV_LinearZ,
  587. R_DrawTranslatedColumn32_PointUV_LinearZ,
  588. R_DrawFuzzColumn32_PointUV_LinearZ,},
  589. {R_DrawColumn32_LinearUV_LinearZ,
  590. R_DrawTLColumn32_LinearUV_LinearZ,
  591. R_DrawTranslatedColumn32_LinearUV_LinearZ,
  592. R_DrawFuzzColumn32_LinearUV_LinearZ,},
  593. {R_DrawColumn32_RoundedUV_LinearZ,
  594. R_DrawTLColumn32_RoundedUV_LinearZ,
  595. R_DrawTranslatedColumn32_RoundedUV_LinearZ,
  596. R_DrawFuzzColumn32_RoundedUV_LinearZ,},
  597. },
  598. },
  599. };
  600. R_DrawColumn_f R_GetDrawColumnFunc(enum column_pipeline_e type,
  601. enum draw_filter_type_e filter,
  602. enum draw_filter_type_e filterz) {
  603. R_DrawColumn_f result = drawcolumnfuncs[V_GetMode()][filterz][filter][type];
  604. if (result == NULL)
  605. I_Error("R_GetDrawColumnFunc: undefined function (%d, %d, %d)",
  606. type, filter, filterz);
  607. return result;
  608. }
  609. void R_SetDefaultDrawColumnVars(draw_column_vars_t *dcvars) {
  610. dcvars->x = dcvars->yl = dcvars->yh = dcvars->z = 0;
  611. dcvars->iscale = dcvars->texturemid = dcvars->texheight = dcvars->texu = 0;
  612. dcvars->source = dcvars->prevsource = dcvars->nextsource = NULL;
  613. dcvars->colormap = dcvars->nextcolormap = colormaps[0];
  614. dcvars->translation = NULL;
  615. dcvars->edgeslope = dcvars->drawingmasked = 0;
  616. dcvars->edgetype = drawvars.sprite_edges;
  617. }
  618. //
  619. // R_InitTranslationTables
  620. // Creates the translation tables to map
  621. // the green color ramp to gray, brown, red.
  622. // Assumes a given structure of the PLAYPAL.
  623. // Could be read from a lump instead.
  624. //
  625. byte playernumtotrans[MAXPLAYERS];
  626. extern lighttable_t *(*c_zlight)[LIGHTLEVELS][MAXLIGHTZ];
  627. void R_InitTranslationTables (void)
  628. {
  629. int i, j;
  630. #define MAXTRANS 3
  631. byte transtocolour[MAXTRANS];
  632. // killough 5/2/98:
  633. // Remove dependency of colormaps aligned on 256-byte boundary
  634. if (translationtables == NULL) // CPhipps - allow multiple calls
  635. translationtables = Z_Malloc(256*MAXTRANS, PU_STATIC, 0);
  636. for (i=0; i<MAXTRANS; i++) transtocolour[i] = 255;
  637. for (i=0; i<MAXPLAYERS; i++) {
  638. byte wantcolour = mapcolor_plyr[i];
  639. playernumtotrans[i] = 0;
  640. if (wantcolour != 0x70) // Not green, would like translation
  641. for (j=0; j<MAXTRANS; j++)
  642. if (transtocolour[j] == 255) {
  643. transtocolour[j] = wantcolour; playernumtotrans[i] = j+1; break;
  644. }
  645. }
  646. // translate just the 16 green colors
  647. for (i=0; i<256; i++)
  648. if (i >= 0x70 && i<= 0x7f)
  649. {
  650. // CPhipps - configurable player colours
  651. translationtables[i] = colormaps[0][((i&0xf)<<9) + transtocolour[0]];
  652. translationtables[i+256] = colormaps[0][((i&0xf)<<9) + transtocolour[1]];
  653. translationtables[i+512] = colormaps[0][((i&0xf)<<9) + transtocolour[2]];
  654. }
  655. else // Keep all other colors as is.
  656. translationtables[i]=translationtables[i+256]=translationtables[i+512]=i;
  657. }
  658. //
  659. // R_DrawSpan
  660. // With DOOM style restrictions on view orientation,
  661. // the floors and ceilings consist of horizontal slices
  662. // or spans with constant z depth.
  663. // However, rotation around the world z axis is possible,
  664. // thus this mapping, while simpler and faster than
  665. // perspective correct texture mapping, has to traverse
  666. // the texture at an angle in all but a few cases.
  667. // In consequence, flats are not stored by column (like walls),
  668. // and the inner loop has to step in texture space u and v.
  669. //
  670. #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_PointUV_PointZ
  671. #define R_DRAWSPAN_PIPELINE_BITS 8
  672. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD)
  673. #include "r_drawspan.inl"
  674. #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_PointUV_LinearZ
  675. #define R_DRAWSPAN_PIPELINE_BITS 8
  676. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_DITHERZ)
  677. #include "r_drawspan.inl"
  678. #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_LinearUV_PointZ
  679. #define R_DRAWSPAN_PIPELINE_BITS 8
  680. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR)
  681. #include "r_drawspan.inl"
  682. #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_LinearUV_LinearZ
  683. #define R_DRAWSPAN_PIPELINE_BITS 8
  684. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR | RDC_DITHERZ)
  685. #include "r_drawspan.inl"
  686. #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_RoundedUV_PointZ
  687. #define R_DRAWSPAN_PIPELINE_BITS 8
  688. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED)
  689. #include "r_drawspan.inl"
  690. #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_RoundedUV_LinearZ
  691. #define R_DRAWSPAN_PIPELINE_BITS 8
  692. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED | RDC_DITHERZ)
  693. #include "r_drawspan.inl"
  694. #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_PointUV_PointZ
  695. #define R_DRAWSPAN_PIPELINE_BITS 15
  696. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD)
  697. #include "r_drawspan.inl"
  698. #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_PointUV_LinearZ
  699. #define R_DRAWSPAN_PIPELINE_BITS 15
  700. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_DITHERZ)
  701. #include "r_drawspan.inl"
  702. #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_LinearUV_PointZ
  703. #define R_DRAWSPAN_PIPELINE_BITS 15
  704. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR)
  705. #include "r_drawspan.inl"
  706. #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_LinearUV_LinearZ
  707. #define R_DRAWSPAN_PIPELINE_BITS 15
  708. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR | RDC_DITHERZ)
  709. #include "r_drawspan.inl"
  710. #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_RoundedUV_PointZ
  711. #define R_DRAWSPAN_PIPELINE_BITS 15
  712. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED)
  713. #include "r_drawspan.inl"
  714. #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_RoundedUV_LinearZ
  715. #define R_DRAWSPAN_PIPELINE_BITS 15
  716. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED | RDC_DITHERZ)
  717. #include "r_drawspan.inl"
  718. #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_PointUV_PointZ
  719. #define R_DRAWSPAN_PIPELINE_BITS 16
  720. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD)
  721. #include "r_drawspan.inl"
  722. #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_PointUV_LinearZ
  723. #define R_DRAWSPAN_PIPELINE_BITS 16
  724. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_DITHERZ)
  725. #include "r_drawspan.inl"
  726. #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_LinearUV_PointZ
  727. #define R_DRAWSPAN_PIPELINE_BITS 16
  728. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR)
  729. #include "r_drawspan.inl"
  730. #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_LinearUV_LinearZ
  731. #define R_DRAWSPAN_PIPELINE_BITS 16
  732. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR | RDC_DITHERZ)
  733. #include "r_drawspan.inl"
  734. #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_RoundedUV_PointZ
  735. #define R_DRAWSPAN_PIPELINE_BITS 16
  736. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED)
  737. #include "r_drawspan.inl"
  738. #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_RoundedUV_LinearZ
  739. #define R_DRAWSPAN_PIPELINE_BITS 16
  740. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED | RDC_DITHERZ)
  741. #include "r_drawspan.inl"
  742. #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_PointUV_PointZ
  743. #define R_DRAWSPAN_PIPELINE_BITS 32
  744. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD)
  745. #include "r_drawspan.inl"
  746. #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_PointUV_LinearZ
  747. #define R_DRAWSPAN_PIPELINE_BITS 32
  748. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_DITHERZ)
  749. #include "r_drawspan.inl"
  750. #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_LinearUV_PointZ
  751. #define R_DRAWSPAN_PIPELINE_BITS 32
  752. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR)
  753. #include "r_drawspan.inl"
  754. #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_LinearUV_LinearZ
  755. #define R_DRAWSPAN_PIPELINE_BITS 32
  756. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR | RDC_DITHERZ)
  757. #include "r_drawspan.inl"
  758. #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_RoundedUV_PointZ
  759. #define R_DRAWSPAN_PIPELINE_BITS 32
  760. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED)
  761. #include "r_drawspan.inl"
  762. #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_RoundedUV_LinearZ
  763. #define R_DRAWSPAN_PIPELINE_BITS 32
  764. #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED | RDC_DITHERZ)
  765. #include "r_drawspan.inl"
  766. static R_DrawSpan_f drawspanfuncs[VID_MODEMAX][RDRAW_FILTER_MAXFILTERS][RDRAW_FILTER_MAXFILTERS] = {
  767. {
  768. {
  769. NULL,
  770. NULL,
  771. NULL,
  772. NULL,
  773. },
  774. {
  775. NULL,
  776. R_DrawSpan8_PointUV_PointZ,
  777. R_DrawSpan8_LinearUV_PointZ,
  778. R_DrawSpan8_RoundedUV_PointZ,
  779. },
  780. {
  781. NULL,
  782. R_DrawSpan8_PointUV_LinearZ,
  783. R_DrawSpan8_LinearUV_LinearZ,
  784. R_DrawSpan8_RoundedUV_LinearZ,
  785. },
  786. {
  787. NULL,
  788. NULL,
  789. NULL,
  790. NULL,
  791. },
  792. },
  793. {
  794. {
  795. NULL,
  796. NULL,
  797. NULL,
  798. NULL,
  799. },
  800. {
  801. NULL,
  802. R_DrawSpan15_PointUV_PointZ,
  803. R_DrawSpan15_LinearUV_PointZ,
  804. R_DrawSpan15_RoundedUV_PointZ,
  805. },
  806. {
  807. NULL,
  808. R_DrawSpan15_PointUV_LinearZ,
  809. R_DrawSpan15_LinearUV_LinearZ,
  810. R_DrawSpan15_RoundedUV_LinearZ,
  811. },
  812. {
  813. NULL,
  814. NULL,
  815. NULL,
  816. NULL,
  817. },
  818. },
  819. {
  820. {
  821. NULL,
  822. NULL,
  823. NULL,
  824. NULL,
  825. },
  826. {
  827. NULL,
  828. R_DrawSpan16_PointUV_PointZ,
  829. R_DrawSpan16_LinearUV_PointZ,
  830. R_DrawSpan16_RoundedUV_PointZ,
  831. },
  832. {
  833. NULL,
  834. R_DrawSpan16_PointUV_LinearZ,
  835. R_DrawSpan16_LinearUV_LinearZ,
  836. R_DrawSpan16_RoundedUV_LinearZ,
  837. },
  838. {
  839. NULL,
  840. NULL,
  841. NULL,
  842. NULL,
  843. },
  844. },
  845. {
  846. {
  847. NULL,
  848. NULL,
  849. NULL,
  850. NULL,
  851. },
  852. {
  853. NULL,
  854. R_DrawSpan32_PointUV_PointZ,
  855. R_DrawSpan32_LinearUV_PointZ,
  856. R_DrawSpan32_RoundedUV_PointZ,
  857. },
  858. {
  859. NULL,
  860. R_DrawSpan32_PointUV_LinearZ,
  861. R_DrawSpan32_LinearUV_LinearZ,
  862. R_DrawSpan32_RoundedUV_LinearZ,
  863. },
  864. {
  865. NULL,
  866. NULL,
  867. NULL,
  868. NULL,
  869. },
  870. },
  871. };
  872. R_DrawSpan_f R_GetDrawSpanFunc(enum draw_filter_type_e filter,
  873. enum draw_filter_type_e filterz) {
  874. R_DrawSpan_f result = drawspanfuncs[V_GetMode()][filterz][filter];
  875. if (result == NULL)
  876. I_Error("R_GetDrawSpanFunc: undefined function (%d, %d)",
  877. filter, filterz);
  878. return result;
  879. }
  880. void R_DrawSpan(draw_span_vars_t *dsvars) {
  881. R_GetDrawSpanFunc(drawvars.filterfloor, drawvars.filterz)(dsvars);
  882. }
  883. //
  884. // R_InitBuffer
  885. // Creats lookup tables that avoid
  886. // multiplies and other hazzles
  887. // for getting the framebuffer address
  888. // of a pixel to draw.
  889. //
  890. void R_InitBuffer(int width, int height)
  891. {
  892. int i=0;
  893. // Handle resize,
  894. // e.g. smaller view windows
  895. // with border and/or status bar.
  896. viewwindowx = (SCREENWIDTH-width) >> 1;
  897. // Same with base row offset.
  898. viewwindowy = width==SCREENWIDTH ? 0 : (SCREENHEIGHT-(ST_SCALED_HEIGHT-1)-height)>>1;
  899. drawvars.byte_topleft = screens[0].data + viewwindowy*screens[0].byte_pitch + viewwindowx;
  900. drawvars.short_topleft = (unsigned short *)(screens[0].data) + viewwindowy*screens[0].short_pitch + viewwindowx;
  901. drawvars.int_topleft = (unsigned int *)(screens[0].data) + viewwindowy*screens[0].int_pitch + viewwindowx;
  902. drawvars.byte_pitch = screens[0].byte_pitch;
  903. drawvars.short_pitch = screens[0].short_pitch;
  904. drawvars.int_pitch = screens[0].int_pitch;
  905. if (V_GetMode() == VID_MODE8) {
  906. for (i=0; i<FUZZTABLE; i++)
  907. fuzzoffset[i] = fuzzoffset_org[i]*screens[0].byte_pitch;
  908. } else if ((V_GetMode() == VID_MODE15) || (V_GetMode() == VID_MODE16)) {
  909. for (i=0; i<FUZZTABLE; i++)
  910. fuzzoffset[i] = fuzzoffset_org[i]*screens[0].short_pitch;
  911. } else if (V_GetMode() == VID_MODE32) {
  912. for (i=0; i<FUZZTABLE; i++)
  913. fuzzoffset[i] = fuzzoffset_org[i]*screens[0].int_pitch;
  914. }
  915. }
  916. //
  917. // R_FillBackScreen
  918. // Fills the back screen with a pattern
  919. // for variable screen sizes
  920. // Also draws a beveled edge.
  921. //
  922. // CPhipps - patch drawing updated
  923. void R_FillBackScreen (void)
  924. {
  925. int x,y;
  926. if (scaledviewwidth == SCREENWIDTH)
  927. return;
  928. V_DrawBackground(gamemode == commercial ? "GRNROCK" : "FLOOR7_2", 1);
  929. for (x=0; x<scaledviewwidth; x+=8)
  930. V_DrawNamePatch(viewwindowx+x,viewwindowy-8,1,"brdr_t", CR_DEFAULT, VPT_NONE);
  931. for (x=0; x<scaledviewwidth; x+=8)
  932. V_DrawNamePatch(viewwindowx+x,viewwindowy+viewheight,1,"brdr_b", CR_DEFAULT, VPT_NONE);
  933. for (y=0; y<viewheight; y+=8)
  934. V_DrawNamePatch(viewwindowx-8,viewwindowy+y,1,"brdr_l", CR_DEFAULT, VPT_NONE);
  935. for (y=0; y<viewheight; y+=8)
  936. V_DrawNamePatch(viewwindowx+scaledviewwidth,viewwindowy+y,1,"brdr_r", CR_DEFAULT, VPT_NONE);
  937. // Draw beveled edge.
  938. V_DrawNamePatch(viewwindowx-8,viewwindowy-8,1,"brdr_tl", CR_DEFAULT, VPT_NONE);
  939. V_DrawNamePatch(viewwindowx+scaledviewwidth,viewwindowy-8,1,"brdr_tr", CR_DEFAULT, VPT_NONE);
  940. V_DrawNamePatch(viewwindowx-8,viewwindowy+viewheight,1,"brdr_bl", CR_DEFAULT, VPT_NONE);
  941. V_DrawNamePatch(viewwindowx+scaledviewwidth,viewwindowy+viewheight,1,"brdr_br", CR_DEFAULT, VPT_NONE);
  942. }
  943. //
  944. // Copy a screen buffer.
  945. //
  946. void R_VideoErase(int x, int y, int count)
  947. {
  948. if (V_GetMode() != VID_MODEGL)
  949. memcpy(screens[0].data+y*screens[0].byte_pitch+x*V_GetPixelDepth(),
  950. screens[1].data+y*screens[1].byte_pitch+x*V_GetPixelDepth(),
  951. count*V_GetPixelDepth()); // LFB copy.
  952. }
  953. //
  954. // R_DrawViewBorder
  955. // Draws the border around the view
  956. // for different size windows?
  957. //
  958. void R_DrawViewBorder(void)
  959. {
  960. int top, side, i;
  961. if (V_GetMode() == VID_MODEGL) {
  962. // proff 11/99: we don't have a backscreen in OpenGL from where we can copy this
  963. R_FillBackScreen();
  964. return;
  965. }
  966. if ((SCREENHEIGHT != viewheight) ||
  967. ((automapmode & am_active) && ! (automapmode & am_overlay)))
  968. {
  969. // erase left and right of statusbar
  970. side= ( SCREENWIDTH - ST_SCALED_WIDTH ) / 2;
  971. if (side > 0) {
  972. for (i = (SCREENHEIGHT - ST_SCALED_HEIGHT); i < SCREENHEIGHT; i++)
  973. {
  974. R_VideoErase (0, i, side);
  975. R_VideoErase (ST_SCALED_WIDTH+side, i, side);
  976. }
  977. }
  978. }
  979. if ( viewheight >= ( SCREENHEIGHT - ST_SCALED_HEIGHT ))
  980. return; // if high-res, don´t go any further!
  981. top = ((SCREENHEIGHT-ST_SCALED_HEIGHT)-viewheight)/2;
  982. side = (SCREENWIDTH-scaledviewwidth)/2;
  983. // copy top
  984. for (i = 0; i < top; i++)
  985. R_VideoErase (0, i, SCREENWIDTH);
  986. // copy sides
  987. for (i = top; i < (top+viewheight); i++) {
  988. R_VideoErase (0, i, side);
  989. R_VideoErase (viewwidth+side, i, side);
  990. }
  991. // copy bottom
  992. for (i = top+viewheight; i < (SCREENHEIGHT - ST_SCALED_HEIGHT); i++)
  993. R_VideoErase (0, i, SCREENWIDTH);
  994. }