ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
bitmap_enable.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
56/* <usermanual>
57@keyword BITMAP ENABLE
58
59@english
60
61The ''BITMAP ENABLE' command is a fundamental tool, since it allows to
62configure the graphics mode of the screen, that is, to define how data
63was displayed on the screen, determining aspects such as the number of
64horizontal and vertical pixels that make up the image on the screen, and
65the color palette available for drawing images.
66
67In 8-bit computers, memory was limited and processing power was much
68lower than modern computers. The ''BITMAP ENABLE'' allows you to optimize
69the use of resources by choosing the graphics mode best suited to the
70needs of the program and, at the same time, to generalize if the
71program must be ported on other hardware.
72
73Given the great variety of hardware that ugBASIC supports and the
74isomorphic approach adopted, this commands can be used to require a
75specific resolution, color depth and other characteristics in a
76hardware independent way.
77
78In this regard, the following approach has been adopted. It is possible
79to ask for specific chacteristics, such as height and width of the
80screen. However ugBASIC will choose the closest resolution, based
81on the hardware on which it will runs.
82
83Likewise, if no type of resolution constraint is set, the best is offered.
84
85To change resolution and colors, you can use the ''([width],[height],[colors])'',
86''([width],[height])'' or the ''([colors])'' syntax after ''BITMAP ENABLE'' command.
87So, if you omit a parameters, it means thatit is not important to set.
88
89Finally, you can use the ''WIDTH'' or ''HEIGHT'' to select just one dimension only.
90
91The command can be shortened as ''BITMAP'' alone.
92
93@italian
94
95Il comando ''BITMAP ENABLE'' è uno strumento fondamentale, poiché consente
96di configurare la modalità grafica dello schermo, ovvero di definire come i
97dati sono stati visualizzati sullo schermo, determinando aspetti come il
98numero di pixel orizzontali e verticali che compongono l'immagine sullo
99schermo e la tavolozza dei colori disponibile per disegnare le immagini.
100
101Nei computer a 8 bit, la memoria era limitata e la potenza di elaborazione
102era molto inferiore rispetto ai computer moderni. Il comando ''BITMAP ENABLE''
103consente di ottimizzare l'uso delle risorse scegliendo la modalità grafica
104più adatta alle esigenze del programma e, allo stesso tempo, di generalizzare
105se il programma deve essere portato su altro hardware.
106
107Data la grande varietà di hardware che ugBASIC supporta e l'approccio
108isomorfo adottato, questi comandi possono essere utilizzati per richiedere
109una risoluzione specifica, profondità di colore e altre caratteristiche in
110modo indipendente dall'hardware.
111
112A questo proposito, è stato adottato il seguente approccio. È possibile richiedere
113caratteristiche specifiche, come altezza e larghezza dello schermo. Tuttavia
114ugBASIC sceglierà la risoluzione più vicina, in base all'hardware su cui verrà eseguito.
115
116Allo stesso modo, se non è impostato alcun tipo di vincolo di risoluzione,
117viene offerto il migliore. Per modificare la risoluzione e i colori, puoi usare
118la sintassi ''(width, height, colors)'', ''(width, height)'' o ''(colors) ''
119dopo il comando ''BITMAP ENABLE''. Quindi, se ometti un parametro, significa
120che non è importante impostarlo.
121
122Infine, puoi usare ''WIDTH'' o ''HEIGHT'' per selezionare una sola dimensione.
123
124Il comando può essere abbreviato come ''BITMAP'' da solo.
125
126@syntax BITMAP [ENABLE]
127@syntax BITMAP [ENABLE] (colors)
128@syntax BITMAP [ENABLE] (width, height)
129@syntax BITMAP [ENABLE] (width, height, colors)
130@syntax BITMAP [ENABLE] WIDTH width
131@syntax BITMAP [ENABLE] HEIGHT width
132
133@example BITMAP [ENABLE]
134@example BITMAP [ENABLE] (320,200,16)
135@example BITMAP [ENABLE] (160,200,2)
136@example BITMAP [ENABLE] WIDTH 320
137
138@usedInExample screens_resolution_01.bas
139
140@seeAlso BITMAP DISABLE
141@seeAlso TILEMAP ENABLE
142
143@target c128
144</usermanual> */
145void bitmap_enable( Environment * _environment, int _width, int _height, int _colors ) {
146
147 // Let's define the special variable bitmapAddress.
148 Variable * bitmapAddress = variable_retrieve( _environment, "BITMAPADDRESS" );
149
150 // Let's define the special variable colormapAddress.
151 Variable * colormapAddress = variable_retrieve_or_define( _environment, "COLORMAPADDRESS", VT_ADDRESS, 0x8400 );
152
153 vic2_bitmap_enable( _environment, _width, _height, _colors );
154
155}
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
void bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
Emit ASM implementation for BITMAP ENABLE instruction.
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_ADDRESS
Definition ugbc.h:465
void vic2_bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
Definition vic2.c:1231