home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 211 / 211.d81 / t.basics < prev    next >
Text File  |  2022-08-26  |  3KB  |  124 lines

  1. u
  2.       D R A W I N G   B O X E S
  3.  
  4.          by Jeffrey L. Jones
  5.  
  6.  
  7.     Fast routines aren't exclusively
  8. ML. The Box Demo that comes with this
  9. article shows how you can use BASIC to
  10. draw boxes of any color or size, at
  11. any location on the screen.
  12.  
  13.     But drawing boxes in BASIC is
  14. slow, right? Not if you do it in a
  15. fast way! How does two tenths of a
  16. second grab you? Printing strings in
  17. BASIC is fast -- I mean FAST on a
  18. C-64. The text screen is updated so
  19. fast that most text seems to "appear"
  20. before your eyes. POOF!
  21.  
  22.  
  23.     My box routine uses two string
  24. variables to make a box. When the
  25. routine is initialized, BA$ becomes a
  26. bar 38 columns across. BD$ is a little
  27. more complicated. It contains the
  28. vertical bar for the box. Since the
  29. cursor will advance right after any
  30. character is printed, the variable
  31. includes a cursor left and a cursor
  32. down after each bar printed.
  33.  
  34.     So how do I make boxes of any and
  35. all sizes using only two strings?
  36. Using the LEFT$ function! I only print
  37. the portion of the box strings that I
  38. need.
  39.  
  40.         LEFT$(string$,integer)
  41.  
  42. LEFT$ will print only the leftmost
  43. part of a string that you specify. For
  44. instance, if A$="LOADSTAR" and you use
  45. the command:
  46.  
  47.           PRINT LEFT$(A$,4)
  48.  
  49. you will see
  50.  
  51.                  LOAD
  52.  
  53. Only "LOAD" will be printed because
  54. the LEFT$ function has been told to
  55. pass only the first four characters in
  56. the string.
  57.  
  58.     If the integer specified is of
  59. greater length than the string itself,
  60. the entire string will be printed. If
  61. the integer is zero then a null string
  62. will be returned.
  63.  
  64.      Something else should be
  65. explained:
  66.  
  67.    POKE211,bx:POKE214,by:SYS58732
  68.  
  69. is a routine I use to move the cursor
  70. to the exact location I need before
  71. printing.
  72.  
  73.             POKE 646,bc
  74.  
  75. Location 646 is used to either check
  76. or change cursor color.
  77.  
  78.     Here's how to use the routine:
  79. GOSUB 40000 to initialize the routine.
  80. This needs to be done only ONCE to
  81. define the variables. Do this early in
  82. your program while you're declaring
  83. other variables.
  84.  
  85.     To print a box, GOSUB 40040.
  86.  
  87.     But first you must declare the
  88. dimensions and locations of the box.
  89. Here are the variables you will be
  90. using:
  91.  
  92.  BX - leftmost X coordinate
  93.  BY - uppermost Y coordinate
  94.  EX - rightmost X coordinate
  95.  BD - how many rows to enclose in box
  96.      (number of rows deep)
  97.  RV - if non-zero the box is reversed
  98.  BC - color of the box
  99.  
  100. Naturally no x coordinate can be wider
  101. than the screen. Very large boxes may
  102. cause scrolling.
  103.  
  104.     If you want to print a box inside
  105. a box, there's no need to redefine the
  106. variables. Just GOSUB 40120 to make
  107. the box shrink. To make it grow out,
  108. GOSUB 40100. Since RV is cleared every
  109. time a box is printed, RV must be
  110. updated if being used.
  111.  
  112.     By printing a box in different
  113. colors, you can make it appear to glow
  114. or flash on and off. Run this program
  115. to see a demo of my box-making
  116. technique.
  117.  
  118.     I might mention that the box
  119. routine is significantly sped up if
  120. compiled.
  121.  
  122.  JLJ
  123.  
  124.  
  125.