ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
_var.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
41extern char BANK_TYPE_AS_STRING[][16];
42extern char DATATYPE_AS_STRING[][16];
43
44static void variable_cleanup_entry( Environment * _environment, Variable * _first ) {
45
46 Variable * variable = _first;
47
48 while( variable ) {
49 if ( ( !variable->assigned || ( variable->assigned && !variable->temporary ) ) ) {
50 switch( variable->type ) {
51 case VT_CHAR:
52 case VT_BYTE:
53 case VT_SBYTE:
54 case VT_COLOR:
55 case VT_THREAD:
56 if ( variable->memoryArea ) {
57 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
58 } else {
59 outhead0("section data_user");
60 vars_emit_byte( _environment, variable->realName, variable->initialValue );
61 outhead0("section code_user");
62 }
63 break;
64 case VT_DOJOKA:
65 if ( variable->memoryArea ) {
66 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
67 } else {
68 outhead0("section data_user");
69 outline1("%s: defs 4", variable->realName);
70 outhead0("section code_user");
71 }
72 break;
73 case VT_IMAGEREF:
74 if ( variable->memoryArea ) {
75 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
76 } else {
77 outhead0("section data_user");
78 outline1("%s: defs 14", variable->realName);
79 outhead0("section code_user");
80 }
81 break;
82 case VT_PATH:
83 if ( variable->memoryArea ) {
84 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
85 } else {
86 outhead0("section data_user");
87 outline1("%s: defs 16", variable->realName);
88 outhead0("section code_user");
89 }
90 break;
91 case VT_VECTOR2:
92 if ( variable->memoryArea ) {
93 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
94 } else {
95 outhead0("section data_user");
96 outline1("%s: defs 4", variable->realName);
97 outhead0("section code_user");
98 }
99 break;
100 case VT_WORD:
101 case VT_SWORD:
102 case VT_POSITION:
103 case VT_ADDRESS:
104 if ( variable->memoryArea ) {
105 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
106 } else {
107 outhead0("section data_user");
108 vars_emit_word( _environment, variable->realName, variable->initialValue );
109 outhead0("section code_user");
110 }
111 break;
112 case VT_DWORD:
113 case VT_SDWORD:
114 if ( variable->memoryArea ) {
115 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
116 } else {
117 outhead0("section data_user");
118 vars_emit_dword( _environment, variable->realName, variable->initialValue );
119 outhead0("section code_user");
120 }
121 break;
122 case VT_NUMBER:
123 if ( variable->memoryArea ) {
124 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
125 } else {
126 outhead0("section data_user");
127 vars_emit_number( _environment, variable->realName, variable->initialValue );
128 outhead0("section code_user");
129 }
130 break;
131 case VT_FLOAT:
132 if ( variable->memoryArea ) {
133 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
134 } else {
135 outhead0("section data_user");
136 outline2("%s: defs %d", variable->realName, 1 << VT_FLOAT_NORMALIZED_POW2_WIDTH( variable->arrayPrecision) );
137 outhead0("section code_user");
138 }
139 break;
140 case VT_STRING:
141 outline2("%s: EQU cstring%d", variable->realName, variable->valueString->id );
142 break;
143 case VT_DSTRING:
144 if ( variable->memoryArea ) {
145 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
146 } else {
147 outhead0("section data_user");
148 outline1("%s: db 0", variable->realName);
149 outhead0("section code_user");
150 }
151 break;
152 case VT_MSPRITE:
153 case VT_SPRITE:
154 if ( variable->memoryArea ) {
155 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
156 } else {
157 outhead0("section data_user");
158 outline1("%s: db 0", variable->realName);
159 outhead0("section code_user");
160 }
161 break;
162 case VT_TILE:
163 if ( variable->memoryArea ) {
164 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
165 } else {
166 outhead0("section data_user");
167 outline1("%s: db 0", variable->realName);
168 outhead0("section code_user");
169 }
170 break;
171 case VT_TILESET:
172 if ( variable->memoryArea ) {
173 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
174 } else {
175 outhead0("section data_user");
176 outline1("%s: db 0", variable->realName);
177 outhead0("section code_user");
178 }
179 break;
180 case VT_TILES:
181 if ( variable->memoryArea ) {
182 outline2("%s: EQU $%4.4x", variable->realName, variable->absoluteAddress);
183 } else {
184 outhead0("section data_user");
185 outline1("%s: db 0,0,0,0", variable->realName);
186 outhead0("section code_user");
187 }
188 break;
189 case VT_BLIT:
190 break;
191 case VT_IMAGE:
192 case VT_IMAGES:
193 case VT_SEQUENCE:
194 case VT_MUSIC:
195 case VT_BUFFER:
196 case VT_TYPE:
197 if ( variable->bankAssigned != -1 ) {
198 outhead2("; relocated on bank %d (at %4.4x)", variable->bankAssigned, variable->absoluteAddress );
199 outhead2("%s EQU $%4.4x", variable->realName, variable->absoluteAddress );
200 } else {
201 if ( ! variable->absoluteAddress ) {
202 if ( variable->valueBuffer ) {
203 if ( variable->printable ) {
204 char * string = malloc( variable->size + 1 );
205 memset( string, 0, variable->size + 1 );
206 memcpy( string, variable->valueBuffer, variable->size );
207 outline2("%s: db %s", variable->realName, escape_newlines( string ) );
208 } else {
209 if ( !variable->readonly ) {
210 outhead0("section data_user");
211 }
212 out1("%s: db ", variable->realName);
213 int i=0;
214 for (i=0; i<(variable->size-1); ++i ) {
215 if ( ( ( i + 1 ) % 16 ) == 0 ) {
216 outline1("%d", variable->valueBuffer[i]);
217 out0(" db " );
218 } else {
219 out1("%d,", variable->valueBuffer[i]);
220 }
221 }
222 outline1("%d", variable->valueBuffer[(variable->size-1)]);
223 if ( !variable->readonly ) {
224 outhead0("section code_user");
225 }
226 }
227 } else {
228 outhead0("section data_user");
229 outline2("%s: defs %d", variable->realName, variable->size);
230 outhead0("section code_user");
231 }
232 } else {
233 outline2("%s = $%4.4x", variable->realName, variable->absoluteAddress);
234 if ( variable->valueBuffer ) {
235 if ( variable->printable ) {
236 char * string = malloc( variable->size + 1 );
237 memset( string, 0, variable->size + 1 );
238 memcpy( string, variable->valueBuffer, variable->size );
239 outline2("%scopy: db %s", variable->realName, escape_newlines( string ) );
240 } else {
241 out1("%scopy: db ", variable->realName);
242 int i=0;
243 for (i=0; i<(variable->size-1); ++i ) {
244 out1("%d,", variable->valueBuffer[i]);
245 }
246 outline1("%d", variable->valueBuffer[(variable->size-1)]);
247 }
248 }
249 }
250 }
251 break;
252 case VT_TILEMAP:
253 case VT_TARRAY: {
254 if ( variable->bankAssigned != -1 ) {
255 outhead0("section data_user");
256 outhead4("; relocated on bank %d (at %4.4x) for %d bytes (uncompressed: %d)", variable->bankAssigned, variable->absoluteAddress, variable->size, variable->uncompressedSize );
257 if ( variable->type == VT_TARRAY ) {
258 if (VT_BITWIDTH( variable->arrayType ) == 0 ) {
260 }
261 // force +1 byte if size is odd
262 outhead2("%s: defs %d, $00", variable->realName, (VT_BITWIDTH( variable->arrayType )>>3) );
263 } else {
264 if (VT_BITWIDTH( variable->type ) == 0 ) {
265 CRITICAL_DATATYPE_UNSUPPORTED( "BANKED", DATATYPE_AS_STRING[ variable->type ] );
266 }
267 // force +1 byte if size is odd
268 outhead2("%s: defs %d, $00", variable->realName, (VT_BITWIDTH( variable->type )>>3) );
269 }
270 outhead0("section code_user");
271 } else {
272
273 if ( variable->readonly ) {
274 } else {
275 outhead0("section data_user");
276 }
277 if ( variable->valueBuffer ) {
278 out1("%s: db ", variable->realName);
279 int i=0;
280 for (i=0; i<(variable->size-1); ++i ) {
281 out1("%d,", variable->valueBuffer[i]);
282 }
283 outline1("%d", variable->valueBuffer[(variable->size-1)]);
284 } else if ( variable->value ) {
285
286 switch( VT_BITWIDTH( variable->arrayType ) ) {
287 case 32: {
288 out1("%s: db ", variable->realName );
289 for( int i=0; i<(variable->size/4)-1; ++i ) {
290 out4("$%2.2x, $%2.2x, $%2.2x, $%2.2x, ", (unsigned int)( variable->value & 0xff ), (unsigned int)( ( variable->value >> 8 ) & 0xff ), (unsigned int)( ( variable->value >> 16 ) & 0xff ), (unsigned int)( ( variable->value >> 24 ) & 0xff ) );
291 }
292 out4("$%2.2x, $%2.2x, $%2.2x, $%2.2x", (unsigned int)( variable->value & 0xff ), (unsigned int)( ( variable->value >> 8 ) & 0xff ), (unsigned int)( ( variable->value >> 16 ) & 0xff ), (unsigned int)( ( variable->value >> 24 ) & 0xff ) );
293 outline0("");
294 break;
295 }
296 case 16: {
297 out1("%s: db ", variable->realName );
298 for( int i=0; i<(variable->size/2)-1; ++i ) {
299 out2("$%2.2x, $%2.2x,", (unsigned int)( variable->value & 0xff ), (unsigned int)( ( variable->value >> 8 ) & 0xff ) );
300 }
301 out2("$%2.2x, $%2.2x", (unsigned int)( variable->value & 0xff ), (unsigned int)( ( variable->value >> 8 ) & 0xff ) );
302 outline0("");
303 break;
304 }
305 case 8:
306 outline3("%s: defs %d, $%2.2x", variable->realName, variable->size, (unsigned char)(variable->value&0xff) );
307 break;
308 case 1:
309 outline3("%s: defs %d, $%2.2x", variable->realName, variable->size, (unsigned char)(variable->value?0xff:0x00));
310 break;
311 }
312
313 } else {
314 outline2("%s: defs %d", variable->realName, variable->size);
315 }
316 if ( variable->readonly ) {
317
318 } else {
319 outhead0("section code_user");
320 }
321
322 }
323 break;
324 }
325 }
326
327 if( variable->type == VT_IMAGES ) {
328 if ( variable->strips ) {
329 vars_emit_strips( _environment, variable->realName, variable->strips );
330 }
331 }
332
333 }
334 variable = variable->next;
335 }
336
337}
338
339static void variable_cleanup_entry_bit( Environment * _environment, Variable * _first ) {
340
341 Variable * variable = _first;
342
343 int bitCount = 0;
344
345 outhead0("section data_user");
346 while( variable ) {
347
348 if ( ( !variable->assigned || ( variable->assigned && !variable->temporary ) ) && !variable->imported && !variable->memoryArea ) {
349
350 if ( variable->memoryArea && _environment->debuggerLabelsFile ) {
351 fprintf( _environment->debuggerLabelsFile, "%4.4x %s\r\n", variable->absoluteAddress, variable->realName );
352 }
353
354 switch( variable->type ) {
355 case VT_BIT:
356 if ( variable->memoryArea ) {
357 // outline2("%s = $%4.4x", variable->realName, variable->absoluteAddress);
358 } else {
359 outline1("%s:", variable->realName);
360 }
361 ++bitCount;
362 if ( bitCount == 8 ) {
363 outline0(" defs 1");
364 }
365 break;
366 }
367
368 }
369
370 variable = variable->next;
371
372 }
373
374 if ( bitCount > 0 ) {
375 outline0(" defs 1");
376 }
377
378 outhead0("section code_user");
379
380}
381
391void variable_cleanup( Environment * _environment ) {
392
393 int i=0;
394
395 vars_emit_constants( _environment );
396
397 if ( _environment->dataSegment ) {
398 outhead1("DATAFIRSTSEGMENT EQU %s", _environment->dataSegment->realName );
399 if ( _environment->readDataUsed && _environment->restoreDynamic ) {
400 outhead0("DATASEGMENTNUMERIC:" );
401 DataSegment * actual = _environment->dataSegment;
402 while( actual ) {
403 if ( actual->isNumeric ) {
404 outline2( "dw $%4.4x, %s", actual->lineNumber, actual->realName );
405 }
406 actual = actual->next;
407 }
408 outline0( "dw $ffff, DATAPTRE" );
409 }
410 }
411
412 if ( _environment->offsetting ) {
413 Offsetting * actual = _environment->offsetting;
414 while( actual ) {
415 out1("OFFSETS%4.4x: dw ", actual->size );
416 for( i=0; i<actual->count; ++i ) {
417 out1("$%4.4x", i * actual->size );
418 if ( i < ( actual->count - 1 ) ) {
419 out0(",");
420 } else {
421 outline0("");
422 }
423 }
424 if ( actual->variables ) {
425 OffsettingVariable * actualVariable = actual->variables;
426 while( actualVariable ) {
427 if ( actualVariable->sequence ) {
428 outhead1("%soffsetsequence:", actualVariable->variable->realName );
429 } else {
430 outhead1("%soffsetframe:", actualVariable->variable->realName );
431 }
432 actualVariable = actualVariable->next;
433 }
434 outhead1("fs%4.4xoffsetsequence:", actual->size );
435 outhead1("fs%4.4xoffsetframe:", actual->size );
436 outline0("LD L, A" );
437 outline0("LD H, 0" );
438 outline0("ADD HL, HL" );
439 outline0("LD DE, HL" );
440 outline1("LD HL, OFFSETS%4.4x", actual->size );
441 outline0("ADD HL, DE" );
442 outline0("LD A, (HL)" );
443 outline0("LD E, A" );
444 outline0("INC HL" );
445 outline0("LD A, (HL)" );
446 outline0("LD D, A" );
447 outline0("PUSH IX" );
448 outline0("POP HL" );
449 outline0("ADD HL, DE" );
450 outline0("RET" );
451 }
452 actual = actual->next;
453 }
454
455 int values[MAX_TEMPORARY_STORAGE];
456 char * address[MAX_TEMPORARY_STORAGE];
457
458 actual = _environment->offsetting;
459 int count = 0;
460 while( actual ) {
461 values[count] = actual->size;
462 address[count] = malloc( MAX_TEMPORARY_STORAGE );
463 sprintf( address[count], "fs%4.4xoffsetframe", actual->size );
464 actual = actual->next;
465 ++count;
466 }
467
468 cpu_address_table_build( _environment, "EXECOFFSETS", values, address, count );
469
470 cpu_address_table_lookup( _environment, "EXECOFFSETS", count );
471
472 }
473
474 Constant * c = _environment->constants;
475 while( c ) {
476 if ( c->valueString && c->valueString->value ) {
477 int len = strlen( c->valueString->value );
478 out2("%s: db %d", c->realName, len);
479 if ( len ) {
480 out0(",");
481 int i=0;
482 for (i=0; i<(len-2); ++i ) {
483 out1("$%2.2x,", (unsigned char)c->valueString->value[i]);
484 }
485 outline1("$%2.2x", (unsigned char)c->valueString->value[(len-1)]);
486 } else {
487 outline0(" ");
488 }
489 }
490 c = c->next;
491 }
492
493 generate_cgoto_address_table( _environment );
494
495 for(i=0; i<BANK_TYPE_COUNT; ++i) {
496 Bank * actual = _environment->banks[i];
497 while( actual ) {
498 if ( actual->type == BT_VARIABLES ) {
499 Variable * variable = _environment->variables;
500 variable_cleanup_entry( _environment, variable );
501 variable_cleanup_entry_bit( _environment, variable );
502 } else if ( actual->type == BT_TEMPORARY ) {
503 if ( _environment->bitmaskNeeded ) {
504 outhead0("BITMASK: defm $01,$02,$04,$08,$10,$20,$40,$80");
505 outhead0("BITMASKN: defm $fe,$fd,$fb,$f7,$ef,$df,$bf,$7f");
506 }
507 if ( _environment->deployed.dstring ) {
508 outhead1("max_free_string = $%4.4x", _environment->dstring.space == 0 ? DSTRING_DEFAULT_SPACE : _environment->dstring.space );
509 }
510
511 for( int j=0; j< (_environment->currentProcedure+1); ++j ) {
512 Variable * variable = _environment->tempVariables[j];
513 variable_cleanup_entry( _environment, variable );
514 variable_cleanup_entry_bit( _environment, variable );
515 }
516
517 Variable * variable = _environment->tempResidentVariables;
518
519 variable_cleanup_entry( _environment, variable );
520 variable_cleanup_entry_bit( _environment, variable );
521
522 } else {
523
524 }
525 actual = actual->next;
526 }
527 }
528
529 buffered_push_output( _environment );
530
531 outhead0("SECTION code_user");
532 if ( _environment->outputFileType == OUTPUT_FILE_TYPE_ROM ) {
533 outhead0("ORG $4000");
534 } else {
535 outhead0("ORG $8100");
536 }
537 outhead0("SECTION data_user");
538 outhead0("ORG $C000");
539 outhead0("SECTION code_user");
540
541 if ( _environment->outputFileType == OUTPUT_FILE_TYPE_ROM ) {
542 // +0 ID Put these first two bytes at 041H and 042H ("AB") to indicate that it is an additional ROM.
543 // +2 INIT Address of the routine to call to initialize a work area or I/O ports, or run a game, etc. The system calls the address from INIT of each ROM header during the MSX initialisation in that order.
544 // +4 STATEMENT Runtime address of a program whose purpose is to add instructions to the MSX-Basic using CALL. STATEMENT is called by CALL instructions. It is ignored when 0000h. It is not called at MSX start up.
545 // +6 DEVICE Execution address of a program used to control a device built into the cartridge. For example, a disk interface. It is not called at MSX start up.
546 // +8 TEXT Pointer of the tokenizen Basic program contained in ROM. TEXT must be always an address more than 8000h and be specified in the header of the page 8000h-BFFFh. In other cases, it must always be 0000h under penalty of causing crash or bug.
547 // +10 Reserved 6 bytes reserved for future updates.
548 outline0("DEFB $41, $42");
549 outline0("DEFW CODESTART");
550 outline0("DEFW $0");
551 outline0("DEFW $0");
552 outline0("DEFW $0");
553 outline0("DEFW $0");
554 outline0("DEFW $0");
555 outline0("DEFW $0");
556
557 outhead0("CODESTART:")
558 outline1("LD SP, $%4.4x", _environment->stackStartAddress );
559
560 outline0("CALL $0138");
561 outline0("RRCA");
562 outline0("RRCA");
563 outline0("AND 3");
564 outline0("LD C, A");
565 outline0("LD B, 0");
566 outline0("LD HL, $FCC1");
567 outline0("ADD HL, BC");
568 outline0("LD A, (HL)");
569 outline0("AND $80");
570 outline0("OR C");
571 outline0("LD C, A");
572 outline0("INC HL");
573 outline0("INC HL");
574 outline0("INC HL");
575 outline0("INC HL");
576 outline0("LD A, (HL)");
577 outline0("AND $C" );
578 outline0("OR C");
579 outline0("LD H, $80");
580 outline0("CALL $0024");
581
582 } else {
583 outhead0("CODESTART:")
584 outline0("LD HL, $8000");
585 outline0("LD ($f23d), HL");
586 }
587
588 outline0("JMP CODESTART2");
589
590 deploy_inplace_preferred( startup, src_hw_msx1_startup_asm);
591 deploy_inplace_preferred( tms9918startup, src_hw_tms9918_startup_asm);
592 deploy_inplace_preferred( bank, src_hw_msx1_bank_asm);
593
594 buffered_prepend_output( _environment );
595
596 variable_on_memory_init( _environment, 1 );
597
598 DataSegment * dataSegment = _environment->dataSegment;
599 while( dataSegment ) {
600 int i=0;
601 if ( dataSegment->data ) {
602 out1("%s: db ", dataSegment->realName );
603 } else {
604 outhead1("%s: ", dataSegment->realName );
605 }
606 DataDataSegment * dataDataSegment = dataSegment->data;
607 while( dataDataSegment ) {
608 if ( dataSegment->type ) {
609 if ( dataDataSegment->type == VT_STRING || dataDataSegment->type == VT_DSTRING ) {
610 out1("$%2.2x,", (unsigned char)(dataDataSegment->size) );
611 out1("\"%s\"", dataDataSegment->data );
612 } else {
613 for( i=0; i<(dataDataSegment->size-1); ++i ) {
614 out1("$%2.2x,", (unsigned char)(dataDataSegment->data[i]&0xff) );
615 }
616 out1("$%2.2x", (unsigned char)(dataDataSegment->data[i]&0xff) );
617 }
618 } else {
619 if ( dataDataSegment->type == VT_STRING || dataDataSegment->type == VT_DSTRING ) {
620 out1("$%2.2x,", (unsigned char)(dataDataSegment->type) );
621 out1("$%2.2x,", (unsigned char)(dataDataSegment->size) );
622 out1("\"%s\"", dataDataSegment->data );
623 } else {
624 out1("$%2.2x,", (unsigned char)(dataDataSegment->type) );
625 for( i=0; i<(dataDataSegment->size-1); ++i ) {
626 out1("$%2.2x,", (unsigned char)(dataDataSegment->data[i]&0xff) );
627 }
628 out1("$%2.2x", (unsigned char)(dataDataSegment->data[i]&0xff) );
629 }
630 }
631 dataDataSegment = dataDataSegment->next;
632 if ( dataDataSegment ) {
633 out0(",");
634 }
635 }
636 outline0("");
637 dataSegment = dataSegment->next;
638 }
639
640 if ( _environment->dataNeeded || _environment->dataSegment || _environment->deployed.read_data_unsafe ) {
641 outhead0("DATAPTRE:");
642 }
643
644 StaticString * staticStrings = _environment->strings;
645 while( staticStrings ) {
646 outline3("cstring%d: db %d, %s", staticStrings->id, (int)strlen(staticStrings->value), escape_newlines( staticStrings->value ) );
647 staticStrings = staticStrings->next;
648 }
649
650 if ( _environment->descriptors ) {
651 outhead0("UDCCHAR:" );
652 int i=0,j=0;
653 for(i=_environment->descriptors->first;i<(_environment->descriptors->first+_environment->descriptors->count);++i) {
654 outline1("; $%2.2x ", i);
655 out0("DEFB " );
656 for(j=0;j<7;++j) {
657 out1("$%2.2x,", ((unsigned char)_environment->descriptors->data[i].data[j]) );
658 }
659 outline1("$%2.2x", ((unsigned char)_environment->descriptors->data[i].data[j]) );
660 }
661 outhead0("TMS9918AUDCCHAR01:" );
662 outline1("LD BC, %d", _environment->descriptors->count * 8 );
663 outline0("LD HL, UDCCHAR" );
664 outline1("LD DE, $%4.4x", _environment->descriptors->first*8 );
665 outline0("CALL VDPWRITE" );
666 outline0("RET" );
667 outhead0("TMS9918AUDCCHAR23:" );
668 outline1("LD BC, %d", _environment->descriptors->count * 8 );
669 outline0("LD HL, UDCCHAR" );
670 outline1("LD DE, $%4.4x", _environment->descriptors->first*8 );
671 outline0("CALL VDPWRITE" );
672 outline1("LD BC, %d", _environment->descriptors->count * 8 );
673 outline0("LD HL, UDCCHAR" );
674 outline1("LD DE, $800+$%4.4x", _environment->descriptors->first*8 );
675 outline0("CALL VDPWRITE" );
676 outline1("LD BC, %d", _environment->descriptors->count * 8 );
677 outline0("LD HL, UDCCHAR" );
678 outline1("LD DE, $1000+$%4.4x", _environment->descriptors->first*8 );
679 outline0("CALL VDPWRITE" );
680 outline0("RET" );
681 } else {
682 outhead0("UDCCHAR: EQU $E000");
683 outhead0("TMS9918AUDCCHAR01:" );
684 outline0("RET" );
685 outhead0("TMS9918AUDCCHAR23:" );
686 outline0("RET" );
687 }
688
689 for( i=0; i<MAX_RESIDENT_SHAREDS; ++i ) {
690 if ( _environment->maxExpansionBankSize[i] ) {
691 outhead0("section data_user");
692 outhead1("BANKWINDOWID%2.2x: db $FF, $FF", i );
693 outhead2("BANKWINDOW%2.2x: defs %d", i, _environment->maxExpansionBankSize[i]);
694 outhead0("section code_user");
695 }
696 }
697
698}
void vars_emit_constants(Environment *_environment)
Definition _vars.c:58
void vars_emit_strips(Environment *_environment, char *_name, Strip *_strips)
Definition _vars.c:118
void cpu_address_table_build(Environment *_environment, char *_table, int *_values, char *_address[], int _count)
Definition 6309.c:7344
void cpu_address_table_lookup(Environment *_environment, char *_table, int _count)
Definition 6309.c:7353
#define VT_FLOAT_NORMALIZED_POW2_WIDTH(p)
Definition 6309.h:50
void vars_emit_word(Environment *_environment, char *_name, int _value)
Definition _vars.c:92
void vars_emit_dword(Environment *_environment, char *_name, int _value)
Definition _vars.c:100
void vars_emit_number(Environment *_environment, char *_name, int _value)
Definition _vars.c:108
void vars_emit_byte(Environment *_environment, char *_name, int _value)
Definition _vars.c:84
void buffered_prepend_output(Environment *_environment)
char * escape_newlines(char *_string)
void buffered_push_output(Environment *_environment)
void variable_cleanup(Environment *_environment)
Emit source and configuration lines for variables.
Definition _var.c:559
char BANK_TYPE_AS_STRING[][16]
Description of BANK TYPE, in readable format.
#define DSTRING_DEFAULT_SPACE
Definition atari.h:152
void generate_cgoto_address_table(Environment *_environment)
Definition _var.c:122
void variable_on_memory_init(Environment *_environment, int _imported_too)
Definition _var.c:41
struct _Bank * next
Definition ugbc.h:185
BankType type
Definition ugbc.h:162
StaticString * valueString
Definition ugbc.h:820
struct _Constant * next
Definition ugbc.h:832
char * realName
Definition ugbc.h:803
int space
Definition ugbc.h:1970
struct _DataDataSegment * next
Definition ugbc.h:2181
char * data
Definition ugbc.h:2178
VariableType type
Definition ugbc.h:2175
struct _DataSegment * next
Definition ugbc.h:2198
DataDataSegment * data
Definition ugbc.h:2196
int lineNumber
Definition ugbc.h:2193
VariableType type
Definition ugbc.h:2187
int isNumeric
Definition ugbc.h:2189
char * realName
Definition ugbc.h:2192
int read_data_unsafe
Definition ugbc.h:1923
int dstring
Definition ugbc.h:1789
Variable * tempResidentVariables
Definition ugbc.h:2595
int stackStartAddress
Definition ugbc.h:3296
Offsetting * offsetting
Definition ugbc.h:2937
Bank * banks[BANK_TYPE_COUNT]
Definition ugbc.h:2514
int maxExpansionBankSize[MAX_RESIDENT_SHAREDS]
Definition ugbc.h:3010
OutputFileType outputFileType
Definition ugbc.h:2452
Variable * tempVariables[MAX_PROCEDURES]
Definition ugbc.h:2606
DataSegment * dataSegment
Definition ugbc.h:2568
FILE * debuggerLabelsFile
Definition ugbc.h:3319
StaticString * strings
Definition ugbc.h:2641
int restoreDynamic
Definition ugbc.h:2573
int bitmaskNeeded
Definition ugbc.h:2659
int currentProcedure
Definition ugbc.h:2601
DString dstring
Definition ugbc.h:2405
Variable * variables
Definition ugbc.h:2616
int dataNeeded
Definition ugbc.h:2557
Constant * constants
Definition ugbc.h:2611
TileDescriptors * descriptors
Definition ugbc.h:2939
int readDataUsed
Definition ugbc.h:2578
Deployed deployed
Definition ugbc.h:2921
int size
Definition ugbc.h:892
struct _Offsetting * next
Definition ugbc.h:905
int count
Definition ugbc.h:897
OffsettingVariable * variables
Definition ugbc.h:902
struct _Variable * variable
Definition ugbc.h:880
struct _OffsettingVariable * next
Definition ugbc.h:883
char * value
Definition ugbc.h:337
struct _StaticString * next
Definition ugbc.h:342
char data[8]
Definition ugbc.h:2141
TileData data[512]
Definition ugbc.h:2153
int bankAssigned
Definition ugbc.h:1172
unsigned char * valueBuffer
Definition ugbc.h:1061
int printable
Definition ugbc.h:1097
Strip * strips
Definition ugbc.h:1215
StaticString * valueString
Definition ugbc.h:1041
int assigned
Definition ugbc.h:1020
struct _Variable * next
Definition ugbc.h:1225
int initialValue
Definition ugbc.h:1030
int size
Definition ugbc.h:1077
int absoluteAddress
Definition ugbc.h:1092
FloatTypePrecision arrayPrecision
Definition ugbc.h:1128
VariableType type
Definition ugbc.h:988
int readonly
Definition ugbc.h:1195
MemoryArea * memoryArea
Definition ugbc.h:1107
int uncompressedSize
Definition ugbc.h:1082
int value
Definition ugbc.h:1025
int imported
Definition ugbc.h:1014
VariableType arrayType
Definition ugbc.h:1125
int temporary
Definition ugbc.h:996
char * realName
Definition ugbc.h:982
void * malloc(YYSIZE_T)
#define out4(s, a, b, c, d)
Definition ugbc.h:4263
#define deploy_inplace_preferred(s, e)
Definition ugbc.h:4313
#define BANK_TYPE_COUNT
Maximum number of bank types.
Definition ugbc.h:145
@ OUTPUT_FILE_TYPE_ROM
Definition ugbc.h:265
#define MAX_TEMPORARY_STORAGE
Definition ugbc.h:563
struct _Offsetting Offsetting
#define MAX_RESIDENT_SHAREDS
Definition ugbc.h:572
#define outline3(s, a, b, c)
Definition ugbc.h:4255
struct _Variable Variable
Structure of a single variable.
#define outline2(s, a, b)
Definition ugbc.h:4254
struct _Environment Environment
Structure of compilation environment.
@ VT_THREAD
Definition ugbc.h:492
@ VT_DOJOKA
Definition ugbc.h:534
@ VT_TILE
Definition ugbc.h:504
@ VT_FLOAT
Definition ugbc.h:522
@ VT_BLIT
Definition ugbc.h:519
@ VT_TARRAY
Definition ugbc.h:480
@ VT_WORD
Definition ugbc.h:455
@ VT_POSITION
Definition ugbc.h:468
@ VT_NUMBER
Definition ugbc.h:549
@ VT_SDWORD
Definition ugbc.h:462
@ VT_MSPRITE
Definition ugbc.h:531
@ VT_STRING
Definition ugbc.h:474
@ VT_TILEMAP
Definition ugbc.h:525
@ VT_TILES
Definition ugbc.h:507
@ VT_SWORD
Definition ugbc.h:457
@ VT_BYTE
Definition ugbc.h:450
@ VT_DWORD
Definition ugbc.h:460
@ VT_BIT
Definition ugbc.h:528
@ VT_IMAGEREF
Definition ugbc.h:537
@ VT_VECTOR2
Definition ugbc.h:543
@ VT_CHAR
Definition ugbc.h:498
@ VT_BUFFER
Definition ugbc.h:477
@ VT_SPRITE
Definition ugbc.h:501
@ VT_SBYTE
Definition ugbc.h:452
@ VT_IMAGES
Definition ugbc.h:495
@ VT_MUSIC
Definition ugbc.h:516
@ VT_TYPE
Definition ugbc.h:546
@ VT_ADDRESS
Definition ugbc.h:465
@ VT_COLOR
Definition ugbc.h:471
@ VT_TILESET
Definition ugbc.h:510
@ VT_DSTRING
Definition ugbc.h:483
@ VT_PATH
Definition ugbc.h:540
@ VT_IMAGE
Definition ugbc.h:489
@ VT_SEQUENCE
Definition ugbc.h:513
struct _OffsettingVariable OffsettingVariable
#define outhead0(s)
Definition ugbc.h:4246
#define outhead4(s, a, b, c, d)
Definition ugbc.h:4250
#define out0(s)
Definition ugbc.h:4259
struct _Constant Constant
Structure of a single constant.
@ BT_VARIABLES
Definition ugbc.h:126
@ BT_TEMPORARY
Definition ugbc.h:129
#define out2(s, a, b)
Definition ugbc.h:4261
#define outline0(s)
Definition ugbc.h:4252
struct _StaticString StaticString
Structure of a single (static) string.
#define outhead2(s, a, b)
Definition ugbc.h:4248
#define CRITICAL_DATATYPE_UNSUPPORTED(k, v)
Definition ugbc.h:3447
struct _DataDataSegment DataDataSegment
#define out1(s, a)
Definition ugbc.h:4260
#define outline1(s, a)
Definition ugbc.h:4253
struct _DataSegment DataSegment
#define VT_BITWIDTH(t)
Definition ugbc.h:595
struct _Bank Bank
Structure of a single bank.
#define outhead1(s, a)
Definition ugbc.h:4247
char DATATYPE_AS_STRING[][16]