ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
copper_color.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 COLOR
49
50@english
51
52The ''COPPER COLOR'' command is a fundamental instruction used
53in copper lists to dynamically change the color of the any color register,
54where present. The copper list is a sequence of instructions executed
55synchronized with the raster stream (the monitor's horizontal scanning
56of the screen line).
57
58When a ''COPPER COLOR'' instruction is encountered in the copper
59list, the processor directly writes the color value to the hardware
60color register of the target graphics chip (which will vary
61depending on the target computer). This color change occurs
62instantaneously and with pixel-level precision, based on the position
63of the raster beam on the screen at the time the instruction is
64executed.
65
66@italian
67
68Il comando ''COPPER COLOR'' è un'istruzione fondamentale
69utilizzata nelle copper list per modificare dinamicamente il valore
70di un registro di colore dello schermo, laddove sia presente. La copper list è una
71sequenza di istruzioni eseguite in modo sincronizzato con il flusso del
72raster (la scansione orizzontale della linea dello schermo da parte
73del monitor).
74
75Quando un'istruzione ''COPPER COLOR'' viene incontrata nella
76copper list, il processore scrive direttamente il valore di un registro hardware
77del colore del chip grafico di
78riferimento (che sarà diverso a seconda del computer target). Questo
79cambiamento di colore avviene istantaneamente e con una precisione al
80singolo pixel, in base alla posizione del raster beam sullo schermo nel
81momento in cui l'istruzione viene eseguita.
82
83@syntax BEGIN COPPER
84@syntax COPPER WAIT LINE 10
85@syntax COPPER COLOR RED
86@syntax COPPER WAIT LINE 30
87@syntax COPPER COLOR BLUE
88@syntax END COPPER
89
90@seeAlso BEGIN COPPER...END COPPER
91
92</usermanual> */
93
94void copper_color( Environment * _environment, int _index, int _color ) {
95
96 if ( !_environment->insideCopperList ) {
98 }
99
101 memset( color, 0, sizeof( CopperInstruction ) );
102
103 color->operation = COP_COLOR;
104 color->param1 = _index;
105 color->param2 = _color;
106
107 if ( _environment->copperList->first ) {
108 CopperInstruction * actual = _environment->copperList->first;
109 while( actual->next ) {
110 actual = actual->next;
111 }
112 actual->next = color;
113 } else {
114 _environment->copperList->first = color;
115 }
116
117}
void color(Environment *_environment, int _index, int _shade)
Emit ASM code for instruction COLOR [int], [int].
Definition color.c:59
void copper_color(Environment *_environment, int _index, int _color)
Emit code for BEGIN COPPER.
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_COLOR
Definition ugbc.h:2237
struct _Environment Environment
Structure of compilation environment.
#define CRITICAL_COPPER_LIST_NOT_OPENED()
Definition ugbc.h:3841
struct _CopperInstruction CopperInstruction