home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / texmap / tmapfade.asm < prev    next >
Assembly Source File  |  1998-06-08  |  4KB  |  154 lines

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