ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
gr.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
48/* <usermanual>
49@keyword GR LOCATE
50
51@english
52
53The ''GR LOCATE'' allows you to position the graphics cursor in a specific position on the screen,
54thus preparing the ground for subsequent drawing operations, such as printing text, drawing lines
55or shapes.
56
57Before drawing lines, rectangles, or other shapes, you must position the graphics cursor at the
58starting point of the shape. By combining ''GR LOCATE'' with other graphics commands, you can
59create animations by moving objects around the screen.
60
61Obviously, the coordinate system and screen size depend on the graphics mode selected with the
62''BITMAP ENABLE'' or ''SCREEN'' commands. The ugBASIC offers other graphics functions, such as
63''PLOT'' for drawing points, ''LINE'' for drawing lines, and many more.
64
65@italian
66
67''GR LOCATE'' consente di posizionare il cursore grafico in una posizione specifica sullo
68schermo, preparando così il terreno per le successive operazioni di disegno,
69come la stampa di testo, il disegno di linee o forme.
70
71Prima di disegnare linee, rettangoli o altre forme, è necessario posizionare il cursore
72grafico nel punto di partenza della forma. Combinando ''GR LOCATE'' con altri comandi
73grafici, è possibile creare animazioni spostando gli oggetti sullo schermo.
74
75Ovviamente, il sistema di coordinate e le dimensioni dello schermo dipendono dalla modalità
76grafica selezionata con i comandi ''BITMAP ENABLE'' o ''SCREEN''. ugBASIC offre altre
77funzioni grafiche, come ''PLOT'' per disegnare punti, ''LINE'' per disegnare linee e molte
78altre.
79
80@syntax GR LOCATE [x], [y]
81
82@example GR LOCATE 100,10
83
84@usedInExample graphics_clip_01.bas
85@usedInExample graphics_position_01.bas
86@usedInExample graphics_shapes_02.bas
87</usermanual> */
88
89void gr_locate( Environment * _environment, char * _x, char * _y ) {
90
91 if ( _x ) {
92 Variable * x = variable_retrieve( _environment, _x );
93 if ( x->origin ) {
94 Variable * xgr = variable_retrieve( _environment, "XGR" );
95 variable_move( _environment, x->origin->name, xgr->name );
96 } else {
97 if ( x->reflected ) {
98 Variable * xgr = variable_retrieve( _environment, "XGR" );
99 variable_move( _environment, x->name, xgr->name );
100 } else {
101 Variable * xgr = variable_retrieve( _environment, "XGR" );
102 if ( x->initializedByConstant ) {
103 variable_store( _environment, xgr->name, x->value );
104 } else {
105 variable_move( _environment, x->name, xgr->name );
106 }
107 }
108 }
109 }
110
111 if ( _y ) {
112 Variable * y = variable_retrieve( _environment, _y );
113 if ( y->origin ) {
114 Variable * ygr = variable_retrieve( _environment, "YGR" );
115 variable_move( _environment, y->origin->name, ygr->name );
116 } else {
117 if ( y->reflected ) {
118 Variable * ygr = variable_retrieve( _environment, "YGR" );
119 variable_move( _environment, y->name, ygr->name );
120 } else {
121 Variable * ygr = variable_retrieve( _environment, "YGR" );
122 if ( y->initializedByConstant ) {
123 variable_store( _environment, ygr->name, y->value );
124 } else {
125 variable_move( _environment, y->name, ygr->name );
126 }
127 }
128 }
129 }
130
131}
Variable * variable_retrieve(Environment *_environment, char *_name)
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.
void gr_locate(Environment *_environment, char *_x, char *_y)
Emit code for GR LOCATE command.
Definition gr.c:89
unsigned char * reflected
Definition ugbc.h:1072
struct _Variable * origin
Definition ugbc.h:1067
char * name
Definition ugbc.h:979
int value
Definition ugbc.h:1025
int initializedByConstant
Definition ugbc.h:1036
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.