ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
paper.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 PAPER (instruction)
49
50@english
51
52The ''PAPER'' command define the background color of the screen. Imagine having a blank sheet of
53paper to draw on: with ''PAPER'', you can choose the color of this sheet, turning it into a colored
54sheet, lined or squared, depending on your preferences and the capabilities of your computer.
55
56The parameter ''color'' is represented by a value in the available colors, from 0 to maximum
57(''PAPER COLORS''). For the very specific reasons, each color is encoded by a literal constant,
58like ''WHITE'' or ''YELLOW''. Those constants will be replaced by proper color index or
59values, depending on the hardware. Obviously, you can directly put the numeric value
60for the color, but you have to know the underlying encoding of the colors.
61
62By combining the background color (defined with ''PAPER'') with the color of the text or lines
63(defined with ''PEN''), you can create interesting visual effects and improve the readability
64of your programs. You can also use ''PAPER'' to create colored backgrounds that simulate
65different environments, such as a starry sky, a green meadow or a blue ocean. In simple games,
66''PAPER'' allows you to define the game background, creating a more immersive atmosphere.
67
68So the graphics capabilities of the ''PAPER'' command are closely tied to the capabilities of
69the target running the program. The resolution of the screen affected the quality of the colors displayed.
70On lower-resolution screens, colors could appear less sharp. Some systems offers a wider color
71gamut and more flexibility in defining colors. Others use a limited color palette could result
72in some uniformity in the colors available. In some target you can define your own palettes,
73so there is no guarantee that the constants and values are the same.
74
75You can use the ''DEFAULT'' constant to use the default paper color for
76the considered target, again if no color replacement has been done.
77
78@italian
79
80Il comando ''PAPER'' definisce il colore di sfondo dello schermo. Immagina di avere un
81foglio bianco su cui disegnare: con ''PAPER'' puoi scegliere il colore di questo foglio,
82trasformandolo in un foglio colorato, a righe o a quadretti, a seconda delle tue preferenze
83e delle capacità del tuo computer.
84
85Il parametro ''color'' è rappresentato da un valore nei colori disponibili, da 0 al massimo
86(''PAPER COLORS''). Per motivi molto specifici, ogni colore è codificato da una costante
87letterale, come ''WHITE'' o ''YELLOW''. Tali costanti saranno sostituite da un indice o
88valori di colore appropriati, a seconda dell'hardware. Ovviamente, puoi inserire
89direttamente il valore numerico per il colore, ma devi conoscere la codifica sottostante
90dei colori.
91
92Combinando il colore di sfondo (definito con ''PAPER'') con il colore del testo o delle
93linee (definiti con ''PEN''), puoi creare interessanti effetti visivi e migliorare la
94leggibilità dei tuoi programmi. Puoi anche usare ''PAPER'' per creare sfondi colorati
95che simulano diversi ambienti, come un cielo stellato, un prato verde o un oceano blu.
96Nei giochi semplici, ''PAPER'' ti consente di definire lo sfondo del gioco,
97creando un'atmosfera più immersiva.
98
99Quindi le capacità grafiche del comando ''PAPER'' sono strettamente legate alle capacità
100del target che esegue il programma. La risoluzione dello schermo ha influenzato la qualità
101dei colori visualizzati. Su schermi a bassa risoluzione, i colori potrebbero apparire meno nitidi.
102Alcuni sistemi offrono una gamma di colori più ampia e maggiore flessibilità nella
103definizione dei colori. Altri utilizzano una tavolozza di colori limitata che potrebbe
104comportare una certa uniformità nei colori disponibili. In alcuni target puoi definire
105le tue tavolozze, quindi non c'è garanzia che le costanti e i valori siano gli stessi.
106
107Puoi usare la costante ''DEFAULT'' per usare il colore della carta predefinito
108per il target considerato, sempre se non è stata effettuata alcuna sostituzione del colore.
109
110@syntax PAPER color
111
112@example PAPER GREEN
113@example PAPER colore
114
115@UsedInExample texts_options_01.bas
116@UsedInExample texts_options_02.bas
117
118@seeAlso PEN (instruction)
119@seeAlso PAPER (function)
120
121</usermanual> */
122void paper( Environment * _environment, char * _color ) {
123
124 Variable * paper = variable_retrieve( _environment, "PAPER" );
125 Variable * color = variable_retrieve_or_define( _environment, _color, VT_COLOR, COLOR_BLACK );
126
127 vic2_background_color_vars( _environment, "#0", color->realName );
128
129 variable_move( _environment, color->name, paper->name );
130 // vic2_border_color( _environment, color->realName );
131
132}
#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 paper(Environment *_environment, char *_color)
Emit code for PAPER ... command.
Definition paper.c:47
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_COLOR
Definition ugbc.h:471
void vic2_background_color_vars(Environment *_environment, char *_index, char *_background_color)
VIC-II: emit code to change background color
Definition vic2.c:691