home *** CD-ROM | disk | FTP | other *** search
- ;Copyright 1990 by John Wiley & Sons, Inc.
- ; All Rights Reserved.
- ;
- ; VGA Mode 13 hex -- 256 color 320x200 functions
- ;
- ; written by Craig A. Lindley
- ; last update: 12/21/89
- ;
- ;
- vgagraph_TEXT segment byte public 'CODE'
- DGROUP group _DATA,_BSS
- assume cs:vgagraph_TEXT,ds:DGROUP,ss:DGROUP
- vgagraph_TEXT ends
-
- _DATA segment word public 'DATA'
- ;
- _DATA ends
-
- _BSS segment word public 'BSS'
- ;
- _BSS ends
- ;
- ;
- vgagraph_TEXT segment byte public 'CODE'
- ;
- ;320x200 256 Color Mode Routines
- ;
- ; Procedure _PutPixel256
- ;
- ; This procedure is used to directly access the video memory when the VGA or
- ; MCGA is in the 256 color mode 13H.
- ;
- ; CALL: callable from C.
- ; PROTOTYPE: void PutPixel256 (unsigned Col, unsigned Row, unsigned Color);
- ; INPUT: all parameters passed to this function are on the stack. The
- ; stack should contain the following: Color at [bp+8], Row
- ; at [bp+6] and the Col at [bp+4].
- ; OUTPUT: the specified pixel on the VGA screen is modified.
- ; USES: and destroys ax,bx,cx,dx registers
- ;
- Public _PutPixel256
- ;
- _PutPixel256 proc far
- ;
- push bp
- mov bp,sp
- mov cx,[bp+10] ;get pixel color in cl reg
- mov ax,[bp+8] ;get Row #
- mov bx,[bp+6] ;get Col #
- ;
- ;compute the address of the pixel in the video buffer
- ;
- mov dx,320 ;each pixel is one byte
- mul dx ;find offset
- add bx,ax ;bx = x + 320 * y
- mov ax,0A000H ;seg of video buffer
- mov es,ax ;es:bx pts at pixel in buffer
- mov es:[bx],cl ;update the pixel
- pop bp
- ret
- ;
- _PutPixel256 endp
- ;
- ; Procedure _GetPixel256
- ;
- ; This procedure is used to directly access the video memory when the VGA or
- ; MCGA is in the 256 color mode 13H.
- ;
- ; CALL: callable from C.
- ; PROTOTYPE: unsigned PutPixel256 (unsigned Col, unsigned Row);
- ; INPUT: all parameters passed to this function are on the stack. The
- ; stack should contain the following: Row at [bp+6] and
- ; the Col at [bp+4].
- ; OUTPUT: the specified pixel on the VGA screen is returned in ax.
- ; USES: and destroys ax,bx,cx,dx registers
- ;
- Public _GetPixel256
- ;
- _GetPixel256 proc far
- ;
- push bp
- mov bp,sp
- mov ax,[bp+8] ;get Row #
- mov bx,[bp+6] ;get Col #
- ;
- ;compute the address of the pixel in the video buffer
- ;
- mov dx,320 ;each pixel is one byte
- mul dx ;find offset
- add bx,ax ;bx = x + 320 * y
- mov ax,0A000H ;seg of video buffer
- mov es,ax ;es:bx pts at pixel in buffer
- mov al,es:[bx] ;get the pixels value
- xor ah,ah ;mask most significant byte
- pop bp
- ret
- ;
- _GetPixel256 endp
-
- ;
- vgagraph_TEXT ends
- end