home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / IMGPROC.ZIP / C6VIEW.ZIP / VGAGRAPH.ASM next >
Encoding:
Assembly Source File  |  1990-10-11  |  2.6 KB  |  103 lines

  1. ;Copyright 1990 by John Wiley & Sons, Inc.
  2. ;          All Rights Reserved.
  3. ;
  4. ; VGA Mode 13 hex -- 256 color 320x200 functions
  5. ;
  6. ; written by Craig A. Lindley
  7. ; last update: 12/21/89
  8. ;
  9. ;
  10. vgagraph_TEXT    segment    byte public 'CODE'
  11.       DGROUP    group    _DATA,_BSS
  12.       assume    cs:vgagraph_TEXT,ds:DGROUP,ss:DGROUP
  13. vgagraph_TEXT    ends
  14.  
  15. _DATA    segment word public 'DATA'
  16. ;
  17. _DATA    ends
  18.  
  19. _BSS    segment word public 'BSS'
  20. ;
  21. _BSS    ends
  22. ;
  23. ;
  24. vgagraph_TEXT    segment    byte public 'CODE'
  25. ;
  26. ;320x200 256 Color Mode Routines
  27. ;
  28. ; Procedure _PutPixel256
  29. ;
  30. ; This procedure is used to directly access the video memory when the VGA or
  31. ; MCGA is in the 256 color mode 13H.
  32. ;
  33. ; CALL:   callable from C.
  34. ; PROTOTYPE: void PutPixel256 (unsigned Col, unsigned Row, unsigned Color);
  35. ; INPUT:  all parameters passed to this function are on the stack. The
  36. ;         stack should contain the following: Color at [bp+8], Row
  37. ;         at [bp+6] and the Col at [bp+4].
  38. ; OUTPUT: the specified pixel on the VGA screen is modified.
  39. ; USES:   and destroys ax,bx,cx,dx registers
  40. ;
  41.     Public _PutPixel256
  42. ;
  43. _PutPixel256    proc    far
  44. ;
  45.     push    bp
  46.     mov    bp,sp
  47.     mov    cx,[bp+10]        ;get pixel color in cl reg
  48.     mov    ax,[bp+8]        ;get Row #
  49.     mov    bx,[bp+6]        ;get Col #
  50. ;
  51. ;compute the address of the pixel in the video buffer
  52. ;
  53.     mov    dx,320            ;each pixel is one byte
  54.     mul    dx            ;find offset
  55.     add    bx,ax            ;bx = x + 320 * y
  56.     mov    ax,0A000H        ;seg of video buffer
  57.     mov    es,ax            ;es:bx pts at pixel in buffer
  58.     mov    es:[bx],cl        ;update the pixel
  59.     pop    bp
  60.     ret
  61. ;
  62. _PutPixel256    endp
  63. ;
  64. ; Procedure _GetPixel256
  65. ;
  66. ; This procedure is used to directly access the video memory when the VGA or
  67. ; MCGA is in the 256 color mode 13H.
  68. ;
  69. ; CALL:   callable from C.
  70. ; PROTOTYPE: unsigned PutPixel256 (unsigned Col, unsigned Row);
  71. ; INPUT:  all parameters passed to this function are on the stack. The
  72. ;         stack should contain the following: Row at [bp+6] and
  73. ;         the Col at [bp+4].
  74. ; OUTPUT: the specified pixel on the VGA screen is returned in ax.
  75. ; USES:   and destroys ax,bx,cx,dx registers
  76. ;
  77.     Public _GetPixel256
  78. ;
  79. _GetPixel256    proc    far
  80. ;
  81.     push    bp
  82.     mov    bp,sp
  83.     mov    ax,[bp+8]        ;get Row #
  84.     mov    bx,[bp+6]        ;get Col #
  85. ;
  86. ;compute the address of the pixel in the video buffer
  87. ;
  88.     mov    dx,320            ;each pixel is one byte
  89.     mul    dx            ;find offset
  90.     add    bx,ax            ;bx = x + 320 * y
  91.     mov    ax,0A000H        ;seg of video buffer
  92.     mov    es,ax            ;es:bx pts at pixel in buffer
  93.     mov    al,es:[bx]        ;get the pixels value
  94.     xor     ah,ah            ;mask most significant byte
  95.     pop    bp
  96.     ret
  97. ;
  98. _GetPixel256    endp
  99.  
  100. ;
  101. vgagraph_TEXT    ends
  102.     end
  103.