ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
downb.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 DOWNB
52
53@english
54
55''DOWNB'' allows the programmer to scroll down a section of the text screen from ''x,y''
56with the ''width'' and the ''height'', including the colors, line by line.
57The new lines inserted are filled in the upper line with a "blank" character.
58
59Note that this command uses console #3 to store the current console values, in order to
60restore them after scrolling. So it cannot be used by the program.
61
62@italian
63
64''DOWNBN'' consente al programmatore di scorrere verso il basso una sezione dello schermo
65di testo da ''x,y'' con la ''width'' e l''height'', inclusi i colori, riga per riga.
66Le nuove righe inserite vengono riempite nella riga superiore con un carattere "vuoto".
67
68Da notare che questo comando utilizza la console nr. 3 per stoccare i valori della
69console attuale, al fine di ripristinarli al termine dello scorrimento. Quindi non
70può essere utilizzato dal programma.
71
72@syntax DOWNB y, x, width, height
73
74@example DOWNB 1, 1, 10, 10
75
76@seeAlso DOWNW
77
78@target all
79</usermanual> */
80void downb( Environment * _environment, char * _line, char * _column, char * _width, char * _height ) {
81
82 Variable * column = variable_retrieve_or_define( _environment, _column, VT_BYTE, 0 );
83 Variable * line = variable_retrieve_or_define( _environment, _line, VT_BYTE, 0 );
84 Variable * width = variable_retrieve_or_define( _environment, _width, VT_BYTE, _environment->screenTilesWidth );
85 Variable * height = variable_retrieve_or_define( _environment, _height, VT_BYTE, _environment->screenTilesHeight );
86
87 Variable * x2 = variable_add( _environment, column->name, width->name );
88 Variable * y2 = variable_add( _environment, line->name, height->name );
89
90 variable_decrement( _environment, x2->name );
91 variable_decrement( _environment, y2->name );
92
93 int previous = _environment->activeConsole.id;
94 console_save( _environment, 3 );
95 console_vars( _environment, _column, _line, x2->name, y2->name );
96 text_vscroll_screen( _environment, 1, 0 );
97 console_restore( _environment, previous );
98
99}
100
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.
void downb(Environment *_environment, char *_line, char *_column, char *_width, char *_height)
Emit code for DOWNB ....
Definition downb.c:80
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