ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
upw.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 UPW
52
53@english
54
55''UPW'' allows the programmer to scroll up a section of the text screen from ''x,y''
56with the ''width'' and the ''height'', including the colors, line by line. The new
57lines inserted are filled in the bottom line 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''UPW'' consente al programmatore di scorrere verso l'alto una sezione dello schermo
66di testo da ''x,y'' con la ''width'' e l''height'', inclusi i colori, riga per riga.
67Le nuove righe inserite vengono riempite nella riga inferiore con il carattere che
68esce dal bordo inferiore.
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 UPW y, x, width, height
75
76@example UPW 1, 1, 10, 10
77
78@seeAlso UPB
79
80@target all
81</usermanual> */
82void upw( 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_vscroll_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_vscroll_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.
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
void upw(Environment *_environment, char *_line, char *_column, char *_width, char *_height)
Emit code for UPB ....
Definition upw.c:82