home *** CD-ROM | disk | FTP | other *** search
/ The Equalizer BBS / equalizer-bbs-collection_2004.zip / equalizer-bbs-collection / DEMOSCENE-STUFF / IBYTES02.ZIP / SRC_HI!.ZIP / ROT.ASM < prev    next >
Assembly Source File  |  1994-07-05  |  4KB  |  200 lines

  1. TTEST        =    0
  2.  
  3. ; What this code expects :
  4. ; General computation coefficients
  5. FRACBITS    =    10
  6. FRACMUL        =    (1 shl FRACBITS)
  7. FRACMASK    =    FRACMUL-1
  8.  
  9. ; Bitmap side sizes
  10. IF    TTEST
  11. BMPXBITS    =    3
  12. ELSE
  13. BMPXBITS    =    7    ; Bits in X side
  14. ENDIF
  15. BMPXMUL        =    (1 shl BMPXBITS)
  16. IF    TTEST
  17. BMPYBITS    =    3
  18. ELSE
  19. BMPYBITS    =    7    ; Bits in Y side
  20. ENDIF
  21. BMPYMUL        =    (1 shl BMPYBITS)
  22.  
  23. ; Usual or special VGA mode
  24. USUALVGA    =    1    ; 320x200x256, 1 page, else --//--, 4 pages
  25. IF    USUALVGA
  26. NEXTROWO    =    320
  27. ELSE
  28. NEXTROWO    =    80
  29. ENDIF
  30.  
  31.         ideal
  32.         p386
  33.         model    large,pascal
  34.         codeseg
  35. MACRO    udat
  36.         ufardata    ROT_PSEG
  37. ENDM
  38.  
  39. ; -- set_rotate_texture ----------------------------------------
  40. ;
  41. @rotps    dw    ROT_PSEG
  42.         udat
  43. textureseg    dw    ?
  44.         codeseg
  45. public        set_rotate_texture
  46. proc        set_rotate_texture
  47.     push    ds
  48.     mov    ds,[@rotps]
  49.     assume    ds:ROT_PSEG
  50.     mov    [textureseg],ax
  51.     pop    ds
  52.     assume    ds:NOTHING
  53.     ret
  54. endp        set_rotate_texture
  55.  
  56. ; -- set_rotate_params -----------------------------------------
  57. ; EAX,EBX-rotation coefs,ECX-coords zoom coef.
  58.         udat
  59. rot_xcoef    dd    ?
  60. _rot_xcoef    dd    ?
  61. rot_ycoef    dd    ?
  62. _rot_ycoef    dd    ?
  63.         codeseg
  64. public        set_rotate_params
  65. proc        set_rotate_params    far
  66.     push    ds
  67.     mov    ds,[@rotps]
  68.     assume    ds:ROT_PSEG
  69. ;;;
  70. neg    eax
  71. ;neg    ebx
  72.     xchg    eax,ebx
  73.     imul    ecx
  74.     shrd    eax,edx,FRACBITS
  75.     mov    [rot_xcoef],eax
  76.     shl    eax,32-FRACBITS-BMPXBITS
  77.     mov    [_rot_xcoef],eax
  78.     xchg    eax,ebx
  79.     imul    ecx
  80.     shrd    eax,edx,FRACBITS
  81.     mov    [rot_ycoef],eax
  82.     shl    eax,32-FRACBITS-BMPYBITS
  83.     mov    [_rot_ycoef],eax
  84.     pop    ds
  85.     assume    ds:NOTHING
  86.     ret
  87. endp        set_rotate_params
  88.  
  89. ; -- set_rotate_center -----------------------------------------
  90. ; AX,BX-center coordinates
  91.         udat
  92. centerx    dw    ?
  93. centery    dw    ?
  94.         codeseg
  95. public        set_rotate_center
  96. proc        set_rotate_center    far
  97.     push    ds
  98.     mov    ds,[@rotps]
  99.     assume    ds:ROT_PSEG
  100.     mov    [centerx],ax
  101.     mov    [centery],bx
  102.     pop    ds
  103.     assume    ds:NOTHING
  104.     ret
  105. endp        set_rotate_center
  106.  
  107. ; -- rot_draw_page ---------------------------------------------
  108. ;
  109.         udat
  110. rot_dpage    dw    ?
  111.         codeseg
  112. public        rot_draw_page
  113. proc        rot_draw_page    far
  114.     push    ds
  115.     mov    ds,[@rotps]
  116.     assume    ds:ROT_PSEG
  117.     mov    [rot_dpage],ax
  118.     pop    ds
  119.     assume    ds:NOTHING
  120.     ret
  121. endp        rot_draw_page
  122.  
  123. ; -- rot_draw_column -------------------------------------------
  124. ; AX,BX-column screen coords(x,y), CX-end y
  125. ; No bounds checking is performed.
  126. public        rot_draw_column
  127. proc        rot_draw_column    far    uses    esi edi edx ebp ds es fs
  128.     mov    ds,[@rotps]
  129.     assume    ds:ROT_PSEG
  130.     mov    dx,ax
  131.     sub    cx,bx    ; Number of dots to draw
  132.     inc    cx
  133.     imul    di,bx,NEXTROWO
  134.     IF    USUALVGA eq 0
  135.     shr    dx,2    ; Strip pixel mask bits
  136.     ENDIF
  137.     add    di,dx
  138.     mov    es,[rot_dpage]
  139.     sub    ax,[centerx]
  140. neg    ax
  141.     movsx    eax,ax
  142.     mov    esi,eax
  143.     imul    [rot_xcoef]
  144.     mov    ebp,eax
  145.     sub    bx,[centery]
  146.     neg    bx
  147.     movsx    ebx,bx
  148.     mov    eax,ebx
  149.     imul    [rot_ycoef]
  150.     sub    ebp,eax
  151.     shl    ebp,32-FRACBITS-BMPXBITS
  152.     xor    ebp,80000000h    ; These XORs to put rotation center and picture center into one point
  153.     mov    eax,esi
  154.     imul    [rot_ycoef]
  155.     mov    esi,eax
  156.     movsx    eax,bx
  157.     imul    [rot_xcoef]
  158.     mov    edx,eax
  159.     add    edx,esi
  160.     shl    edx,32-FRACBITS-BMPYBITS
  161.     xor    edx,80000000h
  162.     mov    eax,[_rot_xcoef]
  163.     neg    eax
  164.     mov    esi,[_rot_ycoef]
  165.     mov    ds,[textureseg]
  166.     assume    ds:NOTHING
  167. @@test:
  168.     test    cl,3
  169.     jz    @@shift
  170.     MACRO    moveb    step,isend
  171.     xor    bx,bx
  172.     shld    ebx,edx,BMPYBITS
  173.     shld    ebx,ebp,BMPXBITS
  174.     mov    bl,[bx]
  175.     mov    [es:di+(step)*NEXTROWO],bl
  176.     add    edx,eax
  177.     add    ebp,esi
  178.     IFNB    <isend>
  179.     add    di,(isend)*NEXTROWO
  180.     ENDIF
  181.     ENDM
  182.     moveb    0,1
  183.     dec    cx
  184.     jnz    @@test
  185. @@shift:
  186.     shr    cx,2
  187.     jz    @@end
  188. @@loop:
  189.     moveb    0
  190.     moveb    1
  191.     moveb    2
  192.     moveb    3,4
  193.     dec    cx
  194.     jnz    @@loop
  195. @@end:
  196.     assume    ds:NOTHING
  197.     ret
  198. endp        rot_draw_column
  199.  
  200.         end