44static void variable_cleanup_entry_multibyte(
Environment * _environment,
Variable * _first,
int _bank_read_write ) {
60 switch( variable->
type ) {
115 memset(
string, 0, variable->
size + 1 );
118 if ( variable->
size & 0x01 ) {
126 for (i=0; i<(variable->
size-1); ++i ) {
127 if ( ( ( i + 1 ) % 16 ) == 0 ) {
135 if ( variable->
size & 0x01 ) {
143 if ( variable->
size & 0x01 ) {
154 memset(
string, 0, variable->
size + 1 );
157 if ( variable->
size & 0x01 ) {
165 for (i=0; i<(variable->
size-1); ++i ) {
169 if ( variable->
size & 0x01 ) {
207 for (i=0; i<(variable->
size-1); ++i ) {
211 if ( variable->
size & 0x01 ) {
216 }
else if ( variable->
value ) {
221 for(
int i=0; i<(variable->
size/4)-1; ++i ) {
222 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 ) );
224 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 ) );
230 for(
int i=0; i<(variable->
size/2)-1; ++i ) {
231 out2(
"$%2.2x, $%2.2x,", (
unsigned int)( ( variable->
value >> 8 ) & 0xff ), (
unsigned int)( variable->
value & 0xff ) );
233 out2(
"$%2.2x, $%2.2x", (
unsigned int)( ( variable->
value >> 8 ) & 0xff ), (
unsigned int)( variable->
value & 0xff ) );
248 if ( variable->
size & 0x01 ) {
279 if ( variable->
size & 0x01 ) {
290 if ( variable->
size & 0x01 ) {
303 variable = variable->
next;
310static void variable_cleanup_entry_byte(
Environment * _environment,
Variable * _first,
int _bank_read_write ) {
323 switch( variable->
type ) {
392 variable = variable->
next;
398static void variable_cleanup_entry(
Environment * _environment,
Variable * _first,
int _bank_read_write ) {
400 variable_cleanup_entry_multibyte( _environment, _first, _bank_read_write );
401 variable_cleanup_entry_byte( _environment, _first, _bank_read_write );
418 switch( variable->
type ) {
431 memset(
string, 0, variable->
size + 1 );
434 if ( variable->
size & 0x01 ) {
442 for (i=0; i<(variable->
size-1); ++i ) {
443 if ( ( ( i + 1 ) % 16 ) == 0 ) {
451 if ( variable->
size & 0x01 ) {
459 if ( variable->
size & 0x01 ) {
470 memset(
string, 0, variable->
size + 1 );
473 if ( variable->
size & 0x01 ) {
481 for (i=0; i<(variable->
size-1); ++i ) {
485 if ( variable->
size & 0x01 ) {
505 variable = variable->
next;
511static void variable_cleanup_entry_bit(
Environment * _environment,
Variable * _first,
int _bank_read_write ) {
526 switch( variable->
type ) {
534 if ( bitCount == 8 ) {
542 variable = variable->
next;
546 if ( bitCount > 0 ) {
575 actual = actual->
next;
587 for( i=0; i<actual->
count; ++i ) {
589 if ( i < ( actual->
count - 1 ) ) {
596 if ( actual->
count == 1 ) {
598 while( actualVariable ) {
604 actualVariable = actualVariable->
next;
611 while( actualVariable ) {
617 actualVariable = actualVariable->
next;
630 actual = actual->
next;
639 values[count] = actual->
size;
641 sprintf( address[count],
"fs%4.4xoffsetframe", actual->
size );
642 actual = actual->
next;
661 variable_cleanup_entry( _environment, variable, 0 );
662 variable_cleanup_entry_bit( _environment, variable, 0 );
671 variable_cleanup_entry( _environment, variable, 0 );
672 variable_cleanup_entry_bit( _environment, variable, 0 );
677 variable_cleanup_entry( _environment, variable, 0 );
678 variable_cleanup_entry_bit( _environment, variable, 0 );
686 actual = actual->
next;
712 while( dataSegment ) {
714 if ( dataSegment->
data ) {
720 while( dataDataSegment ) {
721 if ( dataSegment->
type ) {
723 out1(
"$%2.2x,", (
unsigned char)(dataDataSegment->
size) );
724 out1(
"\"%s\"", dataDataSegment->
data );
726 for( i=0; i<(dataDataSegment->
size-1); ++i ) {
727 out1(
"$%2.2x,", (
unsigned char)(dataDataSegment->
data[i]&0xff) );
729 out1(
"$%2.2x", (
unsigned char)(dataDataSegment->
data[i]&0xff) );
733 out1(
"$%2.2x,", (
unsigned char)(dataDataSegment->
type) );
734 out1(
"$%2.2x,", (
unsigned char)(dataDataSegment->
size) );
735 out1(
"\"%s\"", dataDataSegment->
data );
737 out1(
"$%2.2x,", (
unsigned char)(dataDataSegment->
type) );
738 for( i=0; i<(dataDataSegment->
size-1); ++i ) {
739 out1(
"$%2.2x,", (
unsigned char)(dataDataSegment->
data[i]&0xff) );
741 out1(
"$%2.2x", (
unsigned char)(dataDataSegment->
data[i]&0xff) );
744 dataDataSegment = dataDataSegment->
next;
745 if ( dataDataSegment ) {
750 dataSegment = dataSegment->
next;
758 while( staticStrings ) {
759 outhead2(
"cstring%d fcb %d", staticStrings->
id, (
int)strlen(staticStrings->
value) );
760 if ( strlen( staticStrings->
value ) > 0 ) {
763 staticStrings = staticStrings->
next;
767 outhead0(
"BITMASK fcb $01,$02,$04,$08,$10,$20,$40,$80");
768 outhead0(
"BITMASKN fcb $fe,$fd,$fb,$f7,$ef,$df,$bf,$7f");
799 outhead1(
"BANKUNCOMPRESS%2.2xXSDR", bank->
id );
813 int page0LastAddressUsed = 0;
818 outhead2(
"BANKWINDOWID%2.2x equ $%4.4x", i, page0LastAddressUsed );
819 page0LastAddressUsed += 2;
822 outhead1(
"BANKWINDOWID%2.2x fcb $FF, $FF", i );
826 outhead2(
"BANKWINDOW%2.2x equ $%4.4x", i, page0LastAddressUsed);
846 variable_cleanup_entry_image( _environment, variable );
847 variable_cleanup_entry( _environment, variable, 1 );
852 variable_cleanup_entry_image( _environment, variable );
853 variable_cleanup_entry( _environment, variable, 1 );
854 variable_cleanup_entry_bit( _environment, variable, 1 );
858 variable_cleanup_entry_image( _environment, variable );
859 variable_cleanup_entry( _environment, variable, 1 );
867 actual = actual->
next;
914 sprintf( bankWindowId,
"BANKWINDOWID%2.2x", i );
void vars_emit_constants(Environment *_environment)
void vars_emit_strips(Environment *_environment, char *_name, Strip *_strips)
void cpu_address_table_build(Environment *_environment, char *_table, int *_values, char *_address[], int _count)
void cpu_store_16bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 16 bit
void cpu_address_table_lookup(Environment *_environment, char *_table, int _count)
void vars_emit_word(Environment *_environment, char *_name, int _value)
void vars_emit_dword(Environment *_environment, char *_name, int _value)
void vars_emit_number(Environment *_environment, char *_name, int _value)
void vars_emit_byte(Environment *_environment, char *_name, int _value)
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.
char BANK_TYPE_AS_STRING[][16]
Description of BANK TYPE, in readable format.
Variable * scancode(Environment *_environment)
#define DSTRING_DEFAULT_SPACE
void generate_cgoto_address_table(Environment *_environment)
void variable_on_memory_init(Environment *_environment, int _imported_too)
#define BITMAP_MODE_BITMAP_16
struct _DataDataSegment * next
struct _DataSegment * next
Variable * tempResidentVariables
BankAccessOptimization bankAccessOptimization
Bank * banks[BANK_TYPE_COUNT]
int maxExpansionBankSize[MAX_RESIDENT_SHAREDS]
Variable * tempVariables[MAX_PROCEDURES]
DataSegment * dataSegment
FILE * debuggerLabelsFile
KeyboardConfig keyboardConfig
int residentDetectionEnabled
TileDescriptors * descriptors
struct _Offsetting * next
OffsettingVariable * variables
struct _Variable * variable
struct _OffsettingVariable * next
struct _StaticString * next
unsigned char * valueBuffer
StaticString * valueString
#define out4(s, a, b, c, d)
#define deploy_inplace_preferred(s, e)
#define BANK_TYPE_COUNT
Maximum number of bank types.
#define MAX_TEMPORARY_STORAGE
struct _Offsetting Offsetting
#define MAX_RESIDENT_SHAREDS
struct _Variable Variable
Structure of a single variable.
#define outline2(s, a, b)
struct _Environment Environment
Structure of compilation environment.
struct _OffsettingVariable OffsettingVariable
#define deploy_preferred(s, e)
#define outhead4(s, a, b, c, d)
#define outhead3(s, a, b, c)
struct _StaticString StaticString
Structure of a single (static) string.
#define outhead2(s, a, b)
#define CRITICAL_DATATYPE_UNSUPPORTED(k, v)
struct _DataDataSegment DataDataSegment
struct _DataSegment DataSegment
struct _Bank Bank
Structure of a single bank.
char DATATYPE_AS_STRING[][16]