home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MISC / TNH_PC.ZIP / SCHNELL.NL < prev    next >
Encoding:
Text File  |  1987-01-14  |  6.5 KB  |  215 lines

  1. Alternate Colors for Text and Titles in Medium Res Mode
  2.  
  3.              John Schnell
  4.       New York IBM PC Users Group
  5.  
  6. Anyone who works with graphics soon
  7. discovers that the colors for labels
  8. or titles are limited to yellow in
  9. palette zero or white in palette one.
  10. The BASIC manual mentions a solution
  11. for this, but most people miss it
  12. because it is tucked away in one of
  13. the appendices.
  14.  
  15. To change the color of the text, you
  16. must POKE a new value to a specific
  17. address in the BASIC segment: &H4E.
  18. One line is all you need to get text
  19. in color.  For example, to get text
  20. in red, magenta in palette one, the
  21. following statement is all that's
  22. required:
  23.  
  24. 1000 TEXT.CLR = 2 :DEF SEG
  25. :POKE &H4E, TEXT.CLR
  26.  
  27. Normally, the value at this memory
  28. location is set to three.  That's why
  29. the text is either white or yellow.
  30. The following table states the colors
  31. obtained from the given values.
  32.  
  33. Value   Palette zero   Palette one
  34.  
  35. 0       background     background
  36. 1       GREEN          CYAN
  37. 2       RED            MAGENTA
  38. 3       YELLOW         WHITE
  39.  
  40. (Change TEXT.CLR to 1, 2 or 3..but
  41. never 0.  Note Never insert a zero
  42. value at this location.)
  43.  
  44. You must use care when changing the
  45. color.  The following should
  46. illustrate some problems to watch out
  47. for.
  48.  
  49. Commands and line statements are
  50. entered and edited in BASIC using
  51. full screen editing.  This means you
  52. can move the cursor anywhere on the
  53. screen and insert or delete letters
  54. in lines which are already displayed.
  55. This convenience has many benefits
  56. but some strange consequences.
  57.  
  58. Some of the benefits are:
  59.  
  60. 1.  You don't have to retype whole
  61.     lines.
  62. 2.  You can put the cursor anywhere
  63.     on the line and push ENTER to
  64.     capture the line or execute the
  65.     command.
  66. 3.  You can duplicate a line of code
  67.     by typing over the old line
  68.     number with a new one.
  69. 4.  Short groups of lines can be
  70.     selectively renumbered or swapped
  71.     by simply retyping the line
  72.     numbers when both lines are on
  73.     the screen.
  74.  
  75. Some of the consequences of this are:
  76.  
  77. 1.  You can easily join two lines of
  78.     code without realizing it through
  79.     backward movement of the cursor.
  80.     This can generate some strange
  81.     listings or hard-to-find syntax
  82.     errors.
  83. 2.  Auto-numbered code lines can
  84.     write themselves using screen
  85.     garbage.
  86. 3.  Rewriting the number of a line
  87.     creates a new one but leaves the
  88.     old one (which can go unnoticed
  89.     and create havoc with variables).
  90. 4.  Some direct commands which have
  91.     already been executed remain on
  92.     the screen and can be
  93.     unintentionally executed a second
  94.     time.
  95. 5.  Moving the cursor  up to a
  96.     previous line during auto line
  97.     number mode does not correct the
  98.     previous line and all kinds of
  99.     garbage collects in the line you
  100.     were currently working on!
  101.  
  102. Another thing you may have discovered
  103. when working in text mode, is the
  104. occasional situation when the
  105. foreground and the background colors
  106. for a character have the same
  107. attribute.  Essentially, this creates
  108. writing on the screen which you can
  109. not see, but the computer can. Some
  110. people use this for pass word entry
  111. (not a good idea).
  112.  
  113. You can change the attribute values
  114. by typing in the COLOR command blind.
  115. After hitting the carriage return,
  116. the text becomes visible using the
  117. new attributes.  You become
  118. accustomed to this and expect it to
  119. work in all cases.
  120.  
  121. This works because of the way text is
  122. stored and displayed on the screen
  123. when in text mode. Two bytes of
  124. information are needed for each
  125. letter displayed. One byte contains
  126. the attribute for the letter; the
  127. other byte contains the ASCII bytes
  128. of screen memory to capture the line
  129. of text.
  130.  
  131. It is possible to do interactive
  132. programming and full screen editing
  133. while in medium resolution graphics
  134. mode.  Normally, the text is white or
  135. yellow, depending on the selected
  136. palette. The text is PAINTED on the
  137. screen and exists in display memory
  138. as a series of dots, not as two bytes
  139. per character as in the text mode.
  140. When the letters are only painted on
  141. the screen, what happens during full
  142. screen editing? BASIC can`t just look
  143. at the contents of the ASCII bytes as
  144. in text mode. Instead, it has to read
  145. the screen by looking at each block
  146. of pixels containing a "painted"
  147. letter and somehow convert it into a
  148. series of bytes which can be compared
  149. to the ROM table representing the dot
  150. arrangements for each ASCII
  151. character. This must be done for each
  152. letter displayed or moved on the
  153. graphics display. If even one odd dot
  154. gets mixed into the block of painted
  155. pixels representing a letter, the
  156. letter can't be matched anywhere in
  157. the ROM table and a syntax error
  158. message will appear.
  159.  
  160. There is a great deal of internal
  161. complexity when you do full screen
  162. editing in the medium or high
  163. resolution graphics mode. That's why
  164. the graphics text display updates the
  165. screen so slowly.
  166.  
  167. In the TEXT mode, BASIC can read
  168. commands which are entered but not
  169. displayed on the screen because the
  170. characters are stored in ASCII bytes.
  171. In graphics mode, BASIC uses the dot
  172. pattern of the "painted" letters to
  173. distinguish ASCII characters which
  174. have been written to the screen. When
  175. you POKE a zero at &H4E, the
  176. attribute is the same as the
  177. background and nothing gets painted
  178. to the screen when a letter is typed.
  179. As a consequence, BASIC has no dot
  180. pattern to read and communication
  181. between you and BASIC is impossible.
  182.  
  183. One example of where this can cause a
  184. problem is when you are working on a
  185. graphics program using text labels
  186. for various illustrations.
  187. Accidentally, you set the text to
  188. zero either in direct mode or within
  189. the program. Something doesn't work
  190. right so you break the program. When
  191. you type LIST, the cursor moves but
  192. nothing appears on the screen.  You
  193. type something else. Still nothing.
  194. You're confused, but perhaps you can
  195. save the program.  Typing SAVE also
  196. moves the cursor, but no text is
  197. displayed. BASIC ignores any and all
  198. commands you enter because it can't
  199. "read" you. The only option you have
  200. is to reboot destroying your new
  201. code. After this happens a couple of
  202. times, you are very careful about
  203. POKEing zero into &H4E.
  204.  
  205. This can be a valuable tool, but use
  206. it wisely. In addition, any number
  207. poked to &H4E which is FOUR or a
  208. MULTIPLE OF FOUR will also lock you
  209. out of the keyboard forever...or at
  210. least until you reboot.  Using this
  211. memory address only applies to
  212. interactive BASIC; it won't perform
  213. when included in a compiled BASIC
  214. program.
  215.