home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / prg / dsik205 / dsik.dat / EXAMPLES / EXAMP10B.ASM < prev    next >
Assembly Source File  |  1995-04-10  |  4KB  |  164 lines

  1. ;/***************************************************************************
  2. ;*
  3. ;*                   Digital Sound Interface Kit (DSIK)
  4. ;*                            Version 2.00
  5. ;*
  6. ;*                           by Carlos Hasan
  7. ;*
  8. ;* Filename:    example10b.asm
  9. ;* Version:     Revision 1.0
  10. ;*
  11. ;* Language:    Turbo Assembler 4.0 (Ideal Mode)
  12. ;* Environment: IBM PC (DOS/4GW)
  13. ;*
  14. ;* Description: Assembly routines for the examp10.c source file.
  15. ;*
  16. ;***************************************************************************/
  17.  
  18. ideal
  19. p386
  20. model flat,c
  21.  
  22. ; equates & structures
  23.  
  24. XDOTS   =   256                         ; window width and height in pixels
  25. YDOTS   =   160
  26.  
  27. struc point                             ; (x,y) 2-d point structure
  28.     x   dd      ?
  29.     y   dd      ?
  30. ends point
  31.  
  32.  
  33. ; data segment
  34.  
  35. dataseg
  36.  
  37. x1      dd      ?                       ; temp variables
  38. y1      dd      ?
  39. x2      dd      ?
  40. y2      dd      ?
  41. dx1     dd      ?
  42. dy1     dd      ?
  43. dx2     dd      ?
  44. dy2     dd      ?
  45.  
  46.  
  47. ; code segment
  48.  
  49. codeseg
  50.  
  51. global  drawimage:proc
  52.  
  53. ;============================================================================
  54. ; void drawimage(char *imageptr, point *pnts)
  55. ; In:
  56. ;  EAX = 256x256 image address
  57. ;  EDX = vertex points
  58. ;============================================================================
  59. proc    drawimage
  60.         pushad
  61.         mov     esi,eax                 ; esi = imageptr
  62.         mov     ebx,edx                 ; ebx = pnts
  63.  
  64.         mov     edi,0a0000h+((320-XDOTS)/2)+320*((200-YDOTS)/2)
  65.  
  66.         mov     eax,[ebx+8*0+point.x]   ; (x1,y1) = pnts[0]
  67.         mov     edx,[ebx+8*0+point.y]
  68.         shl     eax,8
  69.         shl     edx,8
  70.         mov     [x1],eax
  71.         mov     [y1],edx
  72.  
  73.         mov     eax,[ebx+8*1+point.x]   ; (x2,y2) = pnts[1]
  74.         mov     edx,[ebx+8*1+point.y]
  75.         shl     eax,8
  76.         shl     edx,8
  77.         mov     [x2],eax
  78.         mov     [y2],edx
  79.  
  80.         mov     eax,[ebx+8*3+point.x]   ; (dx1,dy1) = (pnts[3]-pnts[0])/YDOTS
  81.         sub     eax,[ebx+8*0+point.x]
  82.         cdq
  83.         shld    edx,eax,8
  84.         shl     eax,8
  85.         mov     ecx,YDOTS
  86.         idiv    ecx
  87.         mov     [dx1],eax
  88.         mov     eax,[ebx+8*3+point.y]
  89.         sub     eax,[ebx+8*0+point.y]
  90.         cdq
  91.         shld    edx,eax,8
  92.         shl     eax,8
  93.         idiv    ecx
  94.         mov     [dy1],eax
  95.  
  96.         mov     eax,[ebx+8*2+point.x]   ; (dx2,dy2) = (pnts[2]-pnts[1])/YDOTS
  97.         sub     eax,[ebx+8*1+point.x]
  98.         cdq
  99.         shld    edx,eax,8
  100.         shl     eax,8
  101.         mov     ecx,YDOTS
  102.         idiv    ecx
  103.         mov     [dx2],eax
  104.         mov     eax,[ebx+8*2+point.y]
  105.         sub     eax,[ebx+8*1+point.y]
  106.         cdq
  107.         shld    edx,eax,8
  108.         shl     eax,8
  109.         idiv    ecx
  110.         mov     [dy2],eax
  111.  
  112.         mov     ecx,YDOTS               ; for y=1 to YDOTS do
  113. drawimagel0:
  114.         push    ecx
  115.  
  116.         mov     eax,[y2]                ; stepy = (y2-y1)/XDOTS
  117.         sub     eax,[y1]
  118.         cdq
  119.         mov     ecx,XDOTS
  120.         idiv    ecx
  121.         mov     ebp,eax
  122.  
  123.         mov     eax,[x2]                ; stepx = (x2-x1)/XDOTS
  124.         sub     eax,[x1]
  125.         cdq
  126.         idiv    ecx
  127.         mov     ecx,eax
  128.  
  129.         mov     ebx,[x1]                ; (ebx,edx) = (x1,y1)
  130.         mov     edx,[y1]
  131.         xor     eax,eax
  132.  
  133.         I=0                             ; for x=1 to XDOTS do
  134.         REPT    XDOTS
  135.         mov     al,bh                   ; (ebx,edx) = (posx,posy)
  136.         mov     ah,dh                   ; (ecx,ebp) = (stepx,stepy)
  137.         add     ebx,ecx
  138.         mov     al,[eax+esi]
  139.         add     edx,ebp
  140.         mov     [edi+I],al
  141.         I=I+1
  142.         ENDM                            ; next x
  143.  
  144.         mov     eax,[dx1]               ; (x1,y1) += (dx1,dy1)
  145.         mov     edx,[dy1]
  146.         add     [x1],eax
  147.         add     [y1],edx
  148.  
  149.         mov     eax,[dx2]               ; (x2,y2) += (dx2,dy2)
  150.         mov     edx,[dy2]
  151.         add     [x2],eax
  152.         add     [y2],edx
  153.  
  154.         add     edi,320                 ; screenptr += 320
  155.         pop     ecx
  156.         dec     ecx
  157.         jg      drawimagel0             ; next y
  158.  
  159.         popad
  160.         ret
  161. endp
  162.  
  163. end
  164.