home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / video / 5 / 5_2.asm < prev    next >
Encoding:
Assembly Source File  |  1988-08-11  |  954 b   |  52 lines

  1.         TITLE    'Listing 5-2'
  2.         NAME    ReadPixel06
  3.         PAGE    55,132
  4.  
  5. ;
  6. ; Name:        ReadPixel06
  7. ;
  8. ; Function:    Read the value of a pixel in 640x200 2-color mode
  9. ;
  10. ; Caller:    Microsoft C:
  11. ;
  12. ;            int ReadPixel06(x,y);
  13. ;
  14. ;            int x,y;        /* pixel coordinates */
  15. ;
  16.  
  17. ARGx        EQU    word ptr [bp+4]    ; stack frame addressing
  18. ARGy        EQU    word ptr [bp+6]
  19.  
  20.  
  21. _TEXT        SEGMENT    byte public 'CODE'
  22.         ASSUME    cs:_TEXT
  23.  
  24.         EXTRN    PixelAddr06:near
  25.  
  26.         PUBLIC    _ReadPixel06
  27. _ReadPixel06    PROC    near
  28.  
  29.         push    bp        ; preserve caller registers
  30.         mov    bp,sp
  31.  
  32.         mov    ax,ARGy        ; AX := y
  33.         mov    bx,ARGx        ; BX := x
  34.         call    PixelAddr06    ; AH := bit mask
  35.                     ; ES:BX -> buffer
  36.                     ; CL := #bits to shift
  37.  
  38.         mov    al,es:[bx]    ; AL := byte containing pixel
  39.         shr    al,cl        ; shift pixel value to low-order bits
  40.         and    al,ah        ; AL := pixel value
  41.         xor    ah,ah        ; AX := pixel value
  42.  
  43.         mov    sp,bp        ; restore caller registers and return
  44.         pop    bp
  45.         ret
  46.  
  47. _ReadPixel06    ENDP
  48.  
  49. _TEXT        ENDS
  50.  
  51.         END
  52.