home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / Information / CBMDOS1.ARC / WINDOWS128.TXT < prev   
Encoding:
Text File  |  2019-04-13  |  5.5 KB  |  67 lines

  1. ***************************************
  2. THIS ARTICLE IS BEING PRESENTED THROUGH
  3. THE  CBMDOS.MAG,  ON-MAGAZINE OF  THE  
  4. FLAGSHIP (625) ROUNDTABLE  ON GENIE.   
  5. copyright (c) 1989  BY  BILL JULIANI.  
  6. ALL RIGHTS RESERVED.   PERMISSION IS   
  7. HEREBY GRANTED TO NON-PROFIT           
  8. ORGANIZATIONS  ONLY TO  REPRINT THIS   
  9. ARTICLE OR PASS IT ALONG ELECTRONICALLY
  10. AS LONG  AS PROPER CREDIT IS GIVEN TO  
  11. BOTH THE AUTHOR AND GENIE. READ FILE   
  12. COPYRIGHT.DOC FOR MORE INFORMATION.    
  13. ***************************************
  14.  
  15.  
  16. This article is reproduced by permission from the Jan., 1989 MIDWEST NEWS, the monthly journal of the Midwest Commodore Users Group. Permission is granted to reproduce this article for non-profit purposes only.
  17.  
  18. 128 WINDOWS: CLEARED UP
  19.  
  20. By Steve Mitchell
  21.  
  22. Here's a footnote in the never-ending search for new ways to jazz up screens: Using the window command to clear your screens. Chr$(147) does an adequate job--but sort of plain-jane. Here's a group of 1-liners that does the same job with a little flash. What we'll do is use the optional clear flag on the end of the window command. In way of review; the window command must have 4 parameters following it--the beginning col and row then the ending col and row. You also may add a ",1" to the end to clear the window as it is made. We will create a series of windows, each bigger than the last in the direction(s) that we choose.
  23.  
  24. First, let's fill the screen with the letter "A". Lines 100-120 do that. Then we create our series of windows. Using a for/next loop in line 600 we create 24 windows as wide as the screen, each starting at the top of the screen and each extending one line lower than the last. Finally the last window is the size of the normal 40 col screen. That was easy, huh? Go ahead and type in the short demo at the end of this column and see the results for yourself. The demo has 6 different examples of this technique. It would take a long article to give you a blow-by-blow of each of them, but they can be easily understood by seeing them one time. However, there are 2 constructions that may seem unfamiliar to some readers, so I'll explain them (we're all here to learn together, right?).
  25.  
  26. The first is the RWINDOW command. You could look it up in most any manual, but I'll explain it anyway. The RWINDOW command returns information similar to the way RSPPOS (read sprite position) and RREG (reads the processor registers) do. There are three possible values that can be put into parenthesis after the command. RWINDOW(0) returns the number of rows -1 in current window. RWINDOW(1) returns the number of columns -1 in the current window. RWINDOW(2) returns the width of the current screen (40 or 80). Using the RWINDOW(2) command you could make a title screen center itself whether you are in 40 or 80 col mode. Also the RWINDOW command can be used in loops to do something the same number of times that you have columns on your screen. Any of these demos could be converted to work in 40 and 80 col quite easily. There are other uses for RWINDOW but they are beyond what we're doing here today.
  27.  
  28. The second construction that may cause some puzzlement is the formulas used in the examples that go from center-out and from top-left to bottom-right. Let's figure out what we want one of them to do and then figure out how it does it.
  29.  
  30. Let's do the top-left to bottom-right. We want to start in the upper left corner with the first window and increment the window bigger each way till it fills the screen. But wait! the screen is not square so we will reach the bottom before we reach the right side. That will result in an illegal quantity error. Here is how I resolved this dilemma. I know that I only want to go down a certain number of times--i.e.24. In this loop of 24 cycles I want to increment sideways a total of 39 times. So using a ratio, I can figure that to do it absolutely evenly, I would need to go sideways 39/24 for each increment down. That could be written as (increment * 39/24). Follow me so far? Good. The problem is that the window command must have integers so I rewrote it to say int(increment*(39/24)). Not trusting my own math, I made a truth chart showing the integer increment sideways for each of the 24 vertical increments. It works!
  31.  
  32. There may be faster ways to do this such as inserting a decimal (1.625) instead of the fraction 39/24--or making a variable equal to 1.625 and inserting the variable, but the important thing in this column is that not that you are impressed by a construction you don't understand, but that you understand why something works and hey, maybe you can go on to improve it yourself! If you do, by all means, run it my way.
  33.  
  34. Happy Computing! ...................S.Mitchell
  35.  
  36. 1 REM 128 PROGRAMMER'S PAGE
  37. 2 REM SCREEN CLEARS USING WINDOW CMD
  38. 3 REM BY STEVE MITCHELL
  39. 4 COLOR4,7:COLOR0,7:COLOR5,2
  40. 5 GOSUB100:GOSUB200:SLEEP1:REM L TO R 
  41. 6 GOSUB100:GOSUB300:SLEEP1:REM R TO L
  42. 7 GOSUB100:GOSUB400:SLEEP1:REM T TO B
  43. 8 GOSUB100:GOSUB500:SLEEP1:REM B TO T
  44. 9 GOSUB100:GOSUB600:SLEEP1:REM TL TO BR
  45. 10 GOSUB100:GOSUB700:SLEEP1:REM CENTER OUT
  46. 20 END
  47. 100 F$="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  48. 110 FORI=0TO24:PRINTF$:NEXT
  49. 120 PRINT";HOME=":RETURN
  50. 200 FORI=0TO(RWINDOW(2)-1)
  51. 210 WINDOW0,0,I,24,1
  52. 220 NEXT:RETURN
  53. 300 FORI=(RWINDOW(2)-1)TO0STEP-1
  54. 310 WINDOWI,0,39,24,1
  55. 320 NEXT:RETURN
  56. 400 FORI=0TORWINDOW(0)
  57. 410 WINDOW0,0,39,I,1
  58. 420 NEXT:RETURN
  59. 500 FORI=RWINDOW(0)TO0STEP-1
  60. 510 WINDOW0,I,39,24,1:NEXT:RETURN
  61. 600 FORI=1TO24:II=INT(I*(39/24))
  62. 610 WINDOW0,0,II,I,1
  63. 620 NEXT:RETURN
  64. 700 FORI=1TO12
  65. 710 WINDOW19-INT(I*(19/12)),12-I,20+INT(I*(19/12)),12+I,1
  66. 710 NEXT:RETURN
  67.