home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / texmap / temp.asm < prev    next >
Assembly Source File  |  1998-06-08  |  5KB  |  225 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. public tmap_loop_fast_nolight
  12. tmap_loop_fast_nolight:
  13.  
  14.     align    4
  15. NotDwordAligned1_nolight:
  16.     test    edi, 11b
  17.     jz    DwordAligned1_nolight
  18.  
  19.     xchg    ebx, esi
  20.  
  21.     ; compute v coordinate
  22.     mov    eax,ebp    ; get v
  23.     cdq
  24.     idiv    ecx    ; eax = (v/z)
  25.  
  26.     and    eax,3fh    ; mask with height-1
  27.     mov    ebx,eax
  28.  
  29.     ; compute u coordinate
  30.     mov    eax,esi    ; get u
  31.     cdq
  32.     idiv    ecx    ; eax = (u/z)
  33.  
  34.     shl     eax,26
  35.     shld     ebx,eax,6        ; esi = v*64+u
  36.  
  37.     ; read 1  pixel
  38.     mov    al,es:[ebx]    ; get pixel from source bitmap
  39.     ; write 1 pixel
  40.     mov    [edi],al
  41.     inc    edi
  42.     
  43.     ; update deltas
  44.     add    ebp,_fx_dv_dx
  45.     add    esi,_fx_du_dx
  46.     add    ecx,_fx_dz_dx
  47.  
  48.     xchg    esi, ebx
  49.  
  50.     dec    _loop_count
  51.     jns    NotDwordAligned1_nolight
  52.     jmp    _none_to_do
  53.  
  54. DwordAligned1_nolight:
  55.     mov    eax, _loop_count
  56.     inc    eax
  57.     mov    num_left_over, eax
  58.     shr    eax, NBITS
  59.  
  60.     cmp    eax, 0        
  61.     je    tmap_loop
  62.     
  63.     mov     _loop_count, eax    ; _loop_count = pixels / NPIXS
  64.     ;OPshl    eax, NBITS
  65.     lea    eax, [eax*8]
  66.     sub    num_left_over, eax    ; num_left_over = obvious
  67.         
  68.     ; compute initial v coordinate
  69.     mov    eax,ebp    ; get v
  70.     PDIV
  71.     mov    V0, eax
  72.  
  73.     ; compute initial u coordinate
  74.     mov    eax,ebx    ; get u
  75.     PDIV    
  76.     mov    U0, eax
  77.  
  78.     ; Set deltas to NPIXS pixel increments
  79.     mov    eax, _fx_du_dx
  80.     ;OPshl    eax, NBITS
  81.     lea    eax, [eax*8]
  82.     mov    DU1, eax
  83.     mov    eax, _fx_dv_dx
  84.     ;OPshl    eax, NBITS
  85.     lea    eax, [eax*8]
  86.     mov    DV1, eax
  87.     mov    eax, _fx_dz_dx
  88.     ;OPshl    eax, NBITS
  89.     lea    eax, [eax*8]
  90.     mov    DZ1, eax
  91.  
  92.     align    4
  93. TopOfLoop4_nolight:
  94.         add    ebx, DU1
  95.         add    ebp, DV1
  96.         add    ecx, DZ1
  97.  
  98.         ; Done with ebx, ebp, ecx until next iteration
  99.         push    ebx
  100.         push    ecx
  101.         push    ebp
  102.         push    edi
  103.     
  104.         ; Find fixed U1        
  105.         mov    eax, ebx
  106.         PDIV
  107.         mov    ebx, eax    ; ebx = U1 until pop's
  108.  
  109.         ; Find fixed V1        
  110.         mov    eax, ebp
  111.         PDIV
  112.         mov    ebp, eax    ; ebp = V1 until pop's
  113.  
  114.         mov    ecx, U0        ; ecx = U0 until pop's
  115.         mov    edi, V0        ; edi = V0 until pop's
  116.  
  117.         ; Make ESI =  V0:U0 in 6:10,6:10 format
  118.         mov    eax, ecx
  119.         shr    eax, 6
  120.         mov    esi, edi
  121.         shl    esi, 10
  122.         mov    si, ax
  123.         
  124.         ; Make EDX = DV:DU in 6:10,6:10 format
  125.         mov    eax, ebx
  126.         sub    eax, ecx
  127.         sar    eax, NBITS+6
  128.         mov    edx, ebp
  129.         sub    edx, edi
  130.         shl    edx, 10-NBITS    ; EDX = V1-V0/ 4 in 6:10 int:frac
  131.         mov    dx, ax        ; put delta u in low word
  132.  
  133.         ; Save the U1 and V1 so we don't have to divide on the
  134.         ; next iteration
  135.         mov    U0, ebx
  136.         mov    V0, ebp
  137.  
  138.         pop    edi        ; Restore EDI before using it
  139.         
  140.         REPT (1 SHL (NBITS-2))
  141.             REPT 4    
  142.                 ; Do 1 pixel 
  143.                 mov    eax, esi    ; get u,v
  144.                 shr    eax, 26        ; shift out all but int(v)
  145.                 shld    ax,si,6        ; shift in u, shifting up v
  146.                 mov    cl, es:[eax]    ; load into buffer register
  147.                 add    esi, edx    ; inc u,v
  148.                 ror    ecx, 8        ; move to next dest pixel
  149.  
  150.             ENDM
  151.                     
  152.             mov     [edi],ecx        ; Draw 4 pixels to display
  153.             add     edi,4
  154.         ENDM
  155.  
  156.         pop    ebp
  157.         pop    ecx
  158.         pop    ebx
  159.         dec    _loop_count
  160.         jnz    TopOfLoop4_nolight
  161.  
  162. EndOfLoop4_nolight:
  163.  
  164.     cmp    num_left_over, 0
  165.     je    _none_to_do
  166.  
  167. DoEndPixels_nolight:
  168.         add    ebx, DU1
  169.         add    ebp, DV1
  170.         add    ecx, DZ1
  171.  
  172.         push    edi        ; use edi as a temporary variable
  173.  
  174.         ; Find fixed U1        
  175.         mov    eax, ebx
  176.         PDIV
  177.         mov    ebx, eax    ; ebx = U1 until pop's
  178.  
  179.         ; Find fixed V1        
  180.         mov    eax, ebp
  181.         PDIV
  182.         mov    ebp, eax    ; ebp = V1 until pop's
  183.  
  184.         mov    ecx, U0        ; ecx = U0 until pop's
  185.         mov    edi, V0        ; edi = V0 until pop's
  186.  
  187.         ; Make ESI =  V0:U0 in 6:10,6:10 format
  188.         mov    eax, ecx
  189.         shr    eax, 6
  190.         mov    esi, edi
  191.         shl    esi, 10
  192.         mov    si, ax
  193.         
  194.         ; Make EDX = DV:DU in 6:10,6:10 format
  195.         mov    eax, ebx
  196.         sub    eax, ecx
  197.         sar    eax, NBITS+6
  198.         mov    edx, ebp
  199.         sub    edx, edi
  200.         shl    edx, 10-NBITS    ; EDX = V1-V0/ 4 in 6:10 int:frac
  201.         mov    dx, ax        ; put delta u in low word
  202.  
  203.         pop    edi        ; Restore EDI before using it
  204.         
  205.         mov    ecx, num_left_over
  206.  
  207.         ITERATION = 0
  208.         REPT (1 SHL NBITS)
  209.             ; Do 1 pixel 
  210.             mov    eax, esi    ; get u,v
  211.             shr    eax, 26        ; shift out all but int(v)
  212.             shld    ax,si,6        ; shift in u, shifting up v
  213.             mov    al, es:[eax]    ; load into buffer register
  214.             add    esi, edx    ; inc u,v
  215.             mov    [edi+ITERATION], al    ; write pixel
  216.             dec    ecx
  217.             jz    _none_to_do
  218.             ITERATION = ITERATION + 1
  219.         ENDM
  220.  
  221.         ; Should never get here!!!!!
  222.         int    3
  223.         jmp    _none_to_do
  224. 
  225.