ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
copper_wait.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
47 /* <usermanual>
48@keyword COPPER WAIT LINE
49
50@english
51
52The ''COPPER WAIT LINE'' instruction is an essential command. Unlike ''COPPER MOVE'' and
53''COPPER STORE'', which are used to modify values in memory, the ''COPPER WAIT LINE'' instruction
54does not directly modify anything. Its primary purpose is to pause execution until the
55television's video brush reaches a specific position on the screen.
56
57In other words, ''COPPER WAIT LINE'' is a synchronization instruction, necessary to avoid
58flickering and visual artifacts: making hardware changes at the wrong time relative
59to the video scan can cause corrupted or unstable images.
60
61Waiting for a specific location allows you to change colors, shift registers, or
62enable/disable hardware features exactly where and when needed, without the human eye
63perceiving the change as a "jump."
64
65It is therefore possible to define areas of the screen with different color palettes or
66resolutions simply by waiting for the appropriate line with a ''WAIT LINE'' command and then
67using a ''MOVE'' command to set the new parameters.
68
69In short, ''COPPER WAIT LINE'' is the heart of synchronization, allowing complex and dynamic
70changes on the display to be orchestrated in perfect harmony with the video signal flow,
71enabling otherwise impossible graphical effects.
72
73@italian
74
75L'istruzione ''COPPER WAIT LINE'' è un comando essenziale. A differenza di ''COPPER MOVE'' e
76''COPPER STORE'', che vengono utilizzate per modificare valori in memoria, l'istruzione
77''COPPER WAIT LINE'' non modifica direttamente nulla. Il suo scopo principale è quello di mettere
78in pausa l'esecuzione finché il pennello video del televisore non raggiunge una posizione
79specifica sullo schermo.
80
81In altre parole, ''COPPER WAIT LINE'' è un'istruzione di sincronizzazione, necessaria per evitare
82sfarfallio e artefatti visivi: apportare modifiche hardware al momento sbagliato rispetto
83alla scansione video può causare immagini corrotte o instabili.
84
85L'attesa di una posizione specifica consente di modificare i colori, i registri a scorrimento o
86attivare/disattivare le funzionalità hardware esattamente dove e quando necessario, senza
87che l'occhio umano percepisca la modifica come un "salto".
88
89È quindi possibile definire aree dello schermo con diverse palette di colori o risoluzioni semplicemente
90attendendo la riga appropriata con un comando ''WAIT LINE'' e quindi utilizzando un comando ''MOVE''
91per impostare i nuovi parametri.
92
93In breve, ''COPPER WAIT'' è il cuore della sincronizzazione, consentendo di orchestrare
94cambiamenti complessi e dinamici sul display in perfetta armonia con il flusso del
95segnale video, consentendo effetti grafici altrimenti impossibili.
96
97@syntax BEGIN COPPER
98@syntax COPPER WAIT LINE 10
99@syntax COPPER STORE &H2c8, RED AS BYTE
100@syntax COPPER WAIT LINE 30
101@syntax COPPER STORE &H2c8, BLUE AS BYTE
102@syntax END COPPER
103
104@alias WAIT
105@seeAlso BEGIN COPPER...END COPPER
106
107</usermanual> */
108
109void copper_wait( Environment * _environment, int _line ) {
110
111 if ( !_environment->insideCopperList ) {
113 }
114
115 if ( _line <= 0 ) {
117 }
118
119 CopperInstruction * wait = malloc( sizeof( CopperInstruction ) );
120 memset( wait, 0, sizeof( CopperInstruction ) );
121
122 wait->operation = COP_WAIT;
123 wait->param1 = _line;
124
125 if ( _environment->copperList->first ) {
126 CopperInstruction * actual = _environment->copperList->first;
127 while( actual->next ) {
128 actual = actual->next;
129 }
130 actual->next = wait;
131 } else {
132 _environment->copperList->first = wait;
133 }
134
135}
void copper_wait(Environment *_environment, int _line)
Emit code for BEGIN COPPER.
CopperOperation operation
Definition ugbc.h:2243
struct _CopperInstruction * next
Definition ugbc.h:2246
struct _CopperInstruction * first
Definition ugbc.h:2254
CopperList * copperList
Definition ugbc.h:3282
int insideCopperList
Definition ugbc.h:3280
void * malloc(YYSIZE_T)
@ COP_WAIT
Definition ugbc.h:2225
struct _Environment Environment
Structure of compilation environment.
#define CRITICAL_WAIT_INVALID_VALUE(t)
Definition ugbc.h:3847
#define CRITICAL_COPPER_LIST_NOT_OPENED()
Definition ugbc.h:3841
struct _CopperInstruction CopperInstruction