home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / video / 4 / 4_5.asm < prev   
Encoding:
Assembly Source File  |  1988-08-11  |  803 b   |  44 lines

  1.         TITLE    'Listing 4-5'
  2.         NAME    PixelAddr13
  3.         PAGE    55,132
  4.  
  5. ;
  6. ; Name:        PixelAddr13
  7. ;
  8. ; Function:    Determine buffer address of pixel in 320x200 256-color mode
  9. ;
  10. ; Caller:    AX = y-coordinate (0-199)
  11. ;        BX = x-coordinate (0-319)
  12. ;
  13. ; Returns:    BX = byte offset in buffer
  14. ;        ES = video buffer segment
  15. ;
  16.  
  17.  
  18. OriginOffset    EQU    0        ; byte offset of (0,0)
  19. VideoBufferSeg    EQU    0A000h
  20.  
  21. _TEXT        SEGMENT    byte public 'CODE'
  22.         ASSUME    cs:_TEXT
  23.  
  24.         PUBLIC    PixelAddr13
  25. PixelAddr13    PROC    near
  26.  
  27.         xchg    ah,al        ; AX := 256*y
  28.         add    bx,ax        ; BX := 256*y + x
  29.         shr    ax,1
  30.         shr    ax,1        ; AX := 64*y
  31.         add    bx,ax        ; BX := 320*y + x
  32.  
  33.         add    bx,OriginOffset    ; BX := byte offset in video buffer
  34.  
  35.         mov    ax,VideoBufferSeg
  36.         mov    es,ax        ; ES:BX := byte address of pixel
  37.         ret
  38.  
  39. PixelAddr13    ENDP
  40.  
  41. _TEXT        ENDS
  42.  
  43.         END
  44.