ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
colormap.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
57/* <usermanual>
58@keyword COLORMAP AT
59
60@target pc1403
61</usermanual> */
62void colormap_at( Environment * _environment, int _address ) {
63
64
65
66 // Let's define the special variable and fill up with the value.
67 Variable * colormapAddress = variable_retrieve_or_define( _environment, "COLORMAPADDRESS", VT_ADDRESS, _address );
68
69 // TODO: colormapAddress must be retrieved by a // // tms9918_get_colormapAddress()
70
71 variable_store( _environment, colormapAddress->name, 0x5800 );
72
73}
74
90void colormap_at_var( Environment * _environment, char * _address ) {
91
92
93
94 // Let's define the special variable and fill up with the value.
95 // TODO: colormapAddress must be retrieved by a // // tms9918_get_colormapAddress()
96 Variable * colormapAddress = variable_retrieve_or_define( _environment, "COLORMAPADDRESS", VT_ADDRESS, 0x5800 );
97 Variable * address = variable_retrieve_or_define( _environment, _address, VT_ADDRESS, 0x0000 );
98
99 // variable_store( _environment, colormapAddress->name, ( ( ( _address >> 10 ) & 0x0f ) * 0x0400 ) );
100
101}
102
117void colormap_clear_with( Environment * _environment, int _foreground, int _background ) {
118
119
120
121 Variable * colormapAddress = variable_retrieve( _environment, "COLORMAPADDRESS" );
122
123 Variable * value = variable_temporary( _environment, VT_BYTE, "(background + foreground)" );
124 Variable * blocks = variable_temporary( _environment, VT_BYTE, "(blocks)" );
125
126 variable_store( _environment, blocks->name, 3 );
127
128 variable_store( _environment, value->name, ( ( _background & 0x07 ) << 3 ) | ( _foreground & 0x07 ) );
129
130 cpu_fill_blocks( _environment, colormapAddress->realName, blocks->realName, value->realName );
131
132}
133
148void colormap_clear_with_vars( Environment * _environment, char * _foreground, char * _background ) {
149
150 Variable * colormapAddress = variable_retrieve_or_define( _environment, "COLORMAPADDRESS", VT_ADDRESS, 0x0400 );
151
152 Variable * foreground = variable_retrieve_or_define( _environment, _foreground, VT_COLOR, COLOR_WHITE );
153
154 Variable * background = variable_retrieve_or_define( _environment, _background, VT_COLOR, COLOR_BLACK );
155
156 Variable * pattern = variable_temporary( _environment, VT_BYTE, "(pattern)" );
157 Variable * blocks = variable_temporary( _environment, VT_BYTE, "(blocks)" );
158
159 variable_store( _environment, blocks->name, 3 );
160
161 outline1("LD A, (%s)", background->realName );
162 outline0("RL A" );
163 outline0("RL A" );
164 outline0("RL A" );
165 outline0("LD B, A" );
166 outline1("LD A, (%s)", foreground->realName );
167 outline0("AND $07" );
168 outline0("OR B" );
169 outline1("LD (%s), A", pattern->realName );
170
171 cpu_fill_blocks( _environment, colormapAddress->realName, blocks->realName, pattern->realName );
172
173}
174
186void colormap_clear( Environment * _environment ) {
187
188 // Equals to: "COLORMAP CLEAR WITH 0 AND 1"
190
191}
void cpu_fill_blocks(Environment *_environment, char *_address, char *_blocks, char *_pattern)
CPU 6309: emit code to fill up a memory area
Definition 6309.c:484
#define COLOR_WHITE
Definition 6847.h:39
#define COLOR_BLACK
Definition 6847.h:36
Variable * variable_retrieve(Environment *_environment, char *_name)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
Variable * variable_store(Environment *_environment, char *_destination, unsigned int _value)
Store a direct value to a variable.
void colormap_clear_with(Environment *_environment, int _foreground, int _background)
Emit ASM implementation for COLORMAP CLEAR WITH [int]x ON [int]x instruction.
Definition colormap.c:115
void colormap_clear_with_vars(Environment *_environment, char *_foreground, char *_background)
Emit ASM implementation for COLORMAP CLEAR WITH [expression] ON [expression] instruction.
Definition colormap.c:145
void colormap_clear(Environment *_environment)
Emit ASM implementation for COLORMAP CLEAR instruction.
Definition colormap.c:184
void colormap_at_var(Environment *_environment, char *_address)
Emit ASM implementation for COLORMAP AT [expression] instruction.
Definition colormap.c:88
void colormap_at(Environment *_environment, int _address)
Emit ASM implementation for COLORMAP AT [int]x instruction.
Definition colormap.c:60
char * name
Definition ugbc.h:979
char * realName
Definition ugbc.h:982
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_BYTE
Definition ugbc.h:450
@ VT_ADDRESS
Definition ugbc.h:465
@ VT_COLOR
Definition ugbc.h:471
#define outline0(s)
Definition ugbc.h:4252
#define outline1(s, a)
Definition ugbc.h:4253