home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CLIPB52.ZIP / COLE.ZIP / SHDW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-14  |  2.5 KB  |  77 lines

  1. /* SHDW.C
  2.    Clipper function Shadow(), which creates "see through" shadows
  3.    to the right and below a box, given its dimensions.
  4.  
  5.    Syntax : Shadow( <N top>, <N left>, <N bottom>, <N right>)
  6.    Return : None
  7.    Compile: I used MSC 5.1 in the following manner -
  8.             cl /c /AL /Zl /Oalt /FPa /Gs shdw.c
  9.    Link   : I used MS Overlay Linker v3.65 -
  10.             link /se:256 /noe test shdw,,,clipper extend
  11. */
  12.  
  13. /* Header files required by Clipper */
  14. #include <nandef.h>
  15. #include <extend.h>
  16.  
  17. /* Video mode can be found at segment 0x0040 offset 0x0049
  18.    Mode = 7 if mono display adapter is in use
  19.    The starting address (segments & offsets) is different
  20.    for color vs monochrome.
  21. */
  22.  
  23. extern _MAXROW;      /* Clipper internal */
  24.  
  25. #define VIDEO_MODE    *(char far *)0x00400049
  26. #define MONO_MODE     0x07
  27. #define COLOR_PTR     0xB8000000
  28. #define MONO_PTR      0xB0000000
  29. #define GREY_ON_BLACK 0x07
  30. #define TEXT_ROWS     24
  31.  
  32. /* The next line is commented out because it only works on EGA/VGA
  33.    It is left here only as a reference to the memory location.
  34.  
  35.    #define TEXT_ROWS     *(char far *)0x00400084 + 1
  36. */
  37.  
  38. CLIPPER Shadow()
  39. {
  40.    char far *scrn_ptr;
  41.    unsigned int offset, top, left, bottom, right, upper_right, lower_right;
  42.    unsigned int lower_left;
  43.  
  44.    /* Depending on the adapter installed, set starting address */
  45.    scrn_ptr = ( char far *)(VIDEO_MODE == MONO_MODE ? MONO_PTR : COLOR_PTR);
  46.  
  47.    /* Receive parameters passed by Clipper and
  48.       adjust for desired location of shadows. */
  49.    top    = _parni(1) + 1;
  50.    left   = _parni(2) + 1;
  51.    bottom = _parni(3) + 1;
  52.    right  = _parni(4) + 1;
  53.  
  54.    /* Make sure that shadow won't go off the edge of screen */
  55.    if( (bottom < TEXT_ROWS) && (right < 80) )
  56.       {
  57.       
  58.       /* The next 3 vars aren't necessary, but they keep the FOR statements
  59.       from running over 80 characters long & they reduce EXE size.
  60.       */
  61.       
  62.       upper_right = (((top * 80) + right) * 2) + 1;
  63.       lower_right = (((bottom * 80) + right) * 2) + 1;
  64.       lower_left  = (((bottom * 80) + left) * 2) + 1;
  65.  
  66.       /* shadow below the box  - attribute 0x07 sets color to grey on black */
  67.       for( offset = lower_left; offset <= lower_right; offset = offset + 2)
  68.          *(scrn_ptr + offset) = GREY_ON_BLACK;
  69.  
  70.       /* shadow to the right of box */
  71.       for( offset = upper_right; offset <= lower_right; offset = offset + 160)
  72.          *(scrn_ptr + offset) = GREY_ON_BLACK;
  73.       }
  74.  
  75.    _ret();
  76. }
  77.