'===========================================================================
' Subject: RECOLOR PART OF SCREEN             Date: 04-04-99 (16:14)       
'  Author: Dieter Folger                      Code: PB                     
'  Origin: folger@bamberg.baynet.de         Packet: PB.ABC
'===========================================================================
'----------------------------------------------------
' RECOLOR.BAS for PowerBasic
' Recolor a part of screen from OldAttr to NewAttr
' Demo program shows usage
' Freeware (c) 1999 by Dieter Folger
'----------------------------------------------------
DEFINT A-Z
FOR i = 1 TO 25 'fill the screen with something
    IF i MOD 2 THEN
       COLOR 15,1 : PRINT STRING$(80, "*");
    ELSE
       COLOR 14,3 : PRINT STRING$(80, "@");
    END IF
NEXT
LOCATE 12, 28 : COLOR 11,4 : PRINT "Press a key to end demo";

DO
  DELAY 2
  ReColor 5,10,15,70,31,32 'change color attributes within the window
                           'from bright white on blue to black on green
  DELAY 2
  ReColor 5,10,15,70,32,31 'Restore old color attributes
LOOP UNTIL INSTAT 'repeat demo until user presses a key
COLOR 7,0 : CLS
END
'-----------------------------------------------------------------
SUB ReColor (StartRow, StartCol, EndRow, EndCol, OldAttr, NewAttr)
'-----------------------------------------------------------------
 IF (pbvScrnCard AND 1) = 0 THEN Address = &HB800 ELSE Address = &HB000
 DEF SEG = Address
 FOR i = StartRow TO EndRow
     FOR j= StartCol TO EndCol
         Offset = (160 * i) + (2 * j) + 1
         IF PEEK (Offset) = OldAttr THEN POKE Offset, NewAttr
     NEXT
 NEXT
 DEF SEG
END SUB
