ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
pen.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
47/* <usermanual>
48@keyword PEN (instrucion)
49
50@english
51
52The ''PEN'' command define the color that will be used to draw lines, shapes, or write text
53on the screen. In practice, it is like choosing the color of a pen or marker before you
54start drawing. Depending on the hardware capabilities of the computer, the range of colors
55available could be limited or very large. Some systems used predefined color palettes,
56while others allowed you to define your own colors.
57
58In order to be isomorphic, the ''color'' parameter repesents a value in the available
59colors, from 0 to maximum (''PEN COLORS''). For the very specific reasons, each color is encoded by a literal constant,
60like ''WHITE'' or ''YELLOW''. Those constants will be replaced by proper color index or
61values, depending on the hardware. Obviously, you can directly put the numeric value
62for the color, but you have to know the underlying encoding of the colors.
63
64So the graphics capabilities of the ''PEN'' command are closely tied to the capabilities of
65the target running the program. The resolution of the screen affected the quality of the colors displayed.
66On lower-resolution screens, colors could appear less sharp. Some systems offers a wider color
67gamut and more flexibility in defining colors. Others use a limited color palette could result
68in some uniformity in the colors available. In some target you can define your own palettes,
69so there is no guarantee that the constants and values are the same.
70
71You can use the ''DEFAULT'' constant to use the default pen color for
72the considered target, again if no color replacement has been done.
73
74@italian
75
76Il comando ''PEN'' definisce il colore che verrà utilizzato per disegnare linee, forme o scrivere
77testo sullo schermo. In pratica, è come scegliere il colore di una penna o di un pennarello prima
78di iniziare a disegnare. A seconda delle capacità hardware del computer, la gamma di colori
79disponibili potrebbe essere limitata o molto ampia. Alcuni sistemi utilizzavano tavolozze di
80colori predefinite, mentre altri consentivano di definire i propri colori.
81
82Per essere isomorfo, il parametro ''color'' rappresenta un valore nelle tonalità di colore disponibili.
83Per queste ragioni molto specifiche, ogni colore è codificato da una costante letterale, come ''WHITE''
84o ''YELLOW''. Tali costanti saranno sostituite da un indice o valori di colore appropriati, a seconda
85dell'hardware. Ovviamente, si può inserire direttamente il valore numerico per il colore, ma si deve
86conoscere la codifica sottostante dei colori.
87
88Quindi le capacità grafiche del comando ''PEN'' sono strettamente legate alle capacità del target
89che esegue il programma. La risoluzione dello schermo influenzava la qualità dei colori visualizzati.
90Su schermi a bassa risoluzione, i colori potrebbero apparire meno nitidi. Alcuni sistemi offrono
91una gamma di colori più ampia e maggiore flessibilità nella definizione dei colori. Altri utilizzano
92una tavolozza di colori limitata che potrebbe comportare una certa uniformità nei colori disponibili.
93In alcuni target puoi definire le tue tavolozze, quindi non c'è garanzia che le costanti e i valori
94siano gli stessi.
95
96Si può usare la costante ''DEFAULT'' per usare il colore penna predefinito per il target
97considerato, sempre se non è stata effettuata alcuna sostituzione di colore.
98
99@syntax PEN color
100
101@example PEN 4
102@example PEN esempio
103
104@UsedInExample texts_options_01.bas
105@UsedInExample texts_options_02.bas
106
107@alias INK
108@seeAlso PAPER (instruction)
109</usermanual> */
110
111void pen( Environment * _environment, char * _color ) {
112
113 Variable * pen = variable_retrieve( _environment, "PEN" );
114 Variable * color = variable_retrieve_or_define( _environment, _color, VT_COLOR, COLOR_BLACK );
115
116 variable_move( _environment, color->name, pen->name );
117
118}
#define COLOR_BLACK
Definition 6847.h:36
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
Variable * variable_move(Environment *_environment, char *_source, char *_destination)
Store the value of a variable inside another variable by converting it.
void color(Environment *_environment, int _index, int _shade)
Emit ASM code for instruction COLOR [int], [int].
Definition color.c:59
void pen(Environment *_environment, char *_color)
Emit code for PEN ... command.
Definition pen.c:47
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_COLOR
Definition ugbc.h:471