ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
ypen.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
51/* <usermanual>
52@keyword YPEN
53
54@english
55
56The ''YPEN'' command is used to query the hardware and get the vertical
57position (Y coordinate) of a light pen attached to the system, if the
58hardware supports such a device. When the ''YPEN' command is executed
59within a program, the underlying hardware attempts to read the Y coordinate
60value detected by the light pen. This value represents the vertical position
61of where the pen is currently pointing on the screen or a touch-sensitive surface.
62
63It is important to note that the ''YPEN'' command will only work if the hardware
64on which the program is running actually has a pen interface, and if the pen is
65properly connected and working. If the hardware does not support a pen, the
66value returned by ''YPEN'' may be undefined (often 0 or some other default value),
67and will not represent a valid position.
68
69On some systems, a pen calibration step may be necessary to ensure an accurate
70correspondence between the physical position of the pen and the coordinates on
71the screen. The language itself does not handle calibration directly, which is
72usually handled by the operating system or hardware-specific routines.
73
74To track the movement of the pen, you will need to read the value of ''YPEN'' (and
75usually also ''XPEN'' for the horizontal coordinate) in a continuous loop within
76the program.
77
78The value returned by ''YPEN'' represents the horizontal coordinate. The range of
79these values will depend on the horizontal resolution of the screen or touch
80surface supported by the pen.
81
82@italian
83
84Il comando ''YPEN'' viene utilizzato per interrogare l'hardware e ottenere la
85posizione verticale (coordinata Y) di una penna ottica collegata al sistema,
86se l'hardware la supporta. Quando il comando ''YPEN'' viene eseguito all'interno
87di un programma, l'hardware sottostante tenta di leggere il valore della coordinata
88Y rilevato dalla penna ottica. Questo valore rappresenta la posizione orizzontale
89del punto in cui la penna sta attualmente puntando sullo schermo o su una
90superficie sensibile al tocco.
91
92È importante notare che il comando ''YPEN'' funziona
93solo se l'hardware su cui è in esecuzione il programma dispone effettivamente di
94un'interfaccia penna e se la penna è correttamente collegata e funzionante.
95
96Se l'hardware non supporta una penna, il valore restituito da ''YPEN'' potrebbe
97essere indefinito (spesso 0 o un altro valore predefinito) e non rappresenterà
98una posizione valida.
99
100Su alcuni sistemi, potrebbe essere necessaria una fase di
101calibrazione della penna per garantire una corrispondenza accurata tra la posizione
102fisica della penna e le coordinate sullo schermo. Il linguaggio stesso non gestisce
103direttamente la calibrazione, che solitamente viene gestita dal sistema operativo
104o da routine specifiche dell'hardware.
105
106Per tracciare il movimento della penna, è necessario leggere il valore di ''YPEN''
107(e solitamente anche ''XPEN'' per la coordinata orizzontale) in un ciclo continuo
108all'interno del programma. Il valore restituito da ''YPEN'' rappresenta la
109coordinata orizzontale. L'intervallo di questi valori dipenderà dalla risoluzione
110orizzontale dello schermo o della superficie touch supportata dalla penna.
111
112@syntax = YPEN( )
113
114@example x = YPEN( )
115
116@target c128
117@target c128reu
118@target c128
119
120@alias Y PEN
121@seeAlso XPEN
122</usermanual> */
123/* <usermanual>
124@keyword Y PEN
125@alias YPEN
126@seeAlso X PEN
127</usermanual> */
128Variable * ypen( Environment * _environment ) {
129
130 Variable * result = variable_temporary( _environment, VT_POSITION, "(result)" );
131
132 c128_ypen( _environment, result->realName );
133
134 return result;
135
136}
137
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
Variable * ypen(Environment *_environment)
Emit ASM code for = YPEN().
Definition ypen.c:51
void c128_ypen(Environment *_environment, char *_destination)
Definition c128.c:57
char * realName
Definition ugbc.h:982
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_POSITION
Definition ugbc.h:468