ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
clip.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 *****************************************************************************
4 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *----------------------------------------------------------------------------
18 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19 * (la "Licenza"); è proibito usare questo file se non in conformità alla
20 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
25 * il software distribuito nei termini della Licenza è distribuito
26 * "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27 * implicite. Consultare la Licenza per il testo specifico che regola le
28 * autorizzazioni e le limitazioni previste dalla medesima.
29 ****************************************************************************/
30
31/****************************************************************************
32 * INCLUDE SECTION
33 ****************************************************************************/
34
35#include "../../ugbc.h"
36
37/****************************************************************************
38 * CODE SECTION
39 ****************************************************************************/
40
50/* <usermanual>
51@keyword CLIP
52
53@english
54
55The ''CLIP'' instruction allows you to delimit the area in which the graphics
56are actually drawn. In general, the area corresponds to the entire surface
57of the screen ''(0,0)-(SCREEN WIDTH-1,SCREEN HEIGHT-1)''. However, it is possible
58to limit the drawing to a sub area, to ensure that the area outside this crop
59area is not altered or modified. The area is bounded by the coordinate ''(x1, y1)''
60to the coordinate ''(x2, y2)''. If components are omitted, the screen limits will be used.
61
62@italian
63L'istruzione ''CLIP'' permette di delimitare l'area nella quale la grafica
64viene effettivamente disegnata. In generale, l'area corrisponde all'intera
65superficie dello schermo. E' tuttavia possibile limitare il disegno a una sotto
66area, di modo da garantire che l'are al di fuori di tale area di ritaglio non
67venga alterata o modificata. L'area viene delimitata dalla coordinata ''(x1,y1)''
68alla coordinata ''(x2,y2)''. In mancanza di componenti, l'intero schermo sarà
69considerato.
70
71@syntax CLIP x1,y1 TO x2, x2
72
73@example CLIP 42,42 TO 84,84
74@usedInExample graphics_clip_01.bas
75
76@target all
77</usermanual> */
78void clip( Environment * _environment, char * _x1, char * _y1, char * _x2, char * _y2 ) {
79
80 Variable * c;
81
82 c = variable_retrieve( _environment, "CLIPX1" );
83 if ( _x1 ) {
84 Variable * x = variable_retrieve_or_define( _environment, _x1, VT_POSITION, 0 );
85 variable_move( _environment, x->name, c->name );
86 } else {
87 variable_store( _environment, c->name, 0 );
88 }
89
90 c = variable_retrieve( _environment, "CLIPY1" );
91 if ( _y1 ) {
92 Variable * x = variable_retrieve_or_define( _environment, _y1, VT_POSITION, 0 );
93 variable_move( _environment, x->name, c->name );
94 } else {
95 variable_store( _environment, c->name, 0 );
96 }
97
98 c = variable_retrieve( _environment, "CLIPX2" );
99 if ( _x2 ) {
100 Variable * x = variable_retrieve_or_define( _environment, _x2, VT_POSITION, 0 );
101 variable_move( _environment, x->name, c->name );
102 } else {
103 variable_move( _environment, screen_get_width( _environment )->name, c->name );
104 }
105
106 c = variable_retrieve( _environment, "CLIPY2" );
107 if ( _y2 ) {
108 Variable * x = variable_retrieve_or_define( _environment, _y2, VT_POSITION, 0 );
109 variable_move( _environment, x->name, c->name );
110 } else {
111 variable_move( _environment, screen_get_height( _environment )->name, c->name );
112 }
113
114}
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
Variable * variable_move(Environment *_environment, char *_source, char *_destination)
Store the value of a variable inside another variable by converting it.
Variable * variable_store(Environment *_environment, char *_destination, unsigned int _value)
Store a direct value to a variable.
char * name
Definition _optimizer.c:672
void clip(Environment *_environment, char *_x1, char *_y1, char *_x2, char *_y2)
Emit code to implement CLIP command.
Definition clip.c:78
Variable * screen_get_height(Environment *_environment)
Variable * screen_get_width(Environment *_environment)
char * name
Definition ugbc.h:979
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_POSITION
Definition ugbc.h:468