ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
begin_copper.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
46/* <usermanual>
47@keyword BEGIN COPPER...END COPPER
48
49@english
50
51The ''BEGIN COPPER'' and the ''END COPPER'' instructions are fundamental commands
52used in programming hardware that interacts directly with a TV's video signal.
53Their primary purpose is to isolate and delimit a block of instructions (called a
54"Copper list") that must be executed in close synchronization with the TV's video
55brush.
56
57Think of the TV screen as a canvas on which a painter is drawing. This "painter" is
58the video brush, a beam of electrons that slides across the screen's surface to paint
59the image. This process occurs very quickly, line by line, from top to bottom and from
60left to right.
61
62The ''BEGIN COPPER'' and ''END COPPER'' instructions allow you to delimit a list of
63operations that will be performed while the video brush is drawing a specific portion
64of the screen. When the program executes a list of instructions between ''BEGIN COPPER''
65and ''END COPPER'', it waits for the video brush to reach a specific position (specified
66within the list) before executing the next instruction. This allows you to "paint" graphic
67effects exactly at the desired time and location on the screen, avoiding flickering or
68visual artifacts.
69
70Operations in a copper list can include doing nothing (''COPPER NOP''), waiting for a
71specific position (''COPPER WAIT LINE''), or modifying a specific memory location
72(''COPPER MOVE'').
73
74The main advantage of this synchronization is the ability to create complex and fluid
75graphic effects that would be difficult or impossible to achieve with normal CPU
76programming, which is less precise in controlling video timing.
77
78In summary, ''BEGIN COPPER'' and ''END COPPER'' are essential to fully exploit the
79capabilities of dedicated graphics hardware systems, enabling granular and timed
80control of the video generation process to achieve high-quality visual results.
81
82@italian
83
84Le istruzioni ''BEGIN COPPER'' ed ''END COPPER'' sono comandi fondamentali,
85utilizzati nell'ambito della programmazione per hardware che interagisce
86direttamente con il segnale video di una TV. Il loro scopo principale è
87quello di isolare e delimitare un blocco di istruzioni (chiamato
88"lista copper" o "copper list") che devono essere eseguite in stretta
89sincronizzazione con il pennello video della TV.
90
91Immagina lo schermo della TV come una tela su cui un pittore sta disegnando.
92Questo "pittore" è il pennello video, un fascio di elettroni che scorre
93sulla superficie dello schermo per disegnare l'immagine. Questo processo
94avviene molto rapidamente, riga per riga, dall'alto verso il basso e da
95sinistra a destra.
96
97Con le istruzioni ''BEGIN COPPER'' ed ''END COPPER'' è possibile delimitare
98un elenco di operazioni che saranno eseguite mentre il pennello video sta
99disegnando una specifica parte dello schermo. Quando il programma esegue una
100lista di istruzioni tra ''BEGIN COPPER'' ed ''END COPPER'', questo attende
101che il pennello video raggiunga una determinata posizione (specificata
102all'interno della lista stessa) prima di eseguire l'istruzione successiva.
103Questo permette di "dipingere" effetti grafici esattamente nel momento e nel
104punto desiderato sullo schermo, evitando sfarfallii o artefatti visivi.
105
106Le operazioni previste in una lista copper possono includere il non fare nulla
107(''COPPER NOP''), l'attesa di una specifica posizione (''COPPER WAIT LINE'') o la
108modifca di una specifica locazione di memoria (''COPPER MOVE'').
109
110Il vantaggio principale di questa sincronizzazione è la possibilità di creare
111effetti grafici complessi e fluidi che sarebbero difficili o impossibili da
112realizzare con una normale programmazione della CPU, che è meno precisa nel
113controllo dei tempi video.
114
115In sintesi, ''BEGIN COPPER'' ed ''END COPPER'' sono essenziali per sfruttare
116appieno le capacità di sistemi hardware dedicati alla grafica, consentendo
117un controllo granulare e temporizzato del processo di generazione video per
118ottenere risultati visivi di alta qualità.
119
120@syntax BEGIN COPPER [name]
121@syntax ...
122@syntax END COPPER
123
124@alias BEGIN COPPER...ENDCOPPER
125@alias COPPER...ENDCOPPER
126
127</usermanual> */
128/* <usermanual>
129@keyword COPPER...END COPPER
130
131@english
132
133@italian
134
135@alias BEGIN COPPER...END COPPER
136
137</usermanual> */
138/* <usermanual>
139@keyword BEGIN COPPER...ENDCOPPER
140
141@english
142
143@italian
144
145@alias BEGIN COPPER...END COPPER
146
147</usermanual> */
148/* <usermanual>
149@keyword COPPER...END COPPER
150
151@english
152
153@italian
154
155@alias BEGIN COPPER...END COPPER
156
157</usermanual> */
158
159void begin_copper( Environment * _environment, char * _name ) {
160
161 if ( _environment->insideCopperList ) {
163 }
164
165 CopperList * existing = find_copper_list( _environment, _name );
166
167 if ( existing ) {
169 }
170
171 _environment->insideCopperList = 1;
172
173 CopperList * newCopperList = malloc( sizeof( CopperList ) );
174 memset( newCopperList, 0, sizeof( CopperList ) );
175
176 if ( _name ) {
177 newCopperList->name = strdup( _name );
178 }
179
180 newCopperList->next = _environment->copperList;
181 _environment->copperList = newCopperList;
182
183}
CopperList * find_copper_list(Environment *_environment, char *_name)
void begin_copper(Environment *_environment, char *_name)
Emit code for BEGIN COPPER.
char * name
Definition ugbc.h:2252
struct _CopperList * next
Definition ugbc.h:2255
CopperList * copperList
Definition ugbc.h:3282
int insideCopperList
Definition ugbc.h:3280
void * malloc(YYSIZE_T)
struct _Environment Environment
Structure of compilation environment.
#define CRITICAL_NESTED_COPPER_LIST_NOT_ALLOWED()
Definition ugbc.h:3840
#define CRITICAL_COPPER_LIST_ALREADY_DEFINED()
Definition ugbc.h:3842
struct _CopperList CopperList