home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / utils / miscutil.zip / TBWINDOW.ZIP / RECOLOR.ASM < prev    next >
Assembly Source File  |  1987-05-27  |  5KB  |  75 lines

  1.               title          RECOLOR
  2.               page           60,132
  3.  
  4. oldattr       equ            [bp + 0Eh]          ; OLDATTR%
  5. newattr       equ            [bp + 0Ah]          ; NEWATTR%
  6. snochk        equ            [bp + 06h]          ; SNOCHK%
  7.  
  8. program       segment
  9.               assume         cs:program          ; begin program segment
  10.               push           bp                  ; save for basic
  11.               mov            bp,sp               ; establish stack
  12.               push           es                  ; save for return
  13.               push           ds                  ; save for return
  14.               mov            ax,0040h            ; dos segment
  15.               mov            es,ax               ; to es
  16.               mov            si,0001             ; start on odd for attr
  17.               mov            dx,es:[0063h]       ; point to status reg
  18.               add            dx,06h              ;   "    "    "    "
  19.               mov            ax,0b800h           ; assume color
  20.               mov            bx,es:[0010h]       ; get the byte
  21.               and            bx,30h              ; get ready
  22.               cmp            bx,30h              ; compare it
  23.               jnz            SetScrn             ; yup, it's color
  24.               mov            ah,0b0h             ; nope, change it
  25. SetScrn:      lds            di,oldattr          ; get old attribute
  26.               mov            cx,ds:[di]          ; to CX
  27.               lds            di,newattr          ; get new attribute
  28.               mov            bx,ds:[di]          ; to BX
  29.               mov            bh,cl               ; put old in BH,new in BL
  30.               lds            di,SnoChk           ; point to SNOCHK%
  31.               mov            cx,ds:[di]          ; get it
  32.               jcxz           Snow                ; do Snow checking
  33.               mov            ds,ax               ; point to screen
  34.               mov            cx,07d0h            ; do whole screen
  35.               mov            di,0002             ; use for increment
  36.               cld                                ; clear direction flags
  37. ChngColor:    mov            al,[si]             ; get screen attribute
  38.               cmp            al,bh               ; compare it
  39.               jnz            ColorOK             ; don't bother changing
  40.               mov            [si],bl             ; put the new attribute
  41. ColorOK:      add            si,di               ; increment screen pointer
  42.               loop           ChngColor           ; do until CX=0
  43.               jmp            endit               ; done
  44. Snow:         mov            ds,ax               ; point to screen
  45.               mov            cx,07d0h            ; do whole screen
  46.               mov            di,0002             ; use for increment
  47.               cld                                ; clear direction flags
  48. ChngColor1:   cli                                ; disable interrupts
  49. WaitLo1:      in             al,dx               ; get status
  50.               shr            al,1                ; is it low?
  51.               jc             WaitLo1             ; wait until it is
  52. WaitHi1:      in             al,dx               ; get status
  53.               shr            al,1                ; is it high?
  54.               jnc            WaitHi1             ; wait until it is
  55.               mov            al,[si]             ; get screen attribute
  56.               cmp            al,bh               ; compare it
  57.               jnz            ColorOK1            ; don't bother changing
  58. WaitLo2:      in             al,dx               ; get status
  59.               shr            al,1                ; is it low?
  60.               jc             WaitLo2             ; wait until it is
  61. WaitHi2:      in             al,dx               ; get status
  62.               shr            al,1                ; is it high?
  63.               jnc            WaitHi2             ; wait until it is
  64.               mov            [si],bl             ; put the new attribute
  65. ColorOK1:     sti                                ; enable interrupts
  66.               add            si,di               ; increment screen pointer
  67.               loop           ChngColor1          ; do it until CX=0
  68. endit:        pop            ds                  ; restore DS
  69.               pop            es                  ; restore ES
  70.               pop            bp                  ; back to basic
  71. program       ends
  72.               end
  73.  
  74.  
  75.