ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
screen_mode.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
41/* <usermanual>
42@keyword GRAPHICS
43
44@english
45
46The ''GRAPHICS'' command can be used for setting the graphics mode of the screen.
47This command is generally an alias of ''SCREEN''. But, if ''OPTION DIALECT ATARI BASIC''
48is used and you are under ATARI, it changes the behavious of the command to be more similar to the one of
49the ATARI BASIC. In that BASIC, it offered several graphics modes, each with
50different resolutions and color depths. ''GRAPHICS'' allowed you to select the
51one you wanted.
52
53Depending upon how old your ATARI is, the ''GRAPHICS'' command gives you access
54to different graphics modes. The reason for the difference is that a different
55video chipset has been used on older and newer real ATARI hardware. The chips
56are fully compatible, but the latest adds three new graphics modes.
57
58So, you have either nine or twelve basic graphics modes to choose from. In
59addition, most of them have two variations, for a total of up to 20 modes.
60
61The modes are of two main types: pure graphics modes and text modes. The first
62three modes -- ''GRAPHICS 0'', ''1'', and ''2'' --are text modes. When you
63switch on an ATARI, it defaults to ''GRAPHICS 0''. ''GRAPHICS 0'' has 24
64horizontal rows of up to 40 characters each on the screen. The graphics modes
65generally used for creating pictures are ''GRAPHICS 3'' through ''8''.
66
67Note that, after executing the ''GRAPHICS'' command, the screen will be
68automatically cleared. The graphics mode also affected the output commands
69such as ''PRINT'', ''PLOT'', and ''DRAW''. Depending on the graphics mode,
70the color management also changes.
71
72@italian
73
74Il comando ''GRAPHICS'' può essere utilizzato per impostare la modalità grafica dello schermo.
75Questo comando è solitamente un alias per ''SCREEN''. Tuttavia, se si utilizza ''OPTION DIALECT ATARI BASIC''
76e si è su ATARI, il comportamento del comando cambia per essere più simile a quello di
77ATARI BASIC. In quel BASIC, offriva diverse modalità grafiche, ciascuna con
78diverse risoluzioni e profondità di colore. ''GRAPHICS'' consentiva di selezionare
79quella desiderata.
80
81A seconda di quanto è vecchio il tuo ATARI, il comando ''GRAPHICS'' ti dà accesso
82a diverse modalità grafiche. Il motivo della differenza è che un diverso
83chipset video è stato utilizzato su hardware ATARI reale più vecchio e più nuovo. I chip
84sono completamente compatibili, ma l'ultimo aggiunge tre nuove modalità grafiche.
85
86Quindi, hai nove o dodici modalità grafiche di base tra cui scegliere. Inoltre, la maggior parte di esse ha due varianti, per un totale di fino a 20 modalità.
87
88Esistono due tipi principali di modalità: modalità grafiche pure e modalità testo. Le prime
89tre modalità, ''GRAPHICS 0'', ''1'' e ''2'', sono modalità testo. Quando
90accendi un ATARI, è impostato su ''GRAPHICS 0'' per impostazione predefinita. ''GRAPHICS 0'' ha 24
91linee orizzontali fino a 40 caratteri ciascuna sullo schermo. Le
92modalità grafiche generalmente utilizzate per creare immagini sono da ''GRAPHICS 3'' a ''8''.
93
94Nota che dopo aver eseguito il comando ''GRAPHICS'', lo schermo verrà
95automaticamente cancellato. La modalità grafica ha influenzato anche i comandi di output
96come ''PRINT'', ''PLOT'' e ''DRAW''. A seconda della modalità grafica,
97cambia anche la gestione del colore.
98
99@syntax GRAPHICS mode
100
101@example GRAPHICS 0
102
103@seeAlso BITMAP ENABLE
104@seeAlso SCREEN (instruction)
105
106</usermanual> */
107
116void screen_mode( Environment * _environment, int _mode ) {
117
118 if ( _environment->graphicsAtariBasicEnabled ) {
119
120 switch( _mode ) {
121
122 // The modes are of two main types: pure graphics modes and text modes. The first three
123 // modes--GRAPHICS 0, 1, and 2--are text modes. When you switch on an ATARI with a
124 // BASIC cartridge plugged in, it defaults to GRAPHICS 0. GRAPHICS 0 has 24 horizontal rows of
125 // up to 40 characters each on the screen. (If you've counted only 38 characters, it's because
126 // the left margin is pre-adjusted to allow for TVs which overscan, or cut off the left edge of
127 // the screen image.) GRAPHICS 1 and 2 display larger-size characters. GRAPHICS 1 characters are the
128 // same height as those in GRAPHICS 0, but are twice as wide. GRAPHICS 2 characters are not only twice as
129 // wide, but also twice as tall.
130
131 case 0:
132 _mode = TILEMAP_MODE_ANTIC2;
133 break;
134 case 1:
135 _mode = TILEMAP_MODE_ANTIC6;
136 break;
137 case 2:
138 _mode = TILEMAP_MODE_ANTIC7;
139 break;
140
141 // The graphics modes generally used for creating pictures are GRAPHICS 3 through 8 (3 through 11
142 // on GTIA machines). GRAPHICS 3 through 8 are mixed modes. That is, they are combinations of text and
143 // graphics modes. For example, type GRAPHICS 3 into the ATARI. You'll see a black screen with a small
144 // blue rectangle at the bottom. That rectangle is called the text window. Although the upper part of the
145 // screen is a graphics mode for drawing pictures, the text window is a section of GRAPHICS 0 for displaying text.
146 // Think of it as the term implies: a "wall" of GRAPHICS 3 with a "window" of GRAPHICS 0.
147
148 case 3: case 19:
149 _mode = BITMAP_MODE_ANTIC8;
150 break;
151 case 4: case 20:
152 _mode = BITMAP_MODE_ANTIC9;
153 break;
154 case 5: case 21:
155 _mode = BITMAP_MODE_ANTIC10;
156 break;
157 case 6: case 22:
158 _mode = BITMAP_MODE_ANTIC11;
159 break;
160 case 7: case 23:
161 _mode = BITMAP_MODE_ANTIC13;
162 break;
163 case 8: case 24:
164 _mode = BITMAP_MODE_ANTIC15;
165 break;
166
167 }
168
169 }
170
171 ScreenMode * mode = find_screen_mode_by_id( _environment, _mode );
172
173 if ( mode ) {
174 gtia_screen_mode_enable( _environment, mode );
175
176 _environment->currentMode = mode->id;
177 _environment->currentTileMode = mode->bitmap ? 0 : 1;
178
179 cpu_store_8bit( _environment, "CURRENTMODE", _environment->currentMode );
180 cpu_store_8bit( _environment, "CURRENTTILEMODE", _environment->currentTileMode );
181
182 } else {
183 WARNING_SCREEN_MODE( _mode );
184 }
185
186}
187
188void screen_type_color_set( Environment * _environment, int _type, int _color_set ) {
189
190 if ( _type == 0 ) {
191 tilemap_enable( _environment, 0, 0, 0, 0, 0 );
192 } else {
193 bitmap_enable( _environment, 0, 0, 0 );
194 }
195
196}
void cpu_store_8bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 8 bit
Definition 6309.c:761
ScreenMode * find_screen_mode_by_id(Environment *_environment, int _id)
void bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
Emit ASM implementation for BITMAP ENABLE instruction.
void screen_type_color_set(Environment *_environment, int _type, int _color_set)
void screen_mode(Environment *_environment, int _mode)
Emit ASM code for SCREEN [mode].
void tilemap_enable(Environment *_environment, int _width, int _height, int _colors, int _tile_width, int _tile_height)
Emit ASM implementation for TEXT ENABLE instruction.
int gtia_screen_mode_enable(Environment *_environment, ScreenMode *_screen_mode)
Definition gtia.c:1115
#define BITMAP_MODE_ANTIC8
Definition gtia.h:104
#define BITMAP_MODE_ANTIC10
Definition gtia.h:118
#define BITMAP_MODE_ANTIC13
Definition gtia.h:130
#define BITMAP_MODE_ANTIC11
Definition gtia.h:123
#define TILEMAP_MODE_ANTIC2
Definition gtia.h:172
#define BITMAP_MODE_ANTIC15
Definition gtia.h:144
#define BITMAP_MODE_ANTIC9
Definition gtia.h:112
#define TILEMAP_MODE_ANTIC7
Definition gtia.h:189
#define TILEMAP_MODE_ANTIC6
Definition gtia.h:184
int currentMode
Definition ugbc.h:2696
int graphicsAtariBasicEnabled
Definition ugbc.h:3228
int currentTileMode
Definition ugbc.h:2706
int bitmap
Definition ugbc.h:1496
struct _ScreenMode ScreenMode
#define WARNING_SCREEN_MODE(v1)
Definition ugbc.h:3878
struct _Environment Environment
Structure of compilation environment.