GSHAPE (BASIC 3.5)

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: GSHAPE
Abbreviation: G SHIFT+S
Type: Function
Token code: $e3 (227)
Handling routine
in BASIC ROM:
List of all BASIC keywords


Remark: This article describes the BASIC function GSHAPE in Commodore BASIC V3.5 or higher.

Type: Function
General Programming-Syntax: GSHAPE string[,<coordinates>][, [<mode>] ]

The GSHAPE function places the image stored into a text string variable on the bit map screen.

Other sprite commands in BASIC 7.0 are MOVSPR, RSPCOLOR, RSPPOS, RSPRITE, SPRCOLOR, SPRITE, SPRDEF and SPRSAV, also BUMP, COLLISION, and SSHAPE.

Examples[edit | edit source]

In the first example, a white square is first drawn on a black background. Then one background and one foreground pixel is saved in the variables H(background)$ and V(foreground)$. Then the background color is assigned the value 3 (red) and the foreground color is assigned the value 7 (blue). Drawing the variable V$ activates that color (although the bitmap itself doesn't change). Finally, after pressing a button, the background color of the color cell is also changed to red:

10 COLOR 0,1:COLOR 1,2
20 GRAPHIC 1,1
30 BOX 1,4,4,19,19,,1
40 SSHAPE H$,0,0,0,0
50 SSHAPE V$,4,4,4,4
60 COLOR 0,3:COLOR 1,7
70 GSHAPE V$,4,4
80 GETKEY K$
90 GSHAPE H$,0,0

In this example, the pixel information of a house from the DATA lines is read into a variable. This graphic is then output on the graphic screen and an output mask is generated. Graphic shape and mask shape are then drawn to demonstrate the different output modes. Finally, the graphic shape is output at a random position after each keystroke with mode 4 without permanently destroying the graphic:

10 REM SHAPE IN VARIABLE EINLESEN
20 DO:READ D$
30 FOR I=1 TO LEN(D$)-1 STEP 2
40 SH$=SH$+CHR$(DEC(MID$(D$,I,2)))
50 NEXT
60 LOOP UNTIL RIGHT$(D$,1)="X"
70 GRAPHIC 1,1
80 REM MASKIERUNGS-SHAPE ERZEUGEN
90 BOX 1,8,8,35,32,,1
100 GSHAPE SH$,10,10
110 PAINT 1,10,10
120 SSHAPE MS$,10,10,33,33:GSHAPE MS$,10,10,1
130 GSHAPE SH$,10,10,2
140 SSHAPE MS$,10,10,33,33:GSHAPE MS$,10,10,1
150 SSHAPE MS$,10,10,33,33:REM MASKE SICHERN
160 REM HINTERGRUND ERSTELLEN
170 SCNCLR 1
180 FOR I=10 TO 180 STEP 32
190 FOR J=0 TO 20 STEP 5:DRAW 1,0,I+J TO 319,I+J:NEXT
200 NEXT
210 REM MASKE AUSGEBEN
220 FOR I=0 TO 4
230 FOR J=0 TO 5:GSHAPE MS$,10+J*50,41+32*I,I:NEXT
240 NEXT
250 REM SHAPE UEBER MASKE LEGEN
260 FOR I=0 TO 4
270 FOR J=0 TO 5:GSHAPE SH$,60+I*50,09+32*J,I:NEXT
280 NEXT
290 REM SHAPE ZERSTOERUNGSFREI UEBER BILDSCHIRM BEWEGEN
300 DO
310 X=INT(RND(1)*320):Y=INT(RND(1)*200)
320 GSHAPE SH$,X,Y,4
330 GETKEY K$
340 GSHAPE SH$,X,Y,4
350 LOOP UNTIL K$=CHR$(27)
360 DATA "02A0000000000700"
370 DATA "0005180005660005"
380 DATA "8180063860182818"
390 DATA "6038062000042000"
400 DATA "042000042F87C428"
410 DATA "85442887C4288544"
420 DATA "2C87C42880042880"
430 DATA "042880043FFFFC17"
440 DATA "001400X"
BASIC V7.0 Commands

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 FN | DELETE | DIM | DIRECTORY | DLOAD | DO | DOPEN | DRAW | DS | DS$ | DSAVE | DVERIFY | EL | ELSE | END | ENVELOPE | ER | ERR$ | EXIT | EXP | FAST | FETCH | FILTER | FN | FOR | FRE | GET | GET# | GETKEY | GO64 | GOSUB | GOTO | GRAPHIC | GSHAPE | HEADER | HELP | HEX$ | IF | INPUT | INPUT# | 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 | PRINT USING | PRINT# | PUDEF | (QUIT) | RCLR | RDOT | READ | RECORD | REM | RENAME | RENUMBER | RESTORE | RESUME | RETURN | RGR | RIGHT$ | 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$ | TO | TRAP | TROFF | TRON | USR | VAL | VERIFY | VOL | WAIT | WHILE | WINDOW | WIDTH | XOR