TMAPFADE.ASM 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  11. ;
  12. ; $Source: f:/miner/source/texmap/rcs/tmapfade.asm $
  13. ; $Revision: 1.6 $
  14. ; $Author: john $
  15. ; $Date: 1995/02/20 18:23:01 $
  16. ;
  17. ; .
  18. ;
  19. ; $Log: tmapfade.asm $
  20. ; Revision 1.6 1995/02/20 18:23:01 john
  21. ; Put all the externs in the assembly modules into tmap_inc.asm.
  22. ; Also, moved all the C versions of the inner loops into a new module,
  23. ; scanline.c.
  24. ;
  25. ; Revision 1.5 1995/02/20 17:09:15 john
  26. ; Added code so that you can build the tmapper with no assembly!
  27. ;
  28. ; Revision 1.4 1994/12/02 23:29:36 mike
  29. ; change jb/ja to jl/jg.
  30. ;
  31. ; Revision 1.3 1994/11/30 00:57:36 mike
  32. ; *** empty log message ***
  33. ;
  34. ; Revision 1.2 1994/10/06 18:38:49 john
  35. ; Added the ability to fade a scanline by calling gr_upoly_tmap
  36. ; with Gr_scanline_darkening_level with a value < MAX_FADE_LEVELS.
  37. ;
  38. ; Revision 1.1 1994/10/06 18:04:42 john
  39. ; Initial revision
  40. ;
  41. ;
  42. .386
  43. public asm_tmap_scanline_shaded_
  44. include tmap_inc.asm
  45. _DATA SEGMENT DWORD PUBLIC USE32 'DATA'
  46. _loop_count dd 0
  47. _DATA ENDS
  48. DGROUP GROUP _DATA
  49. _TEXT SEGMENT PARA PUBLIC USE32 'CODE'
  50. ASSUME DS:_DATA
  51. ASSUME CS:_TEXT
  52. ; --------------------------------------------------------------------------------------------------
  53. ; Enter:
  54. ; _xleft fixed point left x coordinate
  55. ; _xright fixed point right x coordinate
  56. ; _y fixed point y coordinate
  57. ;**; _pixptr address of source pixel map
  58. ; for (x = (int) xleft; x <= (int) xright; x++) {
  59. ; _setcolor(read_pixel_from_tmap(srcb,((int) (u/z)) & 63,((int) (v/z)) & 63));
  60. ; _setpixel(x,y);
  61. ;
  62. ; z += dz_dx;
  63. ; }
  64. asm_tmap_scanline_shaded_:
  65. push fs
  66. pusha
  67. mov fs, _gr_fade_table_selector
  68. ; Setup for loop: _loop_count iterations = (int) xright - (int) xleft
  69. ; edi initial row pointer = y*320+x
  70. ; set edi = address of first pixel to modify
  71. mov edi,_fx_y
  72. cmp edi,_window_bottom
  73. jae _none_to_do
  74. imul edi,_bytes_per_row
  75. mov eax,_fx_xleft
  76. test eax,eax
  77. jns eax_ok
  78. sub eax,eax
  79. eax_ok:
  80. add edi,eax
  81. add edi,write_buffer
  82. ; set _loop_count = # of iterations
  83. mov eax,_fx_xright
  84. cmp eax,_window_right
  85. jl eax_ok1
  86. mov eax,_window_right
  87. eax_ok1: cmp eax,_window_left
  88. jg eax_ok2
  89. mov eax,_window_left
  90. eax_ok2:
  91. mov ebx,_fx_xleft
  92. sub eax,ebx
  93. js _none_to_do
  94. cmp eax,_window_width
  95. jbe _ok_to_do
  96. mov eax,_window_width
  97. _ok_to_do:
  98. mov _loop_count, eax
  99. mov ecx, 0
  100. mov ch,_tmap_flat_shade_value
  101. and ch, 31
  102. _size = (_end1 - _start1)/num_iters
  103. mov eax,num_iters-1
  104. sub eax,_loop_count
  105. jns j_eax_ok1
  106. inc eax ; sort of a hack, but we can get -1 here and want to be graceful
  107. jns j_eax_ok1 ; if we jump, we had -1, which is kind of ok, if not, we int 3
  108. int 3 ; oops, going to jump behind _start1, very bad...
  109. sub eax,eax ; ok to continue
  110. j_eax_ok1: imul eax,eax,dword ptr _size
  111. add eax,offset _start1
  112. jmp eax
  113. align 4
  114. _start1:
  115. rept num_iters
  116. local l1
  117. mov cl, [edi] ; get pixel
  118. mov al, fs:[ecx] ; darken pixel
  119. mov [edi], al ; write pixel
  120. inc edi ; goto next pixel
  121. endm
  122. _end1:
  123. _none_to_do: popa
  124. pop fs
  125. ret
  126. _TEXT ends
  127. end
  128.