ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
copper_move.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 MOVE
48
49@english
50
51The primary purpose of the ''COPPER MOVE'' instruction is to move the
52value of a specific memory location or hardware register at a specific time, to
53another memory location or hardware gister, and synchronized with the
54television's video display.
55
56A copper list is a sequence of special instructions that the processor executes
57independently of the main execution. These instructions are programmed to execute
58in sync with the video signal, typically when the television's video display
59reaches a specific horizontal and vertical position on the screen.
60
61The instruction acts as a "real-time controller" for various aspects of the
62hardware system, particularly those related to graphics. Essentially, it takes a
63value from a ''source'' and it writes it to a specific ''destination''.
64
65The versatility of ''COPPER MOVE'' lies in its ability to manipulate the hardware
66registers that control critical aspects of the display.
67
68@italian
69
70Lo scopo principale dell'istruzione ''COPPER STORE'' è quello di modificare il
71valore di una specifica posizione di memoria o di un registro hardware in un momento
72specifico, sincronizzato con il display del televisore.
73
74Una copper list è una sequenza di istruzioni speciali che il processore esegue indipendentemente
75dall'esecuzione principale. Queste istruzioni sono programmate per essere eseguite
76in sincronia con il segnale video, in genere quando il display del televisore raggiunge
77una specifica posizione orizzontale e verticale sullo schermo.
78
79L'istruzione funge da "controller in tempo reale" per vari aspetti del sistema hardware, in
80particolare quelli relativi alla grafica. In sostanza, accetta un valore (un dato immediato)
81e lo scrive in una specifica destinazione.
82
83La versatilità di ''COPPER STORE'' risiede nella sua capacità di manipolare i registri hardware
84che controllano gli aspetti critici del display.
85
86@syntax COPPER MOVE source, destination AS datatype
87
88@example BEGIN COPPER
89@example COPPER WAIT LINE 10
90@example COPPER MOVE &H2c8, &H2c7 AS BYTE
91@example COPPER WAIT LINE 30
92@example COPPER MOVE &H2c8, &H2c7 AS BYTE
93@example END COPPER
94
95@alias MOVE
96@seeAlso BEGIN COPPER...END COPPER
97
98</usermanual> */
99/* <usermanual>
100@keyword MOVE
101
102@english
103
104@italian
105
106@syntax MOVE source, destination AS datatype
107
108@example BEGIN COPPER
109@example WAIT 10
110@example MOVE #&H2c8, #&H2c7 AS BYTE
111@example WAIT 30
112@example MOVE #&H2c8, #&H2c7 AS BYTE
113@example END COPPER
114
115@alias COPPER MOVE
116</usermanual> */
117
118extern char DATATYPE_AS_STRING[][16];
119
120void copper_move( Environment * _environment, int _address1, int _address2, VariableType _variableType ) {
121
122 if ( !_environment->insideCopperList ) {
124 }
125
127 memset( move, 0, sizeof( CopperInstruction ) );
128
129 switch( _variableType ) {
130 case VT_BYTE:
131 move->operation = COP_MOVE_BYTE;
132 break;
133 case VT_WORD:
134 move->operation = COP_MOVE_WORD;
135 break;
136 case VT_DWORD:
137 move->operation = COP_MOVE_DWORD;
138 break;
139 default:
141 }
142
143 move->param1 = _address1;
144 move->param2 = _address2;
145
146 if ( _environment->copperList->first ) {
147 CopperInstruction * actual = _environment->copperList->first;
148 while( actual->next ) {
149 actual = actual->next;
150 }
151 actual->next = move;
152 } else {
153 _environment->copperList->first = move;
154 }
155
156}
void copper_move(Environment *_environment, int _address1, int _address2, 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_MOVE_BYTE
Definition ugbc.h:2231
@ COP_MOVE_WORD
Definition ugbc.h:2232
@ COP_MOVE_DWORD
Definition ugbc.h:2233
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_MOVE_WITH_NOT_ALLOWED_TYPE(t)
Definition ugbc.h:3843
#define CRITICAL_COPPER_LIST_NOT_OPENED()
Definition ugbc.h:3841
enum _VariableType VariableType
Type of variables.
struct _CopperInstruction CopperInstruction
char DATATYPE_AS_STRING[][16]