home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / qb_sub / transc2a.sub < prev    next >
Encoding:
Text File  |  1987-07-14  |  2.6 KB  |  93 lines

  1. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. '%  (C) 1987 HUMBLEWARE Custom Programming    Author: Lawrence A. Westhaver  %
  3. '%        247 Paul Martin Drive,  Baltimore MD  21227  (301) 799-1975        %
  4. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. '%                                                                           %
  6. '%     FILENAME: TRANSC2A.SUB                    LAST UPDATE: 05-24-1987     %
  7. '%                                                                           %
  8. '%  DESCRIPTION: Translates the COLOR n,n notation used by QuickBASIC to an  %
  9. '%               ATTRIBUTE value used by many video interupt calls.          %
  10. '%                                                                           %
  11. '%         CALL: CALL TRANSC2A(FG%,BG%,AT%)                                  %
  12. '%                                                                           %
  13. '%       INPUTS: FG% = Foreground color (0-31).                              %
  14. '%                                                                           %
  15. '%               BG% = Background color (0-7).                               %
  16. '%                                                                           %
  17. '%      OUTPUTS: AT% = Attribute value (0-255).                              %
  18. '%                                                                           %
  19. '%         NOTE: If the foreground or background color is out of range, the  %
  20. '%               attribute value will be returned as white foreground on a   %
  21. '%               black background (7).                                       %
  22. '%                                                                           %
  23. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24.  
  25.  
  26. SUB TRANSC2A(FG%,BG%,AT%) Static
  27.  
  28.  
  29. 'zero output
  30.  
  31.     AT%=0
  32.  
  33.  
  34. 'check foreground for out of range
  35.  
  36.     IF FG%<0 OR FG%>31 THEN
  37.       AT%=7
  38.       EXIT SUB
  39.     END IF
  40.  
  41.     'check background for out of range
  42.     IF BG%<0 OR BG%>7 THEN
  43.       AT%=7
  44.       EXIT SUB
  45.     END IF
  46.  
  47.  
  48. 'set foreground blink
  49.  
  50.     IF (FG% AND 16) THEN
  51.       AT%=AT%+128
  52.     END IF
  53.  
  54.  
  55. 'set foreground intensity
  56.  
  57.     IF (FG% AND 8) THEN
  58.       AT%=AT%+8
  59.     END IF
  60.  
  61.  
  62. 'set foreground color
  63.  
  64.     IF (FG% AND 4) THEN
  65.       AT%=AT%+4
  66.     END IF
  67.  
  68.     IF (FG% AND 2) THEN
  69.       AT%=AT%+2
  70.     END IF
  71.  
  72.     IF (FG% AND 1) THEN
  73.       AT%=AT%+1
  74.     END IF
  75.  
  76.  
  77. 'set background color
  78.  
  79.     IF (BG% AND 4) THEN
  80.       AT%=AT%+64
  81.     END IF
  82.  
  83.     IF (BG% AND 2) THEN
  84.       AT%=AT%+32
  85.     END IF
  86.  
  87.     IF (BG% AND 1) THEN
  88.       AT%=AT%+16
  89.     END IF
  90.  
  91.  
  92. END SUB 'transc2a
  93.