home *** CD-ROM | disk | FTP | other *** search
- Alternate Colors for Text and Titles in Medium Res Mode
-
- John Schnell
- New York IBM PC Users Group
-
- Anyone who works with graphics soon
- discovers that the colors for labels
- or titles are limited to yellow in
- palette zero or white in palette one.
- The BASIC manual mentions a solution
- for this, but most people miss it
- because it is tucked away in one of
- the appendices.
-
- To change the color of the text, you
- must POKE a new value to a specific
- address in the BASIC segment: &H4E.
- One line is all you need to get text
- in color. For example, to get text
- in red, magenta in palette one, the
- following statement is all that's
- required:
-
- 1000 TEXT.CLR = 2 :DEF SEG
- :POKE &H4E, TEXT.CLR
-
- Normally, the value at this memory
- location is set to three. That's why
- the text is either white or yellow.
- The following table states the colors
- obtained from the given values.
-
- Value Palette zero Palette one
-
- 0 background background
- 1 GREEN CYAN
- 2 RED MAGENTA
- 3 YELLOW WHITE
-
- (Change TEXT.CLR to 1, 2 or 3..but
- never 0. Note Never insert a zero
- value at this location.)
-
- You must use care when changing the
- color. The following should
- illustrate some problems to watch out
- for.
-
- Commands and line statements are
- entered and edited in BASIC using
- full screen editing. This means you
- can move the cursor anywhere on the
- screen and insert or delete letters
- in lines which are already displayed.
- This convenience has many benefits
- but some strange consequences.
-
- Some of the benefits are:
-
- 1. You don't have to retype whole
- lines.
- 2. You can put the cursor anywhere
- on the line and push ENTER to
- capture the line or execute the
- command.
- 3. You can duplicate a line of code
- by typing over the old line
- number with a new one.
- 4. Short groups of lines can be
- selectively renumbered or swapped
- by simply retyping the line
- numbers when both lines are on
- the screen.
-
- Some of the consequences of this are:
-
- 1. You can easily join two lines of
- code without realizing it through
- backward movement of the cursor.
- This can generate some strange
- listings or hard-to-find syntax
- errors.
- 2. Auto-numbered code lines can
- write themselves using screen
- garbage.
- 3. Rewriting the number of a line
- creates a new one but leaves the
- old one (which can go unnoticed
- and create havoc with variables).
- 4. Some direct commands which have
- already been executed remain on
- the screen and can be
- unintentionally executed a second
- time.
- 5. Moving the cursor up to a
- previous line during auto line
- number mode does not correct the
- previous line and all kinds of
- garbage collects in the line you
- were currently working on!
-
- Another thing you may have discovered
- when working in text mode, is the
- occasional situation when the
- foreground and the background colors
- for a character have the same
- attribute. Essentially, this creates
- writing on the screen which you can
- not see, but the computer can. Some
- people use this for pass word entry
- (not a good idea).
-
- You can change the attribute values
- by typing in the COLOR command blind.
- After hitting the carriage return,
- the text becomes visible using the
- new attributes. You become
- accustomed to this and expect it to
- work in all cases.
-
- This works because of the way text is
- stored and displayed on the screen
- when in text mode. Two bytes of
- information are needed for each
- letter displayed. One byte contains
- the attribute for the letter; the
- other byte contains the ASCII bytes
- of screen memory to capture the line
- of text.
-
- It is possible to do interactive
- programming and full screen editing
- while in medium resolution graphics
- mode. Normally, the text is white or
- yellow, depending on the selected
- palette. The text is PAINTED on the
- screen and exists in display memory
- as a series of dots, not as two bytes
- per character as in the text mode.
- When the letters are only painted on
- the screen, what happens during full
- screen editing? BASIC can`t just look
- at the contents of the ASCII bytes as
- in text mode. Instead, it has to read
- the screen by looking at each block
- of pixels containing a "painted"
- letter and somehow convert it into a
- series of bytes which can be compared
- to the ROM table representing the dot
- arrangements for each ASCII
- character. This must be done for each
- letter displayed or moved on the
- graphics display. If even one odd dot
- gets mixed into the block of painted
- pixels representing a letter, the
- letter can't be matched anywhere in
- the ROM table and a syntax error
- message will appear.
-
- There is a great deal of internal
- complexity when you do full screen
- editing in the medium or high
- resolution graphics mode. That's why
- the graphics text display updates the
- screen so slowly.
-
- In the TEXT mode, BASIC can read
- commands which are entered but not
- displayed on the screen because the
- characters are stored in ASCII bytes.
- In graphics mode, BASIC uses the dot
- pattern of the "painted" letters to
- distinguish ASCII characters which
- have been written to the screen. When
- you POKE a zero at &H4E, the
- attribute is the same as the
- background and nothing gets painted
- to the screen when a letter is typed.
- As a consequence, BASIC has no dot
- pattern to read and communication
- between you and BASIC is impossible.
-
- One example of where this can cause a
- problem is when you are working on a
- graphics program using text labels
- for various illustrations.
- Accidentally, you set the text to
- zero either in direct mode or within
- the program. Something doesn't work
- right so you break the program. When
- you type LIST, the cursor moves but
- nothing appears on the screen. You
- type something else. Still nothing.
- You're confused, but perhaps you can
- save the program. Typing SAVE also
- moves the cursor, but no text is
- displayed. BASIC ignores any and all
- commands you enter because it can't
- "read" you. The only option you have
- is to reboot destroying your new
- code. After this happens a couple of
- times, you are very careful about
- POKEing zero into &H4E.
-
- This can be a valuable tool, but use
- it wisely. In addition, any number
- poked to &H4E which is FOUR or a
- MULTIPLE OF FOUR will also lock you
- out of the keyboard forever...or at
- least until you reboot. Using this
- memory address only applies to
- interactive BASIC; it won't perform
- when included in a compiled BASIC
- program.