TMAP_ED.ASM 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. ; THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  2. ; SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  3. ; END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  4. ; ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  5. ; IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  6. ; SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  7. ; FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  8. ; CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  9. ; AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  10. ; COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  11. .386
  12. option oldstructs
  13. .nolist
  14. include pstypes.inc
  15. include psmacros.inc
  16. include tmap_inc.asm
  17. .list
  18. assume cs:_TEXT, ds:_DATA
  19. _DATA segment dword public USE32 'DATA'
  20. rcsid db "$Id: tmap_ed.asm 1.1 1996/01/24 16:35:44 champaign Exp $"
  21. align 4
  22. _DATA ends
  23. _TEXT segment dword public USE32 'CODE'
  24. ; --------------------------------------------------------------------------------------------------
  25. ; Enter:
  26. ; _xleft fixed point left x coordinate
  27. ; _xright fixed point right x coordinate
  28. ; _y fixed point y coordinate
  29. ; _pixptr address of source pixel map
  30. ; _u fixed point initial u coordinate
  31. ; _v fixed point initial v coordinate
  32. ; _z fixed point initial z coordinate
  33. ; _du_dx fixed point du/dx
  34. ; _dv_dx fixed point dv/dx
  35. ; _dz_dx fixed point dz/dx
  36. ; for (x = (int) xleft; x <= (int) xright; x++) {
  37. ; _setcolor(read_pixel_from_tmap(srcb,((int) (u/z)) & 63,((int) (v/z)) & 63));
  38. ; _setpixel(x,y);
  39. ;
  40. ; u += du_dx;
  41. ; v += dv_dx;
  42. ; z += dz_dx;
  43. ; }
  44. zonk equ 1
  45. xonk equ 01010101h
  46. public asm_tmap_scanline_editor_
  47. asm_tmap_scanline_editor_:
  48. pusha
  49. ;---------------------------- setup for loop ---------------------------------
  50. ; Setup for loop: _loop_count iterations = (int) xright - (int) xleft
  51. ; esi source pixel pointer = pixptr
  52. ; edi initial row pointer = y*320+x
  53. ; set esi = pointer to start of texture map data
  54. mov edi, _dest_row_data
  55. ; set initial values
  56. mov ebx,_fx_u
  57. mov ebp,_fx_v
  58. mov ecx,_fx_z
  59. ;-------------------- NORMAL PERSPECTIVE TEXTURE MAP LOOP -----------------
  60. align 4
  61. tmap_loop:
  62. xchg ebx, esi
  63. ; compute v coordinate
  64. mov eax,ebp ; get v
  65. cdq
  66. idiv ecx ; eax = (v/z)
  67. and eax,3fh ; mask with height-1
  68. mov ebx,eax
  69. ; compute u coordinate
  70. mov eax,esi ; get u
  71. cdq
  72. idiv ecx ; eax = (u/z)
  73. shl eax,26
  74. shld ebx,eax,6 ; esi = v*64+u
  75. ; read 1 pixel
  76. add ebx, _pixptr
  77. movzx eax,byte ptr [ebx] ; get pixel from source bitmap
  78. ; transparency check
  79. NoLight1: cmp al,255
  80. je skip1
  81. mov byte ptr [edi],zonk
  82. skip1: inc edi
  83. ; update deltas
  84. add ebp,_fx_dv_dx
  85. add esi,_fx_du_dx
  86. add ecx,_fx_dz_dx
  87. je _div_0_abort ; would be dividing by 0, so abort
  88. xchg esi, ebx
  89. dec _loop_count
  90. jns tmap_loop
  91. _div_0_abort:
  92. _none_to_do:
  93. popa
  94. ret
  95. _TEXT ends
  96. end