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-2024 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");
60 vars_emit_byte( _environment, variable->realName, variable->initialValue );
61 outhead0("section code");
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");
69 outline1("%s: defs 4", variable->realName);
70 outhead0("section code");
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");
78 outline1("%s: defs 14", variable->realName);
79 outhead0("section code");
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");
87 outline1("%s: defs 16", variable->realName);
88 outhead0("section code");
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");
96 outline1("%s: defs 4", variable->realName);
97 outhead0("section code");
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");
108 vars_emit_word( _environment, variable->realName, variable->initialValue );
109 outhead0("section code");
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");
118 vars_emit_dword( _environment, variable->realName, variable->initialValue );
119 outhead0("section code");
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");
127 vars_emit_number( _environment, variable->realName, variable->initialValue );
128 outhead0("section code");
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");
136 outline2("%s: defs %d", variable->realName, 1 << VT_FLOAT_NORMALIZED_POW2_WIDTH( variable->arrayPrecision) );
137 outhead0("section code");
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");
148 outline1("%s: db 0", variable->realName);
149 outhead0("section code");
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");
158 outline1("%s: db 0", variable->realName);
159 outhead0("section code");
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");
167 outline2("%s: db %d", variable->realName, variable->initialValue );
168 outhead0("section code");
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");
176 outline1("%s: db 0", variable->realName);
177 outhead0("section code");
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");
185 outline1("%s: db 0,0,0,0", variable->realName);
186 outhead0("section code");
187 }
188 break;
189 case VT_BLIT:
190 break;
191 case VT_IMAGE:
192 {
193 if ( variable->bankAssigned != -1 ) {
194 outhead2("; relocated on bank %d (at %4.4x)", variable->bankAssigned, variable->absoluteAddress );
195 outhead1("%s: db $0", variable->realName );
196 } else {
197 int writableSize = 0;
198 if ( variable->size > 3 ) {
199 writableSize = 3 + variable->valueBuffer[2];
200 outhead0("section data");
201 out1("%s: db ", variable->realName);
202 int i=0;
203 for (i=0; i<(writableSize-1); ++i ) {
204 if ( ( ( i + 1 ) % 16 ) == 0 ) {
205 outline1("%d", variable->valueBuffer[i]);
206 out0(" db " );
207 } else {
208 out1("%d,", variable->valueBuffer[i]);
209 }
210 }
211 outline1("%d", variable->valueBuffer[i]);
212 }
213 outhead0("section code");
214 if ( ! variable->absoluteAddress ) {
215 if ( variable->valueBuffer ) {
216 if ( variable->printable ) {
217 char * string = malloc( variable->size + 1 );
218 memset( string, 0, variable->size + 1 );
219 memcpy( string, variable->valueBuffer, variable->size );
220 outline2("%s: db %s", variable->realName, escape_newlines( string ) );
221 } else {
222 if ( !variable->readonly ) {
223 outhead0("section data");
224 }
225 out1("%sdata: db ", variable->realName);
226 int i=0;
227 for (i=writableSize; i<(variable->size-1); ++i ) {
228 if ( ( ( i + 1 ) % 16 ) == 0 ) {
229 outline1("%d", variable->valueBuffer[i]);
230 out0(" db " );
231 } else {
232 out1("%d,", variable->valueBuffer[i]);
233 }
234 }
235 outline1("%d", variable->valueBuffer[(variable->size-1)]);
236 if ( !variable->readonly ) {
237 outhead0("section code");
238 }
239 }
240 } else {
241 outhead0("section data");
242 outline2("%s: defs %d", variable->realName, variable->size - writableSize);
243 outhead0("section code");
244 }
245 } else {
246 outline2("%s = $%4.4x", variable->realName, variable->absoluteAddress);
247 if ( variable->valueBuffer ) {
248 if ( variable->printable ) {
249 char * string = malloc( variable->size + 1 );
250 memset( string, 0, variable->size + 1 );
251 memcpy( string, variable->valueBuffer, variable->size );
252 outline2("%scopy: db %s", variable->realName, escape_newlines( string ) );
253 } else {
254 out1("%scopy: db ", variable->realName);
255 int i=0;
256 for (i=0; i<(variable->size-1); ++i ) {
257 out1("%d,", variable->valueBuffer[i]);
258 }
259 outline1("%d", variable->valueBuffer[(variable->size-1)]);
260 }
261 }
262 }
263 }
264 }
265 break;
266 case VT_IMAGES:
267 case VT_SEQUENCE:
268 case VT_MUSIC:
269 case VT_BUFFER:
270 case VT_TYPE:
271 if ( variable->bankAssigned != -1 ) {
272 outhead2("; relocated on bank %d (at %4.4x)", variable->bankAssigned, variable->absoluteAddress );
273 outhead1("%s: db $0", variable->realName );
274 } else {
275 if ( ! variable->absoluteAddress ) {
276 if ( variable->valueBuffer ) {
277 if ( variable->printable ) {
278 char * string = malloc( variable->size + 1 );
279 memset( string, 0, variable->size + 1 );
280 memcpy( string, variable->valueBuffer, variable->size );
281 outline2("%s: db %s", variable->realName, escape_newlines( string ) );
282 } else {
283 if ( !variable->readonly ) {
284 outhead0("section data");
285 }
286 out1("%s: db ", variable->realName);
287 int i=0;
288 for (i=0; i<(variable->size-1); ++i ) {
289 if ( ( ( i + 1 ) % 16 ) == 0 ) {
290 outline1("%d", variable->valueBuffer[i]);
291 out0(" db " );
292 } else {
293 out1("%d,", variable->valueBuffer[i]);
294 }
295 }
296 outline1("%d", variable->valueBuffer[(variable->size-1)]);
297 if ( !variable->readonly ) {
298 outhead0("section code");
299 }
300 }
301 } else {
302 outhead0("section data");
303 outline2("%s: defs %d", variable->realName, variable->size);
304 outhead0("section code");
305 }
306 } else {
307 outline2("%s = $%4.4x", variable->realName, variable->absoluteAddress);
308 if ( variable->valueBuffer ) {
309 if ( variable->printable ) {
310 char * string = malloc( variable->size + 1 );
311 memset( string, 0, variable->size + 1 );
312 memcpy( string, variable->valueBuffer, variable->size );
313 outline2("%scopy: db %s", variable->realName, escape_newlines( string ) );
314 } else {
315 out1("%scopy: db ", variable->realName);
316 int i=0;
317 for (i=0; i<(variable->size-1); ++i ) {
318 out1("%d,", variable->valueBuffer[i]);
319 }
320 outline1("%d", variable->valueBuffer[(variable->size-1)]);
321 }
322 }
323 }
324 }
325 break;
326 case VT_TILEMAP:
327 case VT_TARRAY: {
328 if ( variable->bankAssigned != -1 ) {
329 outhead0("section data");
330 outhead4("; relocated on bank %d (at %4.4x) for %d bytes (uncompressed: %d)", variable->bankAssigned, variable->absoluteAddress, variable->size, variable->uncompressedSize );
331 if ( variable->type == VT_TARRAY ) {
332 if (VT_BITWIDTH( variable->arrayType ) == 0 ) {
334 }
335 // force +1 byte if size is odd
336 outhead2("%s: defs %d, $00", variable->realName, (VT_BITWIDTH( variable->arrayType )>>3) );
337 } else {
338 if (VT_BITWIDTH( variable->type ) == 0 ) {
339 CRITICAL_DATATYPE_UNSUPPORTED( "BANKED", DATATYPE_AS_STRING[ variable->type ] );
340 }
341 // force +1 byte if size is odd
342 outhead2("%s: defs %d, $00", variable->realName, (VT_BITWIDTH( variable->type )>>3) );
343 }
344 outhead0("section code");
345 } else {
346
347 if ( variable->readonly ) {
348 } else {
349 outhead0("section data");
350 }
351 if ( variable->valueBuffer ) {
352 out1("%s: db ", variable->realName);
353 int i=0;
354 for (i=0; i<(variable->size-1); ++i ) {
355 out1("%d,", variable->valueBuffer[i]);
356 }
357 outline1("%d", variable->valueBuffer[(variable->size-1)]);
358 } else if ( variable->value ) {
359
360 switch( VT_BITWIDTH( variable->arrayType ) ) {
361 case 32: {
362 out1("%s: db ", variable->realName );
363 for( int i=0; i<(variable->size/4)-1; ++i ) {
364 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 ) );
365 }
366 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 ) );
367 outline0("");
368 break;
369 }
370 case 16: {
371 out1("%s: db ", variable->realName );
372 for( int i=0; i<(variable->size/2)-1; ++i ) {
373 out2("$%2.2x, $%2.2x,", (unsigned int)( variable->value & 0xff ), (unsigned int)( ( variable->value >> 8 ) & 0xff ) );
374 }
375 out2("$%2.2x, $%2.2x", (unsigned int)( variable->value & 0xff ), (unsigned int)( ( variable->value >> 8 ) & 0xff ) );
376 outline0("");
377 break;
378 }
379 case 8:
380 outline3("%s: defs %d, $%2.2x", variable->realName, variable->size, (unsigned char)(variable->value&0xff) );
381 break;
382 case 1:
383 outline3("%s: defs %d, $%2.2x", variable->realName, variable->size, (unsigned char)(variable->value?0xff:0x00));
384 break;
385 }
386
387 } else {
388 outline2("%s: defs %d", variable->realName, variable->size);
389 }
390 if ( variable->readonly ) {
391
392 } else {
393 outhead0("section code");
394 }
395
396 }
397 break;
398 }
399 }
400
401 if( variable->type == VT_IMAGES ) {
402 if ( variable->strips ) {
403 vars_emit_strips( _environment, variable->realName, variable->strips );
404 }
405 }
406
407 }
408 variable = variable->next;
409 }
410
411}
412
413static void variable_cleanup_entry_bit( Environment * _environment, Variable * _first ) {
414
415 Variable * variable = _first;
416
417 int bitCount = 0;
418
419 outhead0("section data");
420 while( variable ) {
421
422 if ( ( !variable->assigned || ( variable->assigned && !variable->temporary ) ) && !variable->imported && !variable->memoryArea ) {
423
424 if ( variable->memoryArea && _environment->debuggerLabelsFile ) {
425 fprintf( _environment->debuggerLabelsFile, "%4.4x %s\r\n", variable->absoluteAddress, variable->realName );
426 }
427
428 switch( variable->type ) {
429 case VT_BIT:
430 if ( variable->memoryArea ) {
431 // outline2("%s = $%4.4x", variable->realName, variable->absoluteAddress);
432 } else {
433 outline1("%s:", variable->realName);
434 }
435 ++bitCount;
436 if ( bitCount == 8 ) {
437 outline0(" defs 1");
438 }
439 break;
440 }
441
442 }
443
444 variable = variable->next;
445
446 }
447
448 if ( bitCount > 0 ) {
449 outline0(" defs 1");
450 }
451
452 outhead0("section code");
453
454}
455
465void variable_cleanup( Environment * _environment ) {
466
467 int i=0;
468
469 vars_emit_constants( _environment );
470
471 if ( _environment->dataSegment ) {
472 outhead1("DATAFIRSTSEGMENT EQU %s", _environment->dataSegment->realName );
473 if ( _environment->readDataUsed && _environment->restoreDynamic ) {
474 outhead0("DATASEGMENTNUMERIC:" );
475 DataSegment * actual = _environment->dataSegment;
476 while( actual ) {
477 if ( actual->isNumeric ) {
478 outline2( "dw $%4.4x, %s", actual->lineNumber, actual->realName );
479 }
480 actual = actual->next;
481 }
482 outline0( "dw $ffff, DATAPTRE" );
483 }
484 }
485
486 if ( _environment->offsetting ) {
487 Offsetting * actual = _environment->offsetting;
488 while( actual ) {
489 out1("OFFSETS%4.4x: dw ", actual->size );
490 for( i=0; i<actual->count; ++i ) {
491 out1("$%4.4x", i * actual->size );
492 if ( i < ( actual->count - 1 ) ) {
493 out0(",");
494 } else {
495 outline0("");
496 }
497 }
498 if ( actual->variables ) {
499 OffsettingVariable * actualVariable = actual->variables;
500 while( actualVariable ) {
501 if ( actualVariable->sequence ) {
502 outhead1("%soffsetsequence:", actualVariable->variable->realName );
503 } else {
504 outhead1("%soffsetframe:", actualVariable->variable->realName );
505 }
506 actualVariable = actualVariable->next;
507 }
508 outhead1("fs%4.4xoffsetsequence:", actual->size );
509 outhead1("fs%4.4xoffsetframe:", actual->size );
510 outline0("LD L, A" );
511 outline0("LD H, 0" );
512 outline0("ADD HL, HL" );
513 outline0("LD DE, HL" );
514 outline1("LD HL, OFFSETS%4.4x", actual->size );
515 outline0("ADD HL, DE" );
516 outline0("LD A, (HL)" );
517 outline0("LD E, A" );
518 outline0("INC HL" );
519 outline0("LD A, (HL)" );
520 outline0("LD D, A" );
521 outline0("LD HL, (IXR)" );
522 outline0("ADD HL, DE" );
523 outline0("RET" );
524 }
525 actual = actual->next;
526 }
527
528 int values[MAX_TEMPORARY_STORAGE];
529 char * address[MAX_TEMPORARY_STORAGE];
530
531 actual = _environment->offsetting;
532 int count = 0;
533 while( actual ) {
534 values[count] = actual->size;
535 address[count] = malloc( MAX_TEMPORARY_STORAGE );
536 sprintf( address[count], "fs%4.4xoffsetframe", actual->size );
537 actual = actual->next;
538 ++count;
539 }
540
541 cpu_address_table_build( _environment, "EXECOFFSETS", values, address, count );
542
543 cpu_address_table_lookup( _environment, "EXECOFFSETS", count );
544
545 }
546
547 Constant * c = _environment->constants;
548 while( c ) {
549 if ( c->valueString ) {
550 int len = strlen( c->valueString->value );
551 out2("%s: db %d,", c->realName, len);
552 int i=0;
553 for (i=0; i<(len-1); ++i ) {
554 out1("$%2.2x,", (unsigned char)c->valueString->value[i]);
555 }
556 outline1("$%2.2x", (unsigned char)c->valueString->value[(len-1)]);
557 }
558 c = c->next;
559 }
560
561 generate_cgoto_address_table( _environment );
562
563 banks_generate( _environment );
564
565 for(i=0; i<BANK_TYPE_COUNT; ++i) {
566 Bank * actual = _environment->banks[i];
567 while( actual ) {
568 if ( actual->type == BT_VARIABLES ) {
569 Variable * variable = _environment->variables;
570 variable_cleanup_entry( _environment, variable );
571 variable_cleanup_entry_bit( _environment, variable );
572 } else if ( actual->type == BT_TEMPORARY ) {
573 if ( _environment->bitmaskNeeded ) {
574 outhead0("BITMASK: defm $01,$02,$04,$08,$10,$20,$40,$80");
575 outhead0("BITMASKN: defm $fe,$fd,$fb,$f7,$ef,$df,$bf,$7f");
576 }
577 if ( _environment->deployed.dstring ) {
578 outhead1("max_free_string = $%4.4x", _environment->dstring.space == 0 ? DSTRING_DEFAULT_SPACE : _environment->dstring.space );
579 }
580
581 for( int j=0; j< (_environment->currentProcedure+1); ++j ) {
582 Variable * variable = _environment->tempVariables[j];
583 variable_cleanup_entry( _environment, variable );
584 variable_cleanup_entry_bit( _environment, variable );
585 }
586
587 Variable * variable = _environment->tempResidentVariables;
588
589 variable_cleanup_entry( _environment, variable );
590 variable_cleanup_entry_bit( _environment, variable );
591
592 } else {
593
594 }
595 actual = actual->next;
596 }
597 }
598
599 buffered_push_output( _environment );
600
601 outhead0("SECTION code");
602
603 outhead0("ORG $0000");
604 outline0("DEFS $40, 0");
605 outline0("JP IRQSVC");
606 outline0("DEFS $0d, 0");
607 outline0("JP IRQTMR");
608 outline0("DEFS $0d, 0");
609 outline0("JP IRQJOY");
610 outline0("DEFS $9d, 0");
611 outline0("JP CODESTART");
612 outline0("DEFS $4d, 0");
613
614 outhead0("SECTION data");
615 outhead0("ORG $c000");
616 outhead0("SECTION code");
617
618 deploy_inplace_preferred( startup, src_hw_gb_startup_asm);
619
620 outhead0("CODESTART:");
621
622 if ( _environment->descriptors ) {
623 outline0("CALL COPYUDCCHAR");
624 }
625
626 // deploy_inplace_preferred( tms9918startup, src_hw_// tms9918_startup_asm);
627
628 buffered_prepend_output( _environment );
629
630 variable_on_memory_init( _environment, 1 );
631
632 DataSegment * dataSegment = _environment->dataSegment;
633 while( dataSegment ) {
634 int i=0;
635 if ( dataSegment->data ) {
636 out1("%s: db ", dataSegment->realName );
637 } else {
638 outhead1("%s: ", dataSegment->realName );
639 }
640 DataDataSegment * dataDataSegment = dataSegment->data;
641 while( dataDataSegment ) {
642 if ( dataSegment->type ) {
643 if ( dataDataSegment->type == VT_STRING || dataDataSegment->type == VT_DSTRING ) {
644 out1("$%2.2x,", (unsigned char)(dataDataSegment->size) );
645 out1("\"%s\"", dataDataSegment->data );
646 } else {
647 for( i=0; i<(dataDataSegment->size-1); ++i ) {
648 out1("$%2.2x,", (unsigned char)(dataDataSegment->data[i]&0xff) );
649 }
650 out1("$%2.2x", (unsigned char)(dataDataSegment->data[i]&0xff) );
651 }
652 } else {
653 if ( dataDataSegment->type == VT_STRING || dataDataSegment->type == VT_DSTRING ) {
654 out1("$%2.2x,", (unsigned char)(dataDataSegment->type) );
655 out1("$%2.2x,", (unsigned char)(dataDataSegment->size) );
656 out1("\"%s\"", dataDataSegment->data );
657 } else {
658 out1("$%2.2x,", (unsigned char)(dataDataSegment->type) );
659 for( i=0; i<(dataDataSegment->size-1); ++i ) {
660 out1("$%2.2x,", (unsigned char)(dataDataSegment->data[i]&0xff) );
661 }
662 out1("$%2.2x", (unsigned char)(dataDataSegment->data[i]&0xff) );
663 }
664 }
665 dataDataSegment = dataDataSegment->next;
666 if ( dataDataSegment ) {
667 out0(",");
668 }
669 }
670 outline0("");
671 dataSegment = dataSegment->next;
672 }
673
674 if ( _environment->dataNeeded || _environment->dataSegment || _environment->deployed.read_data_unsafe ) {
675 outhead0("DATAPTRE:");
676 }
677
678 StaticString * staticStrings = _environment->strings;
679 while( staticStrings ) {
680 outline3("cstring%d: db %d, %s", staticStrings->id, (int)strlen(staticStrings->value), escape_newlines( staticStrings->value ) );
681 staticStrings = staticStrings->next;
682 }
683
684 if ( _environment->descriptors ) {
685 outhead0("UDCCHAR:" );
686 int i=0,j=0;
687 for(i=_environment->descriptors->first;i<(_environment->descriptors->first+_environment->descriptors->count);++i) {
688 outline1("; $%2.2x ", i);
689 out0("DEFB " );
690 for(j=0;j<7;++j) {
691 out1("$%2.2x,", ((unsigned char)_environment->descriptors->data[i].data[j]) );
692 }
693 outline1("$%2.2x", ((unsigned char)_environment->descriptors->data[i].data[j]) );
694 }
695 } else {
696 outhead0("UDCCHAR: EQU $E000");
697 }
698
699 if ( _environment->descriptors ) {
700 int j;
701 outhead0("section data");
702 outhead0("TILESETSLOTUSED: ");
703 for(j=0;j<8;++j) {
704 int k;
705 out0(" DB " );
706 for(k=0;k<31;++k) {
707 if ( k < (( _environment->descriptors->firstFree / 8 ) + 1 ) ) {
708 out0("$FF,");
709 } else {
710 out0("$00,");
711 }
712 }
713 outline0("$00");
714 }
715 outhead0("TILESETSLOTATTRIBUTE: ");
716 out0(" DB " );
717 for(j=0;j<255;++j) {
718 int k;
719 if ( j < (( _environment->descriptors->firstFree / 8 ) + 1 ) ) {
720 out0("$07,");
721 } else {
722 out0("$00,");
723 }
724 }
725 outline0("$00");
726 outhead0("section code");
727 } else {
728 outhead0("section data");
729 outhead0("TILESETSLOTUSED: DS 256, $00 ");
730 outhead0("TILESETSLOTATTRIBUTE: DS 256, $00 ");
731 outhead0("section code");
732 }
733
734
735
736 // for( i=0; i<MAX_RESIDENT_SHAREDS; ++i ) {
737 // if ( _environment->maxExpansionBankSize[i] ) {
738 // outhead0("section data");
739 // outhead1("BANKWINDOWID%2.2x: db $FF, $FF", i );
740 // outhead2("BANKWINDOW%2.2x: defs %d", i, _environment->maxExpansionBankSize[i]);
741 // outhead0("section code");
742 // }
743 // }
744
745}
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 banks_generate(Environment *_environment)
Definition _banks.c:45
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
Offsetting * offsetting
Definition ugbc.h:2937
Bank * banks[BANK_TYPE_COUNT]
Definition ugbc.h:2514
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
#define MAX_TEMPORARY_STORAGE
Definition ugbc.h:563
struct _Offsetting Offsetting
#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]