ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
copper_store.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 COPPER STORE
48
49@english
50
51The primary purpose of the ''COPPER STORE'' instruction is to modify the
52value of a specific memory location or hardware register at a specific time,
53synchronized with the television's video display.
54
55A copper list is a sequence of special instructions that the processor executes
56independently of the main execution. These instructions are programmed to execute
57in sync with the video signal, typically when the television's video display
58reaches a specific horizontal and vertical position on the screen.
59
60The instruction acts as a "real-time controller" for various aspects of the
61hardware system, particularly those related to graphics. Essentially, it takes a
62value (immediate ''data'') and writes it to a specific ''destination''.
63
64The versatility of ''COPPER STORE'' lies in its ability to manipulate the hardware
65registers that control critical aspects of the display.
66
67@italian
68
69Lo scopo principale dell'istruzione ''COPPER STORE'' è quello di modificare il
70valore di una specifica posizione di memoria o di un registro hardware in un momento
71specifico, sincronizzato con il display del televisore.
72
73Una copper list è una sequenza di istruzioni speciali che il processore esegue indipendentemente
74dall'esecuzione principale. Queste istruzioni sono programmate per essere eseguite
75in sincronia con il segnale video, in genere quando il display del televisore raggiunge
76una specifica posizione orizzontale e verticale sullo schermo.
77
78L'istruzione funge da "controller in tempo reale" per vari aspetti del sistema hardware, in
79particolare quelli relativi alla grafica. In sostanza, accetta un valore (un dato immediato)
80e lo scrive in una specifica destinazione.
81
82La versatilità di ''COPPER STORE'' risiede nella sua capacità di manipolare i registri hardware
83che controllano gli aspetti critici del display.
84
85@syntax COPPER STORE address, value AS datatype
86
87@example BEGIN COPPER
88@example COPPER WAIT LINE 10
89@example COPPER STORE &H2c8, RED AS BYTE
90@example COPPER WAIT LINE 30
91@example COPPER MOVE &H2c8, BLUE AS BYTE
92@example END COPPER
93
94@alias STORE
95@seeAlso BEGIN COPPER...END COPPER
96@seeAlso COPPER POKE
97@seeAlso COPPER POKEW
98@seeAlso COPPER POKED
99
100</usermanual> */
101/* <usermanual>
102@keyword STORE
103
104@english
105
106@italian
107
108@syntax BEGIN COPPER
109@syntax WAIT #10
110@syntax STORE #&H2c8, #RED AS BYTE
111@syntax WAIT #30
112@syntax STORE #&H2c8, #BLUE AS BYTE
113@syntax END COPPER
114
115@alias COPPER STORE
116</usermanual> */
117 /* <usermanual>
118@keyword COPPER POKE
119
120@english
121
122The primary purpose of the ''COPPER POKE'' instruction is to modify the
123value of a specific memory location or hardware register at a specific time,
124synchronized with the television's video display, and having the size of a single
125byte.
126
127A copper list is a sequence of special instructions that the processor executes
128independently of the main execution. These instructions are programmed to execute
129in sync with the video signal, typically when the television's video display
130reaches a specific horizontal and vertical position on the screen.
131
132The instruction acts as a "real-time controller" for various aspects of the
133hardware system, particularly those related to graphics. Essentially, it takes a
1348 bit unsigned value (immediate ''data'') and writes it to a specific ''destination''.
135
136The versatility of ''COPPER POKE'' lies in its ability to manipulate the hardware
137registers that control critical aspects of the display.
138
139@italian
140
141Lo scopo principale dell'istruzione ''COPPER POKE'' è quello di modificare il valore
142di una specifica posizione di memoria o di un registro hardware in un momento
143specifico, sincronizzato con il display del televisore e avente la dimensione di un
144singolo byte.
145
146Una lista copper è una sequenza di istruzioni speciali che il processore esegue
147indipendentemente dall'esecuzione principale. Queste istruzioni sono programmate
148per essere eseguite in sincronia con il segnale video, in genere quando il display
149del televisore raggiunge una specifica posizione orizzontale e verticale sullo schermo.
150
151L'istruzione funge da "controller in tempo reale" per vari aspetti del sistema hardware,
152in particolare quelli relativi alla grafica. In sostanza, accetta un valore senza segno
153a 8 bit (''dati'' immediati) e lo scrive in una specifica ''destinazione''.
154
155La versatilità di ''COPPER POKE'' risiede nella sua capacità di manipolare i registri
156hardware che controllano aspetti critici del display.
157
158@syntax COPPER STORE address, value
159
160@example BEGIN COPPER
161@example COPPER WAIT LINE 10
162@example COPPER POKE &H2c8, RED
163@example COPPER WAIT LINE 30
164@example COPPER MOVE &H2c8, BLUE AS BYTE
165@example END COPPER
166
167@seeAlso BEGIN COPPER...END COPPER
168@seeAlso COPPER STORE
169@seeAlso COPPER POKEW
170@seeAlso COPPER POKED
171
172</usermanual> */
173/* <usermanual>
174@keyword COPPER POKEW
175
176@english
177
178The primary purpose of the ''COPPER POKEW'' instruction is to modify the
179value of a specific memory location or hardware register at a specific time,
180synchronized with the television's video display, and having the size of two
181bytes.
182
183A copper list is a sequence of special instructions that the processor executes
184independently of the main execution. These instructions are programmed to execute
185in sync with the video signal, typically when the television's video display
186reaches a specific horizontal and vertical position on the screen.
187
188The instruction acts as a "real-time controller" for various aspects of the
189hardware system, particularly those related to graphics. Essentially, it takes a
19016 bit unsigned value (immediate ''data'') and writes it to a specific ''destination''.
191
192The versatility of ''COPPER POKEW'' lies in its ability to manipulate the hardware
193registers that control critical aspects of the display.
194
195@italian
196
197Lo scopo principale dell'istruzione ''COPPER POKEW'' è quello di modificare il valore
198di una specifica posizione di memoria o di un registro hardware in un momento
199specifico, sincronizzato con il display del televisore e avente la dimensione di due
200bytes.
201
202Una lista copper è una sequenza di istruzioni speciali che il processore esegue
203indipendentemente dall'esecuzione principale. Queste istruzioni sono programmate
204per essere eseguite in sincronia con il segnale video, in genere quando il display
205del televisore raggiunge una specifica posizione orizzontale e verticale sullo schermo.
206
207L'istruzione funge da "controller in tempo reale" per vari aspetti del sistema hardware,
208in particolare quelli relativi alla grafica. In sostanza, accetta un valore senza segno
209a 16 bit (''dati'' immediati) e lo scrive in una specifica ''destinazione''.
210
211La versatilità di ''COPPER POKEW'' risiede nella sua capacità di manipolare i registri
212hardware che controllano aspetti critici del display.
213
214@syntax COPPER POKEW address, value
215
216@example BEGIN COPPER
217@example COPPER WAIT LINE 10
218@example COPPER POKEW &H2c8, RED
219@example END COPPER
220
221@seeAlso BEGIN COPPER...END COPPER
222@seeAlso COPPER STORE
223@seeAlso COPPER POKE
224@seeAlso COPPER POKED
225
226</usermanual> */
227/* <usermanual>
228@keyword COPPER POKED
229
230@english
231
232The primary purpose of the ''COPPER POKED'' instruction is to modify the
233value of a specific memory location or hardware register at a specific time,
234synchronized with the television's video display, and having the size of four
235bytes.
236
237A copper list is a sequence of special instructions that the processor executes
238independently of the main execution. These instructions are programmed to execute
239in sync with the video signal, typically when the television's video display
240reaches a specific horizontal and vertical position on the screen.
241
242The instruction acts as a "real-time controller" for various aspects of the
243hardware system, particularly those related to graphics. Essentially, it takes a
24432 bit unsigned value (immediate ''data'') and writes it to a specific ''destination''.
245
246The versatility of ''COPPER POKED'' lies in its ability to manipulate the hardware
247registers that control critical aspects of the display.
248
249@italian
250
251Lo scopo principale dell'istruzione ''COPPER POKED'' è quello di modificare il valore
252di una specifica posizione di memoria o di un registro hardware in un momento
253specifico, sincronizzato con il display del televisore e avente la dimensione di quattro
254bytes.
255
256Una lista copper è una sequenza di istruzioni speciali che il processore esegue
257indipendentemente dall'esecuzione principale. Queste istruzioni sono programmate
258per essere eseguite in sincronia con il segnale video, in genere quando il display
259del televisore raggiunge una specifica posizione orizzontale e verticale sullo schermo.
260
261L'istruzione funge da "controller in tempo reale" per vari aspetti del sistema hardware,
262in particolare quelli relativi alla grafica. In sostanza, accetta un valore senza segno
263a 32 bit (''dati'' immediati) e lo scrive in una specifica ''destinazione''.
264
265La versatilità di ''COPPER POKED'' risiede nella sua capacità di manipolare i registri
266hardware che controllano aspetti critici del display.
267
268@syntax COPPER POKED address, value
269
270@example BEGIN COPPER
271@example COPPER WAIT LINE 10
272@example COPPER POKED &H2c8, RED
273@example END COPPER
274
275@seeAlso BEGIN COPPER...END COPPER
276@seeAlso COPPER STORE
277@seeAlso COPPER POKEB
278@seeAlso COPPER POKEW
279</usermanual> */
280
281extern char DATATYPE_AS_STRING[][16];
282
283void copper_store( Environment * _environment, int _address, int _value, VariableType _variableType ) {
284
285 if ( !_environment->insideCopperList ) {
287 }
288
290 memset( move, 0, sizeof( CopperInstruction ) );
291
292 switch( _variableType ) {
293 case VT_BYTE:
294 move->operation = COP_STORE_BYTE;
295 break;
296 case VT_WORD:
297 move->operation = COP_STORE_WORD;
298 break;
299 case VT_DWORD:
300 move->operation = COP_STORE_DWORD;
301 break;
302 default:
304 }
305
306 move->param1 = _address;
307 move->param2 = _value;
308
309 if ( _environment->copperList->first ) {
310 CopperInstruction * actual = _environment->copperList->first;
311 while( actual->next ) {
312 actual = actual->next;
313 }
314 actual->next = move;
315 } else {
316 _environment->copperList->first = move;
317 }
318
319}
void copper_store(Environment *_environment, int _address, int _value, VariableType _variableType)
void move(Environment *_environment, char *_prefix, char *_movement, char *_x, char *_y, char *_animation)
Emit code for MOVE ....
Definition move.c:81
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_STORE_DWORD
Definition ugbc.h:2229
@ COP_STORE_WORD
Definition ugbc.h:2228
@ COP_STORE_BYTE
Definition ugbc.h:2227
#define CRITICAL_STORE_WITH_NOT_ALLOWED_TYPE(t)
Definition ugbc.h:3844
struct _Environment Environment
Structure of compilation environment.
@ VT_WORD
Definition ugbc.h:455
@ VT_BYTE
Definition ugbc.h:450
@ VT_DWORD
Definition ugbc.h:460
#define CRITICAL_COPPER_LIST_NOT_OPENED()
Definition ugbc.h:3841
enum _VariableType VariableType
Type of variables.
struct _CopperInstruction CopperInstruction
char DATATYPE_AS_STRING[][16]