home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v17n03 / oopasm.exe / VIDEO.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-10  |  2.0 KB  |  89 lines

  1.     .MODEL    SMALL
  2.  
  3.     INCLUDE    equates.inc
  4.     INCLUDE    instance.inc
  5.     INCLUDE    messages.inc
  6.     INCLUDE    objects.inc
  7.  
  8. IF1
  9.     INCLUDE    macros.mac
  10.     INCLUDE    objects.mac
  11.     INCLUDE    video.mac
  12. ENDIF
  13.  
  14.  
  15.     EXTRN    Self:WORD
  16.  
  17.     .CODE
  18.  
  19. COMMENT    %
  20. ==============================================================================
  21. Gets and saves the current screen attributes.
  22.  
  23. =============================================================================%
  24. getVideoState    PROC    NEAR
  25.     readChar    al,ah            ;Get al=char, ah=attr
  26.     setInst        OldAttr,ah,Self        ;Save attribute
  27.     getVideoMode    bh,al            ;Get bh=page, al=mode
  28.     setInst        OldMode,al        ;Save video mode
  29.     call        getVideoSegment        ;Get video segment addr
  30.     ret
  31. getVideoState    ENDP
  32.  
  33.  
  34.  
  35. COMMENT    %
  36. ==============================================================================
  37. Gets and saves the correct video segment to use depending on wether a color
  38. card is installed or not.
  39.  
  40. =============================================================================%
  41. getVideoSegment    PROC    NEAR
  42.     mov        bx,0040h        ;Get port addr
  43.     mov        es,bx            ;Point to port seg
  44.     mov        bx,es:10h        ;Get equipment list
  45.     and        bx,30h            ;Only want bits 5-4
  46.     mov        ax,ColorAddr
  47.     mov        es,ax            ;Make es point to color mem
  48.     neq        bx,30h,gvs1        ;Exit if color card present
  49.     mov        ax,MonoAddr
  50.     mov        es,ax            ;Make es point to mono mem
  51. gvs1:    ret
  52. getVideoSegment    ENDP
  53.  
  54.  
  55.  
  56. COMMENT    %
  57. ==============================================================================
  58. Restores the original screen attributes.
  59.  
  60. =============================================================================%
  61. resetVideoState    PROC    NEAR
  62.     getInst        bl,OldMode,Video    ;Get original video mode
  63.     setVideoMode    0,bl            ;Display page 0, mode
  64.     ret
  65. resetVideoState    ENDP
  66.  
  67.  
  68.  
  69.     .DATA
  70.  
  71. defMsg    Video,\
  72.     Init,\
  73.     <getVideoState,,>
  74.  
  75. defMsg    Video,\
  76.     Reset,\
  77.     <resetVideoState,,>
  78.  
  79. defObj    Video,\
  80.     <>,\
  81.     <OldAttr,1,07h,\
  82.     OldMode,1,2>,\
  83.     <Init,Reset>
  84.  
  85.  
  86.  
  87.     END
  88.  
  89.