ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
double_buffer.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
47/* <usermanual>
48@keyword DOUBLE BUFFER
49
50@english
51
52The ''DOUBLE BUFFER'' is a command that enable / disable the graphics programming
53technique used to avoid screen flickering, which is especially noticeable in
54animations and interactive graphics applications. It is especially useful in
558-bit computers, where graphics resources are limited.
56
57Imagine having a screen and two areas of memory, called buffers, dedicated to
58graphics. In the first the entire frame (the complete image) that we want
59to display on the screen is drawn. While drawing in the first buffer,
60the contents of the second buffer are displayed on the screen. Once the
61drawing in the first buffer is complete, the two buffers are swapped:
62the contents of the first buffer are copied to the second and displayed
63on the screen, while the first buffer is emptied and prepared for the
64next frame. This process is repeated continuously.
65
66The command will enable this method, and screens will be swapped
67if the ''SCREEN SWAP'' is used.
68
69This instruction activates the technique only where available.
70
71@italian
72
73Il ''DOUBLE BUFFER'' è un comando che abilita/disabilita la tecnica
74di programmazione grafica utilizzata per evitare lo sfarfallio dello
75schermo, che è particolarmente evidente nelle animazioni e nelle
76applicazioni grafiche interattive. È particolarmente utile nei
77computer a 8 bit, dove le risorse grafiche sono limitate.
78
79Immagina di avere uno schermo e due aree di memoria, chiamate buffer,
80dedicate alla grafica. Nella prima viene disegnato l'intero frame
81(l'immagine completa) che vogliamo visualizzare sullo schermo.
82Mentre disegni nel primo buffer, il contenuto del secondo buffer
83viene visualizzato sullo schermo. Una volta completato il disegno
84nel primo buffer, i due buffer vengono scambiati: il contenuto del
85primo buffer viene copiato nel secondo e visualizzato sullo schermo,
86mentre il primo buffer viene svuotato e preparato per il frame
87successivo. Questo processo viene ripetuto continuamente.
88
89Il comando abiliterà questo metodo e gli schermi verranno scambiati
90se viene utilizzato ''SCREEN SWAP''.
91
92Questa istruzione attiva la tecnica solo dove disponibile.
93
94@syntax DOUBLE BUFFER [ON|OFF]
95
96@example DOUBLE BUFFER ON
97
98@seeAlso SCREEN SWAP
99
100@target c64
101</usermanual> */
102void double_buffer( Environment * _environment, int _enabled ) {
103
104 if ( _environment->doubleBufferEnabled != _enabled ) {
105
106 _environment->doubleBufferEnabled = _enabled;
107
108 if ( _enabled ) {
109 if ( _environment->deployed.scroll ) {
110 cpu_set_callback( _environment, "SCREENSCROLLEMBED", "SCREENSCROLLVOID" );
111 cpu_set_callback( _environment, "ONSWITCHTILEMAP", "SCREENSCROLL" );
112 }
113 outline0("JSR DOUBLEBUFFERINIT")
114 } else {
115 if ( _environment->deployed.scroll ) {
116 cpu_set_callback( _environment, "SCREENSCROLLEMBED", "SCREENSCROLL" );
117 cpu_set_callback( _environment, "ONSWITCHTILEMAP", "SCREENSCROLLVOID" );
118 }
119 outline0("JSR DOUBLEBUFFERCLEANUP")
120 }
121
122 };
123
124}
void cpu_set_callback(Environment *_environment, char *_callback, char *_label)
Definition 6309.c:6270
void double_buffer(Environment *_environment, int _enabled)
Emit code for DOUBLE BUFFER ....
int scroll
Definition ugbc.h:1812
int doubleBufferEnabled
Definition ugbc.h:2995
Deployed deployed
Definition ugbc.h:2921
struct _Environment Environment
Structure of compilation environment.
#define outline0(s)
Definition ugbc.h:4252