home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT8 / COLOR.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  4.7 KB  |  120 lines

  1. ;*********************************************************************
  2. ;
  3. ;  Program Color ( Chapter 8 )
  4. ;
  5. ;  The PC screen interfacing system.                             
  6. ;
  7. ;  Author: A.I.SOPIN,    Voronezh
  8. ;
  9. :  The procedure for the screen clearing (filling with the prescribed color)
  10. ;
  11. ;  Usage:     Call  COLOR
  12. ;
  13. ;  Entry point: CLEAR - clearing of B&W-screen
  14. ;
  15. ;  Designed to be called from Assembler programs
  16. ;
  17. ;  Input parameters are passed through the registers:
  18. ;
  19. ;  AH - an attribute for colors of the background and text,
  20. ;       isn't used for CLEAR
  21. :  CH - the starting line of the area to be cleared (1 - 25,43,50)
  22. ;  DH - the last line of the area to be cleared (1 - 25,43,50) 
  23. ;  AH - the background and text attribute (not used for CLEAR)
  24. ;
  25. ;********************************************************************
  26. ;
  27. CODE    SEGMENT 'CODE'
  28. COLOR   PROC    FAR
  29.     PUBLIC  COLOR
  30.     ASSUME  CS:CODE
  31.     jmp     short Pushr
  32. ;  The extra entry point for the B&W screen clearing
  33. CLEAR   LABEL   FAR
  34.     PUBLIC  CLEAR
  35.     mov     ah,07h            ;  attribute of B&W screen
  36. ;  Saving all registers used
  37. Pushr:  push    ax
  38.     push    bx
  39.     push    cx
  40.     push    dx
  41.     push    ds
  42.     push    es
  43.     push    si
  44.     push    di
  45. ;----------------------------------------------------------
  46. ;  Parsing parameters given
  47.     mov     bx,ax             ;  saving an attribute of color
  48.     xor     ax,ax             ;
  49.     mov     dl,ch             ;  M
  50.     mov     al,ch             ;  starting line number for change is M
  51.     dec     al                ;  (M-1)
  52.     mov     cl,160            ;
  53.     mul     cl                ;  (M-1)*160
  54.     mov     di,ax             ;  offset for sending to video buffer
  55.     xor     cx,cx             ;
  56.     mov     cl,dh             ;  N
  57.     sub     cl,dl             ;  (N - M)
  58.     inc     cl                ;  quantity of lines 
  59.     xor     ax,ax             ;
  60.     mov     al,cl             ;  first multiplier = (N-M+1)
  61.     mov     dl,80             ;  second multiplier=80
  62.     mul     dl                ;
  63.     mov     cx,ax             ;  quantity of spaces being passed
  64. ;
  65. ;----------------------------------------------------------
  66. ;  Determining the display type (to know the video buffer segment address)
  67.     mov     dx,0B000H           ;  the monochrome video buffer address
  68.     xor     si,si               ;  clearing the CGA indicator 
  69.     mov     ax,40H              ;  segment address of the BIOS area
  70.     mov     ES,ax               ;  ES -address of  BIOS data area
  71.     mov     al,ES:[10H]         ;  reading the hardware list   0040:0010
  72.     and     al,30h              ;  clearing the unnecessary bits
  73.     cmp     al,30h              ;  monochrome display ?
  74.     je      M0                  ;  YES !
  75. ;  Search for active color diplay adapter: EGA (VGA) or CGA
  76.     mov     dx,0B800H               ; the color video buffer address
  77.     mov     si,1                    ; CGA indicator
  78.     cmp     byte ptr ES:[87H],0     ; no EGA ?
  79.     jz      M0                      ; EGA isn't present
  80.     test    byte ptr ES:[87H],08h   ; is EGA not active ?
  81.     jnz     M0                      ; 3-d bit =1  - EGA isn't active
  82.     xor     si,si                   ; Clearing off the CGA indicator
  83. M0:     mov     ES,dx                   ; segient address of a video buffer
  84.     mov     bl,' '                  ; fill character - space
  85.     and     si,si                   ; CGA ?
  86.     jz      Erase                   ; no, no interference
  87.   ;  Putting out the CGA-screen before filling the video buffer
  88.   ;  The current video mode value is stored at the address 0:[465h]
  89.     xor     ax,ax                   ;  the BIOS data area segment address
  90.     mov     al,es:[465h]            ;  the current mode value
  91.     mov     CS:B465,al              ;  save current mode value
  92.     and     al,0F7h                 ;  switch off the video signal
  93.     mov     dx,3D8h                 ;  mode register       
  94.     out     dx,al                   ;  switch off display  
  95. ;  Writing space + attribute at the address of video buffer
  96. Erase:  mov     ES:[DI],bx              ;  passing of space + attribute
  97.     add     DI,2                    ;
  98.     loop    Erase                   ;  to the start of the loop
  99.     and     si,si                   ;    CGA ?
  100.     jz      Popr                    ;  no,no interference
  101.  ;  switching on the screen after filling the buffer
  102.     mov     dx,3D8h                 ;  mode register
  103.     mov     al,CS:B465              ;  switch on video signal
  104.     out     dx,al                   ;  switch on display
  105. ;----------------------------------------------------------
  106. ; Restoring registers and exit 
  107. Popr:   pop     di
  108.     pop     si
  109.     pop     es
  110.     pop     ds
  111.     pop     dx
  112.     pop     cx
  113.     pop     bx
  114.     pop     ax
  115.     RETF
  116. COLOR   ENDP
  117. B465    DB      0                       ;  save current mode 
  118. CODE    ENDS
  119.     END
  120.