Chapter 5

P21Forth Text Video Output


P21Forth 1.02

P21Forth 1.0 uses the Character output routines written by Dr. C. H. Ting in the OK Operating System written by Chuck Moore. These routines have been extended to provide window support by Jeff Fox.

The ANS word EMIT defaults to output to the video display. (See Chapter 4 on changing the output vector for EMIT.) The video display defaults to 48 columns by 24 lines. Some displays will not display the full screen so it is possible to set the window control parameters to setup the video display window to a different size or logical location on the physical screen.

CLS will clear the screen and place the cursor in the upper left corner of the screen. The words AT or AT-XY take column and row numbers off of the stack and set the cursor position on the video display.

The characters that are special to the display are BS, LF, FF, and CR. BackSpace will cause the cursor to move back. LineFeed will cause the cursor to move down one line on the display. FormFeed will clear the screen and move the cursor to the upper left corner. CR will move the cursor to the start of the current line.

The Forth word CR will send both a CR and a LF to the output device. The words CLS and PAGE send a FF character to the output device.

The video display will wrap at the right edge, and wrap back from the left edge from backspaces. It will not backspace past the upper left corner of the screen. A linefeed character issued from the bottom line, or a wrap from the bottom line will cause the display to scroll up.

The foreground and background colors for text display can be set with the words >FOREGROUND and >BACKGROUND or the shorter versions >FG and >BG. The screen colors are given names, so to set the screen to yellow characters on a dark blue background issue the command:

            YELLOW >FG DARKBLUE >BG
The word CDEMO will display all of the combinations of foreground and background colors on the MuP21 video display.

A Glossary of P21Forth Video Words
AT-XY ( x y -- )   position cursor
AT ( x y -- )      position cursor
TX! ( c -- )       display character at cursor
CDEMO ( -- )       display 16 foregrounds on 16 backgrounds
CLINE ( -- )       display 16 foregrounds on a background
BROWN  ( -- u )    brown constant
YELLOW  ( -- u )   yellow constant
DARKCYAN  ( -- u ) dardcyan constant
CYAN  ( -- u )     cyan constant
DARKMAGENTA ( -- u ) darkmagneta constant
MAGENTA ( -- u )   magenta constant
DARKRED ( -- u )   dardred constant
RED ( -- u )       red constant
DARKGREEN ( -- u ) darkgreen constant
GREEN ( -- u )     green constant
DARKBLUE ( -- u )  dardblue constant
BLUE ( -- u )      blue constant
WHITE ( -- u )     white constant
GREY ( -- u )      grey constant
BLACK ( -- u )     black constant
CLS ( -- )         clear the screen position cursor at upper left
PAGE ( -- )        clear screen, eject page if printing
>BACKGROUND ( u -- ) take color to set background
>BG ( u -- )       take color to set background
>FOREGROUND ( u -- ) take color to set foreground
>FG ( u -- )       take color to set foreground
ROWS ( -- a )      variable with number of rows (24 default)
COLS ( -- a )      variable with number of columns ( 48 default)
UL ( -- a )        variable with address of upper left of screen
LEFT-MARGIN ( -- a ) variable with size of left margin in characters
TOP-MARGIN ( -- a ) variable with size of top margin in characters
32X16 ( -- )       set 32 columns in 16 rows in video
48X24 ( -- )       set 48 columns in 24 rows in video
40X16 ( -- )       set 40 columns in 16 rows in video
SET-VIDEO ( -- )   set video from ROWS COLS UL TOP-MARGIN and LEFT-MARGIN
TEXT ( -- )        select the primary page for text and graphics display

End of Chapter 5

Return to Table of Contents

Previous Chapter

Next Chapter