home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 18 / CD_ASCQ_18_111294_W.iso / dos / prg / pas / pscrn55 / basic.exe / DISP_IMG.BAS < prev    next >
BASIC Source File  |  1994-10-09  |  6KB  |  173 lines

  1. '=========================================================== Disp_IMG.Bas
  2. '
  3. '   PowerBASIC users:  UN-REM "PUBLIC" for each procedure.
  4. '                      UN-REM "PUBLIC" for each procedure.
  5. '                      UN-REM "PUBLIC" for each procedure.
  6. '
  7. '                      ALSO:  compile this to a .PBU file,
  8. '                      then add $LINK "Disp_IMG.PBU" to any
  9. '                      file where you want to use psDisplayData.
  10. '
  11. '                      Finally:  speed this up -- a lot -- by
  12. '                      going to SUB psDisplayData and UN-REMming
  13. '                      the PokeI ... line (follow other notes too).
  14. '
  15. '******************************************************************
  16. '   This is a P-Screen module containing:
  17. '
  18. '     psDisplayDATA -- to display P-Screen's IMAGE data screens.
  19. '
  20. '     psPAINT -- called by psDisplayData to (optionally) display
  21. '     "drop shadows" beneath screens you display.
  22. '
  23. '     YOU can also call psPAINT anytime you want to "paint" areas
  24. '     of the screen -- as you might to highlight menu options.
  25. '
  26. '     Color = 0 - 255.  Colors > 127 will blink -or- will appear
  27. '     as bright backgrounds if you've turned bright BGs ON.
  28. '
  29. '
  30. '   BOTH routines are much f-a-s-t-e-r when compiled!
  31. '
  32. '=========================================================== Disp_IMG.Bas
  33.  
  34. DEFINT A-Z
  35.  
  36. '...NOTE:  Since these are BASIC routines, we do NOT pass
  37. '          parameters BYVAL.  Pass them by REFERENCE instead.
  38.  
  39. DECLARE SUB psDisplayData (TopRow%, LeftCol%, BottomRow%, RightCol%, ScrnArray%(), ShadowColr%)
  40. DECLARE SUB psPaint (TopRow%, LeftCol%, BottomRow%, RightCol%, Attribute%)
  41.  
  42. '
  43. SUB psDisplayData (TRow%, LCol%, BRow%, RCol%, ScrArray%(), ShadowColr%) ''Public
  44.  
  45.     IF TRow < 1 THEN EXIT SUB         '...NEVER go backwards!
  46.  
  47.     '*********************************************************
  48.     ' Purpose:  Display P-Screen's IMAGE data screens by
  49.     '           POKE-ing data directly to video memory.
  50.     '           This is much f-a-s-t-e-r when compiled!
  51.     '
  52.     ' Input:    Pass screen coordinates (TRow, LCol, etc.).
  53.     '           Also pass an INTEGER array with screen data.
  54.     '
  55.     '           Finally, pass ShadowColr (1 - 255) IF you want
  56.     '           a drop shadow drawn beneath your screen.
  57.     '           ShadowColr = 0 means "no drop shadow."
  58.     '
  59.     '           Colors > 127 will blink -or- will appear as bright
  60.     '           backgrounds if you've turned bright BGs ON.
  61.     '
  62.     ' Returns:  Nothing
  63.     '*********************************************************
  64.  
  65.  
  66. '*********************************************************
  67. '
  68. '    POKE screen data directly to video memory.
  69. '
  70. '    NOTE:  Since Microsoft BASIC has NO option to poke
  71. '    words/integers (just bytes), we must POKE the character
  72. '    and attribute separately -- a relatively slow process.
  73. '
  74. '    If you own PowerBASIC or Crescent's Quik Pak, you
  75. '    may be able to SPEED this up by replacing the 2 POKE
  76. '    statements below with 1 call to a poke-WORD routine.
  77. '    See the "PokeI..." and "CALL Poke2 ..." lines below.
  78. '
  79. '*********************************************************
  80.  
  81.     '...if ShadowColr <> 0, paint a drop shadow.  NOTE:  you can
  82.     '   CHANGE where the shadow appears by changing "+ 1" and "+ 2"
  83.     '   below.  But NEVER send TopRow < 0!
  84.  
  85.     IF ShadowColr <> 0 THEN
  86.        CALL psPaint(TRow + 1, LCol + 2, BRow + 1, RCol + 2, ShadowColr)
  87.     END IF
  88.  
  89.     '***********************************************************
  90.     '...Determine what type of monitor is being used, and, most
  91.     '   importantly, where to begin POKE-ing around in memory.
  92.     '***********************************************************
  93.  
  94.     DEF SEG = 0
  95.     IF (PEEK(&H410) AND 48) <> 48 THEN VidSeg = &HB800 ELSE VidSeg = &HB000
  96.                                         '...color monitor   '...monochrome
  97.     DEF SEG = VidSeg
  98.  
  99.     Element = 1: LastEl = UBOUND(ScrArray)
  100.  
  101.     FOR Row = TRow TO BRow
  102.         FOR Col = LCol TO RCol
  103.  
  104.             IF Element > LastEl THEN EXIT FOR   '... stay in bounds
  105.  
  106.             Offset = ((Row - 1) * 160) + ((Col - 1) * 2)
  107.  
  108.             '... see notes below about REPLACING these 2 POKEs
  109.             POKE Offset, (ScrArray(Element) AND &HFF)
  110.  
  111.             '...this correctly handles bright background colors!
  112.             POKE Offset + 1, CLNG((ScrArray(Element)) AND 65535) \ 256
  113.             '                                            &HFFFF&) &H100
  114.  
  115.             '...PowerBASIC users:  REM-out the last 2 lines, and
  116.             '   use the next one instead.  It's m-u-c-h faster!
  117.             '''PokeI Offset, ScrArray(Element)
  118.  
  119.             '...Try the NEXT line if you have Crescent's Quik Pak.
  120.             '   When compiled it's a little (but not much) faster.
  121.             ''''CALL Poke2(VidSeg, Offset, ScrArray(Element))
  122.  
  123.             Element = Element + 1
  124.         NEXT
  125.     NEXT
  126.  
  127.     DEF SEG
  128.  
  129. END SUB
  130.  
  131. SUB psPaint (TopRow, LeftCol, BottomRow, RightCol, Attribute)  ''Public
  132.  
  133.     IF TopRow < 1 THEN EXIT SUB         '...NEVER go backwards!
  134.  
  135.     '************************************************************
  136.     ' Purpose:  "paint" a drop shadow beneath screens you display.
  137.     '           This POKEs colors directly to video memory --
  138.     '           ignoring character and changing just the attribute.
  139.     '
  140.     ' Input:    Pass screen coordinates (TRow, LCol, etc.).
  141.     '
  142.     '           Also pass a color attribute (0 - 255).
  143.     '           Colors > 127 will blink -or- will appear as bright
  144.     '           backgrounds if you've turned bright BGs ON.
  145.     '
  146.     ' Returns:  Nothing
  147.     '************************************************************
  148.     '...Determine what type of monitor is being used, and, most
  149.     '   importantly, where to begin POKE-ing around in memory.
  150.     '************************************************************
  151.     DEF SEG = 0
  152.     IF (PEEK(&H410) AND 48) <> 48 THEN VidSeg = &HB800 ELSE VidSeg = &HB000
  153.                                         '...color monitor    '...monochrome
  154.     DEF SEG = VidSeg
  155.  
  156. '*********************************************************
  157. '
  158. '    POKE colors directly to video memory.
  159. '
  160. '*********************************************************
  161.  
  162.     FOR Row = TopRow TO BottomRow
  163.         FOR Col = LeftCol TO RightCol
  164.             Offset = 1 + ((Row - 1) * 160) + ((Col - 1) * 2)
  165.             POKE Offset, Attribute
  166.         NEXT
  167.     NEXT
  168.  
  169.     DEF SEG
  170.  
  171. END SUB
  172.  
  173.