ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
raster_at.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
55/* <usermanual>
56@keyword RASTER AT
57
58@english
59The ''RASTER AT'' instruction will set the next execution raster line for a
60raster routine. A raster routine is a small program or sequence of instructions
61that uses a particular moment in the screen display to be activated. This is
62when the electron beam (the raster beam) scans the screen, line by line, to
63draw the image.
64
65The mechanism is simple. The computer generated an interrupt (a signal that
66stopped the main program being executed) every time the raster beam reached
67the given line on this instruction. When the interrupt occurred, the
68processor passed execution to the raster routine. The routine directly does
69something, like modify the video memory o registers. Once the change was
70complete (by using the instruction ''NEXT RASTER''), the processor would
71resume execution of the main program from where it had stopped.
72
73Using this mechanism, programmers could create very simple, but often
74surprisingly engaging, graphics, animations, and games, considering the
75hardware limitations of the time. They were essential
76for creating effects such as scrolling, moving sprites around the screen,
77creating explosion or deformation effects.
78
79Raster routines offers very precise control over image generation,
80allowing for customized and optimized effects, and stimulated
81the creativity of programmers, who could invent new ways to exploit
82the mechanism to create innovative visual effects.
83
84@italian
85L'istruzione ''RASTER AT'' imposterà la successiva riga raster
86di esecuzione per una routine raster. Una routine raster è un
87piccolo programma o sequenza di istruzioni che utilizza un momento
88particolare nella visualizzazione dello schermo per essere attivata.
89Questo è quando il fascio di elettroni (il fascio raster) esegue
90la scansione dello schermo, riga per riga, per disegnare l'immagine.
91
92Il meccanismo è semplice. Il computer generava un'interruzione
93(un segnale che interrompeva l'esecuzione del programma principale)
94ogni volta che il fascio raster raggiungeva la riga specificata
95in questa istruzione. Quando si verificava l'interruzione, il
96processore passava l'esecuzione alla routine raster. La routine
97fa qualcosa direttamente, come modificare la memoria video o i
98registri. Una volta completata la modifica (utilizzando
99l'istruzione ''NEXT RASTER''), il processore riprendeva l'esecuzione del
100programma principale da dove si era interrotta.
101
102Utilizzando questo meccanismo, i programmatori potevano creare grafiche,
103animazioni e giochi molto semplici, ma spesso sorprendentemente
104coinvolgenti, considerando le limitazioni hardware dell'epoca.
105Erano essenziali per creare effetti come lo scorrimento, lo
106spostamento di sprite sullo schermo, la creazione di effetti
107di esplosione o deformazione.
108
109Le routine raster offrono un controllo molto preciso sulla
110generazione delle immagini, consentendo effetti personalizzati e ottimizzati
111e stimolando la creatività dei programmatori, che hanno potuto inventare
112nuovi modi per sfruttare il meccanismo per creare effetti visivi innovativi.
113
114@syntax RASTER AT line WITH label
115@syntax RASTER label AT line
116
117@example RASTER AT #&H42 WITH rasterRoutine
118
119@target c128
120
121@seeAlso NEXT RASTER
122@seeAlso NEXT RASTER AT
123
124</usermanual> */
125void raster_at( Environment * _environment, char * _label, int _position ) {
126
127
128
129 char positionlo[MAX_TEMPORARY_STORAGE]; sprintf( positionlo, "#$%2.2x", (unsigned char) ( _position & 0xff ) );
130 char positionhi[MAX_TEMPORARY_STORAGE]; sprintf( positionhi, "#$%2.2x", (unsigned char) ( ( ( _position >> 8 ) & 0x01 ) << 8 ) );
131
132 vic2_raster_at( _environment, _label, positionlo, positionhi );
133
134}
135
150/* <usermanual>
151@keyword RASTER AT
152
153@syntax RASTER AT line WITH label
154@syntax RASTER label AT line
155
156@example RASTER AT (rasterLine+1) WITH rasterRoutine
157</usermanual> */
158void raster_at_var( Environment * _environment, char * _label, char * _position ) {
159
160
161
163
164 Variable * var = variable_retrieve( _environment, _position );
165
166 char positionlo[MAX_TEMPORARY_STORAGE]; sprintf( positionlo, "%s", var->realName );
167 char positionhi[MAX_TEMPORARY_STORAGE]; sprintf( positionhi, "%s", address_displacement(_environment, var->realName, "1") );
168
169 vic2_raster_at( _environment, _label, positionlo, positionhi );
170
171}
172
Variable * variable_retrieve(Environment *_environment, char *_name)
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
void raster_at_var(Environment *_environment, char *_label, char *_position)
Emit ASM code for RASTER AT [expression] WITH label.
Definition raster_at.c:73
void raster_at(Environment *_environment, char *_label, int _position)
Emit ASM code for RASTER AT [int] WITH [label].
Definition raster_at.c:55
#define MAX_TEMPORARY_STORAGE
Definition ugbc.h:563
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
#define MAKE_LABEL
Definition ugbc.h:3351
void vic2_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
VIC-II: emit code to set raster irq
Definition vic2.c:806