MC-10 Operation and Language Reference Manual Chapter 15






15/GRAPHICS


It's possible to create graphics displays on your TV screen using the Micro Color BASIC statements SET and RESET and the CHR$ function you were introduced to in the last chapter. SET "sets" a graphic character ON, RESET "reset" that character to its original state (turns it OFF).

Before using these statements, you must think of the TV screen as being divided up into a grid that is 64 blocks horizontally (0 to 63) and 32 blocks vertical (0 to 31).

Figure 19 The MC-10 Graphics Grid


The Graphics Character


The Graphic cell is the space required by any single Graphic character you display.

The Graphics Character is made up of four "blocks". Your Computer has three statements that let you specify or address blocks.

The three keywords are:
  • SET
  • RESET
  • POINT
Actually, you've already seen the Graphics block. We described Micro Color BASIC graphics characters earlier in the "Operation" section of this manual.

The SET and RESET Statements


The SET statement lets you "set" one of the blocks.

SET (x,y,color)
x
is a position on the X-axis (horizontal) and is a numeric expression between 0 and 63.
y is a position on the Y-axis (vertical) and is a numeric expression between 0 and 31.
color is the background color of the Graphics Character you want and is a numeric expression between 0 and 8.


In the Immediate Mode, change the color of the TV screen to black by typing:

    CLS 0 [ENTER]

This is simply for convenience so you can see the true shape of the block. Then type:

    SET (31,16,1) [ENTER]

and a green Graphics Character, on a black background, will appear in the center of the TV screen.

Now type:

    SET (31,16,2) [ENTER]

and the same character, but on a black background, will appear.

RESET, on the other hand, turns the block off after it has been turned on.

RESET (x,y,)
x
is a position on the X-axis (horizontal) and is a numeric expression between 0 and 63.
y is a position on the Y-axis (vertical) and is a numeric expression between 0 and 31.


RESET the block created above by typing:

    RESET (31,16) [ENTER]

Now the yellow block is reset to black.

The following program will change the TV screen to black and create a blue PRINT cell on the right side of the Screen. You can use the backspace key-combination ([CONTROL][A]) to move the blue block to the left-side.

    10 CLS 0
    20 H = 63
    30 SET (H,14,3) :REM TURNS BLOCK ON
    40 A$ = INKEY$
    50 IF A$ = CHR$(8) THEN 70 :REM CHR$(8) IS
        BACKSPACE
    60 GOT 40
    70 H = H -1
    80 IF H < 0 THEN END :REM PROGRAM WILL END WHEN
        THE LEFT MARGIN IS REACHED
    90 SET (H,14,3)
    100 RESET (H+1,14) :REM ERASES BLOCK
    110 GOTO 40

Each time you press the combination of [CONTROL][A], the blue block moves one space to the left.

These examples tell you two things about the fours parts of a Graphics Character:
  • They must be all one color (such as black or blue), or
  • They must be one color and black.
There Has To Be An Easier Way...


To use SET without typing it in, type:

    [CONTROL][E]

To use RESET without typing it in, type:

    [CONTROL][R]

The POINT Function


POINT is a function that returns a value based upon the current status of a Graphics block.

POINT (x,y,)
x
is a position on the X-axis (horizontal) and is a numeric expression between 0 and 63.
y is a position on the Y-axis (vertical) and is a numeric expression between 0 and 31.


POINT returns the following values:

Value Returned
Meaning
-1 Block is character mode
0 Block is turned OFF
color code Block is turned On using
the indicated color code.
(See CLS for a list of
color codes).


The following program will randomly turn on blocks in an area bounded by X=20, Y=10 to the color Blue-color code 3. Each time another block is turned on, POINT tests a specific location, X=10, Y=10 to see if it is set to blue. If the block isn't blue, another block is randomly set. When the specified block is set to blue, program control drops down to line 100 and prints the message.

    10 X = RND (20)
    20 Y = RND (10)
    30 SET (X,Y,3) :REM 3 IS THE COLOR CODE FOR BLUE
    40 IF POINT (10,10) = 3 THEN 100
    50 GOTO 10 :REM AND SET ANOTHER BLOCK
    100 PRINT "10,10 IS SET TO BLUE"
    110 END

RUN the program. Since the blocks are turned on in a random manner, the message will be printed almost at once in some instances. At other times, it may take a while.






Comments should be directed to the following email address:
dsbrain@neosplice.com