home *** CD-ROM | disk | FTP | other *** search
/ norge.freeshell.org (192.94.73.8) / 192.94.73.8.tar / 192.94.73.8 / pub / computers / pcjr / misc / BASIC.LZH / BASIC.TXT
Text File  |  1980-01-01  |  6KB  |  156 lines

  1. (Reading MSDOS.BASIC.SCREEN.TIPS, listing time = 3:14)
  2.  
  3. BASIC Screen Techniques
  4.  
  5.                        Dave Gardner
  6.  
  7.                        Phoenix PC Users Group
  8.  
  9. One problem  about  the IBM BASIC interpreter
  10. is  the  speed  at  which   the   screen   is
  11. displayed.  On the market today you can  find
  12. many  products devoted to  aiding  the  BASIC
  13. programmer in screen development  and  screen
  14. display.  Most of these products use assembly
  15. language routines  to  directly  POKE  screen
  16. contents  into video RAM.  This  practice  is
  17. indeed  fast,   but  it  causes  problems  of
  18. hardware  and software compatibility.   BASIC
  19. offers some procedures, calls and  functions,
  20. which can greatly increase the speed at which
  21. screens can be changed.  In this article some
  22. of these  procedures will be presented.  This
  23. article does  not cover every possible aspect
  24. introductory  knowledge  of  them.    Through
  25. experimentation,  they  can  be  developed to
  26. meet your own specific needs.
  27.  
  28. The  hardware of the IBM PC supports the  use
  29. of a color and a monochrome screen.  For both
  30. screens there  is  an  area  in  memory which
  31. holds  the  current  contents  (character  or
  32. graphics)  of  that  screen.   The  areas  in
  33. memory  are  located  at   &HB0000   for  the
  34. monochrome screen, and &HB8000 for the  color
  35. screen.   In   text   mode,  to  represent  a
  36. character position  on  the screen, two bytes
  37. are required.  The first  byte  contains  the
  38. ASCII value of the character  to be displayed
  39. and the  second  byte contains a color code.
  40. Therefore  to  calculate the number of  bytes
  41. needed to represent an entire screen of data,
  42. we would use the following equation:
  43.  
  44. rows X columns X 2 = # of bytes needed
  45. 25   X   80    X 2 = 4000 bytes needed
  46. If you compare the length of available screen
  47. area  and  the  size  required  to  contain a
  48. screen on the  color  graphics  card, you can
  49. see  there  is extra  space  provided.   This
  50. space  can  be  used  to  contain  additional
  51. screens  of information to be displayed at  a
  52. later time.  The video portion of  the system
  53. normally displays the contents  of the lowest
  54. portion  of  these  blocks  of memory on  the
  55. screen.  A simple command  can  be  issued toèthe video system instructing it to change and
  56. point to  another  address  within the screen
  57. area.  Since  the  video  screen  is merely a
  58. copy of the RAM area in memory, the change is
  59. done  instantly.   BASIC  provides  a  SCREEN
  60. command to do this.  The format of the screen
  61. command is:
  62.  
  63. SCREEN A,B,C,D
  64.  
  65. Where:
  66.  
  67. A=Screen mode (O=Text display)
  68.  
  69. B=Burst mode  (1=colored text)
  70.  
  71. C=Active page (0-3 to indicate
  72. the "Page" within the screen area
  73. that is currently being written
  74. to from BASIC)
  75.  
  76. D=Visual page (0-3 to indicate
  77. the "Page" within the screen area
  78. that the user currently is viewing)
  79.  
  80. This  command can be used  to  alter  screens
  81. very quickly.  I have  included  two programs
  82. which  demonstrate  how to use this  command.
  83. The  first  program takes a "picture" of  the
  84. current screen and saves it into a file.  The
  85. second  program  reads  in  several of  these
  86. picture  files and places  them  in  separate
  87. "page"  areas  of the  video  RAM.  When  the
  88. pictures have  all  been  read,  the  program
  89. waits for you to press a key.   Each  time  a
  90. key  is  pressed,  the next page of video  is
  91. displayed.   Try  holding down the space  bar
  92. and  see  how quickly the screen is changed.
  93. To exit the program, type an upper case  "X".
  94. In  addition to loading screen pages  from  a
  95. file, you also can change  the  active screen
  96. and use  normal  "print"  statements to build
  97. them.  When the screen has been completed you
  98. can then use the SCREEN command to change the
  99. "active" screen to the "visual" screen.
  100.  
  101. The following  commands  can  be  useful  for
  102. changing and developing screens:
  103.  
  104. SCREEN  BSAVE  BLOAD
  105. DEF SEG  COLOR  PRINT
  106.  
  107. ][][][][][][][][][][][][][][
  108.  
  109. 10 '  Sample program #1è
  110. 20 '  This program creates three files containing different colored screens
  111. 30 '
  112. 40 KEY OFF
  113. 50 COLOR 7,1:CLS:PRINT TAB(30);"All blue  screen":GOSUB 100
  114. 60 COLOR 0,2:CLS:PRINT TAB(30);"All green screen":GOSUB 100
  115. 70 COLOR 0,4:CLS:PRINT TAB(30);"All red   screen":GOSUB 100
  116. 80 COLOR 7,0:CLS:END
  117. 90 '
  118. 100 '  Subroutine to take the current contents of the screen and save it in
  119. 110 '  a file.  The file name starts out at "SCRN0001.BIN" and the numeric
  120. 120 '  portion is incremented by one each time this subroutine is called.
  121. 130 '
  122. 140 SCN%=SCN%+1      : '  Add to previous screen file number
  123. 150 DEF SEG=&HB800   : '  Change to &HB000 for monochrome screen
  124. 160 SCN$="SCRN"+"000"+RIGHT$(STR$(SCN%),1)+".BIN" : ' Build name
  125. 170 BSAVE SCN$,0,4000 : '  Write out entire screen to file
  126. 180 RETURN
  127.  
  128. ][][][][][][][][][][][][][][
  129.  
  130. 100 '  Sample program #2   "DISPLAY.BAS"
  131. 110 '  This program reads and displays screen files
  132. 120 '
  133. 130 COLOR 15,5 : CLS
  134. 140 PRINT "Reading screen files...."
  135. 150 FOR X=1 TO 3
  136. 160    SCN$="SCRN"+"000"+RIGHT$(STR$(X),1)+".BIN"
  137. 170    ON ERROR GOTO 250
  138. 180       OPEN SCN$ FOR INPUT AS #1 : CLOSE #1
  139. 190    ON ERROR GOTO 0
  140. 200    DEF SEG=&HB800        :' Change to %HB000 for monochrome screen
  141. 210    BLOAD SCN$,(X*&H1000) :' load screen to appropriate "page"
  142. 220 NEXT X
  143. 230 X=3:GOTO 260
  144. 240 '
  145. 250 X=X-1:RESUME 260     :'  Come here if 3 screens not available
  146. 260 PRINT X; "screens read, press space bar to change screens"
  147. 270 Y=1                      :'  loop through all available screens
  148. 280    A$=INKEY$ : IF A$="" THEN 280 :       'Wait for user to press a key
  149. 290    IF A$="x" THEN SCREEN 0,1,0,0 : END : 'Stop program if user type "x"
  150. 300    SCREEN 0,1,Y,Y
  151. 310    Y = (Y+1) MOD (X+1)
  152. 320    GOTO 280                            : 'Display next screen and loop
  153.  
  154.  
  155. end of file
  156.