38static RGBi SYSTEM_PALETTE[] = {
39 { 0x00, 0x00, 0x00, 0xff, 0,
"BLACK", 0x14 },
40 { 0x00, 0x00, 0x80, 0xff, 1,
"BLUE", 0x04 },
41 { 0x00, 0x00, 0xff, 0xff, 2,
"LIGHT BLUE", 0x15 },
42 { 0x80, 0x00, 0x00, 0xff, 3,
"RED", 0x1c },
43 { 0x80, 0x00, 0x80, 0xff, 4,
"MAGENTA", 0x18 },
44 { 0x80, 0x00, 0xff, 0xff, 5,
"MAUVE", 0x1d },
45 { 0xff, 0x00, 0x00, 0xff, 6,
"LIGHT RED", 0x0c },
46 { 0xff, 0x00, 0x80, 0xff, 7,
"PURPLE", 0x08 },
47 { 0xff, 0x00, 0xff, 0xff, 8,
"LIGHT MAGENTA", 0x0d },
48 { 0x00, 0x80, 0x00, 0xff, 9,
"GREEN", 0x16 },
49 { 0x00, 0x80, 0x80, 0xff, 10,
"CYAN", 0x06 },
50 { 0x00, 0x80, 0xff, 0xff, 11,
"DARK CYAN", 0x17 },
51 { 0x80, 0x80, 0x00, 0xff, 12,
"YELLOW", 0x1e },
52 { 0x80, 0x80, 0x80, 0xff, 13,
"WHITE", 0x00 },
53 { 0x80, 0x80, 0xff, 0xff, 14,
"PASTEL BLUE", 0x5f },
54 { 0xff, 0x80, 0x00, 0xff, 15,
"ORANGE", 0x0e },
55 { 0xff, 0x80, 0x80, 0xff, 16,
"PINK", 0x07 },
56 { 0xff, 0x80, 0xff, 0xff, 17,
"PASTEL MAGENTA", 0x0f },
57 { 0x00, 0xff, 0x00, 0xff, 18,
"LIGHT GREEN", 0x12 },
58 { 0x00, 0xff, 0x80, 0xff, 19,
"SEA GREEN", 0x02 },
59 { 0x00, 0xff, 0xff, 0xff, 20,
"LIGHT CYAN", 0x13 },
60 { 0x80, 0xff, 0x00, 0xff, 21,
"LIME", 0x1a },
61 { 0x80, 0xff, 0x80, 0xff, 22,
"PASTEL GREEN", 0x19 },
62 { 0x80, 0xff, 0xff, 0xff, 23,
"PASTEL CYAN", 0x1b },
63 { 0xff, 0xff, 0x00, 0xff, 24,
"LIGHT YELLOW", 0x0a },
64 { 0xff, 0xff, 0x80, 0xff, 25,
"PASTEL YELLOW", 0x03 },
65 { 0xff, 0xff, 0xff, 0xff, 26,
"LIGHT WHITE", 0x0b },
68static int plotVBase[] = {
69 0xC000, 0xC800, 0xD000, 0xD800, 0xE000, 0xE800, 0xF000, 0xF800,
70 0xC050, 0xC850, 0xD050, 0xD850, 0xE050, 0xE850, 0xF050, 0xF850,
71 0xC0A0, 0xC8A0, 0xD0A0, 0xD8A0, 0xE0A0, 0xE8A0, 0xF0A0, 0xF8A0,
72 0xC0F0, 0xC8F0, 0xD0F0, 0xD8F0, 0xE0F0, 0xE8F0, 0xF0F0, 0xF8F0,
73 0xC140, 0xC940, 0xD140, 0xD940, 0xE140, 0xE940, 0xF140, 0xF940,
74 0xC190, 0xC990, 0xD190, 0xD990, 0xE190, 0xE990, 0xF190, 0xF990,
75 0xC1E0, 0xC9E0, 0xD1E0, 0xD9E0, 0xE1E0, 0xE9E0, 0xF1E0, 0xF9E0,
76 0xC230, 0xCA30, 0xD230, 0xDA30, 0xE230, 0xEA30, 0xF230, 0xFA30,
77 0xC280, 0xCA80, 0xD280, 0xDA80, 0xE280, 0xEA80, 0xF280, 0xFA80,
78 0xC2D0, 0xCAD0, 0xD2D0, 0xDAD0, 0xE2D0, 0xEAD0, 0xF2D0, 0xFAD0,
79 0xC320, 0xCB20, 0xD320, 0xDB20, 0xE320, 0xEB20, 0xF320, 0xFB20,
80 0xC370, 0xCB70, 0xD370, 0xDB70, 0xE370, 0xEB70, 0xF370, 0xFB70,
81 0xC3C0, 0xCBC0, 0xD3C0, 0xDBC0, 0xE3C0, 0xEBC0, 0xF3C0, 0xFBC0,
82 0xC410, 0xCC10, 0xD410, 0xDC10, 0xE410, 0xEC10, 0xF410, 0xFC10,
83 0xC460, 0xCC60, 0xD460, 0xDC60, 0xE460, 0xEC60, 0xF460, 0xFC60,
84 0xC4B0, 0xCCB0, 0xD4B0, 0xDCB0, 0xE4B0, 0xECB0, 0xF4B0, 0xFCB0,
85 0xC500, 0xCD00, 0xD500, 0xDD00, 0xE500, 0xED00, 0xF500, 0xFD00,
86 0xC550, 0xCD50, 0xD550, 0xDD50, 0xE550, 0xED50, 0xF550, 0xFD50,
87 0xC5A0, 0xCDA0, 0xD5A0, 0xDDA0, 0xE5A0, 0xEDA0, 0xF5A0, 0xFDA0,
88 0xC5F0, 0xCDF0, 0xD5F0, 0xDDF0, 0xE5F0, 0xEDF0, 0xF5F0, 0xFDF0,
89 0xC640, 0xCE40, 0xD640, 0xDE40, 0xE640, 0xEE40, 0xF640, 0xFE40,
90 0xC690, 0xCE90, 0xD690, 0xDE90, 0xE690, 0xEE90, 0xF690, 0xFE90,
91 0xC6E0, 0xCEE0, 0xD6E0, 0xDEE0, 0xE6E0, 0xEEE0, 0xF6E0, 0xFEE0,
92 0xC730, 0xCF30, 0xD730, 0xDF30, 0xE730, 0xEF30, 0xF730, 0xFF30,
93 0xC780, 0xCF80, 0xD780, 0xDF80, 0xE780, 0xEF80, 0xF780, 0xFF80
102static RGBi * commonPalette;
135 deploy( joystick, src_hw_cpc_joystick_asm );
152 deploy( joystick, src_hw_cpc_joystick_asm );
169 deploy( joystick, src_hw_cpc_joystick_asm );
190 deploy( joystick, src_hw_cpc_joystick_asm );
291 deploy( joystick, src_hw_cpc_joystick_asm );
331 deploy( joystick, src_hw_cpc_joystick_asm );
409 outline1(
"LD A, (%s)", _border_color);
432 outline1(
"LD A, 0x%2.2x", ( _index & 0x0f ));
434 outline1(
"LD A, 0x%2.2x", ( _background_color & 0x0f ));
459 outline1(
"LD A, (%s)", _background_color);
484 outline1(
"%sbackgroundcolor:", label );
485 outline1(
"LD A, 0x%2.2x", ( _index & 0x0f ));
487 outline1(
"LD A, (%s)", _background_color);
514 outline1(
"LD (%s), A", _background_color);
586static int rgbConverterFunction(
int _red,
int _green,
int _blue ) {
589 unsigned int minDistance = 0xffffffff;
597 for (j = 0; j <
sizeof(SYSTEM_PALETTE)/
sizeof(
RGBi); ++j) {
601 colorIndex = SYSTEM_PALETTE[j].hardwareIndex;
625 outline0(
"CALL CONSOLECALCULATE" );
639 switch( _screen_mode->
id ) {
786 outline1(
"LD A, 0x%2.2x", ( _y & 0xff ) );
788 outline1(
"LD A, 0x%2.2x", ( _x & 0xff ) );
790 outline1(
"LD A, 0x%2.2x", ( ( _x >> 8 ) & 0xff ) );
793 outline1(
"LD A, $%2.2x", ( *_c & 0Xff ) );
975 outline0(
"LD HL, (CURRENTHEIGHT)" );
982 deploy( clsGraphic, src_hw_cpc_cls_graphic_asm );
989 deploy( clsBox, src_hw_cpc_cls_box_asm );
1014 if ( _direction > 0 ) {
1016 outline1(
"LD IYL, $%2.2x", (
unsigned char)(_overlap&0xff) );
1020 outline1(
"LD IYL, $%2.2x", (
unsigned char)(_overlap&0xff) );
1032 outline1(
"LD A, (%s)", _text_size);
1035 deploy( clsGraphic, src_hw_cpc_cls_graphic_asm );
1038 deploy( textEncodedAtGraphic, src_hw_cpc_text_at_graphic_asm );
1228 int defaultPalette[] = {
1235 if ( ! commonPalette ) {
1237 for(
int i=0; i<15; ++i ) {
1238 out1(
"%d,", defaultPalette[i] );
1240 outline1(
"%d", defaultPalette[15] );
1244 out1(
"%d,", commonPalette[i].hardwareIndex );
1247 out1(
"%d,", defaultPalette[i] );
1254 deploy( clsGraphic, src_hw_cpc_cls_graphic_asm );
1262 copperList = copperList->
next;
1272 deploy( textHScrollLine, src_hw_cpc_hscroll_line_asm );
1277 outline1(
"LD A, 0x%2.2x", (
unsigned char)(_direction));
1278 outline1(
"LD IYL, 0x%2.2x", (
unsigned char)(_overlap));
1287 deploy( textHScrollScreen, src_hw_cpc_hscroll_screen_asm );
1289 outline1(
"LD A, 0x%2.2x", (
unsigned char)(_direction));
1290 outline1(
"LD IYL, 0x%2.2x", (
unsigned char)(_overlap));
1303 deploy( textCline, src_hw_cpc_cline_asm );
1305 if ( _characters ) {
1306 outline1(
"LD A, (%s)", _characters);
1320 return 3 + ( ( _width >> 1 ) * _height ) + 16;
1325 return 3 + ( ( _width >> 2 ) * _height ) + 4;
1329 return 3 + ( ( _width >> 3 ) * _height ) + 2;
1336static int calculate_images_size(
Environment * _environment,
int _frames,
int _width,
int _height,
int _mode ) {
1342 return 3 + ( 3 + ( ( _width >> 1 ) * _height ) + 16 ) * _frames;
1347 return 3 + ( 3 + ( ( _width >> 2 ) * _height ) + 4 ) * _frames;
1351 return 3 + ( 3 + ( ( _width >> 3 ) * _height ) + 2 ) * _frames;
1358static int calculate_sequence_size(
Environment * _environment,
int _sequences,
int _frames,
int _width,
int _height,
int _mode ) {
1364 return 3 + ( ( 3 + ( ( _width >> 1 ) * _height ) + 16 ) * _frames ) * _sequences;
1369 return 3 + ( ( 3 + ( ( _width >> 2 ) * _height ) + 4 ) * _frames ) * _sequences;
1373 return 3 + ( ( 3 + ( ( _width >> 3 ) * _height ) + 2 ) * _frames ) * _sequences;
1380static Variable * cpc_image_converter_bitmap_mode_hires(
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 ) {
1383 (void)!_transparent_color;
1389 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
1391 if ( _frame_width % 8 ) {
1392 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
1400 if (paletteColorCount > 2) {
1406 if ( ! commonPalette ) {
1408 commonPalette =
palette_match( palette, paletteColorCount, SYSTEM_PALETTE,
sizeof(SYSTEM_PALETTE) /
sizeof(
RGBi) );
1411 if ( _transparent_color & 0x0f0000 ) {
1414 if ( _transparent_color & 0xf00000 ) {
1416 paletteColorCount = 2;
1424 RGBi * newPalette =
palette_match( palette, paletteColorCount, SYSTEM_PALETTE,
sizeof(SYSTEM_PALETTE) /
sizeof(
RGBi) );
1428 int mergedCommonPalette = 0;
1432 if ( _transparent_color & 0x0f0000 ) {
1435 if ( _transparent_color & 0xf00000 ) {
1437 mergedCommonPalette = 2;
1458 char * buffer =
malloc ( bufferSize );
1461 int image_x, image_y;
1474 *(buffer) = (_frame_width & 0xff);
1475 *(buffer+1) = ( _frame_width >> 8 ) & 0xff;
1476 *(buffer+2) = _frame_height;
1478 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1481 for (image_y = 0; image_y < _frame_height; ++image_y) {
1482 for (image_x = 0; image_x < _frame_width; ++image_x) {
1486 rgb.
green = *(_source + 1);
1487 rgb.
blue = *(_source + 2);
1489 rgb.
alpha = *(_source + 3);
1493 if ( rgb.
alpha == 0 ) {
1499 if ( rgb.
alpha < 255 ) {
1502 int minDistance = 9999;
1516 offset = (image_y *( _frame_width >> 3 ) ) + (image_x >> 3 );
1517 bitmask = 1 << ( 7 - (image_x & 0x7) );
1519 if ( colorIndex == 1 ) {
1520 *( buffer +
offset + 3) |= bitmask;
1522 *( buffer +
offset + 3) &= ~bitmask;
1529 _source += ( _width - _frame_width ) * _depth;
1538 hwIndex = commonPalette[1].hardwareIndex;
1542 *(buffer + 3 + ( ( _frame_width >> 3 ) * _frame_height ) + 1 ) = hwIndex;
1545 hwIndex = commonPalette[0].hardwareIndex;
1549 *(buffer + 3 + ( ( _frame_width >> 3 ) * _frame_height ) ) = hwIndex;
1557static Variable * cpc_image_converter_multicolor_mode_midres(
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 ) {
1563 _width = ( ( ( _width - 1 ) / 4 ) - 1 ) * 4;
1565 if ( _frame_width % 4 ) {
1566 _frame_width = ( ( ( _frame_width - 1 ) / 4 ) - 1 ) * 4;
1574 if (paletteColorCount > 4) {
1580 if ( ! commonPalette ) {
1582 commonPalette =
palette_match( palette, paletteColorCount, SYSTEM_PALETTE,
sizeof(SYSTEM_PALETTE) /
sizeof(
RGBi) );
1584 if ( _transparent_color & 0x0f0000 ) {
1587 if ( _transparent_color & 0xf00000 ) {
1589 paletteColorCount = 4;
1596 RGBi * newPalette =
palette_match( palette, paletteColorCount, SYSTEM_PALETTE,
sizeof(SYSTEM_PALETTE) /
sizeof(
RGBi) );
1600 int mergedCommonPalette = 0;
1604 if ( _transparent_color & 0x0f0000 ) {
1607 if ( _transparent_color & 0xf00000 ) {
1609 mergedCommonPalette = 4;
1630 char * buffer =
malloc ( bufferSize );
1631 memset( buffer, 0, bufferSize );
1634 int image_x, image_y;
1640 int offset, offsetc, bitmask;
1645 *(buffer) = (_frame_width & 0xff);
1646 *(buffer+1) = (_frame_width >> 8 ) & 0xff;
1647 *(buffer+2) = _frame_height;
1649 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1652 for (image_y = 0; image_y < _frame_height; ++image_y) {
1653 for (image_x = 0; image_x < _frame_width; ++image_x) {
1657 rgb.
green = *(_source + 1);
1658 rgb.
blue = *(_source + 2);
1660 rgb.
alpha = *(_source + 3);
1664 if ( rgb.
alpha == 0 ) {
1672 offset = (image_y * ( _frame_width >> 2 ) ) + (image_x>>2);
1676 if ( rgb.
alpha < 255 ) {
1679 int minDistance = 9999;
1691 bitmask = ( ( colorIndex & 0x2 ) >> 1 ) << (3 - ((image_x & 0x3)));
1692 bitmask |= ( ( ( colorIndex & 0x1 ) ) << 4 ) << (3 - ((image_x & 0x3)));
1694 *(buffer + 3 +
offset) |= bitmask;
1700 _source += ( _width - _frame_width ) * _depth;
1708 hwIndex = commonPalette[0].hardwareIndex;
1712 *(buffer + 3 + ( ( _frame_width >> 2 ) * _frame_height ) )= hwIndex;
1715 hwIndex = commonPalette[1].hardwareIndex;
1719 *(buffer + 3 + ( ( _frame_width >> 2 ) * _frame_height ) + 1 ) = hwIndex;
1722 hwIndex = commonPalette[2].hardwareIndex;
1726 *(buffer + 3 + ( ( _frame_width >> 2 ) * _frame_height ) + 2 ) = hwIndex;
1729 hwIndex = commonPalette[3].hardwareIndex;
1733 *(buffer + 3 + ( ( _frame_width >> 2 ) * _frame_height ) + 3 ) = hwIndex;
1741static Variable * cpc_image_converter_multicolor_mode_lores(
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 ) {
1747 _width = ( ( ( _width - 1 ) / 2) - 1 ) * 2;
1749 if ( _frame_width % 2 ) {
1750 _frame_width = ( ( ( _frame_width - 1 ) / 2 ) - 1 ) * 2;
1758 if (paletteColorCount > 16) {
1764 if ( ! commonPalette ) {
1766 commonPalette =
palette_match( palette, paletteColorCount, SYSTEM_PALETTE,
sizeof(SYSTEM_PALETTE) /
sizeof(
RGBi) );
1769 if ( _transparent_color & 0x0f0000 ) {
1772 if ( _transparent_color & 0xf00000 ) {
1774 paletteColorCount = 16;
1782 RGBi * newPalette =
palette_match( palette, paletteColorCount, SYSTEM_PALETTE,
sizeof(SYSTEM_PALETTE) /
sizeof(
RGBi) );
1788 int mergedCommonPalette = 0;
1792 if ( _transparent_color & 0x0f0000 ) {
1795 if ( _transparent_color & 0xf00000 ) {
1797 mergedCommonPalette = 16;
1818 char * buffer =
malloc ( bufferSize );
1819 memset( buffer, 0, bufferSize );
1822 int image_x, image_y;
1828 int offset, offsetc, bitmask;
1833 *(buffer) = (_frame_width & 0xff);
1834 *(buffer+1) = (_frame_width >> 8 ) & 0xff;
1835 *(buffer+2) = _frame_height;
1837 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1840 for (image_y = 0; image_y < _frame_height; ++image_y) {
1841 for (image_x = 0; image_x < _frame_width; ++image_x) {
1845 rgb.
green = *(_source + 1);
1846 rgb.
blue = *(_source + 2);
1848 rgb.
alpha = *(_source + 3);
1852 if ( rgb.
alpha == 0 ) {
1860 offset = (image_y * ( _frame_width >> 1 ) ) + (image_x>>1);
1864 if ( rgb.
alpha < 255 ) {
1867 int minDistance = 9999;
1879 bitmask = ( ( colorIndex & 0x8 ) >> 3 ) << (1 - ((image_x & 0x1)));
1880 bitmask |= ( ( ( colorIndex & 0x2 ) ) << 1 ) << (1 - ((image_x & 0x1)));
1881 bitmask |= ( ( ( colorIndex & 0x4 ) ) << 2 ) << (1 - ((image_x & 0x1)));
1882 bitmask |= ( ( ( colorIndex & 0x1 ) ) << 6 ) << (1 - ((image_x & 0x1)));
1884 *(buffer + 3 +
offset) |= bitmask;
1890 _source += ( _width - _frame_width ) * _depth;
1896 for(
int i=0; i<16; ++i ) {
1899 hwIndex = commonPalette[i].hardwareIndex;
1901 *(buffer + 3 + ( ( _frame_width >> 1 ) * _frame_height ) + i ) = hwIndex;
1910Variable *
cpc_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 ) {
1916 return cpc_image_converter_bitmap_mode_hires( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1920 return cpc_image_converter_multicolor_mode_midres( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1925 return cpc_image_converter_multicolor_mode_lores( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1933static void cpc_load_image_address_to_hl(
Environment * _environment,
char * _source,
char * _sequence,
char * _frame,
int _frame_size,
int _frame_count ) {
1940 if ( strlen(_sequence) == 0 ) {
1944 outline1(
"LD A, (%s)", _sequence );
1949 outline1(
"LD HL, OFFSETS%4.4x", _frame_size * _frame_count );
1961 if ( strlen(_frame) == 0 ) {
1970 outline1(
"LD HL, OFFSETS%4.4x", _frame_size );
1987 if ( strlen(_frame) == 0 ) {
1996 outline1(
"LD HL, OFFSETS%4.4x", _frame_size );
2012static void cpc_load_image_address_to_register(
Environment * _environment,
char * _register,
Resource * _source,
char * _sequence,
char * _frame,
int _frame_size,
int _frame_count ) {
2014 if ( !_sequence && !_frame ) {
2030 if ( strlen(_sequence) == 0 ) {
2033 outline1(
"LD A, (%s)", _sequence );
2036 if ( _frame_size ) {
2037 outline1(
"CALL fs%4.4xoffsetsequence", _frame_size * _frame_count );
2043 if ( strlen(_frame) == 0 ) {
2049 if ( _frame_size ) {
2050 outline1(
"CALL fs%4.4xoffsetframe", _frame_size );
2063 if ( strlen(_frame) == 0 ) {
2069 if ( _frame_size ) {
2070 outline1(
"CALL fs%4.4xoffsetframe", _frame_size );
2081 outline1(
"LD (%s), HL", _register );
2090 deploy( putimage, src_hw_cpc_put_image_asm );
2094 if ( _frame_size ) {
2095 cpc_load_image_address_to_register( _environment, NULL, _image, _sequence, _frame, _frame_size, _frame_count );
2116void cpc_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 ) {
2120 deploy( blitimage, src_hw_cpc_blit_image_asm );
2122 if ( _source_count > 2 ) {
2129 if ( _source_count > 0 ) {
2131 resource.
realName = strdup( _sources[0] );
2134 cpc_load_image_address_to_register( _environment, NULL, &resource, _sequence, _frame, _frame_size, _frame_count );
2143 if ( _source_count > 1 ) {
2145 resource.
realName = strdup( _sources[0] );
2148 cpc_load_image_address_to_register( _environment, NULL, &resource, _sequence, _frame, _frame_size, _frame_count );
2165 outline1(
"LD A, 0x%2.2x", (_flags & 0Xff) );
2167 outline1(
"LD A, 0x%2.2x", ((_flags>>8) & 0Xff) );
2177 deploy( vbl, src_hw_cpc_vbl_asm);
2179 if ( _raster_line ) {
2219 memset( buffer, 0,
size );
2221 *(buffer) = ( _width & 0xff );
2222 *(buffer+1) = ( ( _width >> 8 ) & 0xff );
2223 *(buffer+2) = _height;
2236 int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
2237 int frameSize =
cpc_image_size( _environment, _width, _height, _mode );
2246 memset( buffer, 0,
size );
2248 *(buffer) = _frames;
2249 *(buffer+1) = ( _width & 0xff );
2250 *(buffer+2) = ( _width >> 8 ) & 0xff;
2251 for(
int i=0; i<_frames; ++i ) {
2252 *(buffer+3+(i*frameSize)) = ( _width & 0xff );
2253 *(buffer+3+(i*frameSize)+1) = ( ( _width >> 8 ) & 0xff );
2254 *(buffer+3+(i*frameSize)+2) = ( _height & 0xff );
2270 int size2 = calculate_sequence_size( _environment, _sequences, _frames, _width, _height, _mode );
2271 int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
2272 int frameSize =
cpc_image_size( _environment, _width, _height, _mode );
2280 char * buffer =
malloc ( size2 );
2281 memset( buffer, 0, size2 );
2283 *(buffer) = _frames;
2284 *(buffer+1) = _width;
2285 *(buffer+2) = _sequences;
2286 for(
int i=0; i<(_frames*_sequences); ++i ) {
2287 *(buffer+3+(i*frameSize)) = ( _width & 0xff );
2288 *(buffer+3+(i*frameSize)+1) = ( ( _width >> 8 ) & 0xff );
2289 *(buffer+3+(i*frameSize)+2) = ( _height & 0xff );
2294 result->
size = size2;
2301void cpc_get_image(
Environment * _environment,
char * _image,
char * _x,
char * _y,
char * _frame,
char * _sequence,
int _frame_size,
int _frame_count,
int _palette ) {
2305 deploy( getimage, src_hw_cpc_get_image_asm );
2309 cpc_load_image_address_to_hl( _environment, _image, _sequence, _frame, _frame_size, _frame_count );
2317 outline1(
"LD A, 0x%2.2x", _palette );
2326 deploy( vic2vars, src_hw_cpc_vars_asm);
2328 deploy( textHScrollLine, src_hw_cpc_hscroll_line_asm );
2329 deploy( textHScrollScreen, src_hw_cpc_hscroll_screen_asm );
2333 outline1(
"LD A, 0x%2.2x", (
unsigned char)(_dx&0xff) );
2335 outline1(
"LD A, 0x%2.2x", (
unsigned char)(_dy&0xff) );
2344 deploy( tiles, src_hw_cpc_tiles_asm );
2369 deploy( tiles, src_hw_cpc_tiles_asm );
2407 deploy( tiles, src_hw_cpc_tiles_asm );
2435 deploy( tiles, src_hw_cpc_tiles_asm );
2452 deploy( tiles, src_hw_cpc_tiles_asm );
2486 deploy( duff, src_hw_z80_duff_asm );
2487 deploy( sliceimagecopy, src_hw_cpc_slice_image_copy_asm );
2492 resource.realName = strdup( _image );
2494 cpc_load_image_address_to_register( _environment,
"HL", &resource, _sequence, _frame, _frame_size, _frame_count );
2496 outline1(
"LD DE, %s", _destination );
2506 deploy( duff, src_hw_z80_duff_asm );
2507 deploy( sliceimageextract, src_hw_cpc_slice_image_extract_asm );
2512 resource.realName = strdup( _image );
2514 cpc_load_image_address_to_register( _environment,
"HL", &resource, _sequence, _frame, _frame_size, _frame_count );
2522 outline1(
"LD DE, %s", _destination );
2535 outline1(
"LD (HL), 0x%2.2x", (_destination & 0xff ) );
2537 outline1(
"LD (HL), 0x%2.2x", ((_destination>>8) & 0xff ) );
2547 memcpy( _palette,
palette_match( _palette, paletteColorCount, SYSTEM_PALETTE,
sizeof(SYSTEM_PALETTE) /
sizeof(
RGBi) ), paletteColorCount *
sizeof(
RGBi ) );
2549 int uniquePaletteCount = 0;
2553 return uniquePaletteCount;
2559 deploy( timer, src_hw_z80_timer_asm);
2575 deploy( timer, src_hw_z80_timer_asm);
2592 deploy( timer, src_hw_z80_timer_asm);
2614 deploy( timer, src_hw_z80_timer_asm);
2636 deploy( timer, src_hw_z80_timer_asm);
2680 switch( filename->type ) {
2728 switch( filename->type ) {
2761 if ( !_sequence && !_frame ) {
2769 if ( strlen(_sequence) == 0 ) {
2772 outline1(
"LD A, (%s)", _sequence );
2775 outline1(
"CALL OFFSETS%4.4X", _frame_count * _frame_size );
2778 if ( strlen(_frame) == 0 ) {
2784 outline1(
"CALL OFFSETS%4.4X", _frame_size );
2793 if ( strlen(_frame) == 0 ) {
2799 outline1(
"CALL OFFSETS%4.4X", _frame_size );
2849 deploy( fade, src_hw_cpc_fade_asm );
2855 outline0(
"LD (FADEDURATION), HL" );
2856 outline0(
"LD (FADERESETDURATION), HL" );
2870 outline1(
"LD B, (%s)", _register );
2873 outline0(
"LD HL, FLASHREGISTERADDRESSES" );
2933 switch( filename->type ) {
void cpu_store_16bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 16 bit
void cpu_addressof_16bit(Environment *_environment, char *_source, char *_destination)
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
void cpu_inc_16bit(Environment *_environment, char *_variable)
void cpu_ctoa(Environment *_environment)
void cpu_move_8bit(Environment *_environment, char *_source, char *_destination)
CPU 6309: emit code to move 8 bit
void cpu_dsdescriptor(Environment *_environment, char *_index, char *_address, char *_size)
int lastUsedSlotInCommonPalette
#define BITMAP_MODE_DEFAULT
Variable * variable_retrieve(Environment *_environment, char *_name)
ScreenMode * find_screen_mode_by_id(Environment *_environment, int _id)
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_merge(RGBi *_palette1, int _palette1_size, RGBi *_palette2, int _palette2_size, int *_size)
Make a "palette merge".
void image_converter_asserts_free_height(Environment *_environment, int _width, int _height, int _offset_x, int _offset_y, int *_frame_width, int *_frame_height, int _modulo_x)
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 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".
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
Variable * variable_store_buffer(Environment *_environment, char *_destination, unsigned char *_buffer, int _size, int _at)
void dload(Environment *_environment, char *_filename, char *_offset, char *_address, char *_bank, char *_size)
Emit code for DLOAD(...).
void dsave(Environment *_environment, char *_filename, char *_offset, char *_address, char *_size)
Emit code for DLOAD(...).
void plot(Environment *_environment, char *_x, char *_y, char *_c, int _preserve_color)
void wait_key_or_fire(Environment *_environment, int _port, int _release)
void flash(Environment *_environment, char *_index, char *_register)
void console_init(Environment *_environment)
void cpc_horizontal_scroll(Environment *_environment, char *_displacement)
void cpc_background_color_semivars(Environment *_environment, int _index, char *_background_color)
cpc: emit code to change background color
void cpc_asciicode(Environment *_environment, char *_result)
void cpc_tiles_get(Environment *_environment, char *_result)
Variable * cpc_get_raster_line(Environment *_environment)
void cpc_wait_key(Environment *_environment, int _release)
void cpc_key_state(Environment *_environment, char *_scancode, char *_result)
void cpc_flash_off(Environment *_environment, char *_index)
void cpc_screen_rows(Environment *_environment, char *_rows)
void cpc_chain(Environment *_environment, char *_filename)
Variable * cpc_new_sequence(Environment *_environment, int _sequences, int _frames, int _width, int _height, int _mode)
void cpc_sys_call(Environment *_environment, int _destination)
void cpc_get_image(Environment *_environment, char *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _palette)
void cpc_bank_select(Environment *_environment, int _bank)
void cpc_sprite_common_color(Environment *_environment, char *_index, char *_common_color)
cpc: emit code to change common sprite's color
void cpc_use_tileset(Environment *_environment, char *_tileset)
void cpc_cline(Environment *_environment, char *_characters)
void cpc_joy(Environment *_environment, int _port, char *_value)
void cpc_wait_fire(Environment *_environment, int _port, int _release)
void cpc_tiles_at(Environment *_environment, char *_address)
void cpc_screen_off(Environment *_environment)
void cpc_sprite_expand_horizontal(Environment *_environment, char *_sprite)
void cpc_flash_register(Environment *_environment, char *_index, char *_timer, char *_color)
void cpc_colors_vars(Environment *_environment, char *_foreground_color, char *_background_color)
void cpc_sprite_compress_vertical(Environment *_environment, char *_sprite)
void cpc_back(Environment *_environment)
void cpc_background_color(Environment *_environment, int _index, int _background_color)
cpc: emit code to change background color
void cpc_scroll_text(Environment *_environment, int _direction, int _overlap)
void cpc_busy_wait(Environment *_environment, char *_timing)
void cpc_scroll(Environment *_environment, int _dx, int _dy)
void cpc_pget_color_vars(Environment *_environment, char *_x, char *_y, char *_result)
void cpc_wait_key_or_fire(Environment *_environment, int _port, int _release)
void cpc_hit(Environment *_environment, char *_sprite_mask, char *_result)
cpc: emit code to check for collision
void cpc_bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
void cpc_sprite_disable(Environment *_environment, char *_sprite)
Variable * cpc_new_image(Environment *_environment, int _width, int _height, int _mode)
void cpc_colormap_at(Environment *_environment, char *_address)
void cpc_flash_end(Environment *_environment)
void cpc_initialization(Environment *_environment)
void cpc_wait_key_or_fire_semivar(Environment *_environment, char *_port, int _release)
void cpc_scanshift(Environment *_environment, char *_shifts)
void cpc_key_pressed(Environment *_environment, char *_scancode, char *_result)
void cpc_tilemap_enable(Environment *_environment, int _width, int _height, int _colors, int _tile_width, int _tile_height)
void cpc_pset_vars(Environment *_environment, char *_x, char *_y, char *_c)
void cpc_keyshift(Environment *_environment, char *_shifts)
void cpc_dsave(Environment *_environment, char *_filename, char *_offset, char *_address, char *_size)
void cpc_put_tile(Environment *_environment, char *_tile, char *_x, char *_y)
void cpc_move_tiles(Environment *_environment, char *_tile, char *_x, char *_y)
void cpc_tile_at(Environment *_environment, char *_x, char *_y, char *_result)
void cpc_move_memory_video(Environment *_environment, char *_from, char *_to, char *_size)
void cpc_wait_fire_semivar(Environment *_environment, char *_port, int _release)
Variable * cpc_collision(Environment *_environment, char *_sprite)
cpc: emit code to check for collision
void cpc_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
cpc: emit code to set raster irq
void cpc_screen_on(Environment *_environment)
void cpc_bitmap_disable(Environment *_environment)
void cpc_scancode(Environment *_environment, char *_result)
void cpc_get_width(Environment *_environment, char *_result)
void cpc_timer_set_counter(Environment *_environment, char *_timer, char *_counter)
void cpc_sprite_monocolor(Environment *_environment, char *_sprite)
void cpc_sprite_compress_horizontal(Environment *_environment, char *_sprite)
void cpc_pset_int(Environment *_environment, int _x, int _y, int *_c)
void cpc_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 cpc_slice_image_extract(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
void cpc_next_raster(Environment *_environment)
cpc: emit code to wait for next raster irq
void cpc_timer_set_status_on(Environment *_environment, char *_timer)
void cpc_clear_key(Environment *_environment)
void cpc_get_height(Environment *_environment, char *_result)
Variable * cpc_new_images(Environment *_environment, int _frames, int _width, int _height, int _mode)
void cpc_flash_begin(Environment *_environment, char *_index, char *_register)
void cpc_timer_set_init(Environment *_environment, char *_timer, char *_init)
void cpc_cls(Environment *_environment)
void console_calculate_vars(Environment *_environment)
void cpc_move_video_memory(Environment *_environment, char *_from, char *_to, char *_size)
void cpc_sprite_data_from(Environment *_environment, char *_sprite, char *_address)
void cpc_sprite_expand_vertical(Environment *_environment, char *_sprite)
void cpc_cls_box(Environment *_environment, char *_x1, char *_y1, char *_w, char *_h)
void cpc_sprite_at(Environment *_environment, char *_sprite, char *_x, char *_y)
void cpc_wait_vbl(Environment *_environment, char *_raster_line)
void cpc_sprite_priority(Environment *_environment, char *_sprite, char *_priority)
void cpc_textmap_at(Environment *_environment, char *_address)
void cpc_timer_set_address(Environment *_environment, char *_timer, char *_address)
void cpc_joy_vars(Environment *_environment, char *_port, char *_value)
int cpc_screen_mode_enable(Environment *_environment, ScreenMode *_screen_mode)
void cpc_timer_set_status_off(Environment *_environment, char *_timer)
Variable * cpc_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 cpc_sprite_multicolor(Environment *_environment, char *_sprite)
void cpc_dload(Environment *_environment, char *_filename, char *_offset, char *_address, char *_size)
void cpc_put_key(Environment *_environment, char *_string, char *_size)
int cpc_image_size(Environment *_environment, int _width, int _height, int _mode)
void cpc_flip_image(Environment *_environment, Resource *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_direction)
void cpc_border_color(Environment *_environment, char *_border_color)
cpc: emit code to change border color
void cpc_inkey(Environment *_environment, char *_key)
void cpc_slice_image_copy(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
void cpc_put_image(Environment *_environment, Resource *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_flags)
void cpc_vertical_scroll(Environment *_environment, char *_displacement)
void cpc_next_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
cpc: emit code to wait for next raster irq at different position
void cpc_fade(Environment *_environment, char *_ticks)
void cpc_sprite_data_set(Environment *_environment, char *_sprite, char *_address)
void cpc_put_tiles(Environment *_environment, char *_tile, char *_x, char *_y, char *_w, char *_h)
void cpc_bitmap_at(Environment *_environment, char *_address)
void cpc_hscroll_line(Environment *_environment, int _direction, int _overlap)
void cpc_background_color_get_vars(Environment *_environment, char *_index, char *_background_color)
cpc: emit code to retrieve background color
void cpc_hscroll_screen(Environment *_environment, int _direction, int _overlap)
void cpc_text(Environment *_environment, char *_text, char *_text_size, int _raw)
void cpc_sprite_enable(Environment *_environment, char *_sprite)
void cpc_calculate_sequence_frame_offset(Environment *_environment, char *_offset, char *_sequence, char *_frame, int _frame_size, int _frame_count)
void console_calculate(Environment *_environment)
void cpc_background_color_vars(Environment *_environment, char *_index, char *_background_color)
cpc: emit code to change background color
void cpc_screen_columns(Environment *_environment, char *_columns)
int cpc_palette_extract(Environment *_environment, char *_data, int _width, int _height, int _depth, int _flags, RGBi *_palette)
void cpc_finalization(Environment *_environment)
void cpc_sprite_color(Environment *_environment, char *_sprite, char *_color)
#define BITMAP_MODE_GRAPHIC3
#define BITMAP_MODE_GRAPHIC2
#define CPC_GA_MASK(mask, value)
#define BITMAP_MODE_GRAPHIC1
#define BITMAP_MODE_GRAPHIC0
Variable * distance(Environment *_environment, char *_x1, char *_y1, char *_x2, char *_y2)
Return the distance between two (screen) positions.
struct _CopperList * next
JoystickConfig joystickConfig
RgbConverterFunction currentRgbConverterFunction
KeyboardConfig keyboardConfig
VestigialConfig vestigialConfig
unsigned char * valueBuffer
RGBi originalPalette[MAX_PALETTE]
char rchack_falling_balls_1163
char rchack_pick_the_star_1163
struct _ScreenMode ScreenMode
#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 deploy_deferred(s, e)
struct _Environment Environment
Structure of compilation environment.
#define adiline3(s, a, b, c)
#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 adilinepalette(s, c, p)
#define adilinebeginbitmap(s)
struct _CopperList CopperList
#define CRITICAL_NEW_IMAGE_UNSUPPORTED_MODE(f)
#define CRITICAL_BLIT_TOO_MUCH_SOURCES()