35#if defined(__pc128op__) || defined(__mo5__) || defined(__to8__)
40#if defined(__pc128op__)
42 static RGBi SYSTEM_PALETTE[] = {
43 { 0x00, 0x00, 0x00, 0xff, 0,
"BLACK", 0 },
44 { 0xff, 0xff, 0xff, 0xff, 1,
"WHITE", 1 },
45 { 0x88, 0x00, 0x00, 0xff, 2,
"RED", 2 },
46 { 0xaa, 0xff, 0xe6, 0xff, 3,
"CYAN", 3 },
47 { 0xcc, 0x44, 0xcc, 0xff, 4,
"VIOLET", 4 },
48 { 0x00, 0xcc, 0x55, 0xff, 5,
"GREEN", 5 },
49 { 0x00, 0x00, 0xaa, 0xff, 6,
"BLUE", 6 },
50 { 0xee, 0xee, 0x77, 0xff, 7,
"YELLOW", 7 },
51 { 0xa1, 0x68, 0x3c, 0xff, 8,
"ORANGE", 8 },
52 { 0xdd, 0x88, 0x65, 0xff, 9,
"BROWN", 9 },
53 { 0xff, 0x77, 0x77, 0xff, 10,
"LIGHT RED", 10 },
54 { 0x33, 0x33, 0x33, 0xff, 11,
"DARK GREY", 11 },
55 { 0x77, 0x77, 0x77, 0xff, 12,
"GREY", 12 },
56 { 0xaa, 0xff, 0x66, 0xff, 13,
"LIGHT GREEN", 13 },
57 { 0x00, 0x88, 0xff, 0xff, 14,
"LIGHT BLUE", 14 },
58 { 0xbb, 0xbb, 0xbb, 0xff, 15,
"LIGHT GREY", 15 }
63 static RGBi SYSTEM_PALETTE[] = {
64 { 0x00, 0x00, 0x00, 0xff, 0,
"BLACK", 0 },
65 { 0x88, 0x00, 0x00, 0xff, 1,
"RED", 1 },
66 { 0x00, 0xcc, 0x55, 0xff, 2,
"GREEN", 2 },
67 { 0xee, 0xee, 0x77, 0xff, 3,
"YELLOW", 3 },
68 { 0x00, 0x00, 0xaa, 0xff, 4,
"BLUE", 4 },
69 { 0xcc, 0x44, 0xcc, 0xff, 5,
"VIOLET", 5 },
70 { 0xaa, 0xff, 0xe6, 0xff, 6,
"CYAN", 6 },
71 { 0xff, 0xff, 0xff, 0xff, 7,
"WHITE", 7 },
72 { 0x77, 0x77, 0x77, 0xff, 8,
"GREY", 8 },
73 { 0xff, 0x77, 0x77, 0xff, 9,
"OLD ROSE", 9 },
74 { 0xaa, 0xff, 0x66, 0xff, 10,
"LIGHT GREEN", 10 },
75 { 0xdd, 0x88, 0x65, 0xff, 11,
"SAND", 11 },
76 { 0x00, 0x88, 0xff, 0xff, 12,
"SKY BLUE", 12 },
77 { 0xec, 0x54, 0xe4, 0xff, 13,
"LIGHT MAGENTA", 13 },
78 { 0xee, 0xff, 0xff, 0xff, 14,
"CYAN", 14 },
79 { 0xa1, 0x68, 0x3c, 0xff, 15,
"ORANGE", 15 }
84 static RGBi SYSTEM_PALETTE[] = {
85 { 0x00, 0x00, 0x00, 0xff, 0,
"BLACK", 0 },
86 { 0xff, 0xff, 0xff, 0xff, 1,
"WHITE", 1 },
87 { 0x88, 0x00, 0x00, 0xff, 2,
"RED", 2 },
88 { 0xaa, 0xff, 0xe6, 0xff, 3,
"CYAN", 3 },
89 { 0xcc, 0x44, 0xcc, 0xff, 4,
"VIOLET", 4 },
90 { 0x00, 0xcc, 0x55, 0xff, 5,
"GREEN", 5 },
91 { 0x00, 0x00, 0xaa, 0xff, 6,
"BLUE", 6 },
92 { 0xee, 0xee, 0x77, 0xff, 7,
"YELLOW", 7 },
93 { 0xa1, 0x68, 0x3c, 0xff, 8,
"ORANGE", 8 },
94 { 0xdd, 0x88, 0x65, 0xff, 9,
"BROWN", 9 },
95 { 0xff, 0x77, 0x77, 0xff, 10,
"LIGHT RED", 10 },
96 { 0x33, 0x33, 0x33, 0xff, 11,
"DARK GREY", 11 },
97 { 0x77, 0x77, 0x77, 0xff, 12,
"GREY", 12 },
98 { 0xaa, 0xff, 0x66, 0xff, 13,
"LIGHT GREEN", 13 },
99 { 0x00, 0x88, 0xff, 0xff, 14,
"LIGHT BLUE", 14 },
100 { 0xbb, 0xbb, 0xbb, 0xff, 15,
"LIGHT GREY", 15 }
105static RGBi * commonPalette;
114static int rgbConverterFunction(
int _red,
int _green,
int _blue ) {
116 int value = ( ( ( _blue >> 4 ) & 0x0f ) << 8 ) |
117 ( ( ( _green >> 4 ) & 0x0f ) << 4 ) |
118 ( ( ( _red >> 4 ) & 0x0f ) );
124static void rgbConverterFunctionInverse(
int _value,
unsigned char* _red,
unsigned char* _green,
unsigned char* _blue ) {
126 *_red = (
unsigned char)( _value & 0xf ) << 4;
127 *_green = (
unsigned char)( _value & 0xf0 );
128 *_blue = (
unsigned char)( _value & 0xf00 ) >> 4;
187 outline1(
"LDB #$%2.2x", ( _index & 0x0f ) * 2 );
189 outline1(
"LDD #$%4.4x", _background_color );
190 outline1(
"STD SHADOWPALETTE+$%2.2x", ( _index & 0x0f ) * 2 );
194 rgbConverterFunctionInverse( _background_color, &SYSTEM_PALETTE[_index].red, &SYSTEM_PALETTE[_index].green, &SYSTEM_PALETTE[_index].blue );
202 SYSTEM_PALETTE[_index].index = _index;
203 strcopy( SYSTEM_PALETTE[_index].description,
"custom" );
204 SYSTEM_PALETTE[_index].used = 0;
205 SYSTEM_PALETTE[_index].count = 0;
224 outline1(
"LDD %s", _background_color );
231 outline1(
"LDD %s", _background_color );
248 outline1(
"LDB #$%2.2x", (( _index & 0x0f ) *2) );
250 outline1(
"LDD %s", _background_color );
253 outline1(
"STD SHADOWPALETTE+$%2.2x", ( _index & 0x0f ) * 2 );
273 outline1(
"STD %s", _background_color );
348 int consoleSA = 0x4000;
350 int consoleSA = 0x0000;
378 switch( _screen_mode->
id ) {
518 outline1(
"LDX %4.4x", (_x & 0xffff ) );
519 outline1(
"LDU %4.4x", ( _y & 0xffff ) );
521 outline1(
"LDB #$%2.2x", ( *_c & 0Xff ) );
697 deploy( vScrollText, src_hw_ef936x_vscroll_text_asm );
699 outline1(
"LDA #$%2.2x", ( _direction & 0xff ) );
709 deploy( vScrollText, src_hw_ef936x_vscroll_text_asm );
836extern RGBi * commonPalette;
841static int pc_to_ef936x(
int _pc_color) {
843 double pc_color = _pc_color/255.0;
844 double ef936_color = 15*pow(pc_color, 1.67);
845 return 0x0F & (int)(ef936_color + 0.5);
850static unsigned short df_gamma(
unsigned char c)
853 int ef_vals[16]={0,60,90,110,130,148,165,180,193,205,215,225,230,235,240,255};
856 if((c>=ef_vals[i])&&(c<ef_vals[i+1]))
return i;
870 if ( commonPalette ) {
871 palette = commonPalette;
873 palette = SYSTEM_PALETTE;
876#if defined( __to8__ ) || defined( __mo5__ )
880 rgbi_move( &palette[0], &transposedPalette[8] );
881 rgbi_move( &palette[1], &transposedPalette[10] );
882 rgbi_move( &palette[2], &transposedPalette[12] );
883 rgbi_move( &palette[3], &transposedPalette[14] );
885 rgbi_move( &palette[4], &transposedPalette[0] );
886 rgbi_move( &palette[5], &transposedPalette[2] );
887 rgbi_move( &palette[6], &transposedPalette[4] );
888 rgbi_move( &palette[7], &transposedPalette[6] );
890 palette = transposedPalette;
894 for( i=0; i<15; ++i ) {
897 out4(
"$%1.1x%1.1x%1.1x%1.1x, ",
900 ( ( palette[i].green >> 4 ) & 0x0f ) ,
901 ( ( palette[i].red >> 4 ) & 0x0f )
905 out4(
"$%1.1x%1.1x%1.1x%1.1x, ",
908 ( pc_to_ef936x( palette[i].green >> 4 ) & 0x0f ) ,
909 ( pc_to_ef936x( palette[i].red >> 4 ) & 0x0f )
913 out4(
"$%1.1x%1.1x%1.1x%1.1x, ",
916 ( df_gamma( palette[i].green >> 4 ) & 0x0f ) ,
917 ( df_gamma( palette[i].red >> 4 ) & 0x0f )
922 outline4(
"$%1.1x%1.1x%1.1x%1.1x", 0,
EF936X_COMPONENT_BITMASK * 0x10 | ( ( palette[15].blue >> 4 ) & 0x0f ) , ( ( palette[15].green >> 4 ) & 0x0f ) , ( ( palette[15].red >> 4 ) & 0x0f ) );
934 copperList = copperList->
next;
941 deploy( textHScroll, src_hw_ef936x_hscroll_text_asm );
944 outline1(
"LDA #$%2.2x", ( _direction & 0xff ) );
955 deploy( textHScroll, src_hw_ef936x_hscroll_text_asm );
957 outline1(
"LDA #$%2.2x", ( _direction & 0xff ) );
970 deploy( textCline, src_hw_ef936x_cline_asm );
992 return 3 + 2 * ( ( _width >> 3 ) * _height );
994 return 3 + 2 * ( ( _width >> 3 ) * _height ) ;
997 return 3 + 2 * ( ( _width >> 2 ) * _height ) ;
1007static int calculate_images_size(
Environment * _environment,
int _frames,
int _width,
int _height,
int _mode ) {
1011 return 3 + ( 3 + 2 * ( ( _width >> 3 ) * _height ) ) * _frames;
1013 return 3 + ( 3 + 2 * ( ( _width >> 3 ) * _height ) ) * _frames;
1016 return 3 + ( 3 + 2 * ( ( _width >> 2 ) * _height ) ) * _frames;
1026static int calculate_sequence_size(
Environment * _environment,
int _sequences,
int _frames,
int _width,
int _height,
int _mode ) {
1030 return 3 + ( ( 3 + 2 * ( ( _width >> 3 ) * _height ) ) * _frames ) * _sequences;
1032 return 3 + ( ( 3 + 2 * ( ( _width >> 3 ) * _height ) ) * _frames ) * _sequences;
1035 return 3 + ( ( 3 + 2 * ( ( _width >> 2 ) * _height ) ) * _frames ) * _sequences;
1045static Variable * ef936x_image_converter_bitmap_mode_standard(
Environment * _environment,
char * _source,
int _width,
int _height,
int _depth,
int _offset_x,
int _offset_y,
int _frame_width,
int _frame_height,
int _transparent_color,
int _flags ) {
1048 (void)!_transparent_color;
1056 if (paletteColorCount > 2) {
1062 if ( ! commonPalette ) {
1067 if ( _transparent_color & 0x0f0000 ) {
1070 if ( _transparent_color & 0xf00000 ) {
1072 paletteColorCount = 2;
1084 int mergedCommonPalette = 0;
1088 if ( _transparent_color & 0x0f0000 ) {
1091 if ( _transparent_color & 0xf00000 ) {
1093 mergedCommonPalette = 2;
1115 char * buffer =
malloc ( bufferSize );
1116 memset( buffer, 0, bufferSize );
1119 int image_x, image_y;
1130 *(buffer) = (_frame_width >> 8 ) & 0xff;
1131 *(buffer+1) = (_frame_width ) & 0xff;
1132 *(buffer+2) = _frame_height;
1134 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1137 for (image_y = 0; image_y < _frame_height; ++image_y) {
1138 for (image_x = 0; image_x < _frame_width; ++image_x) {
1142 rgb.
green = *(_source + 1);
1143 rgb.
blue = *(_source + 2);
1145 rgb.
alpha = *(_source + 3);
1149 if ( rgb.
alpha == 0 ) {
1157 if ( _transparent_color & 0x0f0000 ) {
1161 if ( rgb.
alpha < 255 ) {
1164 unsigned int minDistance = 0xffff;
1166 if ( commonPalette[i].alpha < 255 )
continue;
1181 offset = ( image_y * ( _frame_width >> 3 ) ) + ( image_x >> 3 );
1182 bitmask = 1 << ( 7 - (image_x & 0x7) );
1185 *( buffer +
offset + 3) |= bitmask;
1188 *( buffer +
offset + 3) &= ~bitmask;
1196 _source += ( _width - _frame_width ) * _depth;
1214static Variable * ef936x_image_converter_multicolor_mode_standard(
Environment * _environment,
char * _source,
int _width,
int _height,
int _depth,
int _offset_x,
int _offset_y,
int _frame_width,
int _frame_height,
int _transparent_color,
int _flags ) {
1218#if defined( __mo5__ )
1220 RGBi * palette = &SYSTEM_PALETTE[0];
1221 int paletteColorCount = 16;
1222 commonPalette = &SYSTEM_PALETTE[0];
1231 if (paletteColorCount > 16) {
1237 if ( ! commonPalette ) {
1242 if ( ( _transparent_color & 0x0f0000 ) || ( _transparent_color & 0xf00000 ) ) {
1246 if ( _transparent_color & 0x0f0000 ) {
1249 if ( _transparent_color & 0xf00000 ) {
1251 paletteColorCount = 16;
1263 int mergedCommonPalette = 0;
1267 if ( _transparent_color & 0x0f0000 ) {
1270 if ( _transparent_color & 0xf00000 ) {
1272 mergedCommonPalette = 16;
1295 char * buffer =
malloc ( bufferSize );
1296 memset( buffer, 0, bufferSize );
1299 int image_x, image_y;
1305 int offset, offsetc, bitmask;
1310 *(buffer) = (_frame_width >> 8 ) & 0xff;
1311 *(buffer+1) = ( _frame_width ) & 0xff;
1312 *(buffer+2) = _frame_height;
1314 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1317 for (image_y = 0; image_y < _frame_height; ++image_y) {
1318 for (image_x = 0; image_x < _frame_width; image_x+=8) {
1319 int colorIndexes[8];
1320 memset( colorIndexes, 0, 8*
sizeof(
int ) );
1323 for(
int xx = 0; xx<8; ++xx ) {
1326 rgb.
green = *(_source + 1);
1327 rgb.
blue = *(_source + 2);
1329 rgb.
alpha = *(_source + 3);
1333 if ( rgb.
alpha == 0 ) {
1340 if ( _transparent_color & 0x0f0000 ) {
1344 if ( rgb.
alpha < 255 ) {
1345 colorIndexes[xx] = 0;
1347 int minDistance = 9999;
1349 if ( commonPalette[i].alpha < 255 )
continue;
1353 colorIndexes[xx] = i;
1362 int colorIndexesCount[16];
1363 memset( colorIndexesCount, 0, 16*
sizeof(
int ) );
1365 for(
int xx = 0; xx<8; ++xx ) {
1366 ++colorIndexesCount[colorIndexes[xx]];
1369 int colorBackground = 0;
1370 int colorBackgroundMax = 0;
1371 int colorForeground = 0;
1372 int colorForegroundMax = 0;
1377 for(
int xx = 0; xx<16; ++xx ) {
1378 if ( colorIndexesCount[xx] > colorBackgroundMax ) {
1379 colorBackground = xx;
1380 colorBackgroundMax = colorIndexesCount[xx];
1386 colorIndexesCount[colorBackground] = 0;
1388 for(
int xx = 0; xx<16; ++xx ) {
1389 if ( colorIndexesCount[xx] > colorForegroundMax ) {
1390 colorForeground = xx;
1391 colorForegroundMax = colorIndexesCount[xx];
1395 if ( colorForeground == colorBackground ) {
1396 colorForeground = ( colorBackground == 0 ) ? 1 : 0;
1399 for(
int xx = 0; xx<8; ++xx ) {
1400 offset = ( image_y * ( _frame_width >> 3 ) ) + ( image_x >> 3 );
1401 bitmask = 1 << ( 7 - ((image_x+xx) & 0x7) );
1403 if ( colorIndexes[xx] != colorBackground ) {
1405 *( buffer +
offset + 3) |= bitmask;
1408 *( buffer +
offset + 3) &= ~bitmask;
1411 offset = ( image_y * ( _frame_width >> 3 ) ) + ( image_x >> 3 );
1413 bitmask = colorForeground << 4 | ( colorBackground );
1414 *(buffer + 3 + ( ( _frame_width >> 3 ) * _frame_height ) +
offset) = bitmask;
1419 _source += ( _width - _frame_width ) * _depth;
1431static Variable * ef936x_image_converter_multicolor_mode4(
Environment * _environment,
char * _source,
int _width,
int _height,
int _depth,
int _offset_x,
int _offset_y,
int _frame_width,
int _frame_height,
int _transparent_color,
int _flags ) {
1435#if defined( __mo5__ )
1437 RGBi * palette = &SYSTEM_PALETTE[0];
1438 int paletteColorCount = 16;
1439 commonPalette = &SYSTEM_PALETTE[0];
1450 if (paletteColorCount > 4) {
1456 if ( ! commonPalette ) {
1461 if ( ( _transparent_color & 0x0f0000 ) || ( _transparent_color & 0xf00000 ) ) {
1465 if ( _transparent_color & 0x0f0000 ) {
1468 if ( _transparent_color & 0xf00000 ) {
1470 paletteColorCount = 4;
1482 int mergedCommonPalette = 0;
1486 if ( _transparent_color & 0x0f0000 ) {
1489 if ( _transparent_color & 0xf00000 ) {
1491 mergedCommonPalette = 4;
1514 char * buffer =
malloc ( bufferSize );
1515 memset( buffer, 0, bufferSize );
1518 int image_x, image_y;
1524 int offset, offsetc, bitmask;
1529 *(buffer) = ( _frame_width >> 8 ) & 0xff;
1530 *(buffer+1) = ( _frame_width ) & 0xff;
1531 *(buffer+2) = _frame_height;
1533 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1536 for (image_y = 0; image_y < _frame_height; ++image_y) {
1537 for (image_x = 0; image_x < _frame_width; ++image_x) {
1541 rgb.
green = *(_source + 1);
1542 rgb.
blue = *(_source + 2);
1544 rgb.
alpha = *(_source + 3 );
1548 if ( rgb.
alpha == 0 ) {
1554 unsigned int minDistance = 0xffff;
1557 if ( _transparent_color & 0x0f0000 ) {
1563 if ( rgb.
alpha < 255 ) {
1567 if ( commonPalette[i].alpha < 255 )
continue;
1579 bitmask = 1 << ( 7 - (image_x & 0x7) );
1581 *(buffer + 3 + ( image_x >> 3 ) + ( ( _frame_width >> 3 ) * image_y ) ) |= ( ( colorIndex & 0x02 ) == 0x02 ) ? bitmask : 0;
1582 *(buffer + 3 + ( ( _frame_width >> 3 ) * _frame_height ) + ( ( image_x >> 3 ) + ( _frame_width >> 3 ) * image_y ) ) |= ( ( colorIndex & 0x01 ) == 0x01 ) ? bitmask : 0;
1588 _source += ( _width - _frame_width ) * _depth;
1624static Variable * ef936x_image_converter_multicolor_mode16(
Environment * _environment,
char * _source,
int _width,
int _height,
int _depth,
int _offset_x,
int _offset_y,
int _frame_width,
int _frame_height,
int _transparent_color,
int _flags ) {
1628#if defined( __mo5__ )
1630 RGBi * palette = &SYSTEM_PALETTE[0];
1631 int paletteColorCount = 16;
1632 commonPalette = &SYSTEM_PALETTE[0];
1643 if (paletteColorCount > 16) {
1649 if ( ! commonPalette ) {
1653 if ( ( _transparent_color & 0x0f0000 ) || ( _transparent_color & 0xf00000 ) ) {
1657 if ( _transparent_color & 0x0f0000 ) {
1661 if ( _transparent_color & 0xf00000 ) {
1663 paletteColorCount = 16;
1677 int mergedCommonPalette = 0;
1681 if ( _transparent_color & 0x0f0000 ) {
1685 if ( _transparent_color & 0xf00000 ) {
1687 mergedCommonPalette = 16;
1710 char * buffer =
malloc ( bufferSize );
1711 memset( buffer, 0, bufferSize );
1714 int image_x, image_y;
1720 int offset, offsetc, bitmask;
1725 *(buffer) = ( _frame_width >> 8 ) & 0xff;
1726 *(buffer+1) = ( _frame_width ) & 0xff;
1727 *(buffer+2) = _frame_height;
1729 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1732 for (image_y = 0; image_y < _frame_height; ++image_y) {
1733 for (image_x = 0; image_x < _frame_width; ++image_x) {
1737 rgb.
green = *(_source + 1);
1738 rgb.
blue = *(_source + 2);
1740 rgb.
alpha = *(_source + 3);
1744 if ( rgb.
alpha == 0 ) {
1750 int minDistance = 0xffff;
1753 if ( _transparent_color & 0x0f0000 ) {
1759 if ( rgb.
alpha < 255 ) {
1763 if ( commonPalette[i].alpha < 255 )
continue;
1774 bitmask = colorIndex << ( 4 * ( 1 - (image_x & 0x1) ) );
1780 if ( ( ( image_x & 0x03 ) < 0x02 ) ) {
1781 *(buffer + 3 + ( image_x >> 2 ) + ( ( _frame_width >> 2 ) * image_y ) ) |= bitmask;
1783 *(buffer + 3 + ( ( _frame_width >> 2 ) * _frame_height ) + ( ( image_x >> 2 ) + ( _frame_width >> 2 ) * image_y ) ) |= bitmask;
1790 _source += ( _width - _frame_width ) * _depth;
1809Variable *
ef936x_image_converter(
Environment * _environment,
char * _data,
int _width,
int _height,
int _depth,
int _offset_x,
int _offset_y,
int _frame_width,
int _frame_height,
int _mode,
int _transparent_color,
int _flags ) {
1813 return ef936x_image_converter_multicolor_mode_standard( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1815 return ef936x_image_converter_multicolor_mode4( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1818 return ef936x_image_converter_multicolor_mode16( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1830static void ef936x_load_image_address_to_y(
Environment * _environment,
char * _source,
char * _sequence,
char * _frame,
int _frame_size,
int _frame_count ) {
1832 if ( !_sequence && !_frame ) {
1840 if ( strlen(_sequence) == 0 ) {
1843 outline1(
"JSR fs%4.4xoffsetsequence", _frame_count * _frame_size );
1846 if ( strlen(_frame) == 0 ) {
1849 outline1(
"JSR fs%4.4xoffsetframe", _frame_size );
1855 if ( strlen(_frame) == 0 ) {
1858 outline1(
"JSR fs%4.4xoffsetframe", _frame_size );
1867static void ef936x_load_image_address_to_register(
Environment * _environment,
char * _register,
Resource * _source,
char * _sequence,
char * _frame,
int _frame_size,
int _frame_count ) {
1869 if ( !_sequence && !_frame ) {
1885 if ( strlen(_sequence) == 0 ) {
1893 if ( strlen(_frame) == 0 ) {
1903 if ( strlen(_frame) == 0 ) {
1925 if ( _frame_size ) {
1926 ef936x_load_image_address_to_register( _environment, NULL, _image, _sequence, _frame, _frame_size, _frame_count );
2017 if( _flags && ( _environment->
transparencyUsed || strcmp( _flags,
"#PUTIMAGEFLAGS0000" ) ) != 0 ) {
2040 memset( buffer, 0,
size );
2042 *(buffer) = ( _width >> 8 ) & 0xff;
2043 *(buffer+1) = ( _width & 0xff );
2044 *(buffer+2) = _height;
2055 int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
2065 memset( buffer, 0,
size );
2067 *(buffer) = _frames;
2068 *(buffer+1) = ( _width >> 8 ) & 0xff;
2069 *(buffer+2) = ( _width & 0xff );
2070 for(
int i=0; i<_frames; ++i ) {
2071 *(buffer+3+(i*frameSize)) = ( ( _width >> 8 ) & 0xff );
2072 *(buffer+3+(i*frameSize)+1) = ( _width & 0xff );
2073 *(buffer+3+(i*frameSize)+2) = ( _height & 0xff );
2087 int size2 = calculate_sequence_size( _environment, _sequences, _frames, _width, _height, _mode );
2088 int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
2097 char * buffer =
malloc ( size2 );
2098 memset( buffer, 0, size2 );
2100 *(buffer) = _frames;
2101 *(buffer+1) = _width;
2102 *(buffer+2) = _sequences;
2103 for(
int i=0; i<(_frames*_sequences); ++i ) {
2104 *(buffer+3+(i*frameSize)) = ( _width & 0xff );
2105 *(buffer+3+(i*frameSize)+1) = ( ( _width >> 8 ) & 0xff );
2106 *(buffer+3+(i*frameSize)+2) = ( _height & 0xff );
2118void ef936x_get_image(
Environment * _environment,
char * _image,
char * _x,
char * _y,
char * _frame,
char * _sequence,
int _frame_size,
int _frame_count,
int _palette ) {
2123 ef936x_load_image_address_to_y( _environment, _image, _sequence, _frame, _frame_size, _frame_count );
2179 outline1(
"LDA #$%2.2x", _palette );
2190 deploy( textHScroll, src_hw_ef936x_hscroll_text_asm );
2191 deploy( vScrollText, src_hw_ef936x_vscroll_text_asm );
2193 outline1(
"LDA #$%2.2x", (
unsigned char)(_dx&0xff) );
2195 outline1(
"LDA #$%2.2x", (
unsigned char)(_dy&0xff) );
2237 if ( strlen(_sequence) == 0 ) {
2248 outline1(
"JSR fs%4.4xoffsetsequence", _frame_count * _frame_size );
2251 if ( strlen(_frame) == 0 ) {
2262 outline1(
"JSR fs%4.4xoffsetframe", _frame_size );
2268 if ( strlen(_frame) == 0 ) {
2278 outline1(
"JSR fs%4.4xoffsetframe", _frame_size );
2289 if ( strlen(_sequence) == 0 ) {
2293 outline1(
"JSR fs%4.4xoffsetsequence", _frame_count * _frame_size );
2296 if ( strlen(_frame) == 0 ) {
2299 outline1(
"JSR fs%4.4xoffsetframe", _frame_size );
2305 if ( strlen(_frame) == 0 ) {
2308 outline1(
"JSR fs%4.4xoffsetframe", _frame_size );
2321void ef936x_blit_image(
Environment * _environment,
char * _sources[],
int _source_count,
char * _blit,
char * _x,
char * _y,
char * _frame,
char * _sequence,
int _frame_size,
int _frame_count,
int _flags ) {
2324 deploy( blitimage, src_hw_ef936x_blit_image_asm );
2326 if ( _source_count > 2 ) {
2335 outline0(
"STY BLITIMAGEBLITADDR" );
2337 if ( _source_count > 0 ) {
2339 resource.
realName = strdup( _sources[0] );
2341 ef936x_load_image_address_to_register( _environment,
"BLITTMPPTR", &resource, _sequence, _frame, _frame_size, _frame_count );
2347 if ( _source_count > 1 ) {
2349 resource.
realName = strdup( _sources[1] );
2351 ef936x_load_image_address_to_register( _environment,
"BLITTMPPTR2", &resource, _sequence, _frame, _frame_size, _frame_count );
2362 outline1(
"LDA #$%2.2x", ( _flags & 0xff ) );
2364 outline1(
"LDA #$%2.2x", ( (_flags>>8) & 0xff ) );
2379 memcpy( _palette,
palette_match( _palette, paletteColorCount, SYSTEM_PALETTE,
sizeof(SYSTEM_PALETTE) /
sizeof(
RGBi) ), paletteColorCount *
sizeof(
RGBi ) );
2381 int uniquePaletteCount = 0;
2385 return uniquePaletteCount;
2393 if ( strcmp( _direction,
"#FLIPIMAGEDIRECTION0001" ) == 0 || strcmp( _direction,
"#FLIPIMAGEDIRECTION0003" ) == 0 ) {
2394 ef936x_load_image_address_to_register( _environment, NULL, _image, _sequence, _frame, _frame_size, _frame_count );
2395 deploy( flipimagex, src_hw_ef936x_flip_image_x_asm );
2409 ef936x_load_image_address_to_register( _environment, NULL, _image, _sequence, _frame, _frame_size, _frame_count );
2410 deploy( flipimagex, src_hw_ef936x_flip_image_x_asm );
2427 if ( strcmp( _direction,
"#FLIPIMAGEDIRECTION0002" ) == 0 || strcmp( _direction,
"#FLIPIMAGEDIRECTION0003" ) == 0 ) {
2428 ef936x_load_image_address_to_register( _environment, NULL, _image, _sequence, _frame, _frame_size, _frame_count );
2429 deploy( flipimagey, src_hw_ef936x_flip_image_y_asm );
2443 ef936x_load_image_address_to_register( _environment, NULL, _image, _sequence, _frame, _frame_size, _frame_count );
2444 deploy( flipimagey, src_hw_ef936x_flip_image_y_asm );
2465 deploy( fade, src_hw_ef936x_fade_asm );
2479 deploy( fade, src_hw_ef936x_fade_asm );
2493 outline1(
"LDD #$%4.4x", _background_color );
2494 outline1(
"STD COMMONPALETTE+$%2.2x", ( _index & 0x0f ) * 2 );
2504 outline1(
"LDD %s", _background_color );
2511 outline1(
"LDD %s", _background_color );
2512 outline1(
"STD COMMONPALETTE+$%2.2x", ( _index & 0x0f ) * 2 );
void cpu_store_16bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 16 bit
void cpu_move_16bit(Environment *_environment, char *_source, char *_destination)
CPU 6309: emit code to move 16 bit
void cpu_store_8bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 8 bit
int lastUsedSlotInCommonPalette
#define BITMAP_MODE_DEFAULT
Variable * variable_retrieve(Environment *_environment, char *_name)
RGBi * palette_match_hardware_index(RGBi *_source, int _source_size, RGBi *_system, int _system_size)
int reset_screen_mode_selected(Environment *_environment)
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
int rgbi_distance(RGBi *_e1, RGBi *_e2)
Calculate the distance between two colors.
RGBi * palette_shift(RGBi *_source, int _source_size, int _offset)
Shift colors in palette.
RGBi * palette_merge(RGBi *_palette1, int _palette1_size, RGBi *_palette2, int _palette2_size, int *_size)
Make a "palette merge".
void image_converter_asserts_free(Environment *_environment, int _width, int _height, int _offset_x, int _offset_y, int *_frame_width, int *_frame_height)
Variable * variable_import(Environment *_environment, char *_name, VariableType _type, int _size_or_value)
RGBi * palette_promote_color_as_background(int _index, RGBi *_source, int _source_size)
Promote an index color in a palette.
RGBi * malloc_palette(int _size)
Allocate a palette space.
void rgbi_move(RGBi *_source, RGBi *_destination)
void variable_global(Environment *_environment, char *_pattern)
ScreenMode * find_screen_mode_by_suggestion(Environment *_environment, int _bitmap, int _width, int _height, int _colors, int _tile_width, int _tile_height)
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
int rgbi_extract_palette(Environment *_environment, unsigned char *_source, int _width, int _height, int _depth, RGBi _palette[], int _palette_size, int _sorted)
Extract the color palette from the given image.
RGBi * palette_promote_color_as_foreground(int _index, RGBi *_source, int _source_size, int _max_size)
Promote an index color in a palette.
Variable * variable_store(Environment *_environment, char *_destination, unsigned int _value)
Store a direct value to a variable.
RGBi * palette_remove_duplicates(RGBi *_source, int _source_size, int *_unique_size)
Remove duplicates from a palette.
void font_descriptors_init(Environment *_environment, int _embedded_present)
RGBi * palette_match(RGBi *_source, int _source_size, RGBi *_system, int _system_size)
Make a "palette match".
Variable * variable_store_buffer(Environment *_environment, char *_destination, unsigned char *_buffer, int _size, int _at)
void plot(Environment *_environment, char *_x, char *_y, char *_c, int _preserve_color)
void screen_mode(Environment *_environment, int _mode)
Emit ASM code for SCREEN [mode].
void bank_set(Environment *_environment, int _bank)
Emit ASM code for instruction BANK ....
void console_init(Environment *_environment)
Variable * distance(Environment *_environment, char *_x1, char *_y1, char *_x2, char *_y2)
Return the distance between two (screen) positions.
int ef936x_palette_extract(Environment *_environment, char *_data, int _width, int _height, int _depth, int _flags, RGBi *_palette)
void ef936x_sprite_multicolor(Environment *_environment, char *_sprite)
void ef936x_put_image(Environment *_environment, Resource *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_flags)
void ef936x_pset_vars(Environment *_environment, char *_x, char *_y, char *_c)
void ef936x_textmap_at(Environment *_environment, char *_address)
void ef936x_background_color_semivars(Environment *_environment, int _index, char *_background_color)
VIC-II: emit code to change background color
void ef936x_screen_on(Environment *_environment)
void ef936x_calculate_sequence_frame_offset(Environment *_environment, char *_offset, char *_sequence, char *_frame, int _frame_size, int _frame_count)
void ef936x_sprite_data_from(Environment *_environment, char *_sprite, char *_address)
void ef936x_sprite_monocolor(Environment *_environment, char *_sprite)
void ef936x_put_tile(Environment *_environment, char *_tile, char *_x, char *_y)
void ef936x_fade_in(Environment *_environment, char *_period)
void ef936x_tilemap_enable(Environment *_environment, int _width, int _height, int _colors, int _tile_width, int _tile_height)
void ef936x_vertical_scroll(Environment *_environment, char *_displacement)
void ef936x_sprite_priority(Environment *_environment, char *_sprite, char *_priority)
void ef936x_blit_image(Environment *_environment, char *_sources[], int _source_count, char *_blit, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _flags)
void ef936x_bitmap_at(Environment *_environment, char *_address)
Variable * ef936x_new_sequence(Environment *_environment, int _sequences, int _frames, int _width, int _height, int _mode)
void ef936x_put_tiles(Environment *_environment, char *_tile, char *_x, char *_y, char *_w, char *_h)
void ef936x_hscroll_screen(Environment *_environment, int _direction, int _overlap)
void ef936x_calculate_sequence_frame_offset_regy(Environment *_environment, char *_sequence, char *_frame, int _frame_size, int _frame_count)
void ef936x_flip_image(Environment *_environment, Resource *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_direction)
void ef936x_sprite_expand_vertical(Environment *_environment, char *_sprite)
void ef936x_next_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
VIC-II: emit code to wait for next raster irq at different position
int ef936x_image_size(Environment *_environment, int _width, int _height, int _mode)
void ef936x_cline(Environment *_environment, char *_characters)
void ef936x_tile_at(Environment *_environment, char *_x, char *_y, char *_result)
void ef936x_hscroll_line(Environment *_environment, int _direction, int _overlap)
void ef936x_cls_box(Environment *_environment, char *_x1, char *_y1, char *_w, char *_h)
Variable * ef936x_get_raster_line(Environment *_environment)
int ef936x_screen_mode_enable(Environment *_environment, ScreenMode *_screen_mode)
void ef936x_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
VIC-II: emit code to set raster irq
void ef936x_pset_int(Environment *_environment, int _x, int _y, int *_c)
void ef936x_fade_in_color_vars(Environment *_environment, char *_index, char *_background_color)
void ef936x_fade_in_color(Environment *_environment, int _index, int _background_color)
void ef936x_sprite_enable(Environment *_environment, char *_sprite)
void ef936x_get_height(Environment *_environment, char *_result)
void ef936x_tiles_get(Environment *_environment, char *_result)
void ef936x_move_tiles(Environment *_environment, char *_tile, char *_x, char *_y)
void ef936x_slice_image(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
Variable * ef936x_new_images(Environment *_environment, int _frames, int _width, int _height, int _mode)
void ef936x_background_color(Environment *_environment, int _index, int _background_color)
VIC-II: emit code to change background color
void ef936x_pget_color_vars(Environment *_environment, char *_x, char *_y, char *_result)
void ef936x_bitmap_disable(Environment *_environment)
void ef936x_sprite_at(Environment *_environment, char *_sprite, char *_x, char *_y)
void ef936x_sprite_common_color(Environment *_environment, char *_index, char *_common_color)
VIC-II: emit code to change common sprite's color
void ef936x_hit(Environment *_environment, char *_sprite_mask, char *_result)
VIC-II: emit code to check for collision
void ef936x_initialization(Environment *_environment)
void ef936x_fade_out(Environment *_environment, char *_period)
void ef936x_sprite_data_set(Environment *_environment, char *_sprite, char *_address)
void ef936x_screen_rows(Environment *_environment, char *_rows)
Variable * ef936x_new_image(Environment *_environment, int _width, int _height, int _mode)
void ef936x_use_tileset(Environment *_environment, char *_tileset)
void console_calculate_vars(Environment *_environment)
void ef936x_collision(Environment *_environment, char *_sprite_mask, char *_result)
VIC-II: emit code to check for collision
void ef936x_tiles_at(Environment *_environment, char *_address)
void ef936x_next_raster(Environment *_environment)
VIC-II: emit code to wait for next raster irq
void ef936x_text(Environment *_environment, char *_text, char *_text_size, int _raw)
void ef936x_colormap_at(Environment *_environment, char *_address)
void ef936x_finalization(Environment *_environment)
void ef936x_sprite_expand_horizontal(Environment *_environment, char *_sprite)
void ef936x_sprite_disable(Environment *_environment, char *_sprite)
void ef936x_screen_off(Environment *_environment)
void ef936x_background_color_get_vars(Environment *_environment, char *_index, char *_background_color)
VIC-II: emit code to change background color
void ef936x_horizontal_scroll(Environment *_environment, char *_displacement)
void ef936x_screen_columns(Environment *_environment, char *_columns)
void ef936x_bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
void ef936x_sprite_color(Environment *_environment, char *_sprite, char *_color)
void ef936x_background_color_vars(Environment *_environment, char *_index, char *_background_color)
VIC-II: emit code to change background color
void ef936x_sprite_compress_horizontal(Environment *_environment, char *_sprite)
void ef936x_back(Environment *_environment)
void ef936x_get_image(Environment *_environment, char *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _palette)
void ef936x_sprite_compress_vertical(Environment *_environment, char *_sprite)
void ef936x_fade_in_color_semivars(Environment *_environment, int _index, char *_background_color)
void ef936x_cls(Environment *_environment)
void ef936x_get_width(Environment *_environment, char *_result)
void ef936x_bank_select(Environment *_environment, int _bank)
void ef936x_scroll_text(Environment *_environment, int _direction, int _overlap)
Variable * ef936x_image_converter(Environment *_environment, char *_data, int _width, int _height, int _depth, int _offset_x, int _offset_y, int _frame_width, int _frame_height, int _mode, int _transparent_color, int _flags)
void console_calculate(Environment *_environment)
void ef936x_scroll(Environment *_environment, int _dx, int _dy)
void ef936x_border_color(Environment *_environment, char *_border_color)
VIC-II: emit code to change border color
#define BITMAP_MODE_BITMAP_16
#define BITMAP_MODE_80_COLUMN
#define BITMAP_MODE_40_COLUMN
#define BITMAP_MODE_BITMAP_4
#define EF936X_COMPONENT_BITMASK
struct _CopperList * next
RgbConverterFunction currentRgbConverterFunction
TileDescriptors * descriptors
GammaCorrection gammaCorrection
VestigialConfig vestigialConfig
unsigned char * valueBuffer
int initializedByConstant
RGBi originalPalette[MAX_PALETTE]
struct _ScreenMode ScreenMode
#define out4(s, a, b, c, d)
#define CRITICAL_IMAGE_CONVERTER_TOO_COLORS(f)
struct _Resource Resource
struct _RGBi RGBi
Structure to store color components (red, green and blue).
#define adilineendbitmap()
#define WARNING_SCREEN_MODE(v1)
struct _Variable Variable
Structure of a single variable.
#define CRITICAL_PUT_IMAGE_X_UNSUPPORTED(v, t)
struct _Environment Environment
Structure of compilation environment.
#define adiline3(s, a, b, c)
#define CRITICAL_PUT_IMAGE_Y_UNSUPPORTED(v, t)
#define deploy_preferred(s, e)
#define SCREEN_MODE_DEFINE(_id, _bitmap, _width, _height, _colors, _tile_width, _tile_height, _description)
#define CRITICAL_NEW_IMAGES_UNSUPPORTED_MODE(f)
#define CRITICAL_SCREEN_UNSUPPORTED(v)
#define adilinepalette(s, c, p)
#define adilinebeginbitmap(s)
struct _CopperList CopperList
#define outline4(s, a, b, c, d)
#define CRITICAL_NEW_IMAGE_UNSUPPORTED_MODE(f)
#define CRITICAL_BLIT_TOO_MUCH_SOURCES()
char DATATYPE_AS_STRING[][16]
char * strcopy(char *_dest, char *_source)