KEYFBUFF.ASM (131275B)
1 ; 2 ; Copyright 2020 Electronic Arts Inc. 3 ; 4 ; TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 ; software: you can redistribute it and/or modify it under the terms of 6 ; the GNU General Public License as published by the Free Software Foundation, 7 ; either version 3 of the License, or (at your option) any later version. 8 9 ; TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 ; in the hope that it will be useful, but with permitted additional restrictions 11 ; under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 ; distributed with this program. You should have received a copy of the 13 ; GNU General Public License along with permitted additional restrictions 14 ; with this program. If not, see [https://github.com/electronicarts/CnC_Remastered_Collection]>. 15 16 ;*************************************************************************** 17 ;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S ** 18 ;*************************************************************************** 19 ;* * 20 ;* Project Name : Command & Conquer * 21 ;* * 22 ;* File Name : KEYFBUFF.ASM * 23 ;* * 24 ;* Programmer : David R. Dettmer * 25 ;* * 26 ;* Start Date : March 3, 1995 * 27 ;* * 28 ;* Last Update : * 29 ;* * 30 ;*-------------------------------------------------------------------------* 31 ;* Functions: * 32 ;* Buffer_Frame_To_Page -- Copies a linear buffer to a virtual viewport * 33 ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 34 35 ;********************** Model & Processor Directives *********************** 36 ;IDEAL 37 ;P386 38 ;MODEL USE32 FLAT 39 ;jumps 40 41 .MODEL FLAT 42 ;.386 43 44 ;******************************** Includes ********************************* 45 ;INCLUDE "gbuffer.inc" 46 ;include "profile.inc" 47 48 OPTIMAL_BYTE_COPY equ 14 49 50 GraphicViewPort STRUCT 51 GVPOffset DD ? ; offset to virtual viewport 52 GVPWidth DD ? ; width of virtual viewport 53 GVPHeight DD ? ; height of virtual viewport 54 GVPXAdd DD ? ; x mod to get to next line 55 GVPXPos DD ? ; x pos relative to Graphic Buff 56 GVPYPos DD ? ; y pos relative to Graphic Buff 57 GVPPitch dd ? ; modulo of graphic view port 58 GVPBuffPtr DD ? ; ptr to associated Graphic Buff 59 GraphicViewPort ENDS 60 61 ;******************************** Equates ********************************** 62 63 TRUE equ 1 ; Boolean 'true' value 64 FALSE equ 0 ; Boolean 'false' value 65 66 ;*=========================================================================*/ 67 ;* The following are defines used to control what functions are linked * 68 ;* in for Buffer_Frame_To_Page. * 69 ;*=========================================================================*/ 70 ;USE_NORMAL EQU TRUE 71 ;USE_HORZ_REV EQU TRUE 72 ;USE_VERT_REV EQU TRUE 73 ;USE_SCALING EQU TRUE 74 75 76 FLAG_NORMAL EQU 0 77 FLAG_TRANS EQU 1 78 FLAG_GHOST EQU 2 79 FLAG_FADING EQU 4 80 FLAG_PREDATOR EQU 8 81 82 FLAG_MASK EQU 0Fh 83 84 85 SHAPE_NORMAL EQU 0000h ; Standard shape 86 ;SHAPE_HORZ_REV EQU 0001h ; Flipped horizontally 87 ;SHAPE_VERT_REV EQU 0002h ; Flipped vertically 88 ;SHAPE_SCALING EQU 0004h ; Scaled (WORD scale_x, WORD scale_y) 89 ;SHAPE_VIEWPORT_REL EQU 0010h ; Coords are window-relative 90 ;SHAPE_WIN_REL EQU 0010h ; Coordinates are window relative instead of absolute. 91 SHAPE_CENTER EQU 0020h ; Coords are based on shape's center pt 92 SHAPE_TRANS EQU 0040h ; has transparency 93 94 SHAPE_FADING EQU 0100h ; Fading effect (VOID * fading_table, 95 ; WORD fading_num) 96 SHAPE_PREDATOR EQU 0200h ; Transparent warping effect 97 ;SHAPE_COMPACT EQU 0400h ; Never use this bit 98 ;SHAPE_PRIORITY EQU 0800h ; Use priority system when drawing 99 SHAPE_GHOST EQU 1000h ; Shape is drawn ghosted 100 ;SHAPE_SHADOW EQU 2000h 101 SHAPE_PARTIAL EQU 4000h 102 ;SHAPE_COLOR EQU 8000h ; Remap the shape's colors 103 ; (VOID * color_table) 104 105 106 ; 107 ;.......................... Shadow Effect .................................. 108 ; 109 SHADOW_COL EQU 00FFh ; magic number for shadows 110 111 ;......................... Priority System ................................. 112 ; 113 CLEAR_UNUSED_BITS EQU 0007h ; and with 0000-0111 to clear 114 ; non-walkable high bit and 115 ; scaling id bits 116 NON_WALKABLE_BIT EQU 0080h ; and with 1000-0000 to clear all 117 ; but non-walkable bit 118 ; 119 ;......................... Predator Effect ................................. 120 ; 121 ;PRED_MASK EQU 0007h ; mask used for predator pixel puts 122 PRED_MASK EQU 000Eh ; mask used for predator pixel puts 123 124 125 ;--------------------------------------------------------------------------- 126 ; 127 ; Use a macro to make code a little cleaner. 128 ; The parameter varname is optional. 129 ; Syntax to use macro is : 130 ; WANT equ expression 131 ; USE func [,varname] 132 ; If the 'varname' is defined, a table declaration is created like: 133 ; GLOBAL TableName:DWORD 134 ; Then, the table entry is created: 135 ; If WANT is true, the table entry is created for the given function: 136 ; varname DD func 137 ; If WANT is not TRUE, a Not_Supported entry is put in the table: 138 ; varname DD Not_Supported 139 ; The resulting tables look like: 140 ; 141 ; GLOBAL ExampTable:DWORD 142 ; ExampTable DD routine1 143 ; DD routine2 144 ; DD routine3 145 ; ... 146 ; Thus, each table is an array of function pointers. 147 ; 148 ;--------------------------------------------------------------------------- 149 USE MACRO func, varname 150 IF WANT 151 varname DD func 152 ELSE 153 varname DD Not_Supported 154 ENDIF 155 ENDM 156 157 prologue macro 158 endm 159 160 161 162 epilogue macro 163 endm 164 165 166 ; IFNB <varname> 167 ; GLOBAL varname:DWORD 168 ; ENDIF 169 170 ;--------------------------------------------------------------------------- 171 172 173 .DATA 174 175 ;--------------------------------------------------------------------------- 176 ; Predator effect variables 177 ;--------------------------------------------------------------------------- 178 ; make table for negative offset and use the used space for other variables 179 180 BFPredNegTable DW -1, -3, -2, -5, -2, -4, -3, -1 181 ; 8 words below calculated 182 DW 0, 0, 0, 0, 0, 0, 0, 0 ; index ffffff00 183 DD 0, 0, 0, 0 ; index ffffff10 184 BFPredOffset DD 0, 0, 0, 0 ; index ffffff20 185 DD 0, 0, 0, 0 ; index ffffff30 186 ; partially faded predator effect value 187 BFPartialPred DD 0, 0, 0, 0 ; index ffffff40 188 BFPartialCount DD 0, 0, 0, 0 ; index ffffff50 189 DD 0, 0, 0, 0 ; index ffffff60 190 DD 0, 0, 0, 0 ; index ffffff70 191 DD 0, 0, 0, 0 ; index ffffff80 192 DD 0, 0, 0, 0 ; index ffffff90 193 DD 0, 0, 0, 0 ; index ffffffa0 194 DD 0, 0, 0, 0 ; index ffffffb0 195 DD 0, 0, 0, 0 ; index ffffffc0 196 DD 0, 0, 0, 0 ; index ffffffd0 197 DD 0, 0, 0, 0 ; index ffffffe0 198 DD 0, 0, 0, 0 ; index fffffff0 199 BFPredTable DW 1, 3, 2, 5, 2, 3, 4, 1 200 ;BFPredTable DB 1, 3, 2, 5, 4, 3, 2, 1 201 202 203 204 205 206 207 extern C BigShapeBufferStart:dword 208 extern C UseBigShapeBuffer:dword 209 extern C TheaterShapeBufferStart:dword 210 extern C IsTheaterShape:dword 211 ;extern C Single_Line_Trans_Entry:near 212 ;extern C Next_Line:near 213 extern C MMX_Done:near 214 extern C MMXAvailable:dword 215 ;extern C EndNewShapeJumpTable:byte 216 ;extern C NewShapeJumpTable:dword 217 218 219 ;********************************************************************************** 220 ; 221 ; Jump tables for new line header system 222 ; 223 ; Each line of shape data now has a header byte which describes the data on the line. 224 ; 225 226 ; 227 ; Header byte control bits 228 ; 229 BLIT_TRANSPARENT =1 230 BLIT_GHOST =2 231 BLIT_FADING =4 232 BLIT_PREDATOR =8 233 BLIT_SKIP =16 234 BLIT_ALL =BLIT_TRANSPARENT or BLIT_GHOST or BLIT_FADING or BLIT_PREDATOR or BLIT_SKIP 235 236 237 ShapeHeaderType STRUCT 238 239 draw_flags dd ? 240 shape_data dd ? 241 shape_buffer dd ? 242 243 ShapeHeaderType ENDS 244 245 246 247 ; 248 ; Global definitions for routines that draw a single line of a shape 249 ; 250 ;extern Short_Single_Line_Copy:near 251 ;extern Single_Line_Trans:near 252 ;extern Single_Line_Ghost:near 253 ;extern Single_Line_Ghost_Trans:near 254 ;extern Single_Line_Fading:near 255 ;extern Single_Line_Fading_Trans:near 256 ;extern Single_Line_Ghost_Fading:near 257 ;extern Single_Line_Ghost_Fading_Trans:near 258 ;extern Single_Line_Predator:near 259 ;extern Single_Line_Predator_Trans:near 260 ;extern Single_Line_Predator_Ghost:near 261 ;extern Single_Line_Predator_Ghost_Trans:near 262 ;extern Single_Line_Predator_Fading:near 263 ;extern Single_Line_Predator_Fading_Trans:near 264 ;extern Single_Line_Predator_Ghost_Fading:near 265 ;extern Single_Line_Predator_Ghost_Fading_Trans:near 266 ;extern Single_Line_Skip:near 267 268 ;extern Single_Line_Single_Fade:near 269 ;extern Single_Line_Single_Fade_Trans:near 270 271 ;externdef AllFlagsJumpTable:dword 272 ; 273 externdef NewShapeJumpTable:dword 274 externdef EndNewShapeJumpTable:byte 275 externdef CriticalFadeRedirections:dword 276 ;externdef BufferFrameTable:dword 277 278 ;externdef CriticalFadeRedirections:dword 279 ;externdef CriticalFadeRedirections:dword 280 ;externdef CriticalFadeRedirections:dword 281 ;externdef BF_Copy:far ptr 282 ;externdef BF_Trans:dword 283 ;externdef BF_Ghost:dword 284 ;externdef BF_Ghost_Trans:dword 285 ;externdef BF_Fading:dword 286 ;externdef BF_Fading_Trans:dword 287 ;externdef BF_Ghost_Fading:dword 288 ;externdef BF_Ghost_Fading_Trans:dword 289 ;externdef BF_Predator:dword 290 ;externdef BF_Predator_Trans:dword 291 ;externdef BF_Predator_Ghost:dword 292 ;externdef BF_Predator_Ghost_Trans:dword 293 ;externdef BF_Predator_Fading:dword 294 ;externdef BF_Predator_Fading_Trans:dword 295 ;externdef BF_Predator_Ghost_Fading:dword 296 ;externdef BF_Predator_Ghost_Fading_Trans:dword 297 298 externdef C Single_Line_Trans:near 299 externdef C Single_Line_Trans_Entry:near 300 externdef C Next_Line:near 301 302 303 .CODE 304 305 306 ;--------------------------------------------------------------------------- 307 ; Code Segment Tables: 308 ; This code uses the USE macro to set up tables of function addresses. 309 ; The tables have the following format: 310 ; Tables defined are: 311 ; BufferFrameTable 312 ;--------------------------------------------------------------------------- 313 314 WANT equ <TRUE> 315 USE BF_Copy, BufferFrameTable 316 317 WANT equ <TRUE> 318 USE BF_Trans 319 320 WANT equ <TRUE> 321 USE BF_Ghost 322 323 WANT equ <TRUE> 324 USE BF_Ghost_Trans 325 326 WANT equ <TRUE> 327 USE BF_Fading 328 329 WANT equ <TRUE> 330 USE BF_Fading_Trans 331 332 WANT equ <TRUE> 333 USE BF_Ghost_Fading 334 335 WANT equ <TRUE> 336 USE BF_Ghost_Fading_Trans 337 338 WANT equ <TRUE> 339 USE BF_Predator 340 341 WANT equ <TRUE> 342 USE BF_Predator_Trans 343 344 WANT equ <TRUE> 345 USE BF_Predator_Ghost 346 347 WANT equ <TRUE> 348 USE BF_Predator_Ghost_Trans 349 350 WANT equ <TRUE> 351 USE BF_Predator_Fading 352 353 WANT equ <TRUE> 354 USE BF_Predator_Fading_Trans 355 356 WANT equ <TRUE> 357 USE BF_Predator_Ghost_Fading 358 359 WANT equ <TRUE> 360 USE BF_Predator_Ghost_Fading_Trans 361 362 363 364 .DATA 365 366 ;NewShapeJumpTable label near ptr dword 367 368 ; 369 ; Jumptable for shape line drawing with no flags set 370 ; 371 372 NewShapeJumpTable dd Short_Single_Line_Copy 373 dd Short_Single_Line_Copy 374 dd Short_Single_Line_Copy 375 dd Short_Single_Line_Copy 376 ;CriticalFadeRedirections label dword 377 CriticalFadeRedirections dd Short_Single_Line_Copy 378 dd Short_Single_Line_Copy 379 dd Short_Single_Line_Copy 380 dd Short_Single_Line_Copy 381 dd Short_Single_Line_Copy 382 dd Short_Single_Line_Copy 383 dd Short_Single_Line_Copy 384 dd Short_Single_Line_Copy 385 dd Short_Single_Line_Copy 386 dd Short_Single_Line_Copy 387 dd Short_Single_Line_Copy 388 dd Short_Single_Line_Copy 389 dd Single_Line_Skip 390 dd Single_Line_Skip 391 dd Single_Line_Skip 392 dd Single_Line_Skip 393 dd Single_Line_Skip 394 dd Single_Line_Skip 395 dd Single_Line_Skip 396 dd Single_Line_Skip 397 dd Single_Line_Skip 398 dd Single_Line_Skip 399 dd Single_Line_Skip 400 dd Single_Line_Skip 401 dd Single_Line_Skip 402 dd Single_Line_Skip 403 dd Single_Line_Skip 404 dd Single_Line_Skip 405 406 407 ; 408 ; Jumptable for shape line drawing routines with transparent flags set 409 ; 410 dd Short_Single_Line_Copy 411 dd Single_Line_Trans 412 dd Short_Single_Line_Copy 413 dd Single_Line_Trans 414 dd Short_Single_Line_Copy 415 dd Single_Line_Trans 416 dd Short_Single_Line_Copy 417 dd Single_Line_Trans 418 dd Short_Single_Line_Copy 419 dd Single_Line_Trans 420 dd Short_Single_Line_Copy 421 dd Single_Line_Trans 422 dd Short_Single_Line_Copy 423 dd Single_Line_Trans 424 dd Short_Single_Line_Copy 425 dd Single_Line_Trans 426 dd Single_Line_Skip 427 dd Single_Line_Skip 428 dd Single_Line_Skip 429 dd Single_Line_Skip 430 dd Single_Line_Skip 431 dd Single_Line_Skip 432 dd Single_Line_Skip 433 dd Single_Line_Skip 434 dd Single_Line_Skip 435 dd Single_Line_Skip 436 dd Single_Line_Skip 437 dd Single_Line_Skip 438 dd Single_Line_Skip 439 dd Single_Line_Skip 440 dd Single_Line_Skip 441 dd Single_Line_Skip 442 443 444 ; 445 ; Jumptable for shape line drawing routines with ghost flags set 446 ; 447 448 dd Short_Single_Line_Copy 449 dd Short_Single_Line_Copy 450 dd Single_Line_Ghost 451 dd Single_Line_Ghost 452 dd Short_Single_Line_Copy 453 dd Short_Single_Line_Copy 454 dd Single_Line_Ghost 455 dd Single_Line_Ghost 456 dd Short_Single_Line_Copy 457 dd Short_Single_Line_Copy 458 dd Single_Line_Ghost 459 dd Single_Line_Ghost 460 dd Short_Single_Line_Copy 461 dd Short_Single_Line_Copy 462 dd Single_Line_Ghost 463 dd Single_Line_Ghost 464 dd Single_Line_Skip 465 dd Single_Line_Skip 466 dd Single_Line_Skip 467 dd Single_Line_Skip 468 dd Single_Line_Skip 469 dd Single_Line_Skip 470 dd Single_Line_Skip 471 dd Single_Line_Skip 472 dd Single_Line_Skip 473 dd Single_Line_Skip 474 dd Single_Line_Skip 475 dd Single_Line_Skip 476 dd Single_Line_Skip 477 dd Single_Line_Skip 478 dd Single_Line_Skip 479 dd Single_Line_Skip 480 481 482 ; 483 ; Jumptable for shape line drawing routines with ghost and transparent flags set 484 ; 485 486 dd Short_Single_Line_Copy 487 dd Single_Line_Trans 488 dd Single_Line_Ghost 489 dd Single_Line_Ghost_Trans 490 dd Short_Single_Line_Copy 491 dd Single_Line_Trans 492 dd Single_Line_Ghost 493 dd Single_Line_Ghost_Trans 494 dd Short_Single_Line_Copy 495 dd Single_Line_Trans 496 dd Single_Line_Ghost 497 dd Single_Line_Ghost_Trans 498 dd Short_Single_Line_Copy 499 dd Single_Line_Trans 500 dd Single_Line_Ghost 501 dd Single_Line_Ghost_Trans 502 dd Single_Line_Skip 503 dd Single_Line_Skip 504 dd Single_Line_Skip 505 dd Single_Line_Skip 506 dd Single_Line_Skip 507 dd Single_Line_Skip 508 dd Single_Line_Skip 509 dd Single_Line_Skip 510 dd Single_Line_Skip 511 dd Single_Line_Skip 512 dd Single_Line_Skip 513 dd Single_Line_Skip 514 dd Single_Line_Skip 515 dd Single_Line_Skip 516 dd Single_Line_Skip 517 dd Single_Line_Skip 518 519 520 521 522 523 ; 524 ; Jumptable for shape line drawing routines with fading flag set 525 ; 526 527 dd Short_Single_Line_Copy 528 dd Short_Single_Line_Copy 529 dd Short_Single_Line_Copy 530 dd Short_Single_Line_Copy 531 dd Single_Line_Single_Fade 532 dd Single_Line_Single_Fade 533 dd Single_Line_Fading 534 dd Single_Line_Fading 535 dd Short_Single_Line_Copy 536 dd Short_Single_Line_Copy 537 dd Short_Single_Line_Copy 538 dd Short_Single_Line_Copy 539 dd Single_Line_Fading 540 dd Single_Line_Fading 541 dd Single_Line_Fading 542 dd Single_Line_Fading 543 dd Single_Line_Skip 544 dd Single_Line_Skip 545 dd Single_Line_Skip 546 dd Single_Line_Skip 547 dd Single_Line_Skip 548 dd Single_Line_Skip 549 dd Single_Line_Skip 550 dd Single_Line_Skip 551 dd Single_Line_Skip 552 dd Single_Line_Skip 553 dd Single_Line_Skip 554 dd Single_Line_Skip 555 dd Single_Line_Skip 556 dd Single_Line_Skip 557 dd Single_Line_Skip 558 dd Single_Line_Skip 559 560 561 ; 562 ; Jumptable for shape line drawing routines with fading and transparent flags set 563 ; 564 565 dd Short_Single_Line_Copy 566 dd Single_Line_Trans 567 dd Short_Single_Line_Copy 568 dd Single_Line_Trans 569 dd Single_Line_Single_Fade 570 dd Single_Line_Single_Fade_Trans 571 dd Single_Line_Fading 572 dd Single_Line_Fading_Trans 573 dd Short_Single_Line_Copy 574 dd Single_Line_Trans 575 dd Short_Single_Line_Copy 576 dd Single_Line_Trans 577 dd Single_Line_Fading 578 dd Single_Line_Fading_Trans 579 dd Single_Line_Fading 580 dd Single_Line_Fading_Trans 581 dd Single_Line_Skip 582 dd Single_Line_Skip 583 dd Single_Line_Skip 584 dd Single_Line_Skip 585 dd Single_Line_Skip 586 dd Single_Line_Skip 587 dd Single_Line_Skip 588 dd Single_Line_Skip 589 dd Single_Line_Skip 590 dd Single_Line_Skip 591 dd Single_Line_Skip 592 dd Single_Line_Skip 593 dd Single_Line_Skip 594 dd Single_Line_Skip 595 dd Single_Line_Skip 596 dd Single_Line_Skip 597 598 599 ; 600 ; Jumptable for shape line drawing routines with fading and ghost flags set 601 ; 602 603 dd Short_Single_Line_Copy 604 dd Short_Single_Line_Copy 605 dd Single_Line_Ghost 606 dd Single_Line_Ghost 607 dd Single_Line_Single_Fade 608 dd Single_Line_Single_Fade 609 dd Single_Line_Ghost_Fading 610 dd Single_Line_Ghost_Fading 611 dd Short_Single_Line_Copy 612 dd Short_Single_Line_Copy 613 dd Single_Line_Ghost 614 dd Single_Line_Ghost 615 dd Single_Line_Fading 616 dd Single_Line_Fading 617 dd Single_Line_Ghost_Fading 618 dd Single_Line_Ghost_Fading 619 dd Single_Line_Skip 620 dd Single_Line_Skip 621 dd Single_Line_Skip 622 dd Single_Line_Skip 623 dd Single_Line_Skip 624 dd Single_Line_Skip 625 dd Single_Line_Skip 626 dd Single_Line_Skip 627 dd Single_Line_Skip 628 dd Single_Line_Skip 629 dd Single_Line_Skip 630 dd Single_Line_Skip 631 dd Single_Line_Skip 632 dd Single_Line_Skip 633 dd Single_Line_Skip 634 dd Single_Line_Skip 635 636 637 638 ; 639 ; Jumptable for shape line drawing routines with fading, transparent and ghost flags set 640 ; 641 642 dd Short_Single_Line_Copy 643 dd Single_Line_Trans 644 dd Single_Line_Ghost 645 dd Single_Line_Ghost_Trans 646 dd Single_Line_Single_Fade 647 dd Single_Line_Single_Fade_Trans 648 dd Single_Line_Ghost_Fading 649 dd Single_Line_Ghost_Fading_Trans 650 dd Short_Single_Line_Copy 651 dd Single_Line_Trans 652 dd Single_Line_Ghost 653 dd Single_Line_Ghost_Trans 654 dd Single_Line_Fading 655 dd Single_Line_Fading_Trans 656 dd Single_Line_Ghost_Fading 657 dd Single_Line_Ghost_Fading_Trans 658 dd Single_Line_Skip 659 dd Single_Line_Skip 660 dd Single_Line_Skip 661 dd Single_Line_Skip 662 dd Single_Line_Skip 663 dd Single_Line_Skip 664 dd Single_Line_Skip 665 dd Single_Line_Skip 666 dd Single_Line_Skip 667 dd Single_Line_Skip 668 dd Single_Line_Skip 669 dd Single_Line_Skip 670 dd Single_Line_Skip 671 dd Single_Line_Skip 672 dd Single_Line_Skip 673 dd Single_Line_Skip 674 675 676 677 678 679 680 ; 681 ; Jumptable for shape line drawing with predator flag set 682 ; 683 684 dd Short_Single_Line_Copy 685 dd Short_Single_Line_Copy 686 dd Short_Single_Line_Copy 687 dd Short_Single_Line_Copy 688 dd Short_Single_Line_Copy 689 dd Short_Single_Line_Copy 690 dd Short_Single_Line_Copy 691 dd Short_Single_Line_Copy 692 dd Single_Line_Predator 693 dd Single_Line_Predator 694 dd Single_Line_Predator 695 dd Single_Line_Predator 696 dd Single_Line_Predator 697 dd Single_Line_Predator 698 dd Single_Line_Predator 699 dd Single_Line_Predator 700 dd Single_Line_Skip 701 dd Single_Line_Skip 702 dd Single_Line_Skip 703 dd Single_Line_Skip 704 dd Single_Line_Skip 705 dd Single_Line_Skip 706 dd Single_Line_Skip 707 dd Single_Line_Skip 708 dd Single_Line_Skip 709 dd Single_Line_Skip 710 dd Single_Line_Skip 711 dd Single_Line_Skip 712 dd Single_Line_Skip 713 dd Single_Line_Skip 714 dd Single_Line_Skip 715 dd Single_Line_Skip 716 717 718 ; 719 ; Jumptable for shape line drawing routines with transparent and predator flags set 720 ; 721 dd Short_Single_Line_Copy 722 dd Single_Line_Trans 723 dd Short_Single_Line_Copy 724 dd Single_Line_Trans 725 dd Short_Single_Line_Copy 726 dd Single_Line_Trans 727 dd Short_Single_Line_Copy 728 dd Single_Line_Trans 729 dd Single_Line_Predator 730 dd Single_Line_Predator_Trans 731 dd Single_Line_Predator 732 dd Single_Line_Predator_Trans 733 dd Single_Line_Predator 734 dd Single_Line_Predator_Trans 735 dd Single_Line_Predator 736 dd Single_Line_Predator_Trans 737 dd Single_Line_Skip 738 dd Single_Line_Skip 739 dd Single_Line_Skip 740 dd Single_Line_Skip 741 dd Single_Line_Skip 742 dd Single_Line_Skip 743 dd Single_Line_Skip 744 dd Single_Line_Skip 745 dd Single_Line_Skip 746 dd Single_Line_Skip 747 dd Single_Line_Skip 748 dd Single_Line_Skip 749 dd Single_Line_Skip 750 dd Single_Line_Skip 751 dd Single_Line_Skip 752 dd Single_Line_Skip 753 754 755 ; 756 ; Jumptable for shape line drawing routines with ghost and predator flags set 757 ; 758 759 dd Short_Single_Line_Copy 760 dd Short_Single_Line_Copy 761 dd Single_Line_Ghost 762 dd Single_Line_Ghost 763 dd Short_Single_Line_Copy 764 dd Short_Single_Line_Copy 765 dd Single_Line_Ghost 766 dd Single_Line_Ghost 767 dd Single_Line_Predator 768 dd Single_Line_Predator 769 dd Single_Line_Predator_Ghost 770 dd Single_Line_Predator_Ghost 771 dd Single_Line_Predator 772 dd Single_Line_Predator 773 dd Single_Line_Predator_Ghost 774 dd Single_Line_Predator_Ghost 775 dd Single_Line_Skip 776 dd Single_Line_Skip 777 dd Single_Line_Skip 778 dd Single_Line_Skip 779 dd Single_Line_Skip 780 dd Single_Line_Skip 781 dd Single_Line_Skip 782 dd Single_Line_Skip 783 dd Single_Line_Skip 784 dd Single_Line_Skip 785 dd Single_Line_Skip 786 dd Single_Line_Skip 787 dd Single_Line_Skip 788 dd Single_Line_Skip 789 dd Single_Line_Skip 790 dd Single_Line_Skip 791 792 793 ; 794 ; Jumptable for shape line drawing routines with ghost and transparent and predator flags set 795 ; 796 797 dd Short_Single_Line_Copy 798 dd Single_Line_Trans 799 dd Single_Line_Ghost 800 dd Single_Line_Ghost_Trans 801 dd Short_Single_Line_Copy 802 dd Single_Line_Trans 803 dd Single_Line_Ghost 804 dd Single_Line_Ghost_Trans 805 dd Single_Line_Predator 806 dd Single_Line_Predator_Trans 807 dd Single_Line_Predator_Ghost 808 dd Single_Line_Predator_Ghost_Trans 809 dd Single_Line_Predator 810 dd Single_Line_Predator_Trans 811 dd Single_Line_Predator_Ghost 812 dd Single_Line_Predator_Ghost_Trans 813 dd Single_Line_Skip 814 dd Single_Line_Skip 815 dd Single_Line_Skip 816 dd Single_Line_Skip 817 dd Single_Line_Skip 818 dd Single_Line_Skip 819 dd Single_Line_Skip 820 dd Single_Line_Skip 821 dd Single_Line_Skip 822 dd Single_Line_Skip 823 dd Single_Line_Skip 824 dd Single_Line_Skip 825 dd Single_Line_Skip 826 dd Single_Line_Skip 827 dd Single_Line_Skip 828 dd Single_Line_Skip 829 830 831 832 833 834 ; 835 ; Jumptable for shape line drawing routines with fading and predator flags set 836 ; 837 838 dd Short_Single_Line_Copy 839 dd Short_Single_Line_Copy 840 dd Short_Single_Line_Copy 841 dd Short_Single_Line_Copy 842 dd Single_Line_Single_Fade 843 dd Single_Line_Single_Fade 844 dd Single_Line_Fading 845 dd Single_Line_Fading 846 dd Single_Line_Predator 847 dd Single_Line_Predator 848 dd Single_Line_Predator 849 dd Single_Line_Predator 850 dd Single_Line_Predator_Fading 851 dd Single_Line_Predator_Fading 852 dd Single_Line_Predator_Fading 853 dd Single_Line_Predator_Fading 854 dd Single_Line_Skip 855 dd Single_Line_Skip 856 dd Single_Line_Skip 857 dd Single_Line_Skip 858 dd Single_Line_Skip 859 dd Single_Line_Skip 860 dd Single_Line_Skip 861 dd Single_Line_Skip 862 dd Single_Line_Skip 863 dd Single_Line_Skip 864 dd Single_Line_Skip 865 dd Single_Line_Skip 866 dd Single_Line_Skip 867 dd Single_Line_Skip 868 dd Single_Line_Skip 869 dd Single_Line_Skip 870 871 872 ; 873 ; Jumptable for shape line drawing routines with fading and transparent and predator flags set 874 ; 875 876 dd Short_Single_Line_Copy 877 dd Single_Line_Trans 878 dd Short_Single_Line_Copy 879 dd Single_Line_Trans 880 dd Single_Line_Single_Fade 881 dd Single_Line_Single_Fade_Trans 882 dd Single_Line_Fading 883 dd Single_Line_Fading_Trans 884 dd Single_Line_Predator 885 dd Single_Line_Predator_Trans 886 dd Single_Line_Predator 887 dd Single_Line_Predator_Trans 888 dd Single_Line_Predator_Fading 889 dd Single_Line_Predator_Fading_Trans 890 dd Single_Line_Predator_Fading 891 dd Single_Line_Predator_Fading_Trans 892 dd Single_Line_Skip 893 dd Single_Line_Skip 894 dd Single_Line_Skip 895 dd Single_Line_Skip 896 dd Single_Line_Skip 897 dd Single_Line_Skip 898 dd Single_Line_Skip 899 dd Single_Line_Skip 900 dd Single_Line_Skip 901 dd Single_Line_Skip 902 dd Single_Line_Skip 903 dd Single_Line_Skip 904 dd Single_Line_Skip 905 dd Single_Line_Skip 906 dd Single_Line_Skip 907 dd Single_Line_Skip 908 909 910 ; 911 ; Jumptable for shape line drawing routines with fading and ghost and predator flags set 912 ; 913 914 dd Short_Single_Line_Copy 915 dd Short_Single_Line_Copy 916 dd Single_Line_Ghost 917 dd Single_Line_Ghost 918 dd Single_Line_Single_Fade 919 dd Single_Line_Single_Fade 920 dd Single_Line_Ghost_Fading 921 dd Single_Line_Ghost_Fading 922 dd Single_Line_Predator 923 dd Single_Line_Predator 924 dd Single_Line_Predator_Ghost 925 dd Single_Line_Predator_Ghost 926 dd Single_Line_Predator_Fading 927 dd Single_Line_Predator_Fading 928 dd Single_Line_Predator_Ghost_Fading 929 dd Single_Line_Predator_Ghost_Fading 930 dd Single_Line_Skip 931 dd Single_Line_Skip 932 dd Single_Line_Skip 933 dd Single_Line_Skip 934 dd Single_Line_Skip 935 dd Single_Line_Skip 936 dd Single_Line_Skip 937 dd Single_Line_Skip 938 dd Single_Line_Skip 939 dd Single_Line_Skip 940 dd Single_Line_Skip 941 dd Single_Line_Skip 942 dd Single_Line_Skip 943 dd Single_Line_Skip 944 dd Single_Line_Skip 945 dd Single_Line_Skip 946 947 948 949 950 951 952 953 ; 954 ; Jumptable for shape line drawing routines with all flags set 955 ; 956 957 AllFlagsJumpTable label dword 958 dd Short_Single_Line_Copy 959 dd Single_Line_Trans 960 dd Single_Line_Ghost 961 dd Single_Line_Ghost_Trans 962 dd Single_Line_Single_Fade 963 dd Single_Line_Single_Fade_Trans 964 dd Single_Line_Ghost_Fading 965 dd Single_Line_Ghost_Fading_Trans 966 dd Single_Line_Predator 967 dd Single_Line_Predator_Trans 968 dd Single_Line_Predator_Ghost 969 dd Single_Line_Predator_Ghost_Trans 970 dd Single_Line_Predator_Fading 971 dd Single_Line_Predator_Fading_Trans 972 dd Single_Line_Predator_Ghost_Fading 973 dd Single_Line_Predator_Ghost_Fading_Trans 974 dd Single_Line_Skip 975 dd Single_Line_Skip 976 dd Single_Line_Skip 977 dd Single_Line_Skip 978 dd Single_Line_Skip 979 dd Single_Line_Skip 980 dd Single_Line_Skip 981 dd Single_Line_Skip 982 dd Single_Line_Skip 983 dd Single_Line_Skip 984 dd Single_Line_Skip 985 dd Single_Line_Skip 986 dd Single_Line_Skip 987 dd Single_Line_Skip 988 dd Single_Line_Skip 989 dd Single_Line_Skip 990 991 992 EndNewShapeJumpTable db 0 993 994 .CODE 995 996 997 998 ;--------------------------------------------------------------------------- 999 1000 1001 1002 1003 ;********************************************************************************************* 1004 ;* Set_Shape_Header -- create the line header bytes for a shape * 1005 ;* * 1006 ;* INPUT: Shape width * 1007 ;* Shape height * 1008 ;* ptr to raw shape data * 1009 ;* ptr to shape headers * 1010 ;* shape flags * 1011 ;* ptr to translucency table * 1012 ;* IsTranslucent * 1013 ;* * 1014 ;* OUTPUT: none * 1015 ;* * 1016 ;* Warnings: * 1017 ;* * 1018 ;* HISTORY: * 1019 ;* 11/29/95 10:09AM ST : Created. * 1020 ;*===========================================================================================* 1021 1022 Setup_Shape_Header proc C pixel_width:DWORD, pixel_height:DWORD, src:DWORD, headers:DWORD, flags:DWORD, Translucent:DWORD, IsTranslucent:DWORD 1023 1024 ;ARG pixel_width :DWORD ; width of rectangle to blit 1025 ;ARG pixel_height :DWORD ; height of rectangle to blit 1026 ;ARG src :DWORD ; this is a member function 1027 ;ARG headers :DWORD 1028 ;ARG flags :DWORD 1029 ;ARG Translucent :DWORD 1030 ;ARG IsTranslucent :DWORD 1031 LOCAL trans_count :DWORD 1032 1033 pushad 1034 1035 1036 mov esi,[src] ;ptr to raw shape data 1037 mov edi,[headers] ;ptr to headers we are going to set up 1038 mov eax,[flags] 1039 and eax,SHAPE_TRANS or SHAPE_FADING or SHAPE_PREDATOR or SHAPE_GHOST 1040 mov [edi].ShapeHeaderType.draw_flags,eax ;save old flags in header 1041 add edi,size ShapeHeaderType 1042 mov edx,[pixel_height] ;number of shape lines to scan 1043 1044 outer_loop: mov ecx,[pixel_width] ;number of pixels in shape line 1045 xor bl,bl ;flag the we dont know anything about this line yet 1046 mov [trans_count],0 ;we havnt scanned any transparent pixels yet 1047 1048 ; 1049 ; Scan one shape line to see what kind of data it contains 1050 ; 1051 inner_loop: xor eax,eax 1052 mov al,[esi] 1053 inc esi 1054 1055 ; 1056 ; Check for transparent pixel 1057 ; 1058 test al,al 1059 jnz not_transp 1060 test [flags],SHAPE_TRANS 1061 jz not_transp 1062 or bl,BLIT_TRANSPARENT ;flag that pixel is transparent 1063 inc [trans_count] ;keep count of the number of transparent pixels on the line 1064 jmp end_lp 1065 1066 ; 1067 ; Check for predator effect on this line 1068 ; 1069 not_transp: test [flags],SHAPE_PREDATOR 1070 jz not_pred 1071 or bl,BLIT_PREDATOR 1072 1073 ; 1074 ; Check for ghost effects 1075 ; 1076 not_pred: test [flags],SHAPE_GHOST 1077 jz not_ghost 1078 push edi 1079 mov edi,[IsTranslucent] 1080 cmp byte ptr [edi+eax],-1 1081 pop edi 1082 jz not_ghost 1083 or bl,BLIT_GHOST 1084 1085 ; 1086 ; Check if fading is required 1087 ; 1088 not_ghost: test [flags],SHAPE_FADING 1089 jz end_lp 1090 or bl,BLIT_FADING 1091 1092 end_lp: dec ecx 1093 jnz inner_loop 1094 1095 1096 ; 1097 ; Interpret the info we have collected and decide which routine will be 1098 ; used to draw this line 1099 ; 1100 xor bh,bh 1101 1102 test bl,BLIT_TRANSPARENT 1103 jz no_transparencies 1104 or bh,BLIT_TRANSPARENT 1105 mov ecx,[pixel_width] 1106 cmp ecx,[trans_count] 1107 jnz not_all_trans 1108 1109 ; all pixels in the line were transparent so we dont need to draw it at all 1110 mov bh,BLIT_SKIP 1111 jmp got_line_type 1112 1113 not_all_trans: 1114 no_transparencies: 1115 mov al,bl 1116 and al,BLIT_PREDATOR 1117 or bh,al 1118 mov al,bl 1119 and al,BLIT_GHOST 1120 or bh,al 1121 mov al,bl 1122 and al,BLIT_FADING 1123 or bh,al 1124 1125 ; 1126 ; Save the line header and do the next line 1127 ; 1128 got_line_type:mov [edi],bh 1129 inc edi 1130 1131 dec edx 1132 jnz outer_loop 1133 1134 1135 popad 1136 ret 1137 1138 Setup_Shape_Header endp 1139 1140 1141 1142 1143 ;************************************************************** 1144 ; 1145 ; Macro to fetch the header of the next line and jump to the appropriate routine 1146 ; 1147 next_line macro 1148 1149 add edi , [ dest_adjust_width ] ;add in dest modulo 1150 dec edx ;line counter 1151 jz real_out ;return 1152 mov ecx,[save_ecx] ;ecx is pixel count 1153 mov eax,[header_pointer] ;ptr to next header byte 1154 mov al,[eax] 1155 inc [header_pointer] 1156 and eax,BLIT_ALL ;Make sure we dont jump to some spurious address 1157 ; if the header is wrong then its better to draw with the wrong 1158 ; shape routine than to die 1159 shl eax,2 1160 add eax,[ShapeJumpTableAddress] ;get the address to jump to 1161 jmp dword ptr [eax] ;do the jump 1162 1163 endm 1164 1165 1166 1167 1168 1169 1170 ;*************************************************************************** 1171 ;* VVC::TOPAGE -- Copies a linear buffer to a virtual viewport * 1172 ;* * 1173 ;* INPUT: WORD x_pixel - x pixel on viewport to copy from * 1174 ;* WORD y_pixel - y pixel on viewport to copy from * 1175 ;* WORD pixel_width - the width of copy region * 1176 ;* WORD pixel_height - the height of copy region * 1177 ;* BYTE * src - buffer to copy from * 1178 ;* VVPC * dest - virtual viewport to copy to * 1179 ;* * 1180 ;* OUTPUT: none * 1181 ;* * 1182 ;* WARNINGS: Coordinates and dimensions will be adjusted if they exceed * 1183 ;* the boundaries. In the event that no adjustment is * 1184 ;* possible this routine will abort. If the size of the * 1185 ;* region to copy exceeds the size passed in for the buffer * 1186 ;* the routine will automatically abort. * 1187 ;* * 1188 ;* HISTORY: * 1189 ;* 06/15/1994 PWG : Created. * 1190 ;*=========================================================================* 1191 Buffer_Frame_To_Page proc C public USES eax ebx ecx edx esi edi x_pixel:DWORD, y_pixel:DWORD, pixel_width:DWORD, pixel_height:DWORD, src:DWORD, dest:DWORD, flags:DWORD 1192 1193 ;USES eax,ebx,ecx,edx,esi,edi 1194 1195 ;*=================================================================== 1196 ;* define the arguements that our function takes. 1197 ;*=================================================================== 1198 ;ARG x_pixel :DWORD ; x pixel position in source 1199 ;ARG y_pixel :DWORD ; y pixel position in source 1200 ;ARG pixel_width :DWORD ; width of rectangle to blit 1201 ;ARG pixel_height:DWORD ; height of rectangle to blit 1202 ;ARG src :DWORD ; this is a member function 1203 ;ARG dest :DWORD ; what are we blitting to 1204 1205 ;ARG flags :DWORD ; flags passed 1206 1207 ;*=================================================================== 1208 ; Define some locals so that we can handle things quickly 1209 ;*=================================================================== 1210 LOCAL IsTranslucent :DWORD ; ptr to the is_translucent table 1211 LOCAL Translucent :DWORD ; ptr to the actual translucent table 1212 LOCAL FadingTable :DWORD ; extracted fading table pointer 1213 LOCAL FadingNum :DWORD ; get the number of times to fade 1214 1215 LOCAL StashECX :DWORD ; temp variable for ECX register 1216 1217 LOCAL jflags :DWORD ; flags used to goto correct buff frame routine 1218 LOCAL BufferFrameRout :DWORD ; ptr to the buffer frame routine 1219 1220 LOCAL jmp_loc :DWORD ; calculated jump location 1221 LOCAL loop_cnt :DWORD 1222 1223 LOCAL x1_pixel :DWORD 1224 LOCAL y1_pixel :DWORD 1225 LOCAL scr_x :DWORD 1226 LOCAL scr_y :DWORD 1227 LOCAL dest_adjust_width :DWORD 1228 LOCAL scr_adjust_width :DWORD 1229 LOCAL header_pointer :DWORD 1230 LOCAL use_old_draw :DWORD 1231 LOCAL save_ecx :DWORD 1232 LOCAL ShapeJumpTableAddress :DWORD 1233 LOCAL shape_buffer_start :DWORD 1234 1235 prologue 1236 cmp [ src ] , 0 1237 jz real_out 1238 1239 ; 1240 ; Save the line attributes pointers and 1241 ; Modify the src pointer to point to the actual image 1242 ; 1243 cmp [UseBigShapeBuffer],0 1244 jz do_args ;just use the old shape drawing system 1245 1246 mov edi,[src] 1247 mov [header_pointer],edi 1248 1249 mov eax,[BigShapeBufferStart] 1250 cmp [edi].ShapeHeaderType.shape_buffer,0 1251 jz is_ordinary_shape 1252 mov eax,[TheaterShapeBufferStart] 1253 is_ordinary_shape: 1254 mov [shape_buffer_start],eax 1255 1256 mov edi,[edi].ShapeHeaderType.shape_data 1257 add edi,[shape_buffer_start] 1258 mov [src],edi 1259 mov [use_old_draw],0 1260 1261 1262 ;==================================================================== 1263 ; Pull off optional arguments: 1264 ; EDI is used as an offset from the 'flags' parameter, to point 1265 ; to the optional argument currently being processed. 1266 ;==================================================================== 1267 do_args: 1268 mov edi , 4 ; optional params start past flags 1269 mov [ jflags ] , 0 ; clear jump flags 1270 1271 check_centering: 1272 ;------------------------------------------------------------------- 1273 ; See if we need to center the frame 1274 ;------------------------------------------------------------------- 1275 test [ flags ] , SHAPE_CENTER ; does this need to be centered? 1276 je check_trans ; if not the skip over this stuff 1277 1278 mov eax , [ pixel_width ] 1279 mov ebx , [ pixel_height ] 1280 sar eax , 1 1281 sar ebx , 1 1282 sub [ x_pixel ] , eax 1283 sub [ y_pixel ] , ebx 1284 1285 check_trans: 1286 test [ flags ] , SHAPE_TRANS 1287 jz check_ghost 1288 1289 or [ jflags ] , FLAG_TRANS 1290 1291 ;-------------------------------------------------------------------- 1292 ; SHAPE_GHOST: DWORD is_translucent tbl 1293 ;-------------------------------------------------------------------- 1294 check_ghost: 1295 test [ flags ] , SHAPE_GHOST ; are we ghosting this shape 1296 jz check_fading 1297 1298 mov eax , [ flags + edi ] 1299 or [ jflags ] , FLAG_GHOST 1300 mov [ IsTranslucent ] , eax ; save ptr to is_trans. tbl 1301 add eax , 0100h ; add 256 for first table 1302 add edi , 4 ; next argument 1303 mov [ Translucent ] , eax ; save ptr to translucent tbl 1304 1305 1306 1307 check_fading: 1308 ;______________________________________________________________________ 1309 ; If this is the first time through for this shape then 1310 ; set up the shape header 1311 ;______________________________________________________________________ 1312 pushad 1313 1314 cmp [UseBigShapeBuffer],0 1315 jz new_shape 1316 1317 mov edi,[header_pointer] 1318 cmp [edi].ShapeHeaderType.draw_flags,-1 1319 jz setup_headers 1320 mov eax,[flags] ;Redo the shape headers if this shape was 1321 and eax,SHAPE_TRANS or SHAPE_FADING or SHAPE_PREDATOR or SHAPE_GHOST ;initially set up with different flags 1322 cmp eax,[edi].ShapeHeaderType.draw_flags 1323 jz no_header_setup 1324 new_shape: 1325 mov [use_old_draw],1 1326 jmp no_header_setup 1327 1328 setup_headers: 1329 push [IsTranslucent] 1330 push [Translucent] 1331 push [flags] 1332 push [header_pointer] 1333 push [src] 1334 push [pixel_height] 1335 push [pixel_width] 1336 call Setup_Shape_Header 1337 add esp,7*4 1338 mov [ShapeJumpTableAddress], offset AllFlagsJumpTable 1339 jmp headers_set 1340 no_header_setup: 1341 1342 xor eax,eax 1343 test [flags],SHAPE_PREDATOR 1344 jz not_shape_predator 1345 or al,BLIT_PREDATOR 1346 1347 not_shape_predator: 1348 test [flags],SHAPE_FADING 1349 jz not_shape_fading 1350 or al,BLIT_FADING 1351 1352 not_shape_fading: 1353 1354 test [flags],SHAPE_TRANS 1355 jz not_shape_transparent 1356 or al,BLIT_TRANSPARENT 1357 1358 not_shape_transparent: 1359 1360 test [flags],SHAPE_GHOST 1361 jz not_shape_ghost 1362 or al,BLIT_GHOST 1363 1364 not_shape_ghost: 1365 1366 1367 shl eax,7 1368 add eax, offset NewShapeJumpTable 1369 mov [ShapeJumpTableAddress],eax 1370 ;call Init_New_Shape_Jump_Table_Address 1371 1372 1373 headers_set: 1374 popad 1375 1376 ;-------------------------------------------------------------------- 1377 ; SHAPE_FADING: DWORD fade_table[256], DWORD fade_count 1378 ;-------------------------------------------------------------------- 1379 test [ flags ] , SHAPE_FADING ; are we fading this shape 1380 jz check_predator 1381 1382 mov eax , [ flags + edi ] 1383 mov [ FadingTable ] , eax ; save address of fading tbl 1384 mov eax , [ flags + edi + 4 ] ; get fade num 1385 or [ jflags ] , FLAG_FADING 1386 and eax , 03fh ; no need for more than 63 1387 add edi , 8 ; next argument 1388 cmp eax , 0 ; check if it's 0 1389 jnz set_fading ; if not, store fade num 1390 1391 and [ flags ] , NOT SHAPE_FADING ; otherwise, don't fade 1392 1393 set_fading: 1394 mov [ FadingNum ] , eax 1395 1396 mov ebx,[ShapeJumpTableAddress] 1397 mov dword ptr [CriticalFadeRedirections-NewShapeJumpTable+ebx],offset Single_Line_Single_Fade 1398 mov dword ptr [CriticalFadeRedirections-NewShapeJumpTable+ebx+4],offset Single_Line_Single_Fade_Trans 1399 cmp eax,1 1400 jz single_fade 1401 mov dword ptr [CriticalFadeRedirections-NewShapeJumpTable+ebx],offset Single_Line_Fading 1402 mov dword ptr [CriticalFadeRedirections-NewShapeJumpTable+ebx+4],offset Single_Line_Fading_Trans 1403 1404 single_fade: 1405 1406 ;-------------------------------------------------------------------- 1407 ; SHAPE_PREDATOR: DWORD init_pred_lookup_offset (0-7) 1408 ;-------------------------------------------------------------------- 1409 check_predator: 1410 test [ flags ] , SHAPE_PREDATOR ; is predator effect on 1411 jz check_partial 1412 1413 mov eax , [ flags + edi ] ; pull the partial value 1414 or [ jflags ] , FLAG_PREDATOR 1415 shl eax , 1 1416 cmp eax , 0 1417 jge check_range 1418 1419 neg eax 1420 mov ebx , -1 1421 and eax , PRED_MASK ; keep entries within bounds 1422 mov bl , al 1423 mov eax , ebx ; will be ffffff00-ffffff07 1424 jmp pred_cont 1425 1426 check_range: 1427 and eax , PRED_MASK ; keep entries within bounds 1428 1429 pred_cont: 1430 add edi , 4 ; next argument 1431 mov [ BFPredOffset ] , eax 1432 mov [ BFPartialCount ] , 0 ; clear the partial count 1433 mov [ BFPartialPred ] , 100h ; init partial to off 1434 1435 pred_neg_init: 1436 mov esi , [ dest ] ; get ptr to dest 1437 mov ebx, 7 * 2 1438 1439 pred_loop: 1440 movzx eax , [ WORD PTR BFPredNegTable + ebx ] 1441 add eax , [esi].GraphicViewPort.GVPWidth ; add width 1442 add eax , [esi].GraphicViewPort.GVPXAdd ; add x add 1443 add eax , [esi].GraphicViewPort.GVPPitch ; extra pitch of DD surface ST - 9/29/95 1:08PM 1444 mov [ WORD PTR BFPredNegTable + 16 + ebx ] , ax 1445 dec ebx 1446 dec ebx 1447 jge pred_loop 1448 1449 ;-------------------------------------------------------------------- 1450 ; SHAPE_PARTIAL: DWORD partial_pred_value (0-255) 1451 ;-------------------------------------------------------------------- 1452 check_partial: 1453 test [ flags ] , SHAPE_PARTIAL ; is this a partial pred? 1454 jz setupfunc 1455 1456 mov eax , [ flags + edi ] ; pull the partial value 1457 add edi , 4 ; next argument 1458 and eax , 0ffh ; make sure 0-255 1459 mov [ BFPartialPred ] , eax ; store it off 1460 1461 setupfunc: 1462 mov ebx , [ jflags ] ; load flags value 1463 and ebx , FLAG_MASK ; clip high bits 1464 add ebx , ebx ; mult by 4 to get DWORD offset 1465 add ebx , ebx 1466 mov ebx , dword ptr [ BufferFrameTable + ebx ] ; get table value 1467 mov dword ptr [ BufferFrameRout ] , ebx ; store it in the function pointer 1468 1469 ; Clip dest Rectangle against source Window boundaries. 1470 1471 mov [ scr_x ] , 0 1472 mov [ scr_y ] , 0 1473 mov esi , [ dest ] ; get ptr to dest 1474 xor ecx , ecx 1475 xor edx , edx 1476 mov edi , [esi].GraphicViewPort.GVPWidth ; get width into register 1477 mov ebx , [ x_pixel ] 1478 mov eax , [ x_pixel ] 1479 add ebx , [ pixel_width ] 1480 shld ecx , eax , 1 1481 mov [ x1_pixel ] , ebx 1482 inc edi 1483 shld edx , ebx , 1 1484 sub eax , edi 1485 sub ebx , edi 1486 shld ecx , eax , 1 1487 shld edx , ebx , 1 1488 1489 mov edi,[esi].GraphicViewPort.GVPHeight ; get height into register 1490 mov ebx , [ y_pixel ] 1491 mov eax , [ y_pixel ] 1492 add ebx , [ pixel_height ] 1493 shld ecx , eax , 1 1494 mov [ y1_pixel ] , ebx 1495 inc edi 1496 shld edx , ebx , 1 1497 sub eax , edi 1498 sub ebx , edi 1499 shld ecx , eax , 1 1500 shld edx , ebx , 1 1501 1502 xor cl , 5 1503 xor dl , 5 1504 mov al , cl 1505 test dl , cl 1506 jnz real_out 1507 1508 or al , dl 1509 jz do_blit 1510 1511 mov [use_old_draw],1 1512 test cl , 1000b 1513 jz dest_left_ok 1514 1515 mov eax , [ x_pixel ] 1516 neg eax 1517 mov [ x_pixel ] , 0 1518 mov [ scr_x ] , eax 1519 1520 dest_left_ok: 1521 test cl , 0010b 1522 jz dest_bottom_ok 1523 1524 mov eax , [ y_pixel ] 1525 neg eax 1526 mov [ y_pixel ] , 0 1527 mov [ scr_y ] , eax 1528 1529 dest_bottom_ok: 1530 test dl , 0100b 1531 jz dest_right_ok 1532 1533 mov eax , [esi].GraphicViewPort.GVPWidth ; get width into register 1534 mov [ x1_pixel ] , eax 1535 1536 dest_right_ok: 1537 test dl , 0001b 1538 jz do_blit 1539 1540 mov eax , [esi].GraphicViewPort.GVPHeight ; get width into register 1541 mov [ y1_pixel ] , eax 1542 1543 do_blit: 1544 cld 1545 mov eax , [esi].GraphicViewPort.GVPXAdd 1546 add eax , [esi].GraphicViewPort.GVPPitch 1547 add eax , [esi].GraphicViewPort.GVPWidth 1548 mov edi , [esi].GraphicViewPort.GVPOffset 1549 1550 mov ecx , eax 1551 mul [ y_pixel ] 1552 add edi , [ x_pixel ] 1553 add edi , eax 1554 1555 add ecx , [ x_pixel ] 1556 sub ecx , [ x1_pixel ] 1557 mov [ dest_adjust_width ] , ecx 1558 1559 mov esi , [ src ] 1560 mov eax , [ pixel_width ] 1561 sub eax , [ x1_pixel ] 1562 add eax , [ x_pixel ] 1563 mov [ scr_adjust_width ] , eax 1564 1565 mov eax , [ scr_y ] 1566 mul [ pixel_width ] 1567 add eax , [ scr_x ] 1568 add esi , eax 1569 1570 ; 1571 ; If the shape needs to be clipped then we cant handle it with the new header systen 1572 ; so draw it with the old shape drawer 1573 ; 1574 cmp [use_old_draw],0 1575 jnz use_old_stuff 1576 1577 add [header_pointer],size ShapeHeaderType 1578 mov edx,[pixel_height] 1579 mov ecx,[pixel_width] 1580 mov eax,[header_pointer] 1581 mov al,[eax] 1582 mov [save_ecx],ecx 1583 inc [header_pointer] 1584 and eax,BLIT_ALL 1585 shl eax,2 1586 add eax,[ShapeJumpTableAddress] 1587 jmp dword ptr [eax] 1588 1589 1590 use_old_stuff: 1591 mov edx , [ y1_pixel ] 1592 mov eax , [ x1_pixel ] 1593 1594 sub edx , [ y_pixel ] 1595 jle real_out 1596 1597 sub eax , [ x_pixel ] 1598 jle real_out 1599 1600 jmp [ BufferFrameRout ] ; buffer frame to viewport routine 1601 1602 real_out: 1603 1604 cmp [MMXAvailable],0 1605 jz no_mmx_cleanup 1606 call MMX_Done 1607 1608 no_mmx_cleanup: 1609 epilogue 1610 1611 ret 1612 1613 1614 ; ******************************************************************** 1615 ; Forward bitblit only 1616 ; the inner loop is so efficient that 1617 ; the optimal consept no longer apply because 1618 ; the optimal byte have to by a number greather than 9 bytes 1619 ; ******************************************************************** 1620 ;extern BF_Copy:near 1621 1622 BF_Copy: 1623 prologue 1624 1625 cmp eax , 10 1626 jl forward_loop_bytes 1627 1628 forward_loop_dword: 1629 mov ecx , edi 1630 mov ebx , eax 1631 neg ecx 1632 and ecx , 3 1633 sub ebx , ecx 1634 rep movsb 1635 mov ecx , ebx 1636 shr ecx , 2 1637 rep movsd 1638 mov ecx , ebx 1639 and ecx , 3 1640 rep movsb 1641 1642 add esi , [ scr_adjust_width ] 1643 add edi , [ dest_adjust_width ] 1644 dec edx 1645 jnz forward_loop_dword 1646 1647 ret 1648 1649 forward_loop_bytes: 1650 mov ecx , eax 1651 rep movsb 1652 add esi , [ scr_adjust_width ] 1653 add edi , [ dest_adjust_width ] 1654 dec edx ; decrement the height 1655 jnz forward_loop_bytes 1656 1657 epilogue 1658 1659 ret 1660 1661 1662 ;******************************************************************** 1663 ;******************************************************************** 1664 1665 ; segment code page public use32 'code' ; Need stricter segment alignment 1666 ; for pentium optimisations 1667 1668 1669 ; 1670 ; Expand the 'next_line' macro so we can jump to it 1671 ; 1672 ; 1673 ; ST - 12/20/2018 3:48PM 1674 Next_Line:: next_line 1675 1676 1677 1678 ;***************************************************************************** 1679 ; Draw a single line with transparent pixels 1680 ; 1681 ; 11/29/95 10:21AM - ST 1682 ; 1683 ;align 32 1684 1685 Single_Line_Trans:: 1686 prologue 1687 1688 Single_Line_Trans_Entry:: 1689 1690 slt_mask_map_lp: ; Pentium pipeline usage 1691 ;Pipe Cycles 1692 mov al,[esi] ;U 1 1693 inc esi ;Vee 1 1694 1695 test al,al ;U 1 1696 jz slt_skip ;Vee 1/5 1697 1698 slt_not_trans:mov [edi],al ;u 1 1699 1700 inc edi ;vee 1 1701 dec ecx ;u 1 1702 1703 jnz slt_mask_map_lp ;vee (maybe) 1 1704 1705 slt_end_line: epilogue 1706 next_line 1707 1708 ;align 32 1709 1710 slt_skip: inc edi 1711 dec ecx 1712 jz slt_skip_end_line 1713 1714 mov al,[esi] 1715 inc esi 1716 test al,al 1717 jz slt_skip2 1718 mov [edi],al 1719 inc edi 1720 dec ecx 1721 jnz slt_mask_map_lp 1722 1723 epilogue 1724 next_line 1725 1726 ;align 32 1727 1728 slt_skip2: inc edi 1729 dec ecx 1730 jz slt_end_line 1731 1732 ; 1733 ; If we have hit two transparent pixels in a row then we go into 1734 ; the transparent optimised bit 1735 ; 1736 slt_round_again: 1737 rept 64 1738 mov al,[esi] ; ;pipe 1 1739 inc esi ;1 ;pipe 2 1740 test al,al ; ;pipe 1 1741 jnz slt_not_trans;pipe 2 (not pairable in 1) 1742 ;2 1743 inc edi ; ;pipe 1 1744 dec ecx ;3 ;pipe 2 1745 jz slt_end_line ;4 ;pipe 1 (not pairable) 1746 endm ; best case is 4 cycles per iteration 1747 jmp slt_round_again 1748 1749 1750 1751 slt_skip_end_line: 1752 epilogue 1753 next_line 1754 1755 1756 1757 ;***************************************************************************** 1758 ; Draw a single line with no transparent pixels 1759 ; 1760 ; 11/29/95 10:21AM - ST 1761 ; 1762 ; We have to align the destination for cards that dont bankswitch correctly 1763 ; when you write non-aligned data. 1764 ; 1765 ;align 32 1766 Long_Single_Line_Copy: 1767 prologue 1768 1769 rept 3 1770 test edi,3 1771 jz LSLC_aligned 1772 movsb 1773 dec ecx 1774 endm 1775 1776 LSLC_aligned: 1777 mov ebx,ecx 1778 1779 shr ecx,2 1780 rep movsd 1781 and ebx,3 1782 jz proc_out 1783 movsb 1784 dec bl 1785 jz proc_out 1786 movsb 1787 dec bl 1788 jz proc_out 1789 movsb 1790 proc_out: epilogue 1791 next_line 1792 1793 1794 1795 ;***************************************************************************** 1796 ; Draw a single short line with no transparent pixels 1797 ; 1798 ; 11/29/95 10:21AM - ST 1799 ; 1800 ;align 32 1801 Short_Single_Line_Copy: 1802 prologue 1803 cmp ecx,16 1804 jge Long_Single_Line_Copy 1805 mov ebx,ecx 1806 rep movsb 1807 mov ecx,ebx 1808 epilogue 1809 next_line 1810 1811 1812 ;***************************************************************************** 1813 ; Skip a line of source that is all transparent 1814 ; 1815 ; 11/29/95 10:21AM - ST 1816 ; 1817 1818 ;align 32 1819 Single_Line_Skip: 1820 prologue 1821 add esi,ecx 1822 add edi,ecx 1823 epilogue 1824 next_line 1825 1826 1827 1828 ;***************************************************************************** 1829 ; Draw a single line with ghosting 1830 ; 1831 ; 11/29/95 10:21AM - ST 1832 ; 1833 ;align 32 1834 Single_Line_Ghost: 1835 1836 prologue 1837 xor eax,eax 1838 slg_loop: mov al,[esi] 1839 mov ebx,[IsTranslucent] 1840 inc esi 1841 mov bh,[eax+ebx] 1842 cmp bh,-1 1843 jz slg_store_pixel 1844 1845 and ebx,0ff00h 1846 mov al,[edi] 1847 add ebx,[Translucent] 1848 mov al,[eax+ebx] 1849 1850 slg_store_pixel: 1851 mov [edi],al 1852 1853 inc edi 1854 dec ecx 1855 jnz slg_loop 1856 epilogue 1857 next_line 1858 1859 1860 1861 ;***************************************************************************** 1862 ; Draw a single line with transparent pixels and ghosting 1863 ; 1864 ; 11/29/95 10:21AM - ST 1865 ; 1866 ;align 32 1867 Single_Line_Ghost_Trans: 1868 prologue 1869 xor eax,eax 1870 ; cmp ecx,3 1871 ; ja slgt4 1872 1873 slgt_loop: mov al,[esi] 1874 inc esi 1875 test al,al 1876 jz slgt_transparent 1877 1878 slgt_not_transparent: 1879 mov ebx,[IsTranslucent] 1880 mov bh,[eax+ebx] 1881 cmp bh,-1 1882 jz slgt_store_pixel 1883 1884 and ebx,0ff00h 1885 mov al,[edi] 1886 add ebx,[Translucent] 1887 mov al,[eax+ebx] 1888 1889 slgt_store_pixel: 1890 mov [edi],al 1891 inc edi 1892 dec ecx 1893 jnz slgt_loop 1894 epilogue 1895 next_line 1896 1897 1898 ;align 32 1899 1900 slgt_transparent: 1901 inc edi ;1 1902 dec ecx ;2 1903 jz slgt_out ;1 (not pairable) 1904 1905 slgt_round_again: 1906 rept 64 1907 mov al,[esi] ; ;pipe 1 1908 inc esi ;1 ;pipe 2 1909 test al,al ; ;pipe 1 1910 jnz slgt_not_transparent ;pipe 2 (not pairable in 1) 1911 ;2 1912 inc edi ; ;pipe 1 1913 dec ecx ;3 ;pipe 2 1914 jz slgt_out ;4 ;pipe 1 (not pairable) 1915 endm ; best case is 4 cycles per iteration 1916 jmp slgt_round_again 1917 1918 slgt_out: epilogue 1919 next_line 1920 1921 1922 1923 ; 1924 ; Optimised video memory access version 1925 ; 1926 ;align 32 1927 1928 slgt4: push edx 1929 mov edx,[edi] 1930 1931 rept 4 1932 local slgt4_store1 1933 local slgt4_trans1 1934 mov al,[esi] 1935 inc esi 1936 test al,al 1937 jz slgt4_trans1 1938 1939 mov ebx,[IsTranslucent] 1940 mov bh,[eax+ebx] 1941 cmp bh,-1 1942 jz slgt4_store1 1943 1944 and ebx,0ff00h 1945 mov al,dl 1946 add ebx,[Translucent] 1947 mov al,[eax+ebx] 1948 1949 slgt4_store1: mov dl,al 1950 1951 slgt4_trans1: ror edx,8 1952 endm 1953 mov [edi],edx 1954 pop edx 1955 lea edi,[edi+4] 1956 lea ecx,[ecx+0fffffffch] 1957 cmp ecx,3 1958 ja slgt4 1959 test ecx,ecx 1960 jnz slgt_loop 1961 1962 epilogue 1963 next_line 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 ;***************************************************************************** 1975 ; Draw a single line with fading (colour remapping) 1976 ; 1977 ; 11/29/95 10:21AM - ST 1978 ; 1979 ;align 32 1980 1981 Single_Line_Fading: 1982 prologue 1983 xor eax,eax 1984 mov ebx,[FadingTable] 1985 push ebp 1986 mov ebp,[FadingNum] 1987 push ebp 1988 1989 slf_loop: mov al,[esi] 1990 inc esi 1991 1992 mov ebp,[esp] 1993 1994 slf_fade_loop:mov al,[ebx+eax] 1995 dec ebp 1996 jnz slf_fade_loop 1997 1998 mov [edi],al 1999 inc edi 2000 2001 dec ecx 2002 jnz slf_loop 2003 add esp,4 2004 pop ebp 2005 epilogue 2006 next_line 2007 2008 2009 ;***************************************************************************** 2010 ; Draw a single line with transparent pixels and fading (colour remapping) 2011 ; 2012 ; 11/29/95 10:21AM - ST 2013 ; 2014 ;align 32 2015 2016 Single_Line_Fading_Trans: 2017 prologue 2018 xor eax,eax 2019 mov ebx,[FadingTable] 2020 push ebp 2021 mov ebp,[FadingNum] 2022 push ebp 2023 2024 slft_loop: mov al,[esi] 2025 inc esi 2026 test al,al 2027 jz slft_transparent 2028 2029 mov ebp,[esp] 2030 2031 slft_fade_loop: 2032 mov al,[ebx+eax] 2033 dec ebp 2034 jnz slft_fade_loop 2035 2036 mov [edi],al 2037 slft_transparent: 2038 inc edi 2039 2040 dec ecx 2041 jnz slft_loop 2042 add esp,4 2043 pop ebp 2044 epilogue 2045 next_line 2046 2047 2048 2049 2050 2051 ;***************************************************************************** 2052 ; Draw a single line with a single fade level (colour remap) 2053 ; 2054 ; 11/29/95 10:21AM - ST 2055 ; 2056 ;align 32 2057 2058 Single_Line_Single_Fade: 2059 prologue 2060 xor eax,eax 2061 mov ebx,[FadingTable] 2062 2063 slsf_loop: mov al,[esi] 2064 mov al,[ebx+eax] 2065 mov [edi],al 2066 inc esi 2067 inc edi 2068 2069 dec ecx 2070 jnz slsf_loop 2071 epilogue 2072 next_line 2073 2074 2075 2076 ;***************************************************************************** 2077 ; Draw a single line with transparent pixels and a single fade level (colour remap) 2078 ; 2079 ; 11/29/95 10:21AM - ST 2080 ; 2081 ;align 32 2082 2083 Single_Line_Single_Fade_Trans: 2084 prologue 2085 xor eax,eax 2086 mov ebx,[FadingTable] 2087 2088 slsft_loop: mov al,[esi] 2089 inc esi 2090 test al,al 2091 jz slsft_transparent 2092 mov al,[ebx+eax] 2093 mov [edi],al 2094 inc edi 2095 dec ecx 2096 jnz slsft_loop 2097 epilogue 2098 next_line 2099 2100 ;align 32 2101 2102 slsft_transparent: 2103 inc edi 2104 2105 dec ecx 2106 jz slsft_next_line 2107 mov al,[esi] 2108 inc esi 2109 test al,al 2110 jz slsft_transparent 2111 mov al,[ebx+eax] 2112 mov [edi],al 2113 inc edi 2114 dec ecx 2115 jnz slsft_loop 2116 2117 slsft_next_line: 2118 epilogue 2119 next_line 2120 2121 2122 2123 2124 2125 ;***************************************************************************** 2126 ; Draw a single line with ghosting and fading (colour remapping) 2127 ; 2128 ; 11/29/95 10:21AM - ST 2129 ; 2130 ;align 32 2131 2132 Single_Line_Ghost_Fading: 2133 2134 prologue 2135 mov [StashECX],ecx 2136 2137 SLGF_loop: xor eax,eax 2138 mov al,[esi] 2139 mov ebx,[IsTranslucent] 2140 mov bh,[eax+ebx] 2141 cmp bh,-1 2142 jz slgf_do_fading 2143 2144 and ebx,0ff00h 2145 2146 mov al,[edi] 2147 add ebx,[Translucent] 2148 mov al,[ebx+eax] 2149 2150 slgf_do_fading: 2151 mov ebx,[FadingTable] 2152 mov ecx,[FadingNum] 2153 2154 slgf_fade_loop: 2155 mov al,[eax+ebx] 2156 dec ecx 2157 jnz slgf_fade_loop 2158 2159 mov [edi],al 2160 inc esi 2161 inc edi 2162 2163 dec [StashECX] 2164 jnz SLGF_loop 2165 epilogue 2166 next_line 2167 2168 2169 ;***************************************************************************** 2170 ; Draw a single line with transparent pixels, ghosting and fading 2171 ; 2172 ; 11/29/95 10:21AM - ST 2173 ; 2174 ;align 32 2175 2176 Single_Line_Ghost_Fading_Trans: 2177 prologue 2178 mov [StashECX],ecx 2179 xor eax,eax 2180 2181 ; cmp ecx,3 2182 ; ja slgft4 2183 2184 SLGFT_loop: mov al,[esi] 2185 inc esi 2186 test al,al 2187 jz slgft_trans_pixel 2188 mov ebx,[IsTranslucent] 2189 mov bh,[eax+ebx] 2190 cmp bh,-1 2191 jz slgft_do_fading 2192 2193 and ebx,0ff00h 2194 2195 mov al,[edi] 2196 add ebx,[Translucent] 2197 mov al,[ebx+eax] 2198 2199 slgft_do_fading: 2200 mov ebx,[FadingTable] 2201 mov ecx,[FadingNum] 2202 2203 slgft_fade_loop: 2204 mov al,[eax+ebx] 2205 dec ecx 2206 jnz slgft_fade_loop 2207 2208 mov [edi],al 2209 slgft_trans_pixel: 2210 inc edi 2211 2212 dec [StashECX] 2213 jnz SLGFT_loop 2214 epilogue 2215 next_line 2216 2217 2218 ;align 32 2219 2220 slgft4: push edx 2221 mov edx,[edi] 2222 2223 rept 4 2224 local slgft4_fade 2225 local slgft4_fade_lp 2226 local slgft4_trans 2227 mov al,[esi] 2228 inc esi 2229 test al,al 2230 jz slgft4_trans 2231 mov ebx,[IsTranslucent] 2232 mov bh,[eax+ebx] 2233 cmp bh,-1 2234 jz slgft4_fade 2235 2236 and ebx,0ff00h 2237 2238 mov al,dl 2239 add ebx,[Translucent] 2240 mov al,[ebx+eax] 2241 2242 slgft4_fade: mov ebx,[FadingTable] 2243 mov ecx,[FadingNum] 2244 2245 slgft4_fade_lp: mov al,[eax+ebx] 2246 dec ecx 2247 jnz slgft4_fade_lp 2248 2249 mov dl,al 2250 2251 slgft4_trans: ror edx,8 2252 endm 2253 mov [edi],edx 2254 pop edx 2255 lea edi,[edi+4] 2256 sub [StashECX],4 2257 jz slgft4_out 2258 cmp [StashECX],3 2259 ja slgft4 2260 jmp SLGFT_loop 2261 2262 slgft4_out: epilogue 2263 next_line 2264 2265 2266 ;***************************************************************************** 2267 ; Draw a single line with predator effect 2268 ; 2269 ; 11/29/95 10:21AM - ST 2270 ; 2271 ;align 32 2272 2273 Single_Line_Predator: 2274 2275 prologue 2276 2277 slp_loop: mov al,[esi] 2278 2279 mov ebx,[BFPartialCount] 2280 add ebx,[BFPartialPred] 2281 or bh,bh 2282 jnz slp_get_pred 2283 2284 mov [BFPartialCount] , ebx 2285 jmp slp_skip_pixel 2286 2287 slp_get_pred: xor bh , bh 2288 mov eax,[BFPredOffset] 2289 mov [BFPartialCount] , ebx 2290 add byte ptr [BFPredOffset],2 2291 mov eax, dword ptr [BFPredTable+eax] 2292 and byte ptr [BFPredOffset],PRED_MASK 2293 and eax,0ffffh 2294 2295 mov al,[edi+eax] 2296 mov [edi],al 2297 2298 slp_skip_pixel: 2299 inc esi 2300 inc edi 2301 2302 dec ecx 2303 jnz slp_loop 2304 2305 epilogue 2306 next_line 2307 2308 2309 2310 2311 ;***************************************************************************** 2312 ; Draw a single line with transparent pixels and predator effect 2313 ; 2314 ; 11/29/95 10:21AM - ST 2315 ; 2316 ;align 32 2317 2318 Single_Line_Predator_Trans: 2319 2320 prologue 2321 2322 slpt_loop: mov al,[esi] 2323 inc esi 2324 test al,al 2325 jz slpt_skip_pixel 2326 2327 mov ebx,[BFPartialCount] 2328 add ebx,[BFPartialPred] 2329 or bh,bh 2330 jnz slpt_get_pred 2331 2332 mov [BFPartialCount] , ebx 2333 jmp slpt_skip_pixel 2334 2335 slpt_get_pred:xor bh , bh 2336 mov eax,[BFPredOffset] 2337 mov [BFPartialCount] , ebx 2338 add byte ptr [BFPredOffset],2 2339 mov eax,dword ptr [BFPredTable+eax] 2340 and byte ptr [BFPredOffset ] , PRED_MASK 2341 and eax,0ffffh 2342 2343 mov al,[edi+eax] 2344 mov [edi],al 2345 2346 slpt_skip_pixel: 2347 inc edi 2348 2349 dec ecx 2350 jnz slpt_loop 2351 2352 epilogue 2353 next_line 2354 2355 2356 ;***************************************************************************** 2357 ; Draw a single line with predator and ghosting 2358 ; 2359 ; 11/29/95 10:21AM - ST 2360 ; 2361 ;align 32 2362 2363 Single_Line_Predator_Ghost: 2364 2365 prologue 2366 2367 slpg_loop: mov al,[esi] 2368 mov ebx,[BFPartialCount] 2369 add ebx,[BFPartialPred] 2370 test bh,bh 2371 jnz slpg_get_pred ; is this a predator pixel? 2372 2373 mov [BFPartialCount],ebx 2374 jmp slpg_check_ghost 2375 2376 slpg_get_pred: 2377 xor bh,bh 2378 mov eax,[BFPredOffset] 2379 mov [BFPartialCount],ebx 2380 add byte ptr [BFPredOffset],2 2381 mov eax,dword ptr [BFPredTable+eax ] 2382 and byte ptr [BFPredOffset],PRED_MASK 2383 and eax,0ffffh 2384 mov al,[edi+eax] 2385 2386 slpg_check_ghost: 2387 mov ebx,[IsTranslucent] 2388 mov bh,[ebx+eax] 2389 cmp bh,0ffh 2390 je slpg_store_pixel 2391 2392 xor eax,eax 2393 and ebx,0FF00h 2394 2395 mov al,[edi] 2396 add ebx,[Translucent] 2397 2398 mov al,[ebx+eax] 2399 2400 slpg_store_pixel: 2401 mov [edi],al 2402 inc esi 2403 inc edi 2404 2405 dec ecx 2406 jnz slpg_loop 2407 2408 epilogue 2409 next_line 2410 2411 2412 2413 ;***************************************************************************** 2414 ; Draw a single line with transparent pixels, predator and ghosting 2415 ; 2416 ; 11/29/95 10:21AM - ST 2417 ; 2418 ;align 32 2419 2420 Single_Line_Predator_Ghost_Trans: 2421 prologue 2422 2423 slpgt_loop: mov al,[esi] 2424 inc esi 2425 test al,al 2426 jz slpgt_transparent 2427 2428 mov ebx,[BFPartialCount] 2429 add ebx,[BFPartialPred] 2430 test bh,bh 2431 jnz slpgt_get_pred ; is this a predator pixel? 2432 2433 mov [BFPartialCount],ebx 2434 jmp slpgt_check_ghost 2435 2436 slpgt_get_pred: 2437 xor bh,bh 2438 mov eax,[BFPredOffset] 2439 mov [BFPartialCount],ebx 2440 add byte ptr [BFPredOffset],2 2441 mov eax,dword ptr [BFPredTable+eax ] 2442 and byte ptr [BFPredOffset],PRED_MASK 2443 and eax,0ffffh 2444 mov al,[edi+eax] 2445 2446 slpgt_check_ghost: 2447 mov ebx,[IsTranslucent] 2448 mov bh,[ebx+eax] 2449 cmp bh,0ffh 2450 je slpgt_store_pixel 2451 2452 xor eax,eax 2453 and ebx,0FF00h 2454 2455 mov al,[edi] 2456 add ebx,[Translucent] 2457 2458 mov al,[ebx+eax] 2459 2460 slpgt_store_pixel: 2461 mov [edi],al 2462 slpgt_transparent: 2463 inc edi 2464 2465 dec ecx 2466 jnz slpgt_loop 2467 2468 pop ecx 2469 epilogue 2470 next_line 2471 2472 2473 ;***************************************************************************** 2474 ; Draw a single line with predator and fading 2475 ; 2476 ; 11/29/95 10:21AM - ST 2477 ; 2478 ;align 32 2479 2480 Single_Line_Predator_Fading: 2481 2482 prologue 2483 mov [StashECX],ecx 2484 2485 slpf_loop: mov al,[esi] 2486 mov ebx,[BFPartialCount] 2487 inc esi 2488 add ebx,[BFPartialPred] 2489 test bh,bh 2490 jnz slpf_get_pred 2491 2492 mov [BFPartialCount],ebx 2493 jmp slpf_do_fading 2494 2495 slpf_get_pred:xor bh,bh 2496 mov eax,[BFPredOffset] 2497 mov [BFPartialCount],ebx 2498 and byte ptr [BFPredOffset],2 2499 mov eax,dword ptr [BFPredTable+eax] 2500 and byte ptr [BFPredOffset],PRED_MASK 2501 2502 and eax,0ffffh 2503 mov al,[eax+edi] 2504 2505 slpf_do_fading: 2506 and eax,255 2507 mov ebx,[FadingTable] 2508 mov ecx,[FadingNum] 2509 2510 slpf_fade_loop: 2511 mov al,[eax+ebx] 2512 dec ecx 2513 jnz slpf_fade_loop 2514 2515 mov [edi],al 2516 inc edi 2517 2518 dec [StashECX] 2519 jnz slpf_loop 2520 2521 epilogue 2522 next_line 2523 2524 2525 2526 ;***************************************************************************** 2527 ; Draw a single line with transparent pixels, fading and predator 2528 ; 2529 ; 11/29/95 10:21AM - ST 2530 ; 2531 ;align 32 2532 2533 Single_Line_Predator_Fading_Trans: 2534 prologue 2535 mov [StashECX],ecx 2536 2537 slpft_loop: mov al,[esi] 2538 inc esi 2539 test al,al 2540 jz slpft_transparent 2541 mov ebx,[BFPartialCount] 2542 add ebx,[BFPartialPred] 2543 test bh,bh 2544 jnz slpft_get_pred 2545 2546 mov [BFPartialCount],ebx 2547 jmp slpft_do_fading 2548 2549 slpft_get_pred: 2550 xor bh,bh 2551 mov eax,[BFPredOffset] 2552 mov [BFPartialCount],ebx 2553 and byte ptr [BFPredOffset],2 2554 mov eax,dword ptr [BFPredTable+eax] 2555 and byte ptr [BFPredOffset],PRED_MASK 2556 2557 and eax,0ffffh 2558 mov al,[eax+edi] 2559 2560 slpft_do_fading: 2561 and eax,255 2562 mov ebx,[FadingTable] 2563 mov ecx,[FadingNum] 2564 2565 slpft_fade_loop: 2566 mov al,[eax+ebx] 2567 dec ecx 2568 jnz slpft_fade_loop 2569 2570 mov [edi],al 2571 slpft_transparent: 2572 inc edi 2573 2574 dec [StashECX] 2575 jnz slpft_loop 2576 2577 epilogue 2578 next_line 2579 2580 2581 2582 ;***************************************************************************** 2583 ; Draw a single line with predator, ghosting and fading 2584 ; 2585 ; 11/29/95 10:21AM - ST 2586 ; 2587 ;align 32 2588 2589 Single_Line_Predator_Ghost_Fading: 2590 2591 prologue 2592 mov [StashECX],ecx 2593 2594 slpgf_loop: mov al,[esi] 2595 mov ebx,[BFPartialCount] 2596 inc esi 2597 add ebx,[BFPartialPred] 2598 test bh , bh 2599 jnz slpgf_get_pred ; is this a predator pixel? 2600 2601 mov [BFPartialCount],ebx 2602 jmp slpgf_check_ghost 2603 2604 slpgf_get_pred: 2605 xor bh,bh 2606 mov eax,[BFPredOffset] 2607 mov [BFPartialCount],ebx 2608 add byte ptr [BFPredOffset],2 2609 mov eax,dword ptr [BFPredTable+eax] 2610 and byte ptr [BFPredOffset],PRED_MASK 2611 and eax,0ffffh 2612 2613 mov al,[edi+eax] 2614 2615 slpgf_check_ghost: 2616 and eax,255 2617 mov ebx,[IsTranslucent] 2618 mov bh,[ebx+eax] 2619 cmp bh,0ffh 2620 je slpgf_do_fading 2621 2622 and ebx , 0FF00h 2623 2624 mov al,[edi] 2625 add ebx,[Translucent] 2626 2627 mov al,[ebx+eax] 2628 2629 slpgf_do_fading: 2630 xor eax,eax 2631 mov ebx,[FadingTable] 2632 mov ecx,[FadingNum] 2633 2634 slpgf_fade_loop: 2635 mov al,[ebx+eax] 2636 dec ecx 2637 jnz slpgf_fade_loop 2638 2639 slpgf_store_pixel: 2640 mov [edi],al 2641 inc edi 2642 2643 dec [StashECX] 2644 jnz slpgf_loop 2645 2646 epilogue 2647 next_line 2648 2649 2650 2651 ;***************************************************************************** 2652 ; Draw a single line with transparent pixels, predator, ghosting and fading 2653 ; 2654 ; 11/29/95 10:21AM - ST 2655 ; 2656 ;align 32 2657 2658 Single_Line_Predator_Ghost_Fading_Trans: 2659 2660 prologue 2661 mov [StashECX],ecx 2662 2663 slpgft_loop: mov al,[esi] 2664 inc esi 2665 test al,al 2666 jz slpgft_transparent 2667 2668 mov ebx,[BFPartialCount] 2669 add ebx,[BFPartialPred] 2670 test bh , bh 2671 jnz slpgft_get_pred ; is this a predator pixel? 2672 2673 mov [BFPartialCount],ebx 2674 jmp slpgft_check_ghost 2675 2676 slpgft_get_pred: 2677 xor bh,bh 2678 mov eax,[BFPredOffset] 2679 mov [BFPartialCount],ebx 2680 add byte ptr [BFPredOffset],2 2681 mov eax,dword ptr [BFPredTable+eax] 2682 and byte ptr [BFPredOffset],PRED_MASK 2683 and eax,0ffffh 2684 2685 mov al,[edi+eax] 2686 2687 slpgft_check_ghost: 2688 and eax,255 2689 mov ebx,[IsTranslucent] 2690 mov bh,[ebx+eax] 2691 cmp bh,0ffh 2692 je slpgft_do_fading 2693 2694 and ebx , 0FF00h 2695 2696 mov al,[edi] 2697 add ebx,[Translucent] 2698 2699 mov al,[ebx+eax] 2700 2701 slpgft_do_fading: 2702 xor eax,eax 2703 mov ebx,[FadingTable] 2704 mov ecx,[FadingNum] 2705 2706 slpgft_fade_loop: 2707 mov al,[ebx+eax] 2708 dec ecx 2709 jnz slpgft_fade_loop 2710 2711 slpgft_store_pixel: 2712 mov [edi],al 2713 slpgft_transparent: 2714 inc edi 2715 2716 dec [StashECX] 2717 jnz slpgft_loop 2718 2719 epilogue 2720 next_line 2721 2722 2723 2724 2725 ; ends ;end of strict alignment segment 2726 2727 ; codeseg 2728 2729 2730 2731 ;extern BF_Trans:near 2732 2733 BF_Trans: 2734 2735 prologue 2736 ; calc the code location to skip to 10 bytes per REPT below!!!! 2737 mov ecx , eax 2738 and ecx , 01fh 2739 lea ecx , [ ecx + ecx * 4 ] ; quick multiply by 5 2740 neg ecx 2741 shr eax , 5 2742 lea ecx , [ trans_reference + ecx * 2 ] ; next multiply by 2 2743 mov [ loop_cnt ] , eax 2744 mov [ jmp_loc ] , ecx 2745 2746 trans_loop: 2747 mov ecx , [ loop_cnt ] 2748 jmp [ jmp_loc ] 2749 2750 ; the following code should NOT be changed without changing the calculation 2751 ; above!!!!!! 2752 2753 trans_line: 2754 2755 REPT 32 2756 local trans_pixel 2757 mov bl , [ esi ] 2758 inc esi 2759 test bl , bl 2760 jz trans_pixel 2761 2762 mov [ edi ] , bl 2763 2764 trans_pixel: 2765 inc edi 2766 ENDM 2767 2768 trans_reference: 2769 dec ecx 2770 jge trans_line 2771 2772 add esi , [ scr_adjust_width ] 2773 add edi , [ dest_adjust_width ] 2774 dec edx 2775 jnz trans_loop 2776 epilogue 2777 2778 ret 2779 2780 ;******************************************************************** 2781 ;******************************************************************** 2782 2783 ;extern BF_Ghost:near 2784 BF_Ghost: 2785 2786 prologue 2787 mov ebx , eax ; width 2788 2789 ; NOTE: the below calculation assumes a group of instructions is 2790 ; less than 256 bytes 2791 2792 ; get length of the 32 groups of instructions 2793 2794 lea ecx, [offset ghost_reference] 2795 sub ecx, [offset ghost_line] 2796 2797 shr ebx , 5 ; width / 32 2798 shr ecx , 5 ; length of instructions / 32 2799 and eax , 01fh ; mod of width / 32 2800 mul cl ; calc offset to start of group 2801 neg eax ; inverse of width 2802 mov [ loop_cnt ] , ebx ; save width / 32 2803 lea ecx , [ ghost_reference + eax ] 2804 mov eax , 0 2805 mov [ jmp_loc ] , ecx 2806 2807 ghost_loop: 2808 mov ecx , [ loop_cnt ] 2809 jmp [ jmp_loc ] 2810 2811 ghost_line: 2812 2813 REPT 32 2814 local store_pixel 2815 mov al , [ esi ] 2816 inc esi 2817 mov ebx , [ IsTranslucent ] ; is it a translucent color? 2818 mov bh , BYTE PTR [ ebx + eax ] 2819 cmp bh , 0ffh 2820 je store_pixel 2821 2822 and ebx , 0FF00h ; clear all of ebx except bh 2823 ; we have the index to the translation table 2824 ; ((trans_colour * 256) + dest colour) 2825 mov al , [ edi ] ; mov pixel at destination to al 2826 add ebx , [ Translucent ] ; get the ptr to it! 2827 ; Add the (trans_color * 256) of the translation equ. 2828 mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al 2829 2830 store_pixel: 2831 mov [ edi ] , al 2832 inc edi 2833 2834 ENDM 2835 2836 ghost_reference: 2837 dec ecx 2838 jge ghost_line 2839 2840 add esi , [ scr_adjust_width ] 2841 add edi , [ dest_adjust_width ] 2842 dec edx 2843 jnz ghost_loop 2844 2845 epilogue 2846 ret 2847 2848 2849 ;******************************************************************** 2850 ;******************************************************************** 2851 2852 ;extern BF_Ghost_Trans:near 2853 BF_Ghost_Trans: 2854 2855 prologue 2856 mov ebx , eax ; width 2857 2858 ; NOTE: the below calculation assumes a group of instructions is 2859 ; less than 256 bytes 2860 2861 ; get length of the 32 groups of instructions 2862 2863 lea ecx , [ offset ghost_t_reference ] 2864 sub ecx, [ offset ghost_t_line ] 2865 2866 shr ebx , 5 ; width / 32 2867 shr ecx , 5 ; length of instructions / 32 2868 and eax , 01fh ; mod of width / 32 2869 mul cl ; calc offset to start of group 2870 neg eax ; inverse of width 2871 mov [ loop_cnt ] , ebx ; save width / 32 2872 lea ecx , [ ghost_t_reference + eax ] 2873 mov eax , 0 2874 mov [ jmp_loc ] , ecx 2875 2876 ghost_t_loop: 2877 mov ecx , [ loop_cnt ] 2878 jmp [ jmp_loc ] 2879 2880 ghost_t_line: 2881 2882 REPT 32 2883 local transp_pixel 2884 local store_pixel 2885 mov al , [ esi ] 2886 inc esi 2887 test al , al 2888 jz transp_pixel 2889 2890 mov ebx , [ IsTranslucent ] ; is it a translucent color? 2891 mov bh , BYTE PTR [ ebx + eax ] 2892 cmp bh , 0ffh 2893 je store_pixel 2894 2895 and ebx , 0FF00h ; clear all of ebx except bh 2896 ; we have the index to the translation table 2897 ; ((trans_colour * 256) + dest colour) 2898 mov al , [ edi ] ; mov pixel at destination to al 2899 add ebx , [ Translucent ] ; get the ptr to it! 2900 ; Add the (trans_color * 256) of the translation equ. 2901 mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al 2902 2903 store_pixel: 2904 mov [ edi ] , al 2905 2906 transp_pixel: 2907 inc edi 2908 2909 ENDM 2910 2911 ghost_t_reference: 2912 dec ecx 2913 jge ghost_t_line 2914 2915 add esi , [ scr_adjust_width ] 2916 add edi , [ dest_adjust_width ] 2917 dec edx 2918 jnz ghost_t_loop 2919 2920 epilogue 2921 ret 2922 2923 2924 ;******************************************************************** 2925 ;******************************************************************** 2926 2927 ;extern BF_Fading:near 2928 BF_Fading: 2929 2930 prologue 2931 mov ebx , eax ; width 2932 2933 ; NOTE: the below calculation assumes a group of instructions is 2934 ; less than 256 bytes 2935 2936 ; get length of the 32 groups of instructions 2937 2938 lea ecx , [ offset fading_reference ] 2939 sub ecx, [ offset fading_line ] 2940 2941 shr ebx , 5 ; width / 32 2942 shr ecx , 5 ; length of instructions / 32 2943 and eax , 01fh ; mod of width / 32 2944 mul cl ; calc offset to start of group 2945 neg eax ; inverse of width 2946 mov [ loop_cnt ] , ebx ; save width / 32 2947 lea ecx , [ fading_reference + eax ] 2948 mov eax , 0 2949 mov [ jmp_loc ] , ecx 2950 2951 fading_loop: 2952 mov ecx , [ loop_cnt ] 2953 mov [ StashECX ] , ecx ; preserve ecx for later 2954 mov ebx , [ FadingTable ] ; run color through fading table 2955 jmp [ jmp_loc ] 2956 2957 fading_line_begin: 2958 mov [ StashECX ] , ecx ; preserve ecx for later 2959 2960 fading_line: 2961 2962 REPT 32 2963 local fade_loop 2964 mov al , [ esi ] 2965 inc esi 2966 mov ecx , [ FadingNum ] 2967 2968 fade_loop: 2969 mov al, byte ptr [ebx + eax] 2970 dec ecx 2971 jnz fade_loop 2972 2973 mov [ edi ] , al 2974 inc edi 2975 2976 ENDM 2977 2978 fading_reference: 2979 mov ecx , [ StashECX ] ; restore ecx for main draw loop 2980 dec ecx 2981 jge fading_line_begin 2982 2983 add esi , [ scr_adjust_width ] 2984 add edi , [ dest_adjust_width ] 2985 dec edx 2986 jnz fading_loop 2987 2988 epilogue 2989 ret 2990 2991 2992 ;******************************************************************** 2993 ;******************************************************************** 2994 2995 ;extern BF_Fading_Trans:near 2996 BF_Fading_Trans: 2997 2998 prologue 2999 mov ebx , eax ; width 3000 3001 ; NOTE: the below calculation assumes a group of instructions is 3002 ; less than 256 bytes 3003 3004 ; get length of the 32 groups of instructions 3005 3006 lea ecx , [ offset fading_t_reference ] 3007 sub ecx, [ offset fading_t_line ] 3008 3009 shr ebx , 5 ; width / 32 3010 shr ecx , 5 ; length of instructions / 32 3011 and eax , 01fh ; mod of width / 32 3012 mul cl ; calc offset to start of group 3013 neg eax ; inverse of width 3014 mov [ loop_cnt ] , ebx ; save width / 32 3015 lea ecx , [ fading_t_reference + eax ] 3016 mov eax , 0 3017 mov [ jmp_loc ] , ecx 3018 3019 fading_t_loop: 3020 mov ecx , [ loop_cnt ] 3021 mov [ StashECX ] , ecx ; preserve ecx for later 3022 mov ebx , [ FadingTable ] ; run color through fading table 3023 jmp [ jmp_loc ] 3024 3025 fading_t_line_begin: 3026 mov [ StashECX ] , ecx ; preserve ecx for later 3027 3028 fading_t_line: 3029 3030 REPT 32 3031 local transp_pixel 3032 local fade_loop 3033 mov al , [ esi ] 3034 inc esi 3035 test al , al 3036 jz transp_pixel 3037 3038 mov ecx , [ FadingNum ] 3039 3040 fade_loop: 3041 mov al, byte ptr [ebx + eax] 3042 dec ecx 3043 jnz fade_loop 3044 3045 mov [ edi ] , al 3046 3047 transp_pixel: 3048 inc edi 3049 3050 ENDM 3051 3052 fading_t_reference: 3053 mov ecx , [ StashECX ] ; restore ecx for main draw loop 3054 dec ecx 3055 jge fading_t_line_begin 3056 3057 add esi , [ scr_adjust_width ] 3058 add edi , [ dest_adjust_width ] 3059 dec edx 3060 jnz fading_t_loop 3061 3062 epilogue 3063 ret 3064 3065 3066 ;******************************************************************** 3067 ;******************************************************************** 3068 3069 ;extern BF_Ghost_Fading:near 3070 BF_Ghost_Fading: 3071 3072 prologue 3073 mov ebx , eax ; width 3074 3075 ; NOTE: the below calculation assumes a group of instructions is 3076 ; less than 256 bytes 3077 3078 ; get length of the 32 groups of instructions 3079 3080 lea ecx , [ offset ghost_f_reference ] 3081 sub ecx, [ offset ghost_f_line ] 3082 3083 shr ebx , 5 ; width / 32 3084 shr ecx , 5 ; length of instructions / 32 3085 and eax , 01fh ; mod of width / 32 3086 mul cl ; calc offset to start of group 3087 neg eax ; inverse of width 3088 mov [ loop_cnt ] , ebx ; save width / 32 3089 lea ecx , [ ghost_f_reference + eax ] 3090 mov eax , 0 3091 mov [ jmp_loc ] , ecx 3092 3093 ghost_f_loop: 3094 mov ecx , [ loop_cnt ] 3095 mov [ StashECX ] , ecx ; preserve ecx for later 3096 jmp [ jmp_loc ] 3097 3098 ghost_f_line_begin: 3099 mov [ StashECX ] , ecx ; preserve ecx for later 3100 3101 ghost_f_line: 3102 3103 REPT 32 3104 local store_pixel 3105 local do_fading 3106 local fade_loop 3107 mov al , [ esi ] 3108 inc esi 3109 mov ebx , [ IsTranslucent ] ; is it a lucent color? 3110 mov bh , byte ptr [ ebx + eax ] 3111 cmp bh , 0ffh 3112 je do_fading 3113 3114 and ebx , 0FF00h ; clear all of ebx except bh 3115 ; we have the index to the lation table 3116 ; ((_colour * 256) + dest colour) 3117 mov al , [ edi ] ; mov pixel at destination to al 3118 add ebx , [ Translucent ] ; get the ptr to it! 3119 ; Add the (_color * 256) of the lation equ. 3120 mov al , byte ptr [ ebx + eax ] ; get new pixel in al 3121 ; DRD jmp store_pixel 3122 3123 do_fading: 3124 mov ebx , [ FadingTable ] ; run color through fading table 3125 mov ecx , [ FadingNum ] 3126 3127 fade_loop: 3128 mov al, byte ptr [ebx + eax] 3129 dec ecx 3130 jnz fade_loop 3131 3132 store_pixel: 3133 mov [ edi ] , al 3134 inc edi 3135 3136 ENDM 3137 3138 ghost_f_reference: 3139 mov ecx , [ StashECX ] ; restore ecx for main draw loop 3140 dec ecx 3141 jge ghost_f_line_begin 3142 3143 add esi , [ scr_adjust_width ] 3144 add edi , [ dest_adjust_width ] 3145 dec edx 3146 jnz ghost_f_loop 3147 3148 epilogue 3149 ret 3150 3151 3152 ;******************************************************************** 3153 ;******************************************************************** 3154 3155 ;extern BF_Ghost_Fading_Trans:near 3156 BF_Ghost_Fading_Trans: 3157 3158 prologue 3159 mov ebx , eax ; width 3160 3161 ; NOTE: the below calculation assumes a group of instructions is 3162 ; less than 256 bytes 3163 3164 ; get length of the 32 groups of instructions 3165 3166 lea ecx , [ offset ghost_f_t_reference ] 3167 sub ecx, [ offset ghost_f_t_line ] 3168 3169 shr ebx , 5 ; width / 32 3170 shr ecx , 5 ; length of instructions / 32 3171 and eax , 01fh ; mod of width / 32 3172 mul cl ; calc offset to start of group 3173 neg eax ; inverse of width 3174 mov [ loop_cnt ] , ebx ; save width / 32 3175 lea ecx , [ ghost_f_t_reference + eax ] 3176 mov eax , 0 3177 mov [ jmp_loc ] , ecx 3178 3179 ghost_f_t_loop: 3180 mov ecx , [ loop_cnt ] 3181 mov [ StashECX ] , ecx ; preserve ecx for later 3182 jmp [ jmp_loc ] 3183 3184 ghost_f_t_line_begin: 3185 mov [ StashECX ] , ecx ; preserve ecx for later 3186 3187 ghost_f_t_line: 3188 3189 REPT 32 3190 local transp_pixel 3191 local store_pixel 3192 local do_fading 3193 local fade_loop 3194 mov al , [ esi ] 3195 inc esi 3196 test al , al 3197 jz transp_pixel 3198 3199 mov ebx , [ IsTranslucent ] ; is it a translucent color? 3200 mov bh , byte ptr [ ebx + eax ] 3201 cmp bh , 0ffh 3202 je do_fading 3203 3204 and ebx , 0FF00h ; clear all of ebx except bh 3205 ; we have the index to the translation table 3206 ; ((trans_colour * 256) + dest colour) 3207 mov al , [ edi ] ; mov pixel at destination to al 3208 add ebx , [ Translucent ] ; get the ptr to it! 3209 ; Add the (trans_color * 256) of the translation equ. 3210 mov al , byte ptr [ ebx + eax ] ; get new pixel in al 3211 ; DRD jmp store_pixel 3212 3213 do_fading: 3214 mov ebx , [ FadingTable ] ; run color through fading table 3215 mov ecx , [ FadingNum ] 3216 3217 fade_loop: 3218 mov al, byte ptr [ebx + eax] 3219 dec ecx 3220 jnz fade_loop 3221 3222 store_pixel: 3223 mov [ edi ] , al 3224 3225 transp_pixel: 3226 inc edi 3227 3228 ENDM 3229 3230 ghost_f_t_reference: 3231 mov ecx , [ StashECX ] ; restore ecx for main draw loop 3232 dec ecx 3233 jge ghost_f_t_line_begin 3234 3235 add esi , [ scr_adjust_width ] 3236 add edi , [ dest_adjust_width ] 3237 dec edx 3238 jnz ghost_f_t_loop 3239 3240 epilogue 3241 ret 3242 3243 3244 ;******************************************************************** 3245 ;******************************************************************** 3246 3247 ;extern BF_Predator:near 3248 BF_Predator: 3249 3250 prologue 3251 mov ebx , eax ; width 3252 3253 ; NOTE: the below calculation assumes a group of instructions is 3254 ; less than 256 bytes 3255 3256 ; get length of the 32 groups of instructions 3257 3258 lea ecx , [ offset predator_reference ] 3259 sub ecx, [offset predator_line ] 3260 3261 shr ebx , 5 ; width / 32 3262 shr ecx , 5 ; length of instructions / 32 3263 and eax , 01fh ; mod of width / 32 3264 mul cl ; calc offset to start of group 3265 neg eax ; inverse of width 3266 mov [ loop_cnt ] , ebx ; save width / 32 3267 lea ecx , [ predator_reference + eax ] 3268 mov eax , 0 3269 mov [ jmp_loc ] , ecx 3270 3271 predator_loop: 3272 mov ecx , [ loop_cnt ] 3273 jmp [ jmp_loc ] 3274 3275 predator_line: 3276 3277 REPT 32 3278 local get_pred 3279 local skip_pixel 3280 mov al , [ esi ] 3281 inc esi 3282 mov ebx , [ BFPartialCount ] 3283 add ebx , [ BFPartialPred ] 3284 or bh , bh 3285 jnz get_pred ; is this a predator pixel? 3286 3287 mov [ BFPartialCount ] , ebx 3288 jmp skip_pixel 3289 3290 get_pred: 3291 xor bh , bh 3292 mov eax, [ BFPredOffset ] 3293 mov [ BFPartialCount ] , ebx 3294 add BYTE PTR [ BFPredOffset ] , 2 3295 movzx eax , WORD PTR [ BFPredTable + eax ] 3296 and BYTE PTR [ BFPredOffset ] , PRED_MASK 3297 ; pick up a color offset a pseudo- 3298 ; random amount from the current 3299 movzx eax , BYTE PTR [ edi + eax ] ; viewport address 3300 3301 ; xor bh , bh 3302 ; mov eax , [ BFPredValue ] ; pick up a color offset a pseudo- 3303 ; ; random amount from the current 3304 ; mov [ BFPartialCount ] , ebx 3305 ; mov al , [ edi + eax ] ; viewport address 3306 3307 mov [ edi ] , al 3308 3309 skip_pixel: 3310 inc edi 3311 3312 ENDM 3313 3314 predator_reference: 3315 dec ecx 3316 jge predator_line 3317 3318 add esi , [ scr_adjust_width ] 3319 add edi , [ dest_adjust_width ] 3320 dec edx 3321 jnz predator_loop 3322 3323 epilogue 3324 ret 3325 3326 3327 ;******************************************************************** 3328 ;******************************************************************** 3329 3330 ;extern BF_Predator_Trans:near 3331 BF_Predator_Trans: 3332 3333 prologue 3334 mov ebx , eax ; width 3335 3336 ; NOTE: the below calculation assumes a group of instructions is 3337 ; less than 256 bytes 3338 3339 ; get length of the 32 groups of instructions 3340 3341 lea ecx , [ offset predator_t_reference ] 3342 sub ecx, [ offset predator_t_line ] 3343 3344 shr ebx , 5 ; width / 32 3345 shr ecx , 5 ; length of instructions / 32 3346 and eax , 01fh ; mod of width / 32 3347 mul cl ; calc offset to start of group 3348 neg eax ; inverse of width 3349 mov [ loop_cnt ] , ebx ; save width / 32 3350 lea ecx , [ predator_t_reference + eax ] 3351 mov eax , 0 3352 mov [ jmp_loc ] , ecx 3353 3354 predator_t_loop: 3355 mov ecx , [ loop_cnt ] 3356 jmp [ jmp_loc ] 3357 3358 predator_t_line: 3359 3360 REPT 32 3361 local trans_pixel 3362 local get_pred 3363 local store_pixel 3364 mov al , [ esi ] 3365 inc esi 3366 test al , al 3367 jz trans_pixel 3368 3369 mov ebx , [ BFPartialCount ] 3370 add ebx , [ BFPartialPred ] 3371 or bh , bh 3372 jnz get_pred ; is this a predator pixel? 3373 3374 mov [ BFPartialCount ] , ebx 3375 jmp store_pixel 3376 3377 get_pred: 3378 xor bh , bh 3379 mov eax, [ BFPredOffset ] 3380 mov [ BFPartialCount ] , ebx 3381 add BYTE PTR [ BFPredOffset ] , 2 3382 movzx eax , WORD PTR [ BFPredTable + eax ] 3383 and BYTE PTR [ BFPredOffset ] , PRED_MASK 3384 ; pick up a color offset a pseudo- 3385 ; random amount from the current 3386 movzx eax , BYTE PTR [ edi + eax ] ; viewport address 3387 3388 store_pixel: 3389 mov [ edi ] , al 3390 3391 trans_pixel: 3392 inc edi 3393 3394 ENDM 3395 3396 predator_t_reference: 3397 dec ecx 3398 jge predator_t_line 3399 3400 add esi , [ scr_adjust_width ] 3401 add edi , [ dest_adjust_width ] 3402 dec edx 3403 jnz predator_t_loop 3404 3405 epilogue 3406 ret 3407 3408 3409 ;******************************************************************** 3410 ;******************************************************************** 3411 3412 ;extern BF_Predator_Ghost:near 3413 BF_Predator_Ghost: 3414 3415 prologue 3416 mov ebx , eax ; width 3417 3418 ; NOTE: the below calculation assumes a group of instructions is 3419 ; less than 256 bytes 3420 3421 ; get length of the 32 groups of instructions 3422 3423 lea ecx , [ offset predator_g_reference ] 3424 sub ecx, [ offset predator_g_line ] 3425 3426 shr ebx , 5 ; width / 32 3427 shr ecx , 5 ; length of instructions / 32 3428 and eax , 01fh ; mod of width / 32 3429 mul cl ; calc offset to start of group 3430 neg eax ; inverse of width 3431 mov [ loop_cnt ] , ebx ; save width / 32 3432 lea ecx , [ predator_g_reference + eax ] 3433 mov eax , 0 3434 mov [ jmp_loc ] , ecx 3435 3436 predator_g_loop: 3437 mov ecx , [ loop_cnt ] 3438 jmp [ jmp_loc ] 3439 3440 predator_g_line: 3441 3442 REPT 32 3443 local get_pred 3444 local check_ghost 3445 local store_pixel 3446 mov al , [ esi ] 3447 mov ebx , [ BFPartialCount ] 3448 inc esi 3449 add ebx , [ BFPartialPred ] 3450 or bh , bh 3451 jnz get_pred ; is this a predator pixel? 3452 3453 mov [ BFPartialCount ] , ebx 3454 jmp check_ghost 3455 3456 get_pred: 3457 xor bh , bh 3458 mov eax, [ BFPredOffset ] 3459 mov [ BFPartialCount ] , ebx 3460 add BYTE PTR [ BFPredOffset ] , 2 3461 movzx eax , WORD PTR [ BFPredTable + eax ] 3462 and BYTE PTR [ BFPredOffset ] , PRED_MASK 3463 ; pick up a color offset a pseudo- 3464 ; random amount from the current 3465 movzx eax , BYTE PTR [ edi + eax ] ; viewport address 3466 3467 check_ghost: 3468 mov ebx , [ IsTranslucent ] ; is it a translucent color? 3469 mov bh , BYTE PTR [ ebx + eax ] 3470 cmp bh , 0ffh 3471 je store_pixel 3472 3473 and ebx , 0FF00h ; clear all of ebx except bh 3474 ; we have the index to the translation table 3475 ; ((trans_colour * 256) + dest colour) 3476 mov al , [ edi ] ; mov pixel at destination to al 3477 add ebx , [ Translucent ] ; get the ptr to it! 3478 ; Add the (trans_color * 256) of the translation equ. 3479 mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al 3480 3481 store_pixel: 3482 mov [ edi ] , al 3483 inc edi 3484 3485 ENDM 3486 3487 predator_g_reference: 3488 dec ecx 3489 jge predator_g_line 3490 3491 add esi , [ scr_adjust_width ] 3492 add edi , [ dest_adjust_width ] 3493 dec edx 3494 jnz predator_g_loop 3495 3496 epilogue 3497 ret 3498 3499 3500 ;******************************************************************** 3501 ;******************************************************************** 3502 3503 ;extern BF_Predator_Ghost_Trans:near 3504 BF_Predator_Ghost_Trans: 3505 3506 prologue 3507 mov ebx , eax ; width 3508 3509 ; NOTE: the below calculation assumes a group of instructions is 3510 ; less than 256 bytes 3511 3512 ; get length of the 32 groups of instructions 3513 3514 lea ecx , [ offset predator_g_t_reference ] 3515 sub ecx, [ offset predator_g_t_line ] 3516 3517 shr ebx , 5 ; width / 32 3518 shr ecx , 5 ; length of instructions / 32 3519 and eax , 01fh ; mod of width / 32 3520 mul cl ; calc offset to start of group 3521 neg eax ; inverse of width 3522 mov [ loop_cnt ] , ebx ; save width / 32 3523 lea ecx , [ predator_g_t_reference + eax ] 3524 mov eax , 0 3525 mov [ jmp_loc ] , ecx 3526 3527 predator_g_t_loop: 3528 mov ecx , [ loop_cnt ] 3529 jmp [ jmp_loc ] 3530 3531 predator_g_t_line: 3532 3533 REPT 32 3534 local trans_pixel 3535 local get_pred 3536 local check_ghost 3537 local store_pixel 3538 mov al , [ esi ] 3539 inc esi 3540 test al , al 3541 jz trans_pixel 3542 3543 mov ebx , [ BFPartialCount ] 3544 add ebx , [ BFPartialPred ] 3545 or bh , bh 3546 jnz get_pred ; is this a predator pixel? 3547 3548 mov [ BFPartialCount ] , ebx 3549 jmp check_ghost 3550 3551 get_pred: 3552 xor bh , bh 3553 mov eax, [ BFPredOffset ] 3554 mov [ BFPartialCount ] , ebx 3555 add BYTE PTR [ BFPredOffset ] , 2 3556 movzx eax , WORD PTR [ BFPredTable + eax ] 3557 and BYTE PTR [ BFPredOffset ] , PRED_MASK 3558 ; pick up a color offset a pseudo- 3559 ; random amount from the current 3560 movzx eax , BYTE PTR [ edi + eax ] ; viewport address 3561 3562 check_ghost: 3563 mov ebx , [ IsTranslucent ] ; is it a translucent color? 3564 mov bh , BYTE PTR [ ebx + eax ] 3565 cmp bh , 0ffh 3566 je store_pixel 3567 3568 and ebx , 0FF00h ; clear all of ebx except bh 3569 ; we have the index to the translation table 3570 ; ((trans_colour * 256) + dest colour) 3571 mov al , [ edi ] ; mov pixel at destination to al 3572 add ebx , [ Translucent ] ; get the ptr to it! 3573 ; Add the (trans_color * 256) of the translation equ. 3574 mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al 3575 3576 store_pixel: 3577 mov [ edi ] , al 3578 3579 trans_pixel: 3580 inc edi 3581 3582 ENDM 3583 3584 predator_g_t_reference: 3585 dec ecx 3586 jge predator_g_t_line 3587 3588 add esi , [ scr_adjust_width ] 3589 add edi , [ dest_adjust_width ] 3590 dec edx 3591 jnz predator_g_t_loop 3592 3593 epilogue 3594 ret 3595 3596 3597 ;******************************************************************** 3598 ;******************************************************************** 3599 3600 ;extern BF_Predator_Fading:near 3601 BF_Predator_Fading: 3602 3603 prologue 3604 mov ebx , eax ; width 3605 3606 ; NOTE: the below calculation assumes a group of instructions is 3607 ; less than 256 bytes 3608 3609 ; get length of the 32 groups of instructions 3610 3611 lea ecx , [ offset predator_f_reference ] 3612 sub ecx, [ offset predator_f_line ] 3613 3614 shr ebx , 5 ; width / 32 3615 shr ecx , 5 ; length of instructions / 32 3616 and eax , 01fh ; mod of width / 32 3617 mul cl ; calc offset to start of group 3618 neg eax ; inverse of width 3619 mov [ loop_cnt ] , ebx ; save width / 32 3620 lea ecx , [ predator_f_reference + eax ] 3621 mov eax , 0 3622 mov [ jmp_loc ] , ecx 3623 3624 predator_f_loop: 3625 mov ecx , [ loop_cnt ] 3626 mov [ StashECX ] , ecx ; preserve ecx for later 3627 jmp [ jmp_loc ] 3628 3629 predator_f_line_begin: 3630 mov [ StashECX ] , ecx ; preserve ecx for later 3631 3632 predator_f_line: 3633 3634 REPT 32 3635 local get_pred 3636 local do_fading 3637 local fade_loop 3638 mov al , [ esi ] 3639 mov ebx , [ BFPartialCount ] 3640 inc esi 3641 add ebx , [ BFPartialPred ] 3642 or bh , bh 3643 jnz get_pred ; is this a predator pixel? 3644 3645 mov [ BFPartialCount ] , ebx 3646 jmp do_fading 3647 3648 get_pred: 3649 xor bh , bh 3650 mov eax, [ BFPredOffset ] 3651 mov [ BFPartialCount ] , ebx 3652 add BYTE PTR [ BFPredOffset ] , 2 3653 movzx eax , WORD PTR [ BFPredTable + eax ] 3654 and BYTE PTR [ BFPredOffset ] , PRED_MASK 3655 ; pick up a color offset a pseudo- 3656 ; random amount from the current 3657 movzx eax , BYTE PTR [ edi + eax ] ; viewport address 3658 3659 do_fading: 3660 mov ebx , [ FadingTable ] ; run color through fading table 3661 mov ecx , [ FadingNum ] 3662 3663 fade_loop: 3664 mov al, byte ptr [ebx + eax] 3665 dec ecx 3666 jnz fade_loop 3667 3668 mov [ edi ] , al 3669 inc edi 3670 3671 ENDM 3672 3673 predator_f_reference: 3674 mov ecx , [ StashECX ] ; restore ecx for main draw loop 3675 dec ecx 3676 jge predator_f_line_begin 3677 3678 add esi , [ scr_adjust_width ] 3679 add edi , [ dest_adjust_width ] 3680 dec edx 3681 jnz predator_f_loop 3682 3683 epilogue 3684 ret 3685 3686 3687 ;******************************************************************** 3688 ;******************************************************************** 3689 3690 ;extern BF_Predator_Fading_Trans:near 3691 BF_Predator_Fading_Trans: 3692 3693 prologue 3694 mov ebx , eax ; width 3695 3696 ; NOTE: the below calculation assumes a group of instructions is 3697 ; less than 256 bytes 3698 3699 ; get length of the 32 groups of instructions 3700 3701 lea ecx , [ offset predator_f_t_reference ] 3702 sub ecx, [ offset predator_f_t_line ] 3703 3704 shr ebx , 5 ; width / 32 3705 shr ecx , 5 ; length of instructions / 32 3706 and eax , 01fh ; mod of width / 32 3707 mul cl ; calc offset to start of group 3708 neg eax ; inverse of width 3709 mov [ loop_cnt ] , ebx ; save width / 32 3710 lea ecx , [ predator_f_t_reference + eax ] 3711 mov eax , 0 3712 mov [ jmp_loc ] , ecx 3713 3714 predator_f_t_loop: 3715 mov ecx , [ loop_cnt ] 3716 mov [ StashECX ] , ecx ; preserve ecx for later 3717 jmp [ jmp_loc ] 3718 3719 predator_f_t_line_begin: 3720 mov [ StashECX ] , ecx ; preserve ecx for later 3721 3722 predator_f_t_line: 3723 3724 REPT 32 3725 local trans_pixel 3726 local get_pred 3727 local do_fading 3728 local fade_loop 3729 mov al , [ esi ] 3730 inc esi 3731 test al , al 3732 jz trans_pixel 3733 3734 mov ebx , [ BFPartialCount ] 3735 add ebx , [ BFPartialPred ] 3736 or bh , bh 3737 jnz get_pred ; is this a predator pixel? 3738 3739 mov [ BFPartialCount ] , ebx 3740 jmp do_fading 3741 3742 get_pred: 3743 xor bh , bh 3744 mov eax, [ BFPredOffset ] 3745 mov [ BFPartialCount ] , ebx 3746 add BYTE PTR [ BFPredOffset ] , 2 3747 movzx eax , WORD PTR [ BFPredTable + eax ] 3748 and BYTE PTR [ BFPredOffset ] , PRED_MASK 3749 ; pick up a color offset a pseudo- 3750 ; random amount from the current 3751 movzx eax , BYTE PTR [ edi + eax ] ; viewport address 3752 3753 do_fading: 3754 mov ebx , [ FadingTable ] ; run color through fading table 3755 mov ecx , [ FadingNum ] 3756 3757 fade_loop: 3758 mov al, byte ptr [ebx + eax] 3759 dec ecx 3760 jnz fade_loop 3761 3762 mov [ edi ] , al 3763 3764 trans_pixel: 3765 inc edi 3766 3767 ENDM 3768 3769 predator_f_t_reference: 3770 mov ecx , [ StashECX ] ; restore ecx for main draw loop 3771 dec ecx 3772 jge predator_f_t_line_begin 3773 3774 add esi , [ scr_adjust_width ] 3775 add edi , [ dest_adjust_width ] 3776 dec edx 3777 jnz predator_f_t_loop 3778 3779 epilogue 3780 ret 3781 3782 3783 ;******************************************************************** 3784 ;******************************************************************** 3785 3786 ;extern BF_Predator_Ghost_Fading:near 3787 BF_Predator_Ghost_Fading: 3788 3789 prologue 3790 mov ebx , eax ; width 3791 3792 ; NOTE: the below calculation assumes a group of instructions is 3793 ; less than 256 bytes 3794 3795 ; get length of the 32 groups of instructions 3796 3797 lea ecx , [ offset predator_g_f_reference ] 3798 sub ecx, [ offset predator_g_f_line ] 3799 3800 shr ebx , 5 ; width / 32 3801 shr ecx , 5 ; length of instructions / 32 3802 and eax , 01fh ; mod of width / 32 3803 mul cl ; calc offset to start of group 3804 neg eax ; inverse of width 3805 mov [ loop_cnt ] , ebx ; save width / 32 3806 lea ecx , [ predator_g_f_reference + eax ] 3807 mov eax , 0 3808 mov [ jmp_loc ] , ecx 3809 3810 predator_g_f_loop: 3811 mov ecx , [ loop_cnt ] 3812 mov [ StashECX ] , ecx ; preserve ecx for later 3813 jmp [ jmp_loc ] 3814 3815 predator_g_f_line_begin: 3816 mov [ StashECX ] , ecx ; preserve ecx for later 3817 3818 predator_g_f_line: 3819 3820 REPT 32 3821 local get_pred 3822 local check_ghost 3823 local store_pixel 3824 local do_fading 3825 local fade_loop 3826 mov al , [ esi ] 3827 mov ebx , [ BFPartialCount ] 3828 inc esi 3829 add ebx , [ BFPartialPred ] 3830 or bh , bh 3831 jnz get_pred ; is this a predator pixel? 3832 3833 mov [ BFPartialCount ] , ebx 3834 jmp check_ghost 3835 3836 get_pred: 3837 xor bh , bh 3838 mov eax, [ BFPredOffset ] 3839 mov [ BFPartialCount ] , ebx 3840 add BYTE PTR [ BFPredOffset ] , 2 3841 movzx eax , WORD PTR [ BFPredTable + eax ] 3842 and BYTE PTR [ BFPredOffset ] , PRED_MASK 3843 ; pick up a color offset a pseudo- 3844 ; random amount from the current 3845 movzx eax , BYTE PTR [ edi + eax ] ; viewport address 3846 3847 check_ghost: 3848 mov ebx , [ IsTranslucent ] ; is it a translucent color? 3849 mov bh , BYTE PTR [ ebx + eax ] 3850 cmp bh , 0ffh 3851 je do_fading 3852 3853 and ebx , 0FF00h ; clear all of ebx except bh 3854 ; we have the index to the translation table 3855 ; ((trans_colour * 256) + dest colour) 3856 mov al , [ edi ] ; mov pixel at destination to al 3857 add ebx , [ Translucent ] ; get the ptr to it! 3858 ; Add the (trans_color * 256) of the translation equ. 3859 mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al 3860 ; DRD jmp store_pixel 3861 3862 do_fading: 3863 mov ebx , [ FadingTable ] ; run color through fading table 3864 mov ecx , [ FadingNum ] 3865 3866 fade_loop: 3867 mov al, byte ptr [ebx + eax] 3868 dec ecx 3869 jnz fade_loop 3870 3871 store_pixel: 3872 mov [ edi ] , al 3873 inc edi 3874 3875 ENDM 3876 3877 predator_g_f_reference: 3878 mov ecx , [ StashECX ] ; restore ecx for main draw loop 3879 dec ecx 3880 jge predator_g_f_line_begin 3881 3882 add esi , [ scr_adjust_width ] 3883 add edi , [ dest_adjust_width ] 3884 dec edx 3885 jnz predator_g_f_loop 3886 3887 epilogue 3888 ret 3889 3890 3891 ;******************************************************************** 3892 ;******************************************************************** 3893 3894 ;extern BF_Predator_Ghost_Fading_Trans:near 3895 BF_Predator_Ghost_Fading_Trans: 3896 3897 prologue 3898 mov ebx , eax ; width 3899 3900 ; NOTE: the below calculation assumes a group of instructions is 3901 ; less than 256 bytes 3902 3903 ; get length of the 32 groups of instructions 3904 3905 lea ecx , [ offset predator_g_f_t_reference ] 3906 sub ecx, [ offset predator_g_f_t_line ] 3907 3908 shr ebx , 5 ; width / 32 3909 shr ecx , 5 ; length of instructions / 32 3910 and eax , 01fh ; mod of width / 32 3911 mul cl ; calc offset to start of group 3912 neg eax ; inverse of width 3913 mov [ loop_cnt ] , ebx ; save width / 32 3914 lea ecx , [ predator_g_f_t_reference + eax ] 3915 mov eax , 0 3916 mov [ jmp_loc ] , ecx 3917 3918 predator_g_f_t_loop: 3919 mov ecx , [ loop_cnt ] 3920 mov [ StashECX ] , ecx ; preserve ecx for later 3921 jmp [ jmp_loc ] 3922 3923 predator_g_f_t_line_begin: 3924 mov [ StashECX ] , ecx ; preserve ecx for later 3925 3926 predator_g_f_t_line: 3927 3928 REPT 32 3929 local trans_pixel 3930 local get_pred 3931 local check_ghost 3932 local store_pixel 3933 local do_fading 3934 local fade_loop 3935 mov al , [ esi ] 3936 inc esi 3937 test al , al 3938 jz trans_pixel 3939 3940 mov ebx , [ BFPartialCount ] 3941 add ebx , [ BFPartialPred ] 3942 or bh , bh 3943 jnz get_pred ; is this a predator pixel? 3944 3945 mov [ BFPartialCount ] , ebx 3946 jmp check_ghost 3947 3948 get_pred: 3949 xor bh , bh 3950 mov eax, [ BFPredOffset ] 3951 mov [ BFPartialCount ] , ebx 3952 add BYTE PTR [ BFPredOffset ] , 2 3953 movzx eax , WORD PTR [ BFPredTable + eax ] 3954 and BYTE PTR [ BFPredOffset ] , PRED_MASK 3955 ; pick up a color offset a pseudo- 3956 ; random amount from the current 3957 movzx eax , BYTE PTR [ edi + eax ] ; viewport address 3958 3959 check_ghost: 3960 mov ebx , [ IsTranslucent ] ; is it a translucent color? 3961 mov bh , BYTE PTR [ ebx + eax ] 3962 cmp bh , 0ffh 3963 je do_fading 3964 3965 and ebx , 0FF00h ; clear all of ebx except bh 3966 ; we have the index to the translation table 3967 ; ((trans_colour * 256) + dest colour) 3968 mov al , [ edi ] ; mov pixel at destination to al 3969 add ebx , [ Translucent ] ; get the ptr to it! 3970 ; Add the (trans_color * 256) of the translation equ. 3971 mov al , BYTE PTR [ ebx + eax ] ; get new pixel in al 3972 ; DRD jmp store_pixel 3973 3974 do_fading: 3975 mov ebx , [ FadingTable ] ; run color through fading table 3976 mov ecx , [ FadingNum ] 3977 3978 fade_loop: 3979 mov al, byte ptr [ebx + eax] 3980 dec ecx 3981 jnz fade_loop 3982 3983 store_pixel: 3984 mov [ edi ] , al 3985 3986 trans_pixel: 3987 inc edi 3988 3989 ENDM 3990 3991 predator_g_f_t_reference: 3992 mov ecx , [ StashECX ] ; restore ecx for main draw loop 3993 dec ecx 3994 jge predator_g_f_t_line_begin 3995 3996 add esi , [ scr_adjust_width ] 3997 add edi , [ dest_adjust_width ] 3998 dec edx 3999 jnz predator_g_f_t_loop 4000 4001 epilogue 4002 ret 4003 4004 4005 ;******************************************************************** 4006 ;******************************************************************** 4007 4008 Not_Supported: 4009 ret 4010 4011 Buffer_Frame_To_Page ENDP 4012 4013 4014 end 4015 4016 externdef C CPUType:byte 4017 4018 4019 4020 ;********************************************************************************************* 4021 ;* Detect_MMX_Availability -- Detect the presence of MMX technology. * 4022 ;* * 4023 ;* * 4024 ;* INPUT: Nothing * 4025 ;* * 4026 ;* OUTPUT: True if MMX technology is available. * 4027 ;* * 4028 ;* Warnings: * 4029 ;* * 4030 ;* Note: Based in part on CPUID32.ASM by Intel * 4031 ;* * 4032 ;* HISTORY: * 4033 ;* 05/19/96 ST : Created. * 4034 ;*===========================================================================================* 4035 4036 Detect_MMX_Availability proc C 4037 4038 local idflag:byte 4039 local local_cputype:byte 4040 4041 ;assume processor is at least 386 4042 ; 4043 ;check whether AC bit in eflags can be toggled. 4044 ;If not then processor is 386 4045 4046 mov [idflag],0 4047 4048 pushfd ;get Eflags in EAX 4049 pop eax 4050 mov ecx,eax ;save eflags 4051 xor eax,40000h ;toggle AC bit in eflags 4052 push eax ;new eflags on stack 4053 popfd ;move new value into eflags 4054 pushfd ;get new eflags back into eax 4055 pop eax 4056 xor eax,ecx ;if AC bit not toggled then CPU=386 4057 mov [local_cputype],3 4058 jz @@end_get_cpu ;cpu is 386 4059 4060 push ecx 4061 popfd ;restore AC bit in eflags 4062 4063 4064 ;processor is at least 486 4065 ; 4066 ;Check for ability to set/clear ID flag in EFLAGS 4067 ;ID flag indicates ability of processor to execute the CPUID instruction. 4068 ;486 not guaranteed to have CPUID inst? 4069 ; 4070 mov [local_cputype],4 4071 mov eax,ecx ;original EFLAGS 4072 xor eax,200000h ;toggle ID bit 4073 push eax 4074 popfd 4075 pushfd 4076 pop eax 4077 xor eax,ecx ;check if still toggled 4078 jz @@end_get_cpu 4079 4080 4081 ; Execute CPUID instruction to determine vendor, family, 4082 ; model and stepping. 4083 ; 4084 4085 mov [idflag],1 ;flag ID is available 4086 4087 xor eax,eax 4088 cpuid 4089 4090 mov dword ptr [VendorID],ebx 4091 mov dword ptr [VendorID+4],edx 4092 mov dword ptr [VendorID+8],ecx 4093 mov dword ptr [VendorID+12]," " 4094 4095 cmp eax,1 ;check if 1 is valid 4096 jl @@end_get_cpu ;inp for cpuid inst. 4097 4098 xor eax,eax 4099 inc eax 4100 4101 cpuid ;get stepping, model and family 4102 4103 and ax,0f00H 4104 shr ax,08H 4105 4106 mov [local_cputype],al 4107 4108 @@end_get_cpu: mov al,[local_cputype] 4109 mov [CPUType],al 4110 4111 4112 ; 4113 ; We have the CPU type in al now. 4114 ; If we arent on at least a pentium then we can assume there is no MMX 4115 ; 4116 cmp al,5 4117 jl @@no_mmx 4118 4119 mov eax,1 4120 cpuid 4121 test edx,00800000h 4122 jz @@no_mmx 4123 4124 ; 4125 ; MMX detected - return true 4126 ; 4127 mov eax,1 4128 ret 4129 4130 4131 @@no_mmx: xor eax,eax 4132 ret 4133 4134 4135 Detect_MMX_Availability endp 4136 4137 4138 4139 ;********************************************************************************************* 4140 ;* Init_MMX -- Do any special inits required for MMX support * 4141 ;* * 4142 ;* * 4143 ;* INPUT: Nothing * 4144 ;* * 4145 ;* OUTPUT: None * 4146 ;* * 4147 ;* Warnings: * 4148 ;* * 4149 ;* HISTORY: * 4150 ;* 05/19/96 ST : Created. * 4151 ;*===========================================================================================* 4152 4153 Init_MMX proc C 4154 4155 mov edi,offset NewShapeJumpTable 4156 mov ecx,offset EndNewShapeJumpTable 4157 sub ecx,edi 4158 shr ecx,2 4159 mov eax,offset Single_Line_Trans 4160 mov ebx,offset MMX_Single_Line_Trans 4161 cld 4162 4163 4164 @@patch_loop: repnz scasd 4165 jnz @@done 4166 mov [edi-4],ebx 4167 test ecx,ecx 4168 jnz @@patch_loop 4169 4170 @@done: ret 4171 4172 Init_MMX endp 4173 4174 4175 4176 4177 4178 4179 ;********************************************************************************************* 4180 ;* MMX_Done -- Restores floating point capability after MMX usage * 4181 ;* * 4182 ;* * 4183 ;* INPUT: Nothing * 4184 ;* * 4185 ;* OUTPUT: None * 4186 ;* * 4187 ;* Warnings: * 4188 ;* * 4189 ;* HISTORY: * 4190 ;* 05/19/96 ST : Created. * 4191 ;*===========================================================================================* 4192 4193 MMX_Done proc C 4194 4195 emms 4196 ret 4197 4198 MMX_Done endp 4199 4200 4201 4202 4203 4204 4205 4206 code segment page public use32 'code' ; Need stricter segment alignment 4207 ; for pentium optimisations 4208 4209 4210 ;********************************************************************************************* 4211 ;* MMX_Single_Line_Trans -- draw a single line of transparent pixels using MMX technology * 4212 ;* * 4213 ;* * 4214 ;* INPUT: Esi - ptr to source data * 4215 ;* Edi - ptr to destination data * 4216 ;* Ecx - width to draw in bytes * 4217 ;* * 4218 ;* OUTPUT: None * 4219 ;* * 4220 ;* Warnings: * 4221 ;* * 4222 ;* HISTORY: * 4223 ;* 05/19/96 ST : Created. * 4224 ;*===========================================================================================* 4225 4226 align 16 4227 4228 MMX_Single_Line_Trans proc near 4229 4230 ; 4231 ; If we are doing less than 8 bytes then dont use MMX 4232 ; 4233 cmp ecx,8 4234 jge @@mmx_loop 4235 push offset Single_Line_Trans_Entry 4236 ret 4237 4238 ; 4239 ; Use MMX instructions to mask 8 bytes at once 4240 ; 4241 ; Creates a bitmask based on the source bytes equality with zero and then uses this to mask 4242 ; out the source bytes in the destination data. The advatage that MMX gives us is that there is 4243 ; no 'test for zero then jump' required to mask. 4244 ; 4245 align 64 ;MMX instructions like 64 byte alignment! 4246 4247 @@mmx_loop: 4248 movq mm0,[esi] ; move 8 bytes of source into mm0 4249 pxor mm1,mm1 ; zero out mm1 4250 pcmpeqb mm1,mm0 ; compare mm0 with 0. Bits get set in mm1 4251 lea esi,[esi+8] ; adjust the source data pointer 4252 pand mm1,[edi] ; and in the destination data to throw away the bytes which arent zero in the source 4253 sub ecx,8 ; adjust the byte counter 4254 por mm1,mm0 ; or in the source with the destination data 4255 movq [edi],mm1 ; write back the destination data 4256 lea edi,[edi+8] ; adjust the destination pointer 4257 4258 cmp ecx,8 4259 jg @@mmx_loop 4260 4261 ; 4262 ; Jump to the approprite code for drawing the end of this line or going to the next one 4263 ; 4264 push offset Next_Line 4265 jcxz @@next_line 4266 push offset Single_Line_Trans_Entry 4267 @@next_line: ret 4268 4269 4270 MMX_Single_Line_Trans endp 4271 4272 4273 code ends 4274 4275 .data 4276 4277 CPUType db 0 4278 VendorID db "Not available",0,0,0,0,0,0 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 END 4291 4292 ;*************************************************************************** 4293 ;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S ** 4294 ;*************************************************************************** 4295 ;* * 4296 ;* Project Name : Westwood Library * 4297 ;* * 4298 ;* File Name : KEYFBUFF.ASM * 4299 ;* * 4300 ;* Programmer : Phil W. Gorrow * 4301 ;* * 4302 ;* Start Date : July 16, 1992 * 4303 ;* * 4304 ;* Last Update : October 2, 1994 [JLB] * 4305 ;* * 4306 ;*-------------------------------------------------------------------------* 4307 ;* Functions: * 4308 ;* BUFFER_FRAME_TO_LOGICPAGE -- * 4309 ;* Normal_Draw -- Function that writes a normal pixel line * 4310 ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 4311 4312 ; IDEAL 4313 ; P386 4314 ;IDEAL_MODE EQU 1 4315 ; INCLUDE "wwlib.i" 4316 4317 ;------------------------------------------------------------------- 4318 ; Extern all the library variables that this module requires 4319 ;------------------------------------------------------------------- 4320 4321 EXTRN C MaskPage:WORD 4322 EXTRN C BackGroundPage:WORD 4323 4324 ;------------------------------------------------------------------- 4325 ; Define all the equates that this module requires 4326 ;------------------------------------------------------------------- 4327 4328 WIN_X EQU 0 ; offset for the x coordinate 4329 WIN_Y EQU 2 ; offset for the y coordinate 4330 WIN_WIDTH EQU 4 ; offset for the window width 4331 WIN_HEIGHT EQU 6 ; offset for the window height 4332 BYTESPERROW EQU 320 ; number of bytes per row 4333 4334 FLAG_NORMAL EQU 0 ; flag for normal draw 4335 4336 FLAG_GHOST EQU 1 ; This flag enables the ghost 4337 FLAG_PRIORITY_TRANS EQU 2 ; flag for priority and transparent 4338 FLAG_TRANS EQU 4 ; flag for transparent draw 4339 FLAG_PRIORITY EQU 8 ; flag for priority draw 4340 4341 ; fx on the above flags 4342 4343 FLAG_MASK EQU 15 ; used to and of uneeded bits 4344 4345 SHAPE_NORMAL EQU 0000h ; Standard shape. 4346 ;SHAPE_HORZ_REV EQU 0001h ; Flipped horizontally. 4347 ;SHAPE_VERT_REV EQU 0002h ; Flipped vertically. 4348 ;SHAPE_SCALING EQU 0004h ; Scaled (WORD scale_x, WORD scale_y) 4349 4350 SHAPE_WIN_REL EQU 0010h ; Coordinates are window relative instead of absolute. 4351 SHAPE_CENTER EQU 0020h ; Coordinates are based on shape's center point. 4352 SHAPE_TRANS EQU 0040h ; has transparency 4353 4354 4355 ;SHAPE_FADING EQU 0100h ; Fading effect active (VOID * fading_table, WORD fading_num). 4356 ;SHAPE_PREDATOR EQU 0200h ; Transparent warping effect. 4357 ;SHAPE_COMPACT EQU 0400h ; Never use this bit. 4358 SHAPE_PRIORITY EQU 0800h ; Use priority system when drawing. 4359 4360 SHAPE_GHOST EQU 1000h ; Transluscent table process. 4361 ;SHAPE_SHADOW EQU 2000h ; 4362 ;SHAPE_PARTIAL EQU 4000h ; 4363 ;SHAPE_COLOR EQU 8000h ; Remap the shape's colors (VOID * color_table). 4364 4365 4366 ; MBL MOD 12.1.92 4367 4368 CLEAR_NON_WALK_BIT_AND_SCALE_BITS EQU 7 ; Makes it one AND per pixel in Priority_Trans display 4369 CLEAR_NON_WALK_BIT EQU 7fh ; and with 0111-1111 to clear non-walkable high bit 4370 CLEAR_SCALE_BITS EQU 87h ; and with 1000-0111 to clear scaling id bits 4371 NON_WALKABLE_BIT EQU 80h ; and with 1000-0000 to clear all but non-walkable bit 4372 4373 ; END MBL MOD 4374 4375 4376 CODESEG 4377 4378 ; 1 = GHOST (all odd entrys are prefixed with Ghost_) 4379 ; 2 = BLAAAH 4380 ; 4 = Trans (prfx) 4381 ; 8 = Prior (prfx) 4382 4383 4384 ;--------------------------------------------------------------------------- 4385 ; Define the table of different line draw types 4386 ;--------------------------------------------------------------------------- 4387 4388 LineTable DW WSA_Normal_Draw ;0 4389 DW Ghost_Normal_Draw ;1 4390 DW 0 ;2 4391 DW 0 ;3 4392 4393 DW Transparent_Draw ;4 4394 DW Ghost_Transparent_Draw ;5 4395 DW 0 ;6 4396 DW 0 ;7 4397 4398 DW Priority_Draw ;8 4399 DW Ghost_Priority_Draw ;9 4400 DW 0 ;10 4401 DW 0 ;11 4402 4403 DW Priority_Transparent_Draw ;12 4404 DW Ghost_Priority_Transparent_Draw ;13 4405 DW 0 ;14 4406 DW 0 ;15 4407 4408 4409 4410 ;*************************************************************************** 4411 ;* BUFFER_FRAME_TO_LOGICPAGE -- * 4412 ;* * 4413 ;* * 4414 ;* * 4415 ;* INPUT: * 4416 ;* * 4417 ;* OUTPUT: * 4418 ;* * 4419 ;* WARNINGS: * 4420 ;* * 4421 ;* HISTORY: * 4422 ;* 07/16/1992 PWG : Created. * 4423 ;*=========================================================================* 4424 PUBLIC C Buffer_Frame_To_LogicPage 4425 PROC C Buffer_Frame_To_LogicPage FAR USES ax bx ecx dx ds esi es edi 4426 4427 ;------------------------------------------------------------------- 4428 ; Define the arguements that our program takes. 4429 ;------------------------------------------------------------------- 4430 4431 ARG x_pixel:WORD ; x pixel position to draw at 4432 ARG y_pixel:WORD ; y pixel position to draw at 4433 ARG pixel_w:WORD ; pixel width of draw region 4434 ARG pixel_h:WORD ; pixel height of draw region 4435 ARG win:WORD ; window to clip around 4436 ARG flags:WORD ; flags that this routine will take 4437 ARG buffer:DWORD ; pointer to the buffer with data 4438 ARG args:WORD 4439 4440 ;------------------------------------------------------------------- 4441 ; Define the local variables that our program uses 4442 ;------------------------------------------------------------------- 4443 4444 LOCAL IsTranslucent:DWORD ; ptr to the is_translucent table 4445 LOCAL Translucent:DWORD ; ptr to the actual translucent table 4446 4447 LOCAL win_x1:WORD ; clip window left x pixel position 4448 LOCAL win_x2:WORD ; clip window right x pixel position 4449 LOCAL win_y1:WORD ; clip window top y pixel position 4450 LOCAL win_y2:WORD ; clip window bottom y pixel position 4451 LOCAL clipleft:WORD ; number of pixels to clip on left 4452 LOCAL clipright:WORD ; number of pixels to clip on right 4453 LOCAL nextline:WORD ; offset to the next line 4454 LOCAL putmiddle:WORD ; routine to call to put the middle 4455 LOCAL maskpage:WORD ; location of the depth masks 4456 LOCAL background:WORD ; location of the background data 4457 LOCAL jflags:WORD ; location of the background data 4458 4459 LOCAL priority:BYTE ; the priority level of the back 4460 4461 push fs 4462 4463 xor ecx,ecx 4464 4465 ;-------------------------------------------------------------------- 4466 ; Check to see if we have supplied any GHOST tables. 4467 ;-------------------------------------------------------------------- 4468 push di 4469 4470 mov di,6 4471 mov [jflags],0 4472 4473 ghost: 4474 test [flags],SHAPE_GHOST ; are we ghosting this shape 4475 jz short no_ghost ; if not then skip and do more 4476 4477 or [jflags],FLAG_GHOST 4478 4479 les ax,dword ptr [buffer + di] 4480 4481 ; get the "are we really translucent?" table 4482 mov [WORD PTR IsTranslucent],ax 4483 mov [WORD PTR IsTranslucent + 2],es 4484 add ax,0100h ; add to offset for tables 4485 4486 ; get the "ok we are translucent!!" table 4487 mov [WORD PTR Translucent],ax 4488 mov [WORD PTR Translucent + 2],es 4489 4490 add di,4 4491 4492 no_ghost: 4493 4494 pop di 4495 4496 ;------------------------------------------------------------------- 4497 ; See if we need to center the frame 4498 ;------------------------------------------------------------------- 4499 test [flags],SHAPE_CENTER ; does this need to be centered? 4500 je short no_centering ; if not the skip over this stuff 4501 4502 mov ax,[pixel_w] 4503 mov bx,[pixel_h] 4504 sar ax,1 4505 sar bx,1 4506 sub [x_pixel],ax 4507 sub [y_pixel],bx 4508 4509 no_centering: 4510 mov ax,[flags] 4511 and ax,SHAPE_PRIORITY+SHAPE_TRANS 4512 cmp ax,SHAPE_PRIORITY+SHAPE_TRANS 4513 jne short test_trans 4514 4515 or [jflags],FLAG_PRIORITY_TRANS 4516 jmp short priority 4517 4518 ;------------------------------------------------------------------- 4519 ; Get the trans information if we need to get it 4520 ;------------------------------------------------------------------- 4521 test_trans: 4522 test [flags],SHAPE_TRANS ; does this draw use transparencies? 4523 je short test_priority ; if not the skip over this junk 4524 4525 or [jflags],FLAG_TRANS 4526 4527 test_priority: 4528 ;------------------------------------------------------------------- 4529 ; Get the priority information if we need to get it 4530 ;------------------------------------------------------------------- 4531 test [flags],SHAPE_PRIORITY ; does this draw use priorities? 4532 je short no_priority ; if not the skip over this junk 4533 4534 or [jflags],FLAG_PRIORITY 4535 4536 priority: 4537 mov ax,[BackGroundPage] ; get the background page from ds 4538 mov [background],ax ; and store it on the stack 4539 mov ax,[MaskPage] ; get the mask page from ds 4540 mov [maskpage],ax ; and store it on the stack 4541 mov ax,[WORD PTR buffer + 4]; get the priority level from args 4542 mov [priority],al ; and store it in a local 4543 4544 ;------------------------------------------------------------------- 4545 ; Get the draw routine that we are going to draw with 4546 ;------------------------------------------------------------------- 4547 no_priority: 4548 ; mov bx,[flags] ; load in the current flags byte 4549 ; and bx,FLAG_MASK ; prevent lockup on bad value 4550 mov bx,[jflags] ; load in the jump table flags 4551 shl bx,1 4552 mov ax,[WORD PTR LineTable + bx] ; get the offset of the skip table 4553 mov [putmiddle],ax ; store off the new offset 4554 4555 ;------------------------------------------------------------------- 4556 ; Get a pointer to the logic page to where we will draw our buffer 4557 ;------------------------------------------------------------------- 4558 push [LogicPage] ; push the current logic page 4559 call FAR PTR Get_Page ; get the physical page address 4560 add sp,2 ; pull the parameter from the stack 4561 mov es,dx ; store the address in the dest 4562 4563 ;-------------------------------------------------------------------- 4564 ; Point DI to the beginning of the window that we need to look at. 4565 ; that way we can access all of the info through di. 4566 ;-------------------------------------------------------------------- 4567 mov si,OFFSET WindowList ; get the offset of the window list 4568 mov cl,4 ; shift 3 times = multiply by 16 4569 mov ax,[win] ; get the window number we are using 4570 shl ax,cl ; each window is 8 words long 4571 add si,ax ; add that into the offset of window 4572 4573 ;-------------------------------------------------------------------- 4574 ; Place all the clipping values on the stack so our function will 4575 ; be truly re-entrant and will not need to shadow these values. 4576 ;-------------------------------------------------------------------- 4577 mov cl,3 ; to convert x to pixel mult by 8 4578 mov ax,[si + WIN_X] ; get the left clip position 4579 shl ax,cl ; convert to a pixel x position 4580 mov [win_x1],ax ; store the left edge of window 4581 mov [win_x2],ax 4582 4583 mov ax,[si + WIN_WIDTH] ; get the width of the window 4584 shl ax,cl ; convert to a pixel width 4585 add [win_x2],ax ; add to get the right window edge 4586 4587 mov ax,[si + WIN_Y] ; get the win y coordinate to clip 4588 mov [win_y1],ax ; and save it onto the stack 4589 4590 add ax,[si + WIN_HEIGHT] ; calculate the bottom win y coord 4591 mov [win_y2],ax ; and save it onto the stack 4592 4593 test [flags],SHAPE_WIN_REL ; is this window relative? 4594 je short get_buffer ; if not the skip over 4595 4596 mov ax,[win_x1] ; get left edge of window 4597 add [x_pixel],ax ; add to x pixel position 4598 mov ax,[win_y1] ; get top edge of window 4599 add [y_pixel],ax ; add to y pixel position 4600 4601 ;-------------------------------------------------------------------- 4602 ; Get a pointer to the source buffer so we can handle the clipping 4603 ;-------------------------------------------------------------------- 4604 get_buffer: 4605 lds si,[buffer] ; get a pointer to the buffer 4606 4607 ;-------------------------------------------------------------------- 4608 ; Check the top of our shape and clip any lines that are necessary 4609 ;-------------------------------------------------------------------- 4610 mov ax,[y_pixel] ; get the y_pixel draw position 4611 sub ax,[win_y1] ; subtract out the window y top 4612 jns short check_bottom ; skip if y below window top 4613 add ax,[pixel_h] ; add in the height of the region 4614 jg short clip_top ; if positive then clip top lines 4615 4616 jump_exit: 4617 jmp proc_exit ; otherwise completely clipped 4618 4619 clip_top: 4620 xchg [pixel_h],ax 4621 sub ax,[pixel_h] 4622 add [y_pixel],ax 4623 mul [pixel_w] ; convert to number of bytes to skip 4624 add si,ax ; skip past the necessary bytes 4625 4626 ;-------------------------------------------------------------------- 4627 ; Check the bottom of our shape and clip it if necessary 4628 ;-------------------------------------------------------------------- 4629 check_bottom: 4630 mov ax,[win_y2] ; get the bottom y of the window 4631 sub ax,[y_pixel] ; subtract of the y to draw at 4632 js jump_exit ; if its signed then nothing to draw 4633 jz jump_exit ; if its zero then nothing to draw 4634 4635 cmp ax,[pixel_h] ; if more room to draw then height 4636 jae short clip_x_left ; then go check the left clip 4637 mov [pixel_h],ax ; clip all but amount that will fit 4638 4639 clip_x_left: 4640 mov [clipleft],0 ; clear clip on left of region 4641 mov ax,[x_pixel] ; get the pixel x of draw region 4642 sub ax,[win_x1] ; pull out the window coordinate 4643 jns short clip_x_right 4644 neg ax ; negate to get amnt to skip in buf 4645 mov [clipleft],ax ; store it in the left clip info 4646 add [x_pixel],ax ; move to the edge of the window 4647 sub [pixel_w],ax ; pull it out of the pixel width 4648 4649 clip_x_right: 4650 mov [clipright],0 ; clear clip on right of region 4651 mov ax,[win_x2] ; get the window x of clip region 4652 sub ax,[x_pixel] ; subtract the draw edge of region 4653 js jump_exit ; if its negative then get out 4654 jz jump_exit ; if its zero then get out 4655 4656 cmp ax,[pixel_w] ; is space available larger than w 4657 jae short draw_prep ; if so then go get drawing 4658 4659 4660 xchg [pixel_w],ax ; amt to draw in pixel_w (wid in ax) 4661 sub ax,[pixel_w] ; pull out the amount to draw 4662 mov [clipright],ax ; this is the amount to clip on right 4663 4664 draw_prep: 4665 push si ; save off source pos in buffer 4666 push ds ; both offset and segment 4667 mov ax,@data 4668 mov ds,ax 4669 mov bx,[y_pixel] 4670 shl bx,1 ; shift left by 1 for word table look 4671 lds si,[YTable] ; get the address of the ytable 4672 mov di,[ds:si+bx] ; look up the multiplied value 4673 pop ds ; restore source pos in buffer 4674 pop si ; both offset and segment 4675 4676 add di,[x_pixel] ; add in the x pixel position 4677 mov [nextline],di ; save it off in the next line 4678 4679 ;-------------------------------------------------------------------- 4680 ; Now determine the type of the shape and process it in the proper 4681 ; way. 4682 ;-------------------------------------------------------------------- 4683 mov dx,[pixel_h] 4684 4685 ; Check to see if the WSA is the screen width and there is no 4686 ; clipping. In this case, then a special single call to the 4687 ; line processing routine is possible. 4688 mov ax,[clipleft] 4689 add ax,[clipright] 4690 jne short top_of_loop 4691 cmp [pixel_w],BYTESPERROW 4692 jne short top_of_loop 4693 4694 ;------------------------------------ 4695 ; The width of the WSA is the screen width, so just process as 4696 ; one large WSA line. 4697 mov ax,BYTESPERROW 4698 imul dx 4699 mov cx,ax 4700 call [putmiddle] 4701 jmp short proc_exit 4702 4703 ;------------------------------------ 4704 ; Process line by line. 4705 top_of_loop: 4706 add si,[clipleft] ; skip whats necessary on left edge 4707 mov cx,[pixel_w] ; get the width we need to draw 4708 4709 ; Copy the source to the destination as appropriate. This routine can 4710 ; trash AX, BX, CX, and DI. It must properly modify SI to point one byte past 4711 ; the end of the data. 4712 call [putmiddle] 4713 4714 add si,[clipright] ; skip past the left clip 4715 add [nextline],BYTESPERROW 4716 mov di,[nextline] 4717 4718 dec dx 4719 jnz top_of_loop 4720 4721 proc_exit: 4722 pop fs 4723 ret 4724 ENDP 4725 4726 4727 ;*************************************************************************** 4728 ;* NORMAL_DRAW -- Function that writes a normal pixel line * 4729 ;* * 4730 ;* INPUT: cx - number of pixels to write * 4731 ;* ds:si - buffer which holds the pixels to write * 4732 ;* es:di - place to put the pixels we are writing * 4733 ;* * 4734 ;* OUTPUT: ds:si - points to next pixel past last pixel read * 4735 ;* es:di - points to next pixel past last pixel written * 4736 ;* * 4737 ;* WARNINGS: none * 4738 ;* * 4739 ;* HISTORY: * 4740 ;* 07/17/1992 PWG : Created. * 4741 ;*=========================================================================* 4742 4743 PROC NOLANGUAGE WSA_Normal_Draw NEAR 4744 4745 IF 1 4746 ; This version is marginally faster than the later version. 4747 mov ax,cx 4748 shr cx,2 4749 rep movsd 4750 and ax,011b 4751 mov cx,ax 4752 shr cx,1 4753 rep movsw 4754 adc cx,cx 4755 rep movsb 4756 ret 4757 4758 ELSE 4759 4760 shr cx,1 ; convert to words (odd pix in carry) 4761 rep movsw ; write out the needed words 4762 adc cx,0 ; add the carry into cx 4763 rep movsb ; write out the odd byte if any 4764 ret 4765 ENDIF 4766 4767 ENDP 4768 4769 4770 ;*************************************************************************** 4771 ;* TRANSPARENT_DRAW -- Function that writes a transparent pixel line * 4772 ;* * 4773 ;* INPUT: cx - number of pixels to write * 4774 ;* ds:si - buffer which holds the pixels to write * 4775 ;* es:di - place to put the pixels we are writing * 4776 ;* * 4777 ;* OUTPUT: ds:si - points to next pixel past last pixel read * 4778 ;* es:di - points to next pixel past last pixel written * 4779 ;* * 4780 ;* WARNINGS: none * 4781 ;* * 4782 ;* HISTORY: * 4783 ;* 07/17/1992 PWG : Created. * 4784 ;* 10/02/1994 JLB : Optimized for 250% speed improvement. * 4785 ;*=========================================================================* 4786 PROC NOLANGUAGE Transparent_Draw NEAR 4787 4788 IF 1 4789 ; Preserve DX since it is used as a scratch register. 4790 push dx 4791 4792 loop: 4793 ; Swap DS:SI and ES:DI back in preparation for the REP SCASB 4794 ; instruction. 4795 xchg di,si 4796 mov dx,es 4797 mov ax,ds 4798 mov ds,dx 4799 mov es,ax 4800 4801 ; Remember the bytes remaining in order to calculate the position 4802 ; of the scan when it stops. 4803 mov bx,cx 4804 4805 ; Scan looking for a non-zero value in the source buffer. 4806 xor al,al 4807 repe scasb 4808 4809 ; When the loop ends, if the EQ flag is set then the scanning is 4810 ; complete. Jump to the end of the routine in order to fixup the 4811 ; pointers. 4812 je short fini 4813 4814 ; Advance the destination pointer by the amount necessary to match 4815 ; the source movement. DS:SI points to where data should be written. 4816 add si,bx 4817 inc cx ; SCASB leaves CX one too low, fix it. 4818 dec di ; SCASB leaves DI one byte too far, fix it. 4819 sub si,cx 4820 4821 ; Scan for the duration of non-zero pixels. This yields a count which 4822 ; is used to copy the source data to the destination. Preserve DI. 4823 mov dx,di 4824 mov bx,cx 4825 repne scasb 4826 mov di,dx 4827 4828 ; Set BX to equal the number of bytes to copy from source to dest. 4829 inc cx ; SCASB leaves CX one too low, fix it. 4830 sub bx,cx 4831 4832 ; Move the data from ES:DI to DS:SI for BX bytes. 4833 xchg cx,bx ; Make CX=bytes to move, BX=bytes remaining. 4834 4835 ; Swap DS:SI and ES:DI in preparation for the REP MOV instruction. 4836 xchg di,si 4837 mov dx,es 4838 mov ax,ds 4839 mov ds,dx 4840 mov es,ax 4841 4842 ; Move the data from source to dest. First try to move double 4843 ; words. Then copy the remainder bytes (if any). Putting jumps in 4844 ; this section doesn't result in any savings -- oh well. 4845 mov ax,cx 4846 shr cx,2 4847 rep movsd 4848 and ax,0011b 4849 mov cx,ax 4850 shr cx,1 4851 rep movsw 4852 adc cx,cx 4853 rep movsb 4854 4855 ; Restore CX with the remaining bytes to process. 4856 mov cx,bx 4857 4858 ; If there are more bytes to process, then loop back. 4859 or cx,cx 4860 jne short loop 4861 4862 fini: 4863 ; Swap ES:DI and DS:SI back to original orientation. 4864 mov ax,ds 4865 mov bx,es 4866 mov es,ax 4867 mov ds,bx 4868 xchg di,si 4869 4870 ; Restore DX and return. 4871 pop dx 4872 ret 4873 4874 ELSE 4875 4876 loop_top: 4877 lodsb 4878 or al,al 4879 jz short skip 4880 4881 mov [es:di],al ; store the pixel to the screen 4882 skip: 4883 inc di 4884 loop loop_top 4885 ret 4886 4887 ENDIF 4888 4889 ENDP 4890 4891 4892 ;*************************************************************************** 4893 ;* PRIORITY_DRAW -- Function that writes a pixels if they are in front of * 4894 ;* the given plate. * 4895 ;* * 4896 ;* INPUT: cx - number of pixels to write * 4897 ;* ds:si - buffer which holds the pixels to write * 4898 ;* es:di - place to put the pixels we are writing * 4899 ;* * 4900 ;* OUTPUT: ds:si - points to next pixel past last pixel read * 4901 ;* es:di - points to next pixel past last pixel written * 4902 ;* * 4903 ;* WARNINGS: none * 4904 ;* * 4905 ;* HISTORY: * 4906 ;* 07/17/1992 PWG : Created. * 4907 ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. * 4908 ;* 17/01/1993 MCC : Updated for 386, and optimized * 4909 ;*=========================================================================* 4910 4911 PROC NOLANGUAGE Priority_Draw NEAR 4912 4913 mov fs,[background] ; get the SEG of the background page 4914 mov gs,[maskpage] ; get the SEG of the mask info 4915 mov ah,[priority] ; keep a copy of priority varible for faster cmp 4916 4917 4918 loop_top: 4919 lodsb ; get the pixel to draw on the screen 4920 4921 ; get the mask byte for our pixel 4922 mov bl,[ds:di] 4923 ; get rid of non-walkable bit and 4924 ; get rid of scaling id bits 4925 and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS 4926 4927 cmp ah,bl ; are we more toward the front? 4928 jge short out_pixel ; if so then write the pixel 4929 4930 mov al,[fs:di] ; get the pixel to write 4931 out_pixel: 4932 stosb ; write the pixel and inc the DI 4933 loop loop_top 4934 ret 4935 4936 ENDP 4937 4938 4939 ;*************************************************************************** 4940 ;* PRIORITY_TRANSPARENT_DRAW -- Function that writes a pixels if they are * 4941 ;* in front of the given plate. It also deals with * 4942 ;* transparent pixels. * 4943 ;* * 4944 ;* INPUT: cx - number of pixels to write * 4945 ;* ds:si - buffer which holds the pixels to write * 4946 ;* es:di - place to put the pixels we are writing * 4947 ;* * 4948 ;* OUTPUT: ds:si - points to next pixel past last pixel read * 4949 ;* es:di - points to next pixel past last pixel written * 4950 ;* * 4951 ;* WARNINGS: none * 4952 ;* * 4953 ;* HISTORY: * 4954 ;* 07/17/1992 PWG : Created. * 4955 ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. * 4956 ;* 17/01/1993 MCC : Updated for 386, and optimized * 4957 ;*=========================================================================* 4958 4959 PROC NOLANGUAGE Priority_Transparent_Draw NEAR 4960 4961 mov fs,[background] ; get the SEG of the background page 4962 mov gs,[maskpage] ; get the SEG of the mask info 4963 mov ah,[priority] ; keep a copy of priority varible for faster cmp 4964 4965 loop_top: 4966 lodsb ; get the pixel on the screen 4967 or al,al ; check to see if al is transparent 4968 je short write_back ; if it is go write background 4969 4970 mov bl,[gs:di] ; get the mask byte for our pixel 4971 4972 ; get rid of non-walkable bit and 4973 ; get rid of scaling id bits 4974 and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS 4975 4976 cmp ah,bl ; are we more toward the front? 4977 jge short out_pixel ; if so then write the pixel 4978 4979 write_back: 4980 mov al,[fs:di] ; get the pixel to write 4981 out_pixel: 4982 stosb ; write the pixel 4983 loop loop_top 4984 ret 4985 4986 ENDP 4987 4988 4989 ;*************************************************************************** 4990 ;* GHOST_NORMAL_DRAW -- Function that writes a normal pixel line * 4991 ;* * 4992 ;* INPUT: cx - number of pixels to write * 4993 ;* ds:si - buffer which holds the pixels to write * 4994 ;* es:di - place to put the pixels we are writing * 4995 ;* * 4996 ;* OUTPUT: ds:si - points to next pixel past last pixel read * 4997 ;* es:di - points to next pixel past last pixel written * 4998 ;* * 4999 ;* WARNINGS: none * 5000 ;* * 5001 ;* HISTORY: * 5002 ;* 05/27/1993 MCC : Created. * 5003 ;*=========================================================================* 5004 5005 PROC NOLANGUAGE Ghost_Normal_Draw NEAR 5006 5007 loop_top: 5008 lodsb 5009 5010 ;--- 5011 ; Ok, find out if the colour is a Translucent colour 5012 push ax 5013 push ds 5014 5015 lds bx,[IsTranslucent] 5016 mov ah,al ; preserve real pixel 5017 xlat ; get new al (transluecent pixel 5018 xchg ah,al ; get real pixel back into AL just in case 5019 cmp ah,255 5020 je short normal_pixel ; is it a translucent ? 5021 ; if we get passed here value in 5022 ; AH should be 0-15 5023 5024 ; yes, it is a translucent colour so goto our translucent translation 5025 ; table and set up a ptr to the correct table 5026 5027 mov al,[es:di] 5028 ; mov pixel at destination to al and we have 5029 ; the index to the translation table 5030 ; ((trans_colour * 256) + dest colour) 5031 lds bx,[Translucent] ; get the ptr to it! 5032 add bh,ah ; Add the (trans_color * 256) of the translation equ. 5033 ; XLAT only uses AL so no need to clear AH 5034 xlat ; get new pixel in AL 5035 5036 normal_pixel: 5037 pop ds 5038 pop bx 5039 mov ah,bh 5040 ;--- 5041 5042 mov [es:di],al ; store the pixel to the screen 5043 5044 skip: 5045 inc di 5046 loop loop_top 5047 5048 ret 5049 5050 ENDP 5051 5052 5053 ;*************************************************************************** 5054 ;* GHOST_TRANSPARENT_DRAW -- Function that writes a transparent pixel line * 5055 ;* * 5056 ;* INPUT: cx - number of pixels to write * 5057 ;* ds:si - buffer which holds the pixels to write * 5058 ;* es:di - place to put the pixels we are writing * 5059 ;* * 5060 ;* OUTPUT: ds:si - points to next pixel past last pixel read * 5061 ;* es:di - points to next pixel past last pixel written * 5062 ;* * 5063 ;* WARNINGS: none * 5064 ;* * 5065 ;* HISTORY: * 5066 ;* 05/27/1993 MCC : Created. * 5067 ;*=========================================================================* 5068 PROC NOLANGUAGE Ghost_Transparent_Draw NEAR 5069 5070 loop_top: 5071 lodsb 5072 or al,al 5073 jz short skip 5074 5075 ;--- 5076 ; Ok, find out if the colour is a Translucent colour 5077 push ax 5078 push ds 5079 5080 lds bx,[IsTranslucent] 5081 mov ah,al ; preserve real pixel 5082 xlat ; get new al (transluecent pixel 5083 xchg ah,al ; get real pixel back into AL just in case 5084 cmp ah,255 5085 je short normal_pixel ; is it a translucent ? 5086 ; if we get passed here value in 5087 ; AH should be 0-15 5088 5089 ; yes, it is a translucent colour so goto our translucent translation 5090 ; table and set up a ptr to the correct table 5091 5092 mov al,[es:di] 5093 ; mov pixel at destination to al and we have 5094 ; the index to the translation table 5095 ; ((trans_colour * 256) + dest colour) 5096 lds bx,[Translucent] ; get the ptr to it! 5097 add bh,ah ; Add the (trans_color * 256) of the translation equ. 5098 ; XLAT only uses AL so no need to clear AH 5099 xlat ; get new pixel in AL 5100 5101 normal_pixel: 5102 pop ds 5103 pop bx 5104 mov ah,bh 5105 ;--- 5106 5107 mov [es:di],al ; store the pixel to the screen 5108 5109 skip: 5110 inc di 5111 loop loop_top 5112 ret 5113 5114 ENDP 5115 5116 5117 ;*************************************************************************** 5118 ;* GHOST_PRIORITY_DRAW -- Function that writes a pixels if they are in fron* 5119 ;* the given plate. * 5120 ;* * 5121 ;* INPUT: cx - number of pixels to write * 5122 ;* ds:si - buffer which holds the pixels to write * 5123 ;* es:di - place to put the pixels we are writing * 5124 ;* * 5125 ;* OUTPUT: ds:si - points to next pixel past last pixel read * 5126 ;* es:di - points to next pixel past last pixel written * 5127 ;* * 5128 ;* WARNINGS: none * 5129 ;* * 5130 ;* HISTORY: * 5131 ;* 07/17/1992 PWG : Created. * 5132 ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. * 5133 ;* 05/27/1993 MCC : Updated to use the new Ghosting fx * 5134 ;* 17/01/1993 MCC : Updated for 386, and optimized * 5135 ;*=========================================================================* 5136 PROC NOLANGUAGE Ghost_Priority_Draw NEAR 5137 5138 mov fs,[background] ; get the SEG of the background page 5139 mov gs,[maskpage] ; get the SEG of the mask info 5140 mov ah,[priority] ; keep a copy of priority varible for faster cmp 5141 5142 5143 loop_top: 5144 lodsb ; get the pixel to draw on the screen 5145 ; get the mask byte for our pixel 5146 mov bl,[ds:di] 5147 ; get rid of non-walkable bit and 5148 ; get rid of scaling id bits 5149 and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS 5150 cmp ah,bl ; are we more toward the front? 5151 jge short out_pixel ; if so then write the pixel 5152 5153 mov al,[fs:di] ; get the pixel to write 5154 out_pixel: 5155 stosb ; write the pixel and inc the DI 5156 loop loop_top 5157 5158 ret 5159 5160 ENDP 5161 5162 5163 ;*************************************************************************** 5164 ;* GHOST_PRIORITY_TRANSPARENT_DRAW -- Function that writes a pixels if they* 5165 ;* in front of the given plate. It also deals with * 5166 ;* transparent pixels. * 5167 ;* * 5168 ;* INPUT: cx - number of pixels to write * 5169 ;* ds:si - buffer which holds the pixels to write * 5170 ;* es:di - place to put the pixels we are writing * 5171 ;* * 5172 ;* OUTPUT: ds:si - points to next pixel past last pixel read * 5173 ;* es:di - points to next pixel past last pixel written * 5174 ;* * 5175 ;* WARNINGS: none * 5176 ;* * 5177 ;* HISTORY: * 5178 ;* 07/17/1992 PWG : Created. * 5179 ;* 12/01/1992 MBL : Updated to work with latest mask data encoding. * 5180 ;* 05/27/1993 MCC : Updated to use the new Ghosting fx * 5181 ;* 17/01/1993 MCC : Updated for 386, and optimized * 5182 ;*=========================================================================* 5183 PROC NOLANGUAGE Ghost_Priority_Transparent_Draw NEAR 5184 5185 mov fs,[background] ; get the SEG of the background page 5186 mov gs,[maskpage] ; get the SEG of the mask info 5187 mov ah,[priority] ; keep a copy of priority varible for faster cmp 5188 5189 loop_top: 5190 lodsb ; get the pixel on the screen 5191 or al,al ; check to see if al is transparent 5192 je short write_back ; if it is go write background 5193 mov bl,[gs:di] ; get the mask byte for our pixel 5194 ; get rid of non-walkable bit and 5195 ; get rid of scaling id bits 5196 and bl,CLEAR_NON_WALK_BIT_AND_SCALE_BITS 5197 cmp ah,bl ; are we more toward the front? 5198 jge short out_pixel ; if so then write the pixel 5199 write_back: 5200 mov al,[fs:di] ; get the pixel to write 5201 out_pixel: 5202 stosb ; write the pixel 5203 loop loop_top 5204 5205 ret 5206 5207 ENDP 5208 5209 END 5210