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
50 if ( ( !variable->assigned || ( variable->assigned && !variable->temporary ) ) && !variable->imported ) {
51
52 if ( variable->memoryArea && _environment->debuggerLabelsFile ) {
53 fprintf( _environment->debuggerLabelsFile, "%4.4x %s\r\n", variable->absoluteAddress, variable->realName );
54 }
55
56 switch( variable->type ) {
57 case VT_CHAR:
58 case VT_BYTE:
59 case VT_SBYTE:
60 case VT_COLOR:
61 case VT_THREAD:
62 if ( variable->memoryArea ) {
63 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
64 } else {
65 vars_emit_byte( _environment, variable->realName, variable->initialValue );
66 }
67 break;
68 case VT_DOJOKA:
69 if ( variable->memoryArea ) {
70 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
71 } else {
72 outhead1("%s rzb 4", variable->realName);
73 }
74 break;
75 case VT_IMAGEREF:
76 if ( variable->memoryArea ) {
77 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
78 } else {
79 outhead1("%s rzb 14", variable->realName);
80 }
81 break;
82 case VT_PATH:
83 if ( variable->memoryArea ) {
84 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
85 } else {
86 outhead1("%s rzb 16", variable->realName);
87 }
88 break;
89 case VT_VECTOR2:
90 if ( variable->memoryArea ) {
91 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
92 } else {
93 outhead1("%s rzb 4", variable->realName);
94 }
95 break;
96 case VT_WORD:
97 case VT_SWORD:
98 case VT_POSITION:
99 case VT_ADDRESS:
100 if ( variable->memoryArea ) {
101 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
102 } else {
103 vars_emit_word( _environment, variable->realName, variable->initialValue );
104 }
105 break;
106 case VT_DWORD:
107 case VT_SDWORD:
108 if ( variable->memoryArea ) {
109 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
110 } else {
111 vars_emit_dword( _environment, variable->realName, variable->initialValue );
112 }
113 break;
114 case VT_NUMBER:
115 if ( variable->memoryArea ) {
116 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
117 } else {
118 vars_emit_number( _environment, variable->realName, variable->initialValue );
119 }
120 break;
121 case VT_FLOAT:
122 if ( variable->memoryArea ) {
123 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
124 } else {
125 outhead1("%s rzb 5", variable->realName);
126 }
127 break;
128 case VT_STRING:
129 if ( ! variable->valueString ) {
130 printf("%s", variable->realName);
131 exit(EXIT_FAILURE);
132 }
133 if ( variable->memoryArea ) {
134 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
135 } else {
136 outhead2("%s equ cstring%d", variable->realName, variable->valueString->id );
137 }
138 break;
139 case VT_DSTRING:
140 if ( variable->memoryArea ) {
141 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
142 } else {
143 outhead1("%s rzb 1", variable->realName);
144 }
145 break;
146 case VT_MSPRITE:
147 case VT_SPRITE:
148 if ( variable->memoryArea ) {
149 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
150 } else {
151 outhead1("%s rzb 1", variable->realName);
152 }
153 break;
154 case VT_TILE:
155 if ( variable->memoryArea ) {
156 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
157 } else {
158 outhead1("%s rzb 1", variable->realName);
159 }
160 break;
161 case VT_TILESET:
162 if ( variable->memoryArea ) {
163 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
164 } else {
165 outhead1("%s rzb 1", variable->realName);
166 }
167 break;
168 case VT_TILES:
169 if ( variable->memoryArea ) {
170 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
171 } else {
172 outhead1("%s rzb 4", variable->realName);
173 }
174 break;
175 case VT_BLIT:
176 break;
177 case VT_IMAGE:
178 case VT_IMAGES:
179 case VT_SEQUENCE:
180 case VT_MUSIC:
181 case VT_BUFFER:
182 case VT_TYPE:
183 if ( variable->bankAssigned != -1 ) {
184 outhead2("; relocated on bank %d (at %4.4x)", variable->bankAssigned, variable->absoluteAddress );
185 outhead1("%s fcb $0", variable->realName );
186 } else {
187 if ( ! variable->absoluteAddress ) {
188 if ( variable->valueBuffer ) {
189 if ( variable->printable ) {
190 char * string = malloc( variable->size + 1 );
191 memset( string, 0, variable->size + 1 );
192 memcpy( string, variable->valueBuffer, variable->size );
193 outhead2("%s fcc %s", variable->realName, escape_newlines( string ) );
194 } else {
195 out1("%s fcb ", variable->realName);
196 int i=0;
197 for (i=0; i<(variable->size-1); ++i ) {
198 out1("%d,", variable->valueBuffer[i]);
199 }
200 outhead1("%d", variable->valueBuffer[(variable->size-1)]);
201 }
202 } else {
203 outhead2("%s rzb %d", variable->realName, variable->size);
204 }
205 } else {
206 outhead2("%s equ $%4.4x", variable->realName, variable->absoluteAddress);
207 if ( variable->valueBuffer ) {
208 if ( variable->printable ) {
209 char * string = malloc( variable->size + 1 );
210 memset( string, 0, variable->size + 1 );
211 memcpy( string, variable->valueBuffer, variable->size );
212 outhead2("%s fcc %s", variable->realName, escape_newlines( string ) );
213 } else {
214 out1("%scopy fcb ", variable->realName);
215 int i=0;
216 for (i=0; i<(variable->size-1); ++i ) {
217 out1("%d,", variable->valueBuffer[i]);
218 }
219 outhead1("%d", variable->valueBuffer[(variable->size-1)]);
220 }
221 }
222 }
223 }
224 break;
225 case VT_TILEMAP:
226 case VT_TARRAY: {
227 if ( variable->bankAssigned == -1 ) {
228
229 if ( variable->valueBuffer ) {
230 out1("%s fcb ", variable->realName);
231 int i=0;
232 for (i=0; i<(variable->size-1); ++i ) {
233 out1("$%2.2x,", variable->valueBuffer[i]);
234 }
235 // force +1 byte if size is odd
236 if ( variable->size & 0x01 ) {
237 outhead1("$%2.2x,$0", variable->valueBuffer[(variable->size-1)]);
238 } else {
239 outhead1("$%2.2x", variable->valueBuffer[(variable->size-1)]);
240 }
241 } else if ( variable->value ) {
242
243 switch( VT_BITWIDTH( variable->arrayType ) ) {
244 case 32: {
245 out1("%s fcb ", variable->realName );
246 for( int i=0; i<(variable->size/4)-1; ++i ) {
247 out4("$%2.2x, $%2.2x, $%2.2x, $%2.2x, ", (unsigned int)( ( variable->value >> 24 ) & 0xff ), (unsigned int)( ( variable->value >> 16 ) & 0xff ), (unsigned int)( ( variable->value >> 8 ) & 0xff ), (unsigned int)( variable->value & 0xff ) );
248 }
249 out4("$%2.2x, $%2.2x, $%2.2x, $%2.2x", (unsigned int)( ( variable->value >> 24 ) & 0xff ), (unsigned int)( ( variable->value >> 16 ) & 0xff ), (unsigned int)( ( variable->value >> 8 ) & 0xff ), (unsigned int)( variable->value & 0xff ) );
250 outline0("");
251 break;
252 }
253 case 16: {
254 out1("%s fcb ", variable->realName );
255 for( int i=0; i<(variable->size/2)-1; ++i ) {
256 out2("$%2.2x, $%2.2x,", (unsigned int)( ( variable->value >> 8 ) & 0xff ), (unsigned int)( variable->value & 0xff ) );
257 }
258 out2("$%2.2x, $%2.2x", (unsigned int)( ( variable->value >> 8 ) & 0xff ), (unsigned int)( variable->value & 0xff ) );
259 outline0("");
260 break;
261 }
262 case 8:
263 outhead3("%s rzb %d, $%2.2x", variable->realName, variable->size, (unsigned char)(variable->value&0xff) );
264 break;
265 case 1:
266 outhead3("%s rzb %d, $%2.2x", variable->realName, variable->size, (unsigned char)(variable->value?0xff:0x00));
267 break;
268 }
269
270 } else {
271 outhead4("; relocated on bank %d (at %4.4x) for %d bytes (uncompressed: %d)", variable->bankAssigned, variable->absoluteAddress, variable->size, variable->uncompressedSize );
272 // force +1 byte if size is odd
273 if ( variable->size & 0x01 ) {
274 outhead2("%s rzb %d", variable->realName, variable->size+1);
275 } else {
276 outhead2("%s rzb %d", variable->realName, variable->size);
277 }
278 }
279
280 } else {
281 outhead4("; relocated on bank %d (at %4.4x) for %d bytes (uncompressed: %d)", variable->bankAssigned, variable->absoluteAddress, variable->size, variable->uncompressedSize );
282 if ( variable->type == VT_TARRAY ) {
283 // if (VT_BITWIDTH( variable->arrayType ) == 0 && variable->arrayType != VT_TYPE ) {
284 // CRITICAL_DATATYPE_UNSUPPORTED( "BANKED", DATATYPE_AS_STRING[ variable->arrayType ] );
285 // }
286 // force +1 byte if size is odd
287 if ( variable->size & 0x01 ) {
288 outhead2("%s rzb %d, $00", variable->realName, (VT_BITWIDTH( variable->arrayType )>>3)+1 );
289 } else {
290 outhead2("%s rzb %d, $00", variable->realName, (VT_BITWIDTH( variable->arrayType )>>3) );
291 }
292 } else {
293 if (VT_BITWIDTH( variable->type ) == 0 ) {
294 CRITICAL_DATATYPE_UNSUPPORTED( "BANKED", DATATYPE_AS_STRING[ variable->type ] );
295 }
296 // force +1 byte if size is odd
297 if ( variable->size & 0x01 ) {
298 outhead2("%s rzb %d, $00", variable->realName, (VT_BITWIDTH( variable->type )>>3)+1 );
299 } else {
300 outhead2("%s rzb %d, $00", variable->realName, (VT_BITWIDTH( variable->type )>>3) );
301 }
302 }
303 }
304
305 break;
306
307 }
308
309 }
310
311 if( variable->type == VT_IMAGES ) {
312 if ( variable->strips ) {
313 vars_emit_strips( _environment, variable->realName, variable->strips );
314 }
315 }
316
317 }
318
319 variable = variable->next;
320
321 }
322
323}
324
325static void variable_cleanup_entry_bit( Environment * _environment, Variable * _first ) {
326
327 Variable * variable = _first;
328
329 int bitCount = 0;
330
331 while( variable ) {
332
333 if ( ( !variable->assigned || ( variable->assigned && !variable->temporary ) ) && !variable->imported && !variable->memoryArea ) {
334
335 if ( variable->memoryArea && _environment->debuggerLabelsFile ) {
336 fprintf( _environment->debuggerLabelsFile, "%4.4x %s\r\n", variable->absoluteAddress, variable->realName );
337 }
338
339 switch( variable->type ) {
340 case VT_BIT:
341 if ( variable->memoryArea ) {
342 // outline2("%s = $%4.4x", variable->realName, variable->absoluteAddress);
343 } else {
344 outhead1("%s", variable->realName);
345 }
346 ++bitCount;
347 if ( bitCount == 8 ) {
348 outline0(" fcb 0");
349 }
350 break;
351 }
352
353 }
354
355 variable = variable->next;
356
357 }
358
359 if ( bitCount > 0 ) {
360 outline0(" fcb 0");
361 }
362
363}
364
374void variable_cleanup( Environment * _environment ) {
375 int i=0;
376
377 vars_emit_constants( _environment );
378
379 if ( _environment->dataSegment ) {
380 outhead1("DATAFIRSTSEGMENT EQU %s", _environment->dataSegment->realName );
381 if ( _environment->readDataUsed && _environment->restoreDynamic ) {
382 outhead0("DATASEGMENTNUMERIC" );
383 DataSegment * actual = _environment->dataSegment;
384 while( actual ) {
385 if ( actual->isNumeric ) {
386 outline2( "fdb $%4.4x, %s", actual->lineNumber, actual->realName );
387 }
388 actual = actual->next;
389 }
390 outline0( "fdb $ffff, DATAPTRE" );
391 }
392 }
393
394 if ( _environment->offsetting ) {
395 Offsetting * actual = _environment->offsetting;
396 while( actual ) {
397 outline0("ALIGN 2");
398 outhead1("OFFSETS%4.4x", actual->size );
399 out0(" fdb " );
400 for( i=0; i<actual->count; ++i ) {
401 out1("$%4.4x", i * actual->size );
402 if ( i < ( actual->count - 1 ) ) {
403 out0(",");
404 } else {
405 outline0("");
406 }
407 }
408 if ( actual->variables ) {
409 if ( actual->count == 1 ) {
410 OffsettingVariable * actualVariable = actual->variables;
411 while( actualVariable ) {
412 if ( actualVariable->sequence ) {
413 outhead1("%soffsetsequence", actualVariable->variable->realName );
414 } else {
415 outhead1("%soffsetframe", actualVariable->variable->realName );
416 }
417 actualVariable = actualVariable->next;
418 }
419 outhead1("fs%4.4xoffsetsequence", actual->size );
420 outhead1("fs%4.4xoffsetframe", actual->size );
421 outline0("RTS");
422 } else {
423 OffsettingVariable * actualVariable = actual->variables;
424 while( actualVariable ) {
425 if ( actualVariable->sequence ) {
426 outhead1("%soffsetsequence", actualVariable->variable->realName );
427 } else {
428 outhead1("%soffsetframe", actualVariable->variable->realName );
429 }
430 actualVariable = actualVariable->next;
431 }
432 outhead1("fs%4.4xoffsetsequence", actual->size );
433 outhead1("fs%4.4xoffsetframe", actual->size );
434 outline1("LDX #OFFSETS%4.4x", actual->size );
435 outline0("LDA #0" );
436 outline0("ABX" );
437 outline0("ABX" );
438 outline0("LDD ,X" );
439 outline0("LEAY D, Y" );
440 outline0("RTS");
441 }
442 }
443 actual = actual->next;
444 }
445
446 int values[MAX_TEMPORARY_STORAGE];
447 char * address[MAX_TEMPORARY_STORAGE];
448
449 actual = _environment->offsetting;
450 int count = 0;
451 while( actual ) {
452 values[count] = actual->size;
453 address[count] = malloc( MAX_TEMPORARY_STORAGE );
454 sprintf( address[count], "fs%4.4xoffsetframe", actual->size );
455 actual = actual->next;
456 ++count;
457 }
458
459 cpu_address_table_build( _environment, "EXECOFFSETS", values, address, count );
460
461 cpu_address_table_lookup( _environment, "EXECOFFSETS", count );
462
463 }
464
465 for(i=0; i<BANK_TYPE_COUNT; ++i) {
466 Bank * actual = _environment->banks[i];
467 while( actual ) {
468 if ( actual->type == BT_VARIABLES ) {
469 // cfgline3("# BANK %s %s AT $%4.4x", BANK_TYPE_AS_STRING[actual->type], actual->name, actual->address);
470 // cfgline2("%s: load = MAIN, type = ro, optional = yes, start = $%4.4x;", actual->name, actual->address);
471 // outhead1(".segment \"%s\"", actual->name);
472 Variable * variable = _environment->variables;
473
474 variable_cleanup_entry( _environment, variable );
475 variable_cleanup_entry_bit( _environment, variable );
476
477 } else if ( actual->type == BT_TEMPORARY ) {
478 // cfgline3("# BANK %s %s AT $%4.4x", BANK_TYPE_AS_STRING[actual->type], actual->name, actual->address);
479 // cfgline2("%s: load = MAIN, type = ro, optional = yes, start = $%4.4x;", actual->name, actual->address);
480 // outhead1(".segment \"%s\"", actual->name);
481
482 for( int j=0; j< (_environment->currentProcedure+1); ++j ) {
483 Variable * variable = _environment->tempVariables[j];
484 variable_cleanup_entry( _environment, variable );
485 variable_cleanup_entry_bit( _environment, variable );
486 }
487
488 Variable * variable = _environment->tempResidentVariables;
489
490 variable_cleanup_entry( _environment, variable );
491 variable_cleanup_entry_bit( _environment, variable );
492
493 } else if ( actual->type == BT_STRINGS ) {
494 // cfgline3("# BANK %s %s AT $%4.4x", BANK_TYPE_AS_STRING[actual->type], actual->name, actual->address);
495 // cfgline2("%s: load = MAIN, type = ro, optional = yes, start = $%4.4x;", actual->name, actual->address);
496 } else {
497
498 }
499 actual = actual->next;
500 }
501 }
502
503 if ( _environment->descriptors ) {
504 outhead0("UDCCHAR" );
505 int i=0,j=0;
506 for(i=0;i<_environment->descriptors->count;++i) {
507 outline1("; $%2.2x ", i);
508 out0(" fcb " );
509 for(j=0;j<7;++j) {
510 out1("$%2.2x,", ((unsigned char)_environment->descriptors->data[_environment->descriptors->first+i].data[j]) );
511 }
512 outline1("$%2.2x", ((unsigned char)_environment->descriptors->data[_environment->descriptors->first+i].data[j]) );
513 }
514 } else {
515 outhead0("UDCCHAR EQU $E000");
516 }
517
518 generate_cgoto_address_table( _environment );
519
520 variable_on_memory_init( _environment, 0 );
521
522 DataSegment * dataSegment = _environment->dataSegment;
523 while( dataSegment ) {
524 int i=0;
525 if ( dataSegment->data ) {
526 out1("%s fcb ", dataSegment->realName );
527 } else {
528 outhead1("%s ", dataSegment->realName );
529 }
530 DataDataSegment * dataDataSegment = dataSegment->data;
531 while( dataDataSegment ) {
532 if ( dataSegment->type ) {
533 if ( dataDataSegment->type == VT_STRING || dataDataSegment->type == VT_DSTRING ) {
534 out1("$%2.2x,", (unsigned char)(dataDataSegment->size) );
535 out1("\"%s\"", dataDataSegment->data );
536 } else {
537 for( i=0; i<(dataDataSegment->size-1); ++i ) {
538 out1("$%2.2x,", (unsigned char)(dataDataSegment->data[i]&0xff) );
539 }
540 out1("$%2.2x", (unsigned char)(dataDataSegment->data[i]&0xff) );
541 }
542 } else {
543 if ( dataDataSegment->type == VT_STRING || dataDataSegment->type == VT_DSTRING ) {
544 out1("$%2.2x,", (unsigned char)(dataDataSegment->type) );
545 out1("$%2.2x,", (unsigned char)(dataDataSegment->size) );
546 out1("\"%s\"", dataDataSegment->data );
547 } else {
548 out1("$%2.2x,", (unsigned char)(dataDataSegment->type) );
549 for( i=0; i<(dataDataSegment->size-1); ++i ) {
550 out1("$%2.2x,", (unsigned char)(dataDataSegment->data[i]&0xff) );
551 }
552 out1("$%2.2x", (unsigned char)(dataDataSegment->data[i]&0xff) );
553 }
554 }
555 dataDataSegment = dataDataSegment->next;
556 if ( dataDataSegment ) {
557 out0(",");
558 }
559 }
560 outline0("");
561 dataSegment = dataSegment->next;
562 }
563
564 if ( _environment->dataNeeded || _environment->dataSegment || _environment->deployed.read_data_unsafe ) {
565 outhead0("DATAPTRE");
566 }
567
568 StaticString * staticStrings = _environment->strings;
569 while( staticStrings ) {
570 outhead2("cstring%d fcb %d", staticStrings->id, (int)strlen(staticStrings->value) );
571 if ( strlen( staticStrings->value ) > 0 ) {
572 outhead1(" fcc %s", escape_newlines( staticStrings->value ) );
573 }
574 staticStrings = staticStrings->next;
575 }
576
577 if ( _environment->bitmaskNeeded ) {
578 outhead0("BITMASK fcb $01,$02,$04,$08,$10,$20,$40,$80");
579 outhead0("BITMASKN fcb $fe,$fd,$fb,$f7,$ef,$df,$bf,$7f");
580 }
581 if ( _environment->deployed.dstring ) {
582 outhead1("max_free_string equ $%4.4x", _environment->dstring.space == 0 ? DSTRING_DEFAULT_SPACE : _environment->dstring.space );
583 }
584
585 buffered_push_output( _environment );
586
587 outline1("ORG $%4.4x", _environment->program.startingAddress);
588 outhead0("CODESTART");
589 outline1("LDS #$%4.4x", _environment->stackStartAddress);
590 outline0("JMP CODESTART2");
591
592 deploy_inplace_preferred( duff, src_hw_6809_duff_asm );
593 deploy_inplace_preferred( msc1, src_hw_6809_msc1_asm );
594 deploy_inplace_preferred( bank, src_hw_mo5_bank_asm );
595
596 for( i=0; i<MAX_RESIDENT_SHAREDS; ++i ) {
597 if ( _environment->maxExpansionBankSize[i] ) {
598 outhead1("BANKWINDOWID%2.2x fcb $FF, $FF", i );
599 outhead2("BANKWINDOW%2.2x rzb %d", i, _environment->maxExpansionBankSize[i]);
600 }
601 }
602
603 if ( _environment->expansionBanks ) {
604
605 outhead0("BANKLOAD");
606
607 Bank * bank = _environment->expansionBanks;
608 while( bank ) {
609 if ( bank->address ) {
610
611 deploy_preferred( duff, src_hw_6809_duff_asm );
612 deploy_preferred( msc1, src_hw_6809_msc1_asm );
613 deploy_preferred( bank, src_hw_mo5_bank_asm );
614
615 outhead1("BANKREADBANK%2.2xXSDR", bank->id );
616 outline1("LDX #BANKWINDOW%2.2x", bank->defaultResident );
617 outhead1("BANKREADBANK%2.2xXS", bank->id );
618 outline1("LDB #$%2.2x", bank->id );
619 outline0("JMP BANKREAD" );
620 _environment->bankAccessOptimization.readn = 1;
621 }
622 bank = bank->next;
623 }
624
625 bank = _environment->expansionBanks;
626
627 while( bank ) {
628
629 if ( bank->address ) {
630 int realBank = ( ( bank->id & 0xfc ) << 2 ) | ( bank->id & 0x03 );
631 realBank = realBank | 0x0c;
632 outline1("fcb $%2.2x", realBank);
633 } else {
634 outline0("fcb $ff");
635 }
636
637 bank = bank->next;
638
639 }
640
641 outline0("fcb $ff");
642 }
643
644 deploy_inplace_preferred( startup, src_hw_mo5_startup_asm);
645 deploy_inplace_preferred( ef936xvars, src_hw_ef936x_vars_asm);
646 deploy_inplace_preferred( ef936xstartup, src_hw_ef936x_startup_asm);
647 deploy_inplace_preferred( putimage, src_hw_ef936x_put_image_asm );
648 deploy_inplace_preferred( getimage, src_hw_ef936x_get_image_asm );
649 deploy_inplace_preferred( keyboard, src_hw_mo5_keyboard_asm );
650 deploy_inplace_preferred( clsGraphic, src_hw_ef936x_cls_asm );
651 deploy_inplace_preferred( textEncodedAt, src_hw_ef936x_text_at_asm );
652 deploy_inplace_preferred( textEncodedAt, src_hw_ef936x_text_at_asm );
653 deploy_inplace_preferred( textEncodedAtGraphicRaw, src_hw_ef936x_text_at_raw_asm );
654 deploy_inplace_preferred( textEncodedAtGraphic, src_hw_ef936x_text_at_asm );
655 deploy_inplace_preferred( clsBox, src_hw_ef936x_cls_box_asm )
656
657 outhead0("CODESTART2");
658
659 buffered_prepend_output( _environment );
660
661}
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
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
int address
Definition ugbc.h:159
int id
Definition ugbc.h:153
struct _Bank * next
Definition ugbc.h:185
int defaultResident
Definition ugbc.h:182
BankType type
Definition ugbc.h:162
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
BankAccessOptimization bankAccessOptimization
Definition ugbc.h:3269
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
Program program
Definition ugbc.h:3179
Variable * tempVariables[MAX_PROCEDURES]
Definition ugbc.h:2606
DataSegment * dataSegment
Definition ugbc.h:2568
FILE * debuggerLabelsFile
Definition ugbc.h:3319
Bank * expansionBanks
Definition ugbc.h:3005
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
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
int startingAddress
Definition ugbc.h:2217
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
VariableType type
Definition ugbc.h:988
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 MAX_RESIDENT_SHAREDS
Definition ugbc.h:572
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 deploy_preferred(s, e)
Definition ugbc.h:4299
#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
#define outhead3(s, a, b, c)
Definition ugbc.h:4249
@ BT_VARIABLES
Definition ugbc.h:126
@ BT_STRINGS
Definition ugbc.h:135
@ 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]