GRAPHICS 52 (Bit Map & Sprite Commands) öm2,2 öcBIT MAPPED GRAPHICS Note: All of the following commands only work with bit mapped graphics screens. All commands with an asterisk (*) are designed only to work with the HI-RES graphic screens. All other commands will work with both types of screens, unless otherwise specified. SYNTAX: BLOCK x, y, c, b Purpose: To change one color block on the screen. Description: This will change the character and background color of one character block on the screen. If you are using a LOW-RES screen this will change the color in one character block, of all dots DRAWn or PLOTted, with PEN 2 or PEN 3. The position of the character block to be changed is determined by the 'x,y' coordinates you specify. x = 0-39 : horizonal position y = 0-24 : vertical position c = 0-15 : character color or PEN 1 b = 0-15 : background color or PEN 2 * SYNTAX: BOTTOM Purpose: To reformat a HI-RES screen. Description: This will change the 'x,y' coordinates of the screen, so '0,0' is in the bottom left corner of the screen instead of the top left corner. The horizonal coordinates will stay the same as before. The above format will enable the new coordinates system. To restore the graphic screen to normal, place the number sign (#) after the BOTTOM command. BOTTOM : enable the bottom coordinates BOTTOM# : restore the screen to the normal coordinates system. SYNTAX: CHAR s, x, y, ch Purpose: To place a character on a graphic screen, set the position of characters to be PRINTed, and to set the character set, the characters are to be PRINTed with. Description: This command can be used for one of three purposes: (1) To set the character set being used. (2) The above and set the position where the next character(s) will be PRINTed. (3) All the above and actually place a character on the screen enabled. s = 0-5 : character set number (from character set table) x = 0-39 : horizonal position y = 0-24 : vertical position ch = 0-255 : character number (in screen code) EXAMPLE: To PRINT the word "Hello" in character set 5 (upper and lower case with limited graphics), you would use: 100 CHAR 5 :PRINT "Hello" From this point on everything PRINTed, while the graphic screen is enabled, will be PRINTed in character set 5. If you want the word "Hello" PRINTed as above except, four columns over and 6 rows down from the top of the screen, then you would use: 100 CHAR 5, 4, 6 :PRINT "Hello" Now let us say, after this is done, you want to place the letter "A" in the upper right corner of the screen, except in character set 2 (custom set at $7000 hex. 28672 dec.), you would add: 110 CHAR 2, 39, 0, 1 Note: The character set can be switched without affecting any other characters on the screen. Character sets 0 and 1 should not be used because they are located at the same place as SCREEN 1 and SCREEN 3. If you are only using SCREEN 2 there will be no problem. Also the ERASE, BOTTOM, and TOGL commands have no effect on how characters are placed on a graphic screen. SYNTAX: CLEAR Purpose: To clear a graphic screen. Description: This will clear (place the value of 0 in all the memories the graphic screen uses) the complete graphic screen you have enabled at the time you use this command. WARNING: If SCREEN 1 or SCREEN 3 are enabled at the time you use this command, the command will erase character sets 1 and 2. If this is the case, you should probably move them to a safe place, by using the COPY command. Then just COPY them back when they are needed. SYNTAX: COLOR c1, c2, c0, c3 Purpose: Set the color of all graphic screens. Description: On a HI-RES screen this will set the character (all dots or pixels turned on) color to c1 and set the background (all dots or pixels turned off) color to c2. You must not include c0 and c3. With the LOW-RES screen enabled, this command will set all four PEN colors. HI-RES c1 = 0-15 : character color c2 = 0-15 : background color c3 = ---- : not used c0 = ---- : not used LOW-RES c1 = 0-15 : color PEN 1 c2 = 0-15 : color PEN 2 c3 = 0-15 : color PEN 3 c0 = 0-15 : color PEN 0 EXAMPLE: To set the color of a HI-RES screen to: black for the background color and white for the character color, you would use: 100 COLOR 1, 0 Note: Remember not to use c0 and c3 with a HI-RES screen enabled. SYNTAX: DRAW x, y Purpose: This will draw a strait line from one point to another. Description: The above format is one of six different ways of using this command. Here is a list of all the possible combinations: DRAW x, y This will draw a line from a point previously set by the DRAW or PLOT commands, to the point (x,y). DRAW x, y STEP s Same as above except, it will space the dots (pixels) according to the value of 's'. DRAW x1, y1 TO x2, y2 This will draw a line from (x1,y1) to (x2,y2). DRAW x1, y1 TO x2, y1 STEP s Same as above except, in increments of 's'. DRAW IF x1, y1 TO x2, y2 This will draw a line from (x1,y1) to (x2,y2) until, it reaches a dot (pixel) that has already been turned on. If this happens, it will then end the line being DRAWn at this point. To detect if this has happened, the STATUS (ST) variable will be set to a one. DRAW IF x1, y1 TO x2, y2 STEP s This is the same as above except it will draw the line in a increment of 's'. HI-RES x = 0-319 : horizonal position y = 0-199 : vertical position s = 0-255 : increment of dots (pixels) in the line LOW-RES x = 0-159 : horizonal position y = 0-199 : vertical position s = 0-255 : increment Note: Most of the time, the two types of DRAW IF command will not perform properly on the LOW-RES screen. And the larger the value of 's' in the latter of the two, the greater the chance of the line being completed. * SYNTAX: ERASE Purpose: Makes the DRAW and PLOT commands turn off dots, instead of turning them on. Description: With this enabled, all dots to be PLOTted or DRAWn will turn off any dots that happen to be turned on. To enable erase mode, use the ERASE command as above. To disable erase mode, place a number sign (#) after the ERASE command as with the BOTTOM command. * SYNTAX: FLIP Purpose: To switch between the two HI-RES screens. Description: The first time this command is executed after the HI-RES screen has been enabled, the output (all graphics commands and PRINT statements) will be switched to the opposite screen than is enabled. And the screen being viewed is the screen that was enabled. Every time the FLIP command is executed after this point, it will switch the screen being viewed with the opposite screen. The command (or output) will also remain on the screen that is not being viewed. The SCREEN command will set it back to normal. SYNTAX: LOSCR "file name" Purpose: To load the graphic SCREEN1 and 3. Description: This command will load a graphic screen into memory. This is only the screen and not its color. The screen is SCREEN 1 or 3 because they are in the same place in memory. This is always for disk drives only. SYNTAX: PEN p Purpose: This will change the color of all dots which are to be PLOTted or DRAWn. Description: This will change the present PEN color, which the dots are put on the screen with, to one of the colors you have selected with the COLOR command. P = 0-3 : one of the four colors selected with the COLOR command. Note: The PEN command is only of use with the LOW-RES screen, and can not be used with the HI-RES screens. SYNTAX: POINT( x, y ) Purpose: To see if a dot is on or off. Description: This will return the value of the bit at the (x,y) position, if the bit is set to a one (dot turned on). If the bit (dot) is off, the value returned will be 0. x, y = same as with the PLOT and DRAW commands EXAMPLE: 100 PLOT 50, 50:PRINT POINT(50, 50), POINT(0, 0) RUN 32 0 SYNTAX: PLOT x, y Purpose: To turn on one dot. Description: This will turn on one dot (pixel) at the (x,y) location. If the dot (pixel) was already on, the STATUS (ST) variable will have the value of one. If the dot was off the STATUS (ST) will have the value of zero. x, y = same as for the DRAW command SYNTAX: SCREEN s Purpose: To enable or disable a HI-RES or LOW-RES graphic screen. Description: This command will enable a HI-RES or LOW-RES screen, or reset the present condition to the normal screen. s = 0-3 : screen number to enable s = 0 : This is the normal screen, and should be used to return the present condition back to normal. s = 1 : This is one of the HI-RES screens available, and is located at address 40960-49151 ($A000-$BFFF hex.). Screen memory is at location 32768 ($8000 hex.). s = 2 : This is the other HI-RES screen available, and is located at address 57344-65535 ($E000-$FFFF hex.). Screen memory is at location 49152 ($C000 hex.). s = 3 : This is the LOW-RES screen, and is located at the same address as SCREEN 1. SYNTAX: SCRSV "file name" Purpose: To save a graphic screen. Description: This will save SCREEN 1 and SCREEN 3 (remember SCREEN 1 and SCREEN 3 are the same screen) to disk only. * SYNTAX: TOGL Purpose: This will toggle all dots PLOTted or DRAWn. Description: With TOGL (toggle) enabled, all dots PLOTted or DRAWn, which are already on, will be turned off. And if the dot is off, it will be turned on. To enable toggle use the above format. To disable toggle, follow the TOGL command with the number sign (#). Note: Erase mode has priority over toggle mode. Toggle mode will not work if erase mode is enabled. öcSPRITES SYNTAX: DETECT sp1 TO (sp2, sp3) THEN (collision detection) Purpose: Detects sprite to sprite or sprite to background collision. Description: This command works a lot like the 'IF' command, in that it tests to see if the condition is true or false. If it is true, the 'THEN' is performed. Otherwise it will skip the rest of that line and continue with the next line of the program. The above format will check for (or test) a collision between sprites: If sprite 'sp1' has had a collision with 'sp2' or 'sp3', then the BASIC 'THEN' will be performed. The DETECT command checks for a collision between the sprite 'sp1', and any sprite number which is in the parentheses. The number of sprite numbers which can be placed between the parentheses, can be as few as one or as many as six numbers. The above format is for sprite to sprite detection only. If you are checking for a collision between sprites and the background, then you would leave out the first sprite number 'sp1' and the BASIC 'TO'. The number(s) in parentheses will be checked for collision to any background matter. If this is executed twice before the sprites are moved again, you must place a number sign (#) directly after the DETECT command. This will make the DETECT command read and act upon the copy of the sprite collision registers (located at 40958 dec. $9FFE hex. for sprite to sprite, and sprite to background located at 40959 dec. $9FFF hex.). Other-wise the DETECT command will read the actual collision registers and save a copy of there contents in the above locations. Note: Any dot pattern of "01" ('.*' when using the the CPROG or SPROG commands) will not set off a detection between sprites and background. This is useful if you wish a sprite to go over certain characters or background and not register any collision. "01" is also PEN 2 when using a low-res graphic screen. sp1-sp3 = 0-7 : sprite numbers EXAMPLE: To check for a collision between sprite 1 and any other sprite, you would use: 100 DETECT 1 TO (0,2,3,4,5,6,7) THEN PRINT "hit":END The above program line will PRINT the word "hit" and end the program there, if sprite 1 has had a collision with any other sprite. Now let us say you want to check for a collision between sprite 3 or sprite 5 and the background, you would add this to the above: 110 DETECT# (3,5) THEN PRINT "hit the background":END This will check to see if a collision has happened, and if so, PRINT the words "hit the background", and then end the program. SYNTAX: EXPAND Y sp Purpose:This will expand or contract one sprite in one of two directions. Description: The above format will expand sprite 'sp' in the "Y" direction (vertical). For the "X" direction (horizonal), you would substitute the letter "X" for the letter "Y". To contract a sprite, just place a number sign (#) after the EXPAND command. sp = 0-7 : sprite number EXAMPLE: To expand sprite 5 in both directions, you would use: 100 EXPAND Y 5 : EXPAND X 5 To contract the same sprite in both directions, you would use: 110 EXPAND# Y 5 : EXPAND# X 5 SYNTAX: LOSPR s ,"file name" Purpose: This will load certain sprites. Description: This will load previously saved sprites from disk, with the file name you have specified, in memory starting at sprite 's'. s = 0-255 : starting sprite image number SYNTAX: SMOVE sp1 TO dx, dy Purpose: To move a specified sprite to dx,dy coordinates. Description: This will move the sprite specified by 'sp1' to the 'dx,dy' position of the screen. sp1 = 0-7 : sprite number dx = 0-511 : horizonal position dy = 0-255 : vertical position SYNTAX: SDP sp Purpose: This turns on or off a Sprites Display Priority. Description: The above format will disable (turn off) the Sprite Display Priority for sprite 'sp'. To enable (return to normal) the Sprite Display Priority for sprite 'sp', place a number sign (#) after the SPD command. sp = 0-7 : sprite number EXAMPLE: To make sprite 1 to appear under text or background, you would use: 100 SDP 1 To make sprite one appear on top of the text or background, you would use: 100 SDP# 1 SYNTAX: SPRCL sp, c1, c2, c3 Purpose: To set a sprite's color and maybe multi colors. Description: The above format will set the colors for sprite 'sp' to 'c1' , 'c2', and 'c3', and set the sprite 'sp' in multicolor mode. If you are using or want to set the sprite in high resolution mode you would use this command without the last two colors. This will set the sprite 'sp' in high resolution and set its color to 'c1'. sp = 0-7 : sprite number c1 - c3 = 0-15 : sprite colors EXAMPLE: To set sprite 4 in multicolor and set its colors to black, white, and red, you would use: 100 SPRCL 4, 0,1,2 To set sprite 3 in high resolution mode and set its color to blue, you would use: 110 SPRCL 3, 6 SYNTAX: SPRITE sp, im Purpose: This will enable or disable one sprite. Description: The above format will enable (turn on) sprite 'sp' with the image of 'im'. 'im' should be the same number you used when you used the SPROG command. To disable a sprite you must place a number sign (#) in front of 'sp' and leave off the comma and the'im'. sp = 0-7 : this is the sprite number im = same as for the SPROG command EXAMPLE: Let us say you want to enable sprite 2 with an image of 129, you would use: 100 SPRITE 2, 129 Now maybe you want to disable the same sprite, you would use: 110 SPRITE# 2 SYNTAX: SPROG im Purpose: This will set a pointer to memory for the bit pattern for a sprite to be placed. Description: The above format is one of two ways to use this command. As above this will set a pointer to the proper place in memory to store the bit pattern to be specified. im = 28-63 : in bit map mode this is all the space available im = 28-63 and 128-191 : in custom character mode im = 28-63 and 128-254 : in normal mode The second format is: SPROG ".....**...**.....**....." This will set one row of the sprites bit pattern. You simply use a asterisk (*) where a dot is to be on, and a period (.) for off. After this has been called 21 times without changing the pointer, the whole sprite pattern will be set. SYNTAX: SPRSV s TO e, "file name" Purpose: To save sprite images Description: This will save all sprite images from 's' to 'e' (this includes the 'e' sprite image), to disk. s = 0-254 : starting sprite image number e = 0-254 : ending sprite image number Note: If you use the CLEAR command, it will also clear all sprite images from 128 to 254. So it is best to copy them to a safe place in memory before using the CLEAR command.