ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
text.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
41void text_text( Environment * _environment, char * _text, int _raw ) {
42
43 Variable * text = variable_retrieve( _environment, _text );
44 Variable * pen = variable_retrieve( _environment, "PEN" );
45 Variable * paper = variable_retrieve( _environment, "PAPER" );
46
47 text_encoded( _environment, text->name, pen->name, paper->name, _raw );
48
49}
50
51void text_newline( Environment * _environment ) {
52
54
56
57 variable_move( _environment, "CONSOLEX1", "XCURSYS" );
58
59 variable_increment( _environment, "YCURSYS" );
60
61 Variable * result = variable_greater_than( _environment, "YCURSYS", "CONSOLEY2", 0 );
62
63 char endLabel[MAX_TEMPORARY_STORAGE]; sprintf(endLabel, "%send", label);
64 char scrollLabel[MAX_TEMPORARY_STORAGE]; sprintf(scrollLabel, "%sscroll", label);
65
66 cpu_bvneq( _environment, result->realName, scrollLabel );
67
68 cpu_jump( _environment, endLabel );
69
70 cpu_label( _environment, scrollLabel );
71
72 text_vscroll_screen( _environment, -1, 0 );
73
74 variable_move( _environment, "CONSOLEY2", "YCURSYS" );
75
76 cpu_label( _environment, endLabel );
77
78 cpu_return( _environment );
79
81
82 cpu_call( _environment, "lib_text_newline");
83
84}
85
86void text_tab( Environment * _environment ) {
87
88 Variable * tab = variable_retrieve( _environment, "TAB" );
89
90 text_text( _environment, tab->name, 0 );
91
92}
93
94/* <usermanual>
95@keyword TEXT
96
97@english
98
99The ''TEXT'' command allows you to write text at a certain position on the screen.
100
101@italian
102
103Il comando ''TEXT'' permette di scrivere un testo ad una certa posizione sullo schermo.
104
105@syntax TEXT [AT] x, y, string
106
107@seeAlso LOCATE
108@seeAlso PRINT
109
110</usermanual> */
111
112void text_at( Environment * _environment, char * _x, char * _y, char * _text ) {
113
114 setup_text_variables( _environment );
115
116 locate( _environment, _x, _y );
117
118 text_text( _environment, _text, 0 );
119
120}
121
123
124 return variable_retrieve( _environment, "XCURSYS");
125
126}
127
129
130 return variable_retrieve( _environment, "YCURSYS");
131
132}
133
134void text_question_mark( Environment * _environment ) {
135
136 Variable * questionMark = variable_temporary( _environment, VT_STRING, "(question mark)" );
137
138 char resultString[MAX_TEMPORARY_STORAGE]; sprintf( resultString, "?" );
139
140 variable_store_string(_environment, questionMark->name, resultString );
141
142 text_text( _environment, questionMark->name, 0 );
143
144}
145
146/* <usermanual>
147@keyword CDOWN (instruction)
148
149@english
150
151By using the ''CDOWN'' command you can force the text cursor down a single line.
152
153@italian
154
155Utilizzando il comando ''CDOWN'' è possibile forzare il cursore del testo
156verso il basso di una singola riga.
157
158@syntax CDOWN
159
160@example CDOWN
161
162@usedInExample texts_position_04.bas
163
164@seeAlso CMOVE
165@seeAlso CUP
166@seeAlso CDOWN$
167@seeAlso CLEFT
168@seeAlso CRIGHT
169@target all
170</usermanual> */
171
172/* <usermanual>
173@keyword CDOWN (function)
174
175@english
176
177The effect of summoning up the special control character ''CDOWN$'' is exactly the
178same as printing after a ''CDOWN'' command. The advantage of this alternative is
179that several text cursor movements can be combined in a single string, using ''CDOWN$''.
180
181@italian
182
183L'effetto dell'uso del carattere di controllo speciale ''CDOWN$'' è esattamente lo
184stesso della stampa dopo un comando ''CDOWN''. Il vantaggio di questa alternativa
185è che diversi movimenti del cursore di testo possono essere combinati
186in una singola stringa, utilizzando ''CDOWN$''.
187
188@syntax CDOWN$
189
190@example PRINT CDOWN$;
191
192@usedInExample texts_position_10.bas
193
194@seeAlso CMOVE$
195@seeAlso CUP$
196@seeAlso CDOWN
197@seeAlso CLEFT$
198@seeAlso CRIGHT$
199@target all
200</usermanual> */
201
202
203/* <usermanual>
204@keyword CUP (instruction)
205
206@english
207By using the ''CUP'' command you can force the text cursor up a single line.
208
209@italian
210Utilizzando il comando ''CUP'' è possibile forzare il cursore del testo
211verso l'alto di una singola riga.
212
213@syntax CUP
214
215@example CUP
216
217@usedInExample texts_position_04.bas
218
219@seeAlso CMOVE
220@seeAlso CUP$
221@seeAlso CDOWN
222@seeAlso CLEFT
223@seeAlso CRIGHT
224@target all
225</usermanual> */
226
227/* <usermanual>
228@keyword CUP (function)
229
230@english
231The effect of summoning up the special control character ''CUP$'' is exactly the
232same as printing after a ''CUP'' command. The advantage of this alternative is
233that several text cursor movements can be combined in a single string, using ''CUP$''.
234
235@italian
236L'effetto dell'uso del carattere di controllo speciale ''CUP$'' è esattamente lo
237stesso della stampa dopo un comando ''CUP''. Il vantaggio di questa alternativa
238è che diversi movimenti del cursore di testo possono essere combinati
239in una singola stringa, utilizzando ''CUP$''.
240
241@syntax CUP$
242
243@example PRINT CUP$;
244
245@usedInExample texts_position_10.bas
246
247@seeAlso CMOVE$
248@seeAlso CUP
249@seeAlso CDOWN$
250@seeAlso CLEFT$
251@seeAlso CRIGHT$
252@target all
253</usermanual> */
254
255
256/* <usermanual>
257@keyword CRIGHT (instruction)
258
259@english
260By using the ''CRIGHT'' command you can force the text cursor right by a single character.
261
262@italian
263Utilizzando il comando ''CRIGHT'' è possibile forzare il cursore del testo
264verso destra di un singolo carattere.
265
266@syntax CRIGHT
267
268@example CRIGHT
269
270@usedInExample texts_position_04.bas
271
272@seeAlso CMOVE
273@seeAlso CUP
274@seeAlso CDOWN
275@seeAlso CLEFT
276@seeAlso CRIGHT$
277@target all
278</usermanual> */
279
280/* <usermanual>
281@keyword CRIGHT (function)
282
283@english
284The effect of summoning up the special control character ''CRIGHT$'' is exactly the
285same as printing after a ''CRIGHT'' command. The advantage of this alternative is
286that several text cursor movements can be combined in a single string, using ''CRIGHT$''.
287
288@italian
289L'effetto dell'uso del carattere di controllo speciale ''CRIGHT$'' è esattamente lo
290stesso della stampa dopo un comando ''CRIGHT''. Il vantaggio di questa alternativa
291è che diversi movimenti del cursore di testo possono essere combinati
292in una singola stringa, utilizzando ''CRIGHT$''.
293
294@syntax CRIGHT$
295
296@example PRINT CRIGHT$;
297
298@usedInExample texts_position_10.bas
299
300@seeAlso CMOVE$
301@seeAlso CUP$
302@seeAlso CDOWN$
303@seeAlso CLEFT
304@seeAlso CRIGHT$
305@target all
306</usermanual> */
307
308/* <usermanual>
309@keyword CLEFT (instruction)
310
311@english
312By using the ''CLEFT'' command you can force the text cursor left by a single character.
313
314@italian
315Utilizzando il comando ''CLEFT'' è possibile forzare il cursore del testo
316verso sinistra di un singolo carattere.
317
318@syntax CLEFT
319
320@example CLEFT
321
322@usedInExample texts_position_04.bas
323
324@seeAlso CMOVE
325@seeAlso CUP
326@seeAlso CDOWN
327@seeAlso CLEFT$
328@seeAlso CRIGHT
329@target all
330</usermanual> */
331
332/* <usermanual>
333@keyword CLEFT (function)
334
335@english
336The effect of summoning up the special control character ''CLEFT$'' is exactly the
337same as printing after a ''CLEFT'' command. The advantage of this alternative is
338that several text cursor movements can be combined in a single string, using ''CLEFT$''.
339
340@italian
341L'effetto dell'uso del carattere di controllo speciale ''CLEFT$'' è esattamente lo
342stesso della stampa dopo un comando ''CLEFT''. Il vantaggio di questa alternativa
343è che diversi movimenti del cursore di testo possono essere combinati
344in una singola stringa, utilizzando ''CLEFT$''.
345
346@syntax CLEFT$
347
348@example PRINT CLEFT$;
349
350@usedInExample texts_position_10.bas
351
352@seeAlso CMOVE$
353@seeAlso CUP$
354@seeAlso CDOWN$
355@seeAlso CLEFT
356@seeAlso CRIGHT$
357@target all
358</usermanual> */
void cpu_label(Environment *_environment, char *_label)
Definition 6309.c:356
void cpu_call(Environment *_environment, char *_label)
Definition 6309.c:3755
void cpu_jump(Environment *_environment, char *_label)
Definition 6309.c:3739
void cpu_bvneq(Environment *_environment, char *_value, char *_label)
Definition 6309.c:345
void cpu_return(Environment *_environment)
Definition 6309.c:4030
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_greater_than(Environment *_environment, char *_source, char *_destination, int _equal)
Compare two variable and return the result of comparation.
Variable * variable_move(Environment *_environment, char *_source, char *_destination)
Store the value of a variable inside another variable by converting it.
void variable_increment(Environment *_environment, char *_source)
Increment a variable by one.
Variable * variable_store_string(Environment *_environment, char *_destination, char *_value)
Store a string to a variable.
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
struct @110344003176124301103124235173106120065272160135::var * tab
void paper(Environment *_environment, char *_color)
Emit code for PAPER ... command.
Definition paper.c:47
void pen(Environment *_environment, char *_color)
Emit code for PEN ... command.
Definition pen.c:47
void text_encoded(Environment *_environment, char *_text, char *_pen, char *_paper, int _raw)
void text_vscroll_screen(Environment *_environment, int _direction, int _overlap)
void setup_text_variables(Environment *_environment)
Definition _init.c:61
void locate(Environment *_environment, char *_x, char *_y)
Emit code for LOCATE ...,....
Definition locate.c:110
char * name
Definition ugbc.h:979
char * realName
Definition ugbc.h:982
void text_tab(Environment *_environment)
Definition text.c:86
void text_text(Environment *_environment, char *_text, int _raw)
Definition text.c:41
void text_newline(Environment *_environment)
Definition text.c:51
void text_question_mark(Environment *_environment)
Definition text.c:134
void text_at(Environment *_environment, char *_x, char *_y, char *_text)
Definition text.c:112
Variable * text_get_ycurs(Environment *_environment)
Definition text.c:128
Variable * text_get_xcurs(Environment *_environment)
Definition text.c:122
#define deploy_end(s)
Definition ugbc.h:4365
#define MAX_TEMPORARY_STORAGE
Definition ugbc.h:563
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_STRING
Definition ugbc.h:474
#define deploy_begin(s)
Definition ugbc.h:4356
#define MAKE_LABEL
Definition ugbc.h:3351