home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / video / demo / 1_1.asm next >
Encoding:
Assembly Source File  |  1988-08-11  |  1.2 KB  |  67 lines

  1.         TITLE    'Listing 1-1'
  2.         NAME    SetVmode
  3.         PAGE    55,132
  4.  
  5. ;
  6. ; Name:        SetVmode
  7. ;
  8. ; Function:    Call IBM PC ROM BIOS to set a video display mode.
  9. ;
  10. ; Caller:    Microsoft C:
  11. ;
  12. ;            void SetVmode(n);
  13. ;
  14. ;            int n;            /* video mode */
  15. ;
  16.  
  17. ARGn        EQU    byte ptr [bp+4]    ; stack frame addressing
  18.  
  19. EQUIP_FLAG    EQU    byte ptr ds:[10h] ; (in Video Display Data Area)
  20.  
  21. CGAbits        EQU    00100000b    ; bits for EQUIP_FLAG
  22. MDAbits        EQU    00110000b
  23.  
  24. _TEXT        SEGMENT    byte public 'CODE'
  25.         ASSUME    cs:_TEXT
  26.  
  27.         PUBLIC    _SetVmode
  28. _SetVmode    PROC    near
  29.  
  30.         push    bp        ; preserve caller registers
  31.         mov    bp,sp
  32.         push    ds
  33.  
  34.         mov    ax,40h
  35.         mov    ds,ax        ; DS -> Video Display Data Area
  36.  
  37.         mov    bl,CGAbits    ; BL := bits indicating presence of CGA
  38.  
  39.         mov    al,ARGn        ; AL := desired video mode number
  40.  
  41.         mov    ah,al        ; test if desired mode is monochrome
  42.         and    ah,7
  43.         cmp    ah,7
  44.         jne    L01        ; jump if desired mode not 7 or 0Fh
  45.  
  46.         mov    bl,MDAbits    ; BL := bits indicating presence of MDA
  47.  
  48. L01:        and    EQUIP_FLAG,11001111b
  49.         or    EQUIP_FLAG,bl    ; set bits in EQUIP_FLAG
  50.  
  51.         xor    ah,ah        ; AH := 0 (INT 10h function number)
  52.  
  53.         push    bp
  54.         int    10h        ; call ROM BIOS to set the video mode
  55.         pop    bp
  56.  
  57.         pop    ds        ; restore caller registers and return
  58.         mov    sp,bp
  59.         pop    bp
  60.         ret
  61.  
  62. _SetVmode    ENDP
  63.  
  64. _TEXT        ENDS
  65.  
  66.         END
  67.