| Home CBM ASCII-X BASIC Disk Commands Enter RUN mode Program Format Secret Variables Variable Format Expressions Keywords (divide) (equal) (less) (minus) (more) (multiply) (plus) (power) Abs And Append Asc Atn Auto Backup Bank Begin Bend Bload Boot Box Bsave Bump Catalog Char Chr Circle Close Clr Cmd Collect Collision Color Concat Cont Copy Cos Data Dclear Dclose Dec Def Delete Dim Directory Dispose Dload Do Dopen Draw Ds Ds string Dsave Dverify El Else End Envelope Er Err Exit Exp Fast Fetch Filter Fn For Fre Get Get num Getkey Go Gosub Goto Graphic Gshape Header Help Hex If Input Input num Instr Int Joy Key Left Len Let List Load Locate Log Loop Mid Monitor Movspr New Next Not Off On Open Or Paint Peek Pen Pi Play Pointer Poke Pos Pot Print num Pudef Quit Rclr Rdot Read Record Rem Rename Renumber Restore Resume Return Rgr Right Rlum Rnd Rreg Rspcolor Rsppos Rsprite Run Rwindow Save Scale Scnclr Scratch Sgn Sin Sleep Slow Sound Spc Sprcolor Sprdef Sprite Sprsav Sqr Sshape St Stash Step Stop Str Swap Sys Tab Tan Tempo Then Ti Ti string To Trap Troff Tron Until Using Usr Val Verify Vol Wait While Width Window Xor Syntax Tokens C128 D64plus Disk Escape Codes Hardware PCxface PETSCII Pet2asc Futurama IBM PC-AT Contact Games Glossary Hall of fame Hall of shame Miscellaneous Privacy policy Programming Twisty puzzles |
GRAPHIC { CLR | mode [ , clear [ , rows ] ] }
(De)allocate and/or clear a bitmap screen; this typically changes video display mode as well.
The GRAPHIC keyword may be followed by either the CLR keyword or 1 to 3 numeric parameters. With the CLR keyword, the bitmap is de-allocated which frees room for BASIC. The bitmap uses 10K on the C16 and Plus/4, and 9K on the C128 (40 columns). Using the CLR keyword also returns the screen to text mode (assuming it was displaying a bitmap). Once a bitmap is allocated (see below), it consumes memory until removed with GRAPHIC CLR; simply switching to text mode (GRAPHIC 0) will not free the memory used by the bitmap (but it will hide the bitmap). In the case of the numeric parameters, they will be converted to integers if they are floating-point (see INT). You will get TYPE MISMATCH ERROR if any are strings. The first parameter, mode, sets the TED/VIC screen as follows:
The second parameter, clear, acts like a boolean value. If zero, nothing special happens. If one, the bitmap is cleared, all color cells are initialized with the chipColors set by COLOR, and the pixel cursor is set to 0,0 (except GRAPHIC 0 and GRAPHIC 5 which select a text mode). For GRAPHIC 0 or GRAPHIC 5 (or any split-screen mode) the text screen is cleared. Due to the different ways the video chip interprets bitmap data, you should clear the screen when switching between high-resolution and multi-color modes; otherwise you will see strange things. This parameter will not accept a boolean value returned by BASIC's own relational operators! This is because they return -1 for true but the clear parameter only accepts 0 and 1. The third parameter, rows, is intended to set the number of visible bitmap "rows" (where a row is 8 rasters) in the top (bitmap portion) of a split-screen mode. However it is accepted in non-split-screen modes as well. In those cases, it has not effect, but the value must still be "legal" as shown above. This statement updates two secret variables (plus a "public" one, see RGR). One secret variable is the "bitmap allocated" (set to non-zero when a bitmap is allocated, or zeroed when the CLR preposition is used). The second secret variable (only on the C128) is the split screen row (the value is fixed on the Plus/4). Whenever a bitmap is allocated or de-allocated, the BASIC program is moved in memory. This requires the entire program to be re-linked, which can take a few seconds. Threre is also a documented bug (so it is a feature!) with this memory shuffle: any user-functions are not updated to point to their new location in memory. So execute your DEF statements after you (de)allocate your bitmap. If you need your functions both before and after bitmap allocation, you can place them in a subroutine. Then just remember to call your subroutine whenever you (de)allocate a bitmap. BUG: In version 7.0, specifying mode 4 and clear 1 (i.e., clear the multi-color split-screen bitmap) will fail to initialize the memory used for colorSource 3. This is normally not obvious because most bitmap commands will set the color memory when they plot on the bitmap. However CHAR only writes one colorSource to the bitmap and all others take the old value, which could be wrong due to this bug. Examples:
© H2Obsession, 2014 |