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
52
The ''DOUBLE BUFFER'' is a command that enable / disable the graphics programming
53
technique used to avoid screen flickering, which is especially noticeable in
54
animations and interactive graphics applications. It is especially useful in
55
8-bit computers, where graphics resources are limited.
56
57
Imagine having a screen and two areas of memory, called buffers, dedicated to
58
graphics. In the first the entire frame (the complete image) that we want
59
to display on the screen is drawn. While drawing in the first buffer,
60
the contents of the second buffer are displayed on the screen. Once the
61
drawing in the first buffer is complete, the two buffers are swapped:
62
the contents of the first buffer are copied to the second and displayed
63
on the screen, while the first buffer is emptied and prepared for the
64
next frame. This process is repeated continuously.
65
66
The command will enable this method, and screens will be swapped
67
if the ''SCREEN SWAP'' is used.
68
69
This instruction activates the technique only where available.
70
71
@italian
72
73
Il ''DOUBLE BUFFER'' è un comando che abilita/disabilita la tecnica
74
di programmazione grafica utilizzata per evitare lo sfarfallio dello
75
schermo, che è particolarmente evidente nelle animazioni e nelle
76
applicazioni grafiche interattive. È particolarmente utile nei
77
computer a 8 bit, dove le risorse grafiche sono limitate.
78
79
Immagina di avere uno schermo e due aree di memoria, chiamate buffer,
80
dedicate alla grafica. Nella prima viene disegnato l'intero frame
81
(l'immagine completa) che vogliamo visualizzare sullo schermo.
82
Mentre disegni nel primo buffer, il contenuto del secondo buffer
83
viene visualizzato sullo schermo. Una volta completato il disegno
84
nel primo buffer, i due buffer vengono scambiati: il contenuto del
85
primo buffer viene copiato nel secondo e visualizzato sullo schermo,
86
mentre il primo buffer viene svuotato e preparato per il frame
87
successivo. Questo processo viene ripetuto continuamente.
88
89
Il comando abiliterà questo metodo e gli schermi verranno scambiati
90
se viene utilizzato ''SCREEN SWAP''.
91
92
Questa 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> */
102
void
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
}
cpu_set_callback
void cpu_set_callback(Environment *_environment, char *_callback, char *_label)
Definition
6309.c:6270
double_buffer
void double_buffer(Environment *_environment, int _enabled)
Emit code for DOUBLE BUFFER ....
Definition
double_buffer.c:50
_Deployed::scroll
int scroll
Definition
ugbc.h:1812
_Environment::doubleBufferEnabled
int doubleBufferEnabled
Definition
ugbc.h:2995
_Environment::deployed
Deployed deployed
Definition
ugbc.h:2921
ugbc.h
Environment
struct _Environment Environment
Structure of compilation environment.
outline0
#define outline0(s)
Definition
ugbc.h:4252
Z:
ugbasic
ugbc
src
targets
c64
double_buffer.c
Generated by
1.16.1