ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
cmove.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 cmove_direct( Environment * _environment, int _dx, int _dy ) {
42
43 if ( _dx ) {
44 Variable * consoleX1 = variable_retrieve( _environment, "CONSOLEX1" );
45 Variable * consoleX2 = variable_sub_const( _environment, variable_retrieve( _environment, "CONSOLEX2" )->name, 1 );
46 Variable * windowCX = variable_retrieve( _environment, "XCURSYS" );
47 Variable * dx = variable_temporary( _environment, VT_SBYTE, "(cmove hz)" );
48 variable_store( _environment, dx->name, _dx );
49 add_complex_vars( _environment, windowCX->name, dx->name, consoleX1->name, consoleX2->name, 1 );
50 }
51
52 if ( _dy ) {
53 Variable * consoleY1 = variable_retrieve( _environment, "CONSOLEY1" );
54 Variable * consoleY2 = variable_sub_const( _environment, variable_retrieve( _environment, "CONSOLEY2" )->name, 1 );
55 Variable * windowCY = variable_retrieve( _environment, "YCURSYS" );
56 Variable * dy = variable_temporary( _environment, VT_SBYTE, "(cmove vt)" );
57 variable_store( _environment, dy->name, _dy );
58 add_complex_vars( _environment, windowCY->name, dy->name, consoleY1->name, consoleY2->name, 1 );
59 }
60
61}
62
68/* <usermanual>
69@keyword CMOVE (instruction)
70
71@english
72
73''CMOVE'' allows to move the text cursor a pre-set distance away from its current position.
74The command is followed by a pair of variables that represent the width and height of the
75required offset, and these values are added to the current cursor coordinates. Like
76''LOCATE'', either of the coordinates can be omitted, as long as the comma is positioned
77correctly. An additional technique is to use negative values as well as positive offsets.
78
79@italian
80Il comando ''CMOVE'' consente di spostare il cursore del testo di una distanza preimpostata
81dalla sua posizione corrente. Il comando è seguito da una coppia di variabili che rappresentano
82la larghezza e l'altezza dell'offset richiesto e questi valori vengono aggiunti alle coordinate
83correnti del cursore. Come "LOCATE", una delle coordinate può essere omessa, purché la virgola
84sia posizionata correttamente. Una tecnica aggiuntiva consiste nell'utilizzare valori negativi
85e offset positivi.
86
87@syntax CMOVE [dx], [dy]
88
89@example CMOVE -1, -1
90@example CMOVE 4,
91
92@usedInExample texts_position_03.bas
93@usedInExample texts_position_04.bas
94@usedInExample texts_position_07.bas
95
96@seeAlso CMOVE (function)
97
98@target all
99</usermanual> */
100void cmove( Environment * _environment, char * _dx, char * _dy ) {
101
102 if ( _dx ) {
103 Variable * consoleX1 = variable_retrieve( _environment, "CONSOLEX1" );
104 Variable * consoleX2 = variable_retrieve( _environment, "CONSOLEX2" );
105 Variable * windowCX = variable_retrieve( _environment, "XCURSYS" );
106 Variable * dx = variable_retrieve_or_define( _environment, _dx, VT_SBYTE, 0 );
107 add_complex_vars( _environment, windowCX->name, dx->name, consoleX1->name, consoleX2->name, 1 );
108 }
109
110 if ( _dy ) {
111 Variable * consoleY1 = variable_retrieve( _environment, "CONSOLEY1" );
112 Variable * consoleY2 = variable_retrieve( _environment, "CONSOLEY2" );;
113 Variable * windowCY = variable_retrieve( _environment, "YCURSYS" );
114 Variable * dy = variable_retrieve_or_define( _environment, _dy, VT_SBYTE, 0 );
115 add_complex_vars( _environment, windowCY->name, dy->name, consoleY1->name, consoleY2->name, 1 );
116 }
117
118}
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
Variable * variable_sub_const(Environment *_environment, char *_source, int _destination)
Make a differenze between a variable a constant, and return the difference of them.
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
Variable * variable_store(Environment *_environment, char *_destination, unsigned int _value)
Store a direct value to a variable.
void add_complex_vars(Environment *_environment, char *_variable, char *_expression, char *_limit_lower, char *_limit_upper, int _clamp)
Emit code for ADD x,y,a TO b.
Definition add.c:136
char * name
Definition _optimizer.c:672
void cmove_direct(Environment *_environment, int _dx, int _dy)
Definition cmove.c:41
void cmove(Environment *_environment, char *_dx, char *_dy)
Emit code for CMOVE.
Definition cmove.c:100
char * name
Definition ugbc.h:979
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_SBYTE
Definition ugbc.h:452