ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
defdgr.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 DEFDGR
49
50@english
51
52This command allows you to customize a single character from those used in graphical
53mode. The character is defined by means of an 8 pixel by 8 pixel monochrome matrix.
54The ''char'' parameter must be intended as the "screen code" of the character to replace.
55The screen code is the character representation mechanism of the target chipset, and is
56different from the ASCII system. Each video chipset can have its own specific set of screen
57codes and, therefore, it is necessary to retrieve the corresponding character code to
58be redefined.
59
60If the system font has fewer pixels along one or both directions, the character
61will be aligned to the top left and the extra pixels will be ignored. The
62customization of the character occurs at runtime.
63
64If you want to customize the characters used in text mode, or during compilation,
65you must use the ''LOAD FONT'' command.
66
67
68@italian
69
70Questo comando consente di personalizzare un singolo carattere tra quelli
71utilizzati in modalità grafica. Il carattere è definito tramite una matrice
72monocromatica di 8 pixel per 8 pixel. Il parametro ''char'' deve essere
73inteso come "codice schermo" del carattere da sostituire.
74Il codice schermo è il meccanismo di rappresentazione dei caratteri del
75chipset di destinazione, ed è diverso dal sistema ASCII. Ogni chipset video
76può avere il suo set specifico di codici schermo e, pertanto, è necessario
77recuperare il codice carattere corrispondente da ridefinire.
78
79Se il font di sistema ha meno pixel lungo una o entrambe le direzioni, il
80carattere verrà allineato in alto a sinistra e i pixel in più verranno
81ignorati. La personalizzazione del carattere avviene in fase di esecuzione.
82
83Se si desidera personalizzare i caratteri utilizzati in modalità testo o
84durante la compilazione, è necessario utilizzare il comando ''LOAD FONT''.
85
86@syntax DEFDGR[$](char) = b0, b1, ... , b7
87
88@example DEFDGR(0) = $ff, $ff, $ff, $ff, $00, $00, $00, $00
89@example DEFDGR$(1) = $ff, $ff, $ff, $ff, $00, $00, $00, $00
90
91@usedInExample font_example_02.bas
92
93</usermanual> */
94void defdgr_vars( Environment * _environment, char * _character, char * _b0, char * _b1, char * _b2, char * _b3, char * _b4, char * _b5, char * _b6, char * _b7 ) {
95
96 Variable * address = variable_temporary( _environment, VT_ADDRESS, "(address)");
97
98 Variable * offset = variable_retrieve_or_define( _environment, _character, VT_WORD, 0 );
99 Variable * newOffset = variable_sl_const( _environment, offset->name, 3 );
100 Variable * b0 = variable_retrieve_or_define( _environment, _b0, VT_BYTE, 0 );
101 Variable * b1 = variable_retrieve_or_define( _environment, _b1, VT_BYTE, 0 );
102 Variable * b2 = variable_retrieve_or_define( _environment, _b2, VT_BYTE, 0 );
103 Variable * b3 = variable_retrieve_or_define( _environment, _b3, VT_BYTE, 0 );
104 Variable * b4 = variable_retrieve_or_define( _environment, _b4, VT_BYTE, 0 );
105 Variable * b5 = variable_retrieve_or_define( _environment, _b5, VT_BYTE, 0 );
106 Variable * b6 = variable_retrieve_or_define( _environment, _b6, VT_BYTE, 0 );
107 Variable * b7 = variable_retrieve_or_define( _environment, _b7, VT_BYTE, 0 );
108
109 cpu_addressof_16bit( _environment, "UDCCHAR", address->realName );
110 cpu_math_add_16bit( _environment, address->realName, newOffset->realName, address->realName );
111 cpu_move_8bit_indirect_with_offset( _environment, b0->realName, address->realName, 0 );
112 cpu_move_8bit_indirect_with_offset( _environment, b1->realName, address->realName, 1 );
113 cpu_move_8bit_indirect_with_offset( _environment, b2->realName, address->realName, 2 );
114 cpu_move_8bit_indirect_with_offset( _environment, b3->realName, address->realName, 3 );
115 cpu_move_8bit_indirect_with_offset( _environment, b4->realName, address->realName, 4);
116 cpu_move_8bit_indirect_with_offset( _environment, b5->realName, address->realName, 5 );
117 cpu_move_8bit_indirect_with_offset( _environment, b6->realName, address->realName, 6);
118 cpu_move_8bit_indirect_with_offset( _environment, b7->realName, address->realName, 7 );
119
120}
void cpu_addressof_16bit(Environment *_environment, char *_source, char *_destination)
Definition 6309.c:1485
void cpu_math_add_16bit(Environment *_environment, char *_source, char *_destination, char *_other)
CPU 6309: emit code to add two 16 bit values
Definition 6309.c:1661
void cpu_move_8bit_indirect_with_offset(Environment *_environment, char *_source, char *_value, int _offset)
Definition 6309.c:5250
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
Variable * variable_sl_const(Environment *_environment, char *_destination, int _steps)
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
int offset
Definition _optimizer.c:681
void defdgr_vars(Environment *_environment, char *_character, char *_b0, char *_b1, char *_b2, char *_b3, char *_b4, char *_b5, char *_b6, char *_b7)
Emit code for DATA instruction (numeric values).
Definition defdgr.c:94
char * realName
Definition ugbc.h:982
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_WORD
Definition ugbc.h:455
@ VT_BYTE
Definition ugbc.h:450
@ VT_ADDRESS
Definition ugbc.h:465