1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985
|
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// $Id: r_draw8.c,v 1.20 2001/08/06 23:57:09 stroggonmeth Exp $
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// $Log: r_draw8.c,v $
// Revision 1.20 2001/08/06 23:57:09 stroggonmeth
// Removed portal code, improved 3D floors in hardware mode.
//
// Revision 1.19 2001/04/02 18:54:32 bpereira
// no message
//
// Revision 1.18 2001/04/01 17:35:07 bpereira
// no message
//
// Revision 1.17 2001/03/21 18:24:39 stroggonmeth
// Misc changes and fixes. Code cleanup
//
// Revision 1.16 2001/03/13 22:14:20 stroggonmeth
// Long time no commit. 3D floors, FraggleScript, portals, ect.
//
// Revision 1.15 2001/01/25 22:15:44 bpereira
// added heretic support
//
// Revision 1.14 2000/11/21 21:13:18 stroggonmeth
// Optimised 3D floors and fixed crashing bug in high resolutions.
//
// Revision 1.13 2000/11/06 20:52:16 bpereira
// no message
//
// Revision 1.12 2000/11/02 17:50:09 stroggonmeth
// Big 3Dfloors & FraggleScript commit!!
//
// Revision 1.11 2000/09/28 20:57:17 bpereira
// no message
//
// Revision 1.10 2000/04/30 10:30:10 bpereira
// no message
//
// Revision 1.9 2000/04/24 20:24:38 bpereira
// no message
//
// Revision 1.8 2000/04/18 17:39:39 stroggonmeth
// Bug fixes and performance tuning.
//
// Revision 1.7 2000/04/08 17:29:25 stroggonmeth
// no message
//
// Revision 1.6 2000/04/06 21:06:19 stroggonmeth
// Optimized extra_colormap code...
// Added #ifdefs for older water code.
//
// Revision 1.5 2000/04/05 15:47:46 stroggonmeth
// Added hack for Dehacked lumps. Transparent sprites are now affected by colormaps.
//
// Revision 1.4 2000/04/04 19:28:43 stroggonmeth
// Global colormaps working. Added a new linedef type 272.
//
// Revision 1.3 2000/04/04 00:32:47 stroggonmeth
// Initial Boom compatability plus few misc changes all around.
//
// Revision 1.2 2000/02/27 00:42:10 hurdler
// fix CR+LF problem
//
// Revision 1.1.1.1 2000/02/22 20:32:32 hurdler
// Initial import into CVS (v1.29 pr3)
//
//
// DESCRIPTION:
// 8bpp span/column drawer functions
//
// NOTE: no includes because this is included as part of r_draw.c
//
//-----------------------------------------------------------------------------
// ==========================================================================
// COLUMNS
// ==========================================================================
// A column is a vertical slice/span of a wall texture that uses
// a has a constant z depth from top to bottom.
//
#define USEBOOMFUNC
#ifndef USEASM
#ifndef USEBOOMFUNC
void R_DrawColumn_8 (void)
{
register int count;
register byte* dest;
register fixed_t frac;
register fixed_t fracstep;
count = dc_yh - dc_yl + 1;
// Zero length, column does not exceed a pixel.
if (count <= 0)
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);
#endif
// Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth.
// Use columnofs LUT for subwindows?
dest = ylookup[dc_yl] + columnofs[dc_x];
// Determine scaling,
// which is the only mapping to be done.
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl-centery)*fracstep;
// Inner loop that does the actual texture mapping,
// e.g. a DDA-lile scaling.
// This is as fast as it gets.
do
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
*dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]];
dest += vid.width;
frac += fracstep;
} while (--count);
}
#else //USEBOOMFUNC
// SoM: Experiment to make software go faster. Taken from the Boom source
void R_DrawColumn_8 (void)
{
int count, ccount;
register byte *dest;
register fixed_t frac;
fixed_t fracstep;
count = dc_yh - dc_yl + 1;
if (count <= 0) // Zero length, column does not exceed a pixel.
return;
ccount = count;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);
#endif
// Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth.
// Use columnofs LUT for subwindows?
dest = ylookup[dc_yl] + columnofs[dc_x];
// Determine scaling, which is the only mapping to be done.
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl-centery)*fracstep;
// Inner loop that does the actual texture mapping,
// e.g. a DDA-lile scaling.
// This is as fast as it gets.
{
register const byte *source = dc_source;
register const lighttable_t *colormap = dc_colormap;
register int heightmask = dc_texheight-1;
if (dc_texheight & heightmask)
{
heightmask++;
heightmask <<= FRACBITS;
if (frac < 0)
while ((frac += heightmask) < 0);
else
while (frac >= heightmask)
frac -= heightmask;
do
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix -- killough
*dest = colormap[source[frac>>FRACBITS]];
dest += vid.width;
if ((frac += fracstep) >= heightmask)
frac -= heightmask;
}
while (--count);
}
else
{
while ((count-=2)>=0) // texture height is a power of 2 -- killough
{
*dest = colormap[source[(frac>>FRACBITS) & heightmask]];
dest += vid.width;
frac += fracstep;
*dest = colormap[source[(frac>>FRACBITS) & heightmask]];
dest += vid.width;
frac += fracstep;
}
if (count & 1)
*dest = colormap[source[(frac>>FRACBITS) & heightmask]];
}
}
}
#endif //USEBOOMFUNC
#endif
#ifndef USEASM
#ifndef USEBOOMFUNC
void R_DrawSkyColumn_8 (void)
{
register int count;
register byte* dest;
register fixed_t frac;
register fixed_t fracstep;
count = dc_yh - dc_yl;
// Zero length, column does not exceed a pixel.
if (count < 0)
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);
#endif
// Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth.
// Use columnofs LUT for subwindows?
dest = ylookup[dc_yl] + columnofs[dc_x];
// Determine scaling,
// which is the only mapping to be done.
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl-centery)*fracstep;
// Inner loop that does the actual texture mapping,
// e.g. a DDA-lile scaling.
// This is as fast as it gets.
do
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
*dest = dc_colormap[dc_source[(frac>>FRACBITS)&255]];
dest += vid.width;
frac += fracstep;
} while (count--);
}
#else
void R_DrawSkyColumn_8 (void)
{
int count;
register byte *dest;
register fixed_t frac;
fixed_t fracstep;
count = dc_yh - dc_yl + 1;
if (count <= 0) // Zero length, column does not exceed a pixel.
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);
#endif
// Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth.
// Use columnofs LUT for subwindows?
dest = ylookup[dc_yl] + columnofs[dc_x];
// Determine scaling, which is the only mapping to be done.
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl-centery)*fracstep;
// Inner loop that does the actual texture mapping,
// e.g. a DDA-lile scaling.
// This is as fast as it gets.
{
register const byte *source = dc_source;
register const lighttable_t *colormap = dc_colormap;
register int heightmask = 255;
if (dc_texheight & heightmask)
{
heightmask++;
heightmask <<= FRACBITS;
if (frac < 0)
while ((frac += heightmask) < 0);
else
while (frac >= heightmask)
frac -= heightmask;
do
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix -- killough
*dest = colormap[source[frac>>FRACBITS]];
dest += vid.width;
if ((frac += fracstep) >= heightmask)
frac -= heightmask;
}
while (--count);
}
else
{
while ((count-=2)>=0) // texture height is a power of 2 -- killough
{
*dest = colormap[source[(frac>>FRACBITS) & heightmask]];
dest += vid.width;
frac += fracstep;
*dest = colormap[source[(frac>>FRACBITS) & heightmask]];
dest += vid.width;
frac += fracstep;
}
if (count & 1)
*dest = colormap[source[(frac>>FRACBITS) & heightmask]];
}
}
}
#endif // USEBOOMFUNC
#endif
// The standard Doom 'fuzzy' (blur, shadow) effect
// originally used for spectres and when picking up the blur sphere
//
//#ifndef USEASM // NOT IN ASSEMBLER, TO DO.. IF WORTH IT
void R_DrawFuzzColumn_8 (void)
{
register int count;
register byte* dest;
register fixed_t frac;
register fixed_t fracstep;
// Adjust borders. Low...
if (!dc_yl)
dc_yl = 1;
// .. and high.
if (dc_yh == viewheight-1)
dc_yh = viewheight - 2;
count = dc_yh - dc_yl;
// Zero length.
if (count < 0)
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0 || dc_yh >= vid.height)
{
I_Error ("R_DrawFuzzColumn: %i to %i at %i",
dc_yl, dc_yh, dc_x);
}
#endif
// Does not work with blocky mode.
dest = ylookup[dc_yl] + columnofs[dc_x];
// Looks familiar.
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl-centery)*fracstep;
do
{
// Lookup framebuffer, and retrieve
// a pixel that is either one column
// left or right of the current one.
// Add index from colormap to index.
*dest = colormaps[6*256+dest[fuzzoffset[fuzzpos]]];
// Clamp table lookup index.
if (++fuzzpos == FUZZTABLE)
fuzzpos = 0;
dest += vid.width;
frac += fracstep;
} while (count--);
}
//#endif
#ifndef USEASM
// used in tiltview, but never called for now, but who know...
void R_DrawSpanNoWrap (void)
{}
#endif
#ifndef USEASM
void R_DrawShadeColumn_8 (void)
{
register int count;
register byte* dest;
register fixed_t frac;
register fixed_t fracstep;
// check out coords for src*
if((dc_yl<0)||(dc_x>=vid.width))
return;
count = dc_yh - dc_yl;
if (count < 0)
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
{
I_Error ( "R_DrawColumn: %i to %i at %i",
dc_yl, dc_yh, dc_x);
}
#endif
// FIXME. As above.
//src = ylookup[dc_yl] + columnofs[dc_x+2];
dest = ylookup[dc_yl] + columnofs[dc_x];
// Looks familiar.
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl-centery)*fracstep;
// Here we do an additional index re-mapping.
do
{
*dest = *( colormaps + (dc_source[frac>>FRACBITS] <<8) + (*dest) );
dest += vid.width;
frac += fracstep;
} while (count--);
}
#endif
//
// I've made an asm routine for the transparency, because it slows down
// a lot in 640x480 with big sprites (bfg on all screen, or transparent
// walls on fullscreen)
//
#ifndef USEASM
#ifndef USEBOOMFUNC
void R_DrawTranslucentColumn_8 (void)
{
register int count;
register byte* dest;
register fixed_t frac;
register fixed_t fracstep;
// check out coords for src*
if((dc_yl<0)||(dc_x>=vid.width))
return;
count = dc_yh - dc_yl;
if (count < 0)
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
{
I_Error ( "R_DrawColumn: %i to %i at %i",
dc_yl, dc_yh, dc_x);
}
#endif
// FIXME. As above.
//src = ylookup[dc_yl] + columnofs[dc_x+2];
dest = ylookup[dc_yl] + columnofs[dc_x];
// Looks familiar.
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl-centery)*fracstep;
// Here we do an additional index re-mapping.
do
{
*dest = dc_colormap[*( dc_transmap + (dc_source[frac>>FRACBITS] <<8) + (*dest) )];
dest += vid.width;
frac += fracstep;
} while (count--);
}
#else
void R_DrawTranslucentColumn_8 (void)
{
register int count;
register byte *dest;
register fixed_t frac;
register fixed_t fracstep;
count = dc_yh - dc_yl + 1;
if (count <= 0) // Zero length, column does not exceed a pixel.
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);
#endif
// Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth.
// Use columnofs LUT for subwindows?
dest = ylookup[dc_yl] + columnofs[dc_x];
// Determine scaling, which is the only mapping to be done.
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl-centery)*fracstep;
// Inner loop that does the actual texture mapping,
// e.g. a DDA-lile scaling.
// This is as fast as it gets.
{
register const byte *source = dc_source;
//register const lighttable_t *colormap = dc_colormap;
register int heightmask = dc_texheight-1;
if (dc_texheight & heightmask)
{
heightmask++;
heightmask <<= FRACBITS;
if (frac < 0)
while ((frac += heightmask) < 0);
else
while (frac >= heightmask)
frac -= heightmask;
do
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix -- killough
*dest = dc_colormap[*( dc_transmap + (source[frac>>FRACBITS] <<8) + (*dest) )];
dest += vid.width;
if ((frac += fracstep) >= heightmask)
frac -= heightmask;
}
while (--count);
}
else
{
while ((count-=2)>=0) // texture height is a power of 2 -- killough
{
*dest = dc_colormap[*( dc_transmap + (source[frac>>FRACBITS] <<8) + (*dest) )];
dest += vid.width;
frac += fracstep;
*dest = dc_colormap[*( dc_transmap + (source[frac>>FRACBITS] <<8) + (*dest) )];
dest += vid.width;
frac += fracstep;
}
if (count & 1)
*dest = dc_colormap[*( dc_transmap + (source[frac>>FRACBITS] <<8) + (*dest) )];
}
}
}
#endif // USEBOOMFUNC
#endif
//
// Draw columns upto 128high but remap the green ramp to other colors
//
//#ifndef USEASM // STILL NOT IN ASM, TO DO..
void R_DrawTranslatedColumn_8 (void)
{
register int count;
register byte* dest;
register fixed_t frac;
register fixed_t fracstep;
count = dc_yh - dc_yl;
if (count < 0)
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
{
I_Error ( "R_DrawColumn: %i to %i at %i",
dc_yl, dc_yh, dc_x);
}
#endif
// FIXME. As above.
dest = ylookup[dc_yl] + columnofs[dc_x];
// Looks familiar.
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl-centery)*fracstep;
// Here we do an additional index re-mapping.
do
{
// Translation tables are used
// to map certain colorramps to other ones,
// used with PLAY sprites.
// Thus the "green" ramp of the player 0 sprite
// is mapped to gray, red, black/indigo.
*dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]];
dest += vid.width;
frac += fracstep;
} while (count--);
}
//#endif
// ==========================================================================
// SPANS
// ==========================================================================
// Draws the actual span.
//
#ifndef USEASM
#ifndef USEBOOMFUNC
void R_DrawSpan_8 (void)
{
register ULONG xfrac;
register ULONG yfrac;
register byte* dest;
register int count;
#ifdef RANGECHECK
if (ds_x2 < ds_x1
|| ds_x1<0
|| ds_x2>=vid.width
|| (unsigned)ds_y>vid.height)
{
I_Error( "R_DrawSpan: %i to %i at %i",
ds_x1,ds_x2,ds_y);
}
#endif
xfrac = ds_xfrac&0x3fFFff;
yfrac = ds_yfrac;
dest = ylookup[ds_y] + columnofs[ds_x1];
// We do not check for zero spans here?
count = ds_x2 - ds_x1;
do
{
// Lookup pixel from flat texture tile,
// re-index using light/colormap.
*dest++ = ds_colormap[ds_source[((yfrac>>(16-6))&(0x3f<<6)) | (xfrac>>16)]];
// Next step in u,v.
xfrac += ds_xstep;
yfrac += ds_ystep;
xfrac &= 0x3fFFff;
} while (count--);
}
#else
void R_DrawSpan_8 (void)
{
register unsigned position;
unsigned step;
byte *source;
byte *colormap;
byte *dest;
unsigned count;
unsigned spot;
unsigned xtemp;
unsigned ytemp;
position = ((ds_xfrac<<10)&0xffff0000) | ((ds_yfrac>>6)&0xffff);
step = ((ds_xstep<<10)&0xffff0000) | ((ds_ystep>>6)&0xffff);
source = ds_source;
colormap = ds_colormap;
dest = ylookup[ds_y] + columnofs[ds_x1];
count = ds_x2 - ds_x1 + 1;
while (count >= 4)
{
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
dest[0] = colormap[source[spot]];
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
dest[1] = colormap[source[spot]];
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
dest[2] = colormap[source[spot]];
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
dest[3] = colormap[source[spot]];
dest += 4;
count -= 4;
}
while (count)
{
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
*dest++ = colormap[source[spot]];
count--;
}
}
#endif // USEBOOMFUNC
#endif
void R_DrawTranslucentSpan_8 (void)
{
register unsigned position;
unsigned step;
byte *source;
byte *colormap;
byte *transmap;
byte *dest;
unsigned count;
unsigned spot;
unsigned xtemp;
unsigned ytemp;
position = ((ds_xfrac<<10)&0xffff0000) | ((ds_yfrac>>6)&0xffff);
step = ((ds_xstep<<10)&0xffff0000) | ((ds_ystep>>6)&0xffff);
source = ds_source;
colormap = ds_colormap;
transmap = ds_transmap;
dest = ylookup[ds_y] + columnofs[ds_x1];
count = ds_x2 - ds_x1 + 1;
while (count >= 4)
{
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
dest[0] = colormap[*(transmap + (source[spot] << 8) + (dest[0]))];
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
dest[1] = colormap[*(transmap + (source[spot] << 8) + (dest[1]))];
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
dest[2] = colormap[*(transmap + (source[spot] << 8) + (dest[2]))];
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
dest[3] = colormap[*(transmap + (source[spot] << 8) + (dest[3]))];
dest += 4;
count -= 4;
}
while (count--)
{
ytemp = position>>4;
ytemp = ytemp & 4032;
xtemp = position>>26;
spot = xtemp | ytemp;
position += step;
*dest++ = colormap[*(transmap + (source[spot] << 8) + (*dest))];
//count--;
}
}
void R_DrawFogSpan_8 (void)
{
byte *colormap;
byte *transmap;
byte *dest;
unsigned count;
colormap = ds_colormap;
transmap = ds_transmap;
dest = ylookup[ds_y] + columnofs[ds_x1];
count = ds_x2 - ds_x1 + 1;
while (count >= 4)
{
dest[0] = colormap[dest[0]];
dest[1] = colormap[dest[1]];
dest[2] = colormap[dest[2]];
dest[3] = colormap[dest[3]];
dest += 4;
count -= 4;
}
while (count--)
*dest++ = colormap[*dest];
}
//SoM: Fog wall.
void R_DrawFogColumn_8 (void)
{
int count;
byte* dest;
count = dc_yh - dc_yl;
// Zero length, column does not exceed a pixel.
if (count < 0)
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);
#endif
// Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth.
// Use columnofs LUT for subwindows?
dest = ylookup[dc_yl] + columnofs[dc_x];
// Determine scaling,
// which is the only mapping to be done.
do
{
//Simple. Apply the colormap to what's allready on the screen.
*dest = dc_colormap[*dest];
dest += vid.width;
} while (count--);
}
// SoM: This is for 3D floors that cast shadows on walls.
// This function just cuts the column up into sections and calls
// R_DrawColumn_8
void R_DrawColumnShadowed_8 (void)
{
int count;
int realyh, realyl;
int i;
int height, bheight = 0;
int solid = 0;
realyh = dc_yh;
realyl = dc_yl;
count = dc_yh - dc_yl;
// Zero length, column does not exceed a pixel.
if (count < 0)
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= vid.width
|| dc_yl < 0
|| dc_yh >= vid.height)
I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);
#endif
// SoM: This runs through the lightlist from top to bottom and cuts up
// the column accordingly.
for(i = 0; i < dc_numlights; i++)
{
// If the height of the light is above the column, get the colormap
// anyway because the lighting of the top should be effected.
solid = dc_lightlist[i].flags & FF_CUTSOLIDS;
height = dc_lightlist[i].height >> 16;
if(solid)
bheight = dc_lightlist[i].botheight >> 16;
if(height <= dc_yl)
{
dc_colormap = dc_lightlist[i].rcolormap;
if(solid && dc_yl < bheight)
dc_yl = bheight;
continue;
}
// Found a break in the column!
dc_yh = height;
if(dc_yh > realyh)
dc_yh = realyh;
R_DrawColumn_8();
if(solid)
dc_yl = bheight;
else
dc_yl = dc_yh + 1;
dc_colormap = dc_lightlist[i].rcolormap;
}
dc_yh = realyh;
if(dc_yl <= realyh)
R_DrawColumn_8();
}
|