ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
leftw.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 LEFTW
52
53@english
54
55''LEFTW'' allows the programmer to scroll left a section of the text screen from ''x,y''
56with the ''width'' and the ''height'', including the colors, column by column. The new
57columns inserted are filled in the right column with the correspondent character
58that exit from the top.
59
60Note that this command uses console #3 to store the current console values, in order to
61restore them after scrolling. So it cannot be used by the program.
62
63@italian
64
65''LEFTW'' consente al programmatore di scorrere verso sinistra una sezione dello schermo
66di testo da ''x,y'' con la ''width'' e l''height'', inclusi i colori, colonna per colonna.
67Le nuove colonne inserite vengono riempite nella colonna a destra con il carattere che
68esce dal bordo sinistro.
69
70Da notare che questo comando utilizza la console nr. 3 per stoccare i valori della
71console attuale, al fine di ripristinarli al termine dello scorrimento. Quindi non
72può essere utilizzata dal programma.
73
74@syntax LEFTW y, x, width, height
75
76@example LEFTW 1, 1, 10, 10
77
78@seeAlso LEFTB
79
80@target all
81</usermanual> */
82void leftw( Environment * _environment, char * _line, char * _column, char * _width, char * _height ) {
83
84 Variable * column = variable_retrieve_or_define( _environment, _column, VT_BYTE, 0 );
85 Variable * line = variable_retrieve_or_define( _environment, _line, VT_BYTE, 0 );
86 Variable * width = variable_retrieve_or_define( _environment, _width, VT_BYTE, _environment->screenTilesWidth );
87 Variable * height = variable_retrieve_or_define( _environment, _height, VT_BYTE, _environment->screenTilesHeight );
88
89 Variable * x2 = variable_add( _environment, column->name, width->name );
90 Variable * y2 = variable_add( _environment, line->name, height->name );
91
92 variable_decrement( _environment, x2->name );
93 variable_decrement( _environment, y2->name );
94
95 int previous = _environment->activeConsole.id;
96 console_save( _environment, 3 );
97 console_vars( _environment, _column, _line, x2->name, y2->name );
98 text_hscroll_screen( _environment, -1, 1 );
99 console_restore( _environment, previous );
100
101
102}
103
Variable * variable_add(Environment *_environment, char *_source, char *_destination)
Add two variable and return the sum of them.
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
void variable_decrement(Environment *_environment, char *_source)
Decrement a variable by one.
void text_hscroll_screen(Environment *_environment, int _direction, int _overlap)
void console_vars(Environment *_environment, char *_x1, char *_y1, char *_x2, char *_y2)
Definition console.c:181
void console_restore(Environment *_environment, int _number)
Emit code for CONSOLE.
void console_save(Environment *_environment, int _number)
Emit code for CONSOLE.
void leftw(Environment *_environment, char *_line, char *_column, char *_width, char *_height)
Emit code for LEFTW ....
Definition leftw.c:82
int id
Definition ugbc.h:2204
int screenTilesWidth
Definition ugbc.h:2880
Console activeConsole
Definition ugbc.h:2910
int screenTilesHeight
Definition ugbc.h:2885
char * name
Definition ugbc.h:979
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_BYTE
Definition ugbc.h:450