ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
vdc.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#if defined(__c128xx__)
36
37#include "../ugbc.h"
38#include <math.h>
39
40static RGBi SYSTEM_PALETTE[] = {
41 { 0x00, 0x00, 0x00, 0xff, 0, "BLACK" },
42 { 0xff, 0xff, 0xff, 0xff, 1, "WHITE" },
43 { 0x80, 0x00, 0x00, 0xff, 2, "RED" },
44 { 0xaa, 0xff, 0xe6, 0xff, 3, "CYAN" },
45 { 0xcc, 0x44, 0xcc, 0xff, 4, "VIOLET" },
46 { 0x00, 0xcc, 0x55, 0xff, 5, "GREEN" },
47 { 0x00, 0x00, 0xaa, 0xff, 6, "BLUE" },
48 { 0xee, 0xee, 0x77, 0xff, 7, "YELLOW" },
49 { 0xa1, 0x68, 0x3c, 0xff, 8, "ORANGE" },
50 { 0xdd, 0x88, 0x65, 0xff, 9, "BROWN" },
51 { 0xff, 0x77, 0x77, 0xff, 10, "LIGHT_RED" },
52 { 0x33, 0x33, 0x33, 0xff, 11, "DARK_GREY" },
53 { 0x77, 0x77, 0x77, 0xff, 12, "GREY" },
54 { 0xaa, 0xff, 0x66, 0xff, 13, "LIGHT GREEN" },
55 { 0x00, 0x88, 0xff, 0xff, 14, "LIGHT BLUE" },
56 { 0xbb, 0xbb, 0xbb, 0xff, 15, "LIGHT GREY" }
57};
58
59static RGBi * commonPalette;
60static int lastUsedSlotInCommonPalette = 0;
61
62/****************************************************************************
63 * CODE SECTION
64 ****************************************************************************/
65
66RGBi * vdc_image_nearest_system_color( RGBi * _color ) {
67
68 unsigned int minDistance = 0xffff;
69 int colorIndex = 0;
70 for (int j = 0; j < COLOR_COUNT; ++j) {
71 int distance = rgbi_distance(&SYSTEM_PALETTE[j], _color);
72 if (distance < minDistance) {
73 minDistance = distance;
74 colorIndex = j;
75 }
76 }
77
78 return &SYSTEM_PALETTE[colorIndex];
79
80}
81
93static void vdc_image_converter_tile( Environment * _environment, char * _source, char * _dest, int _width, int _depth, int _source_width ) {
94
95 int colorIndexesCount[COLOR_COUNT];
96 memset(colorIndexesCount, 0, COLOR_COUNT * sizeof( int ) );
97 int trans = 0;
98
99 char * source = _source;
100
101 // Clear the box and colors
102 memset( _dest, 0, 9 );
103
104 // Loop for all the box surface
105 for (int y=0; y<8; ++y) {
106 for (int x=0; x<8; ++x) {
107
108 RGBi rgb;
109
110 memset( &rgb, 0, sizeof( RGBi ) );
111
112 // Take the color of the pixel
113 rgb.red = *source;
114 rgb.green = *(source + 1);
115 rgb.blue = *(source + 2);
116 if ( _depth > 3 ) {
117 rgb.alpha = *(_source + 3);
118 } else {
119 rgb.alpha = 255;
120 }
121 if ( rgb.alpha == 0 ) {
122 rgb.red = 0;
123 rgb.green = 0;
124 rgb.blue = 0;
125 }
126
127 if ( rgb.alpha < 255 ) {
128 trans = 1;
129 } else {
130 RGBi *systemRgb = vdc_image_nearest_system_color( &rgb );
131 ++colorIndexesCount[systemRgb->index];
132 }
133
134 source += _depth;
135
136 }
137
138 source += _depth * ( _source_width - 8 );
139
140 }
141
142 int colorBackground = 0;
143 int colorBackgroundMax = 0;
144 int colorForeground = 0;
145 int colorForegroundMax = 0;
146 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
147 if ( colorIndexesCount[xx] > colorBackgroundMax ) {
148 colorBackground = xx;
149 colorBackgroundMax = colorIndexesCount[xx];
150 };
151 }
152
153 colorIndexesCount[colorBackground] = 0;
154
155 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
156 if ( colorIndexesCount[xx] > colorForegroundMax ) {
157 colorForeground = xx;
158 colorForegroundMax = colorIndexesCount[xx];
159 };
160 }
161
162 if ( trans ) {
163 if ( colorForeground == 0 ) {
164 colorForeground = colorBackground;
165 colorBackground = 0;
166 } else {
167 colorBackground = 0;
168 }
169 }
170
171 if ( colorForeground == colorBackground ) {
172 colorForeground = ( colorBackground == 0 ) ? 1 : 0;
173 }
174
175 source = _source;
176
177 for (int y=0; y<8; ++y) {
178 for (int x=0; x<8; ++x) {
179
180 RGBi rgb;
181
182 memset( &rgb, 0, sizeof( RGBi ) );
183
184 rgb.red = *source;
185 rgb.green = *(source + 1);
186 rgb.blue = *(source + 2);
187 if ( _depth > 3 ) {
188 rgb.alpha = *(_source + 3);
189 } else {
190 rgb.alpha = 255;
191 }
192 if ( rgb.alpha == 0 ) {
193 rgb.red = 0;
194 rgb.green = 0;
195 rgb.blue = 0;
196 }
197
198 RGBi *systemRgb = vdc_image_nearest_system_color( &rgb );
199
200 char bitmask = 1 << ( 7 - ((x) & 0x7) );
201
202 if ( rgb.alpha < 255 ) {
203 *( _dest + y ) &= ~bitmask;
204 adilinepixel(colorBackground);
205 } else {
206 if ( systemRgb->index != colorBackground ) {
207 adilinepixel(colorForeground);
208 *( _dest + y ) |= bitmask;
209 // printf("*");
210 } else {
211 adilinepixel(colorBackground);
212 *( _dest + y ) &= ~bitmask;
213 // printf(" ");
214 }
215 }
216
217 source += _depth;
218
219 }
220
221 source += _depth * ( _source_width - 8 );
222
223 }
224
225 *( _dest + 8 ) = ( colorForeground << 4 ) | colorBackground ;
226
227}
228
240static void vdc_image_converter_tiles( Environment * _environment, char * _source, char * _dest, int _width, int _height, int _depth, int _source_width ) {
241
242 int bitmapSize = ( _width>>3 ) * _height;
243 int colormapSize = ( _width>>3 ) * (_height>>3);
244
245 memset( _dest, 0, bitmapSize + colormapSize );
246
247 adilinebeginbitmap("BMD2");
248
249 for( int y=0; y<_height; y+=8 ) {
250 for( int x=0; x<_width; x+=8 ) {
251
252 char * source = _source + ( ( y * _source_width ) + x ) * _depth;
253 char tile[9];
254
255 vdc_image_converter_tile( _environment, source, tile, _width, _depth, _source_width );
256
257 int offset = ((y>>3) * 8 *( _width >> 3 ) ) + ((x>>3) * 8) + ((y) & 0x07);
258 // x = 8, y = 8
259 // offset = ((8 >> 3) * 8 * (16>>3) ) + ((8>>3) * 8) + ((8) & 7)
260 // offset = (1 * 8 * 2 ) + (1 * 8)
261 // offset = 16 + 8 = 24
262
263 char * destBitmap = _dest + offset;
264 char * destColormap = _dest + bitmapSize + ( ( ( y >> 3 ) * ( _width >> 3 ) ) + ( x >> 3 ) );
265 for( int i=0; i<8; ++i ) {
266 *destBitmap = tile[i];
267 ++destBitmap;
268 }
269 // printf("tile at %d,%d color = %2.2x\n", x, y, tile[8] );
270 *destColormap = tile[8];
271 }
272 }
273
275
276}
277
291static void vdc_image_converter_tile_multicolor( Environment * _environment, char * _source, char * _dest, int _width, int _depth, int _background, int _source_width ) {
292
293 int colorIndexesCount[COLOR_COUNT];
294 memset(colorIndexesCount, 0, COLOR_COUNT * sizeof( int ) );
295 int trans = 0;
296
297 char * source = _source;
298
299 // Clear the box and colors
300 memset( _dest, 0, 10 );
301
302 // Loop for all the box surface
303 for (int y=0; y<8; ++y) {
304 for (int x=0; x<4; ++x) {
305
306 RGBi rgb;
307
308 memset( &rgb, 0, sizeof( RGBi ) );
309
310 // Take the color of the pixel
311 rgb.red = *source;
312 rgb.green = *(source + 1);
313 rgb.blue = *(source + 2);
314 if ( _depth > 3 ) {
315 rgb.alpha = *(_source + 3);
316 } else {
317 rgb.alpha = 255;
318 }
319 if ( rgb.alpha == 0 ) {
320 rgb.red = 0;
321 rgb.green = 0;
322 rgb.blue = 0;
323 }
324
325 if ( rgb.alpha < 255 ) {
326 trans = 1;
327 } else {
328
329 RGBi *systemRgb = vdc_image_nearest_system_color( &rgb );
330
331 ++colorIndexesCount[systemRgb->index];
332
333 }
334
335 source += _depth;
336
337 }
338
339 source += _depth * ( _source_width - 4 );
340
341 }
342
343 if ( trans ) {
344 _background = 0;
345 }
346
347 colorIndexesCount[_background] = 0;
348
349 int colorFirst = 0;
350 int colorFirstMax = 0;
351 int colorSecond = 0;
352 int colorSecondMax = 0;
353 int colorThird = 0;
354 int colorThirdMax = 0;
355
356 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
357 if ( colorIndexesCount[xx] > colorFirstMax ) {
358 colorFirst = xx;
359 colorFirstMax = colorIndexesCount[xx];
360 };
361 }
362
363 colorIndexesCount[colorFirst] = 0;
364
365 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
366 if ( colorIndexesCount[xx] > colorSecondMax ) {
367 colorSecond = xx;
368 colorSecondMax = colorIndexesCount[xx];
369 };
370 }
371
372 colorIndexesCount[colorSecond] = 0;
373
374 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
375 if ( colorIndexesCount[xx] > colorThirdMax ) {
376 colorThird = xx;
377 colorThirdMax = colorIndexesCount[xx];
378 };
379 }
380
381 colorIndexesCount[colorThird] = 0;
382
383 source = _source;
384
385 for (int y=0; y<8; ++y) {
386 for (int x=0; x<4; ++x) {
387
388 RGBi rgb;
389
390 memset( &rgb, 0, sizeof( RGBi ) );
391
392 rgb.red = *source;
393 rgb.green = *(source + 1);
394 rgb.blue = *(source + 2);
395 if ( _depth > 3 ) {
396 rgb.alpha = *(_source + 3);
397 } else {
398 rgb.alpha = 255;
399 }
400 if ( rgb.alpha == 0 ) {
401 rgb.red = 0;
402 rgb.green = 0;
403 rgb.blue = 0;
404 }
405
406 char colorIndex = 0;
407
408 if ( rgb.alpha < 255 ) {
409 adilinepixel(_background);
410 colorIndex = 0;
411 } else {
412
413 RGBi *systemRgb = vdc_image_nearest_system_color( &rgb );
414
415 if ( systemRgb->index == colorFirst ) {
416 adilinepixel(colorFirst);
417 colorIndex = 1;
418 } else if ( systemRgb->index == colorSecond ) {
419 adilinepixel(colorSecond);
420 colorIndex = 2;
421 } else if ( systemRgb->index == colorThird ) {
422 adilinepixel(colorThird);
423 colorIndex = 3;
424 } else {
425 adilinepixel(_background);
426 }
427
428 }
429
430 char bitmask = colorIndex << (6 - ((x & 0x3) * 2));
431
432 *(_dest + y) |= bitmask;
433
434 source += _depth;
435
436 }
437
438 source += _depth * ( _source_width - 4 );
439
440 }
441
442 *( _dest + 8 ) = ( colorFirst << 4 ) | colorSecond ;
443 *( _dest + 9 ) = ( _background << 4 ) | colorThird;
444
445}
446
460static void vdc_image_converter_tiles_multicolor( Environment * _environment, char * _source, char * _dest, int _width, int _height, int _depth, int _source_width, int _background ) {
461
462 int bitmapSize = ( _width>>2 ) * _height;
463 int colormap1Size = ( _width>>2 ) * (_height>>3);
464 int colormap2Size = ( _width>>2 ) * (_height>>3);
465
466 memset( _dest, 0, bitmapSize + colormap1Size + colormap2Size );
467
468 adilinebeginbitmap("BMD4");
469
470 for( int y=0; y<_height; y+=8 ) {
471 for( int x=0; x<_width; x+=4 ) {
472
473 char * source = _source + ( ( y * _source_width ) + x ) * _depth;
474 char tile[10];
475
476 vdc_image_converter_tile_multicolor( _environment, source, tile, _width, _depth, _background, _source_width );
477
478 int offset = ((y>>3) * 8 *( _width >> 2 ) ) + ((x>>2) * 8) + ((y) & 0x07);
479
480 char * destBitmap = _dest + offset;
481 char * destColormap1 = _dest + bitmapSize + ( ( ( y >> 3 ) * ( _width >> 2 ) ) + ( x >> 2 ) );
482 char * destColormap2 = _dest + bitmapSize + colormap1Size + ( ( ( y >> 3 ) * ( _width >> 2 ) ) + ( x >> 2 ) );
483 for( int i=0; i<8; ++i ) {
484 *destBitmap = tile[i];
485 ++destBitmap;
486 }
487 *destColormap1 = tile[8];
488 *destColormap2 = tile[9];
489 }
490 }
491
493
494}
495
507Variable * vdc_collision( Environment * _environment, char * _sprite ) {
508
509 Variable * result = variable_temporary( _environment, VT_SBYTE, "(collision result)");
510
511 return result;
512
513}
514
526void vdc_hit( Environment * _environment, char * _sprite_mask, char * _result ) {
527
528 // Generate unique label for ASM code.
530
531}
532
542void vdc_border_color( Environment * _environment, char * _border_color ) {
543
544}
545
556void vdc_background_color( Environment * _environment, int _index, int _background_color ) {
557
558}
559
570void vdc_background_color_vars( Environment * _environment, char * _index, char * _background_color ) {
571
572}
573
584void vdc_background_color_semivars( Environment * _environment, int _index, char * _background_color ) {
585
586}
587
598void vdc_background_color_get_vars( Environment * _environment, char * _index, char * _background_color ) {
599
600}
601
612void vdc_sprite_common_color( Environment * _environment, char * _index, char * _common_color ) {
613
614}
615
631void vdc_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
632
633}
634
645void vdc_next_raster( Environment * _environment ) {
646
647}
648
662void vdc_next_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
663
664}
665
666void vdc_bank_select( Environment * _environment, int _bank ) {
667
668}
669
670static int rgbConverterFunction( int _red, int _green, int _blue ) {
671
672 int colorIndex = 0;
673 unsigned int minDistance = 0xffffffff;
674 int j;
675
676 RGBi rgb;
677 rgb.red = _red;
678 rgb.green = _green;
679 rgb.blue = _blue;
680
681 for (j = 0; j < sizeof(SYSTEM_PALETTE)/sizeof(RGBi); ++j) {
682 int distance = rgbi_distance(&SYSTEM_PALETTE[j], &rgb);
683 if (distance < minDistance) {
684 minDistance = distance;
685 colorIndex = j;
686 }
687 }
688
689 return colorIndex;
690
691}
692
693int vdc_screen_mode_enable( Environment * _environment, ScreenMode * _screen_mode ) {
694
695}
696
697void vdc_bitmap_enable( Environment * _environment, int _width, int _height, int _colors ) {
698
699}
700
701void vdc_bitmap_disable( Environment * _environment ) {
702
703}
704
705void vdc_tilemap_enable( Environment * _environment, int _width, int _height, int _colors, int _tile_width, int _tile_height ) {
706
707}
708
709void vdc_bitmap_at( Environment * _environment, char * _address ) {
710
711}
712
713void vdc_colormap_at( Environment * _environment, char * _address ) {
714
715}
716
717void vdc_textmap_at( Environment * _environment, char * _address ) {
718
719}
720
721void vdc_pset_int( Environment * _environment, int _x, int _y, int *_c ) {
722
723 deploy( vdcvars, src_hw_vdc_vars_asm);
724 deploy( vdcvarsGraphic, src_hw_vdc_vars_graphic_asm );
725 deploy( plot, src_hw_vdc_plot_asm );
726
727}
728
729void vdc_pset_vars( Environment * _environment, char *_x, char *_y, char *_c ) {
730
731 Variable * x = variable_retrieve( _environment, _x );
732 Variable * y = variable_retrieve( _environment, _y );
733
734 deploy( vdcvars, src_hw_vdc_vars_asm);
735 deploy( vdcvarsGraphic, src_hw_vdc_vars_graphic_asm );
736 deploy( plot, src_hw_vdc_plot_asm );
737
738}
739
740void vdc_pget_color_vars( Environment * _environment, char *_x, char *_y, char * _result ) {
741
742 Variable * x = variable_retrieve( _environment, _x );
743 Variable * y = variable_retrieve( _environment, _y );
744 Variable * result = variable_retrieve( _environment, _result );
745
746 deploy( vdcvars, src_hw_vdc_vars_asm);
747 deploy( vdcvarsGraphic, src_hw_vdc_vars_graphic_asm );
748 deploy( plot, src_hw_vdc_plot_asm );
749
750}
751
752void vdc_screen_on( Environment * _environment ) {
753
754}
755
756void vdc_screen_off( Environment * _environment ) {
757
758}
759
760void vdc_screen_rows( Environment * _environment, char * _rows ) {
761
762}
763
764void vdc_screen_columns( Environment * _environment, char * _columns ) {
765
766}
767
768void vdc_sprite_data_set( Environment * _environment, char * _sprite, char * _image ) {
769
770}
771
772void vdc_sprite_data_from( Environment * _environment, char * _sprite, char * _image ) {
773
774 _environment->bitmaskNeeded = 1;
775
776 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
777 Variable * image = variable_retrieve_or_define( _environment, _image, VT_IMAGE, 0 );
778
779 deploy( sprite, src_hw_vdc_sprites_asm );
780
781}
782
783void vdc_sprite_enable( Environment * _environment, char * _sprite ) {
784
785 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
786
787 deploy( sprite, src_hw_vdc_sprites_asm );
788
789}
790
791void vdc_sprite_disable( Environment * _environment, char * _sprite ) {
792
793 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
794
795 deploy( sprite, src_hw_vdc_sprites_asm );
796
797}
798
799void vdc_sprite_at( Environment * _environment, char * _sprite, char * _x, char * _y ) {
800
801 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
802 Variable * x = variable_retrieve_or_define( _environment, _x, VT_POSITION, 0 );
803 Variable * y = variable_retrieve_or_define( _environment, _y, VT_POSITION, 0 );
804
805 deploy( sprite, src_hw_vdc_sprites_asm );
806
807}
808
809void vdc_sprite_expand_vertical( Environment * _environment, char * _sprite ) {
810
811 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
812
813 deploy( sprite, src_hw_vdc_sprites_asm );
814
815}
816
817void vdc_sprite_expand_horizontal( Environment * _environment, char * _sprite ) {
818
819 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
820
821 deploy( sprite, src_hw_vdc_sprites_asm );
822
823}
824
825void vdc_sprite_compress_vertical( Environment * _environment, char * _sprite ) {
826
827 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
828
829 deploy( sprite, src_hw_vdc_sprites_asm );
830
831}
832
833void vdc_sprite_compress_horizontal( Environment * _environment, char * _sprite ) {
834
835 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
836
837 deploy( sprite, src_hw_vdc_sprites_asm );
838
839}
840
841void vdc_sprite_multicolor( Environment * _environment, char * _sprite ) {
842
843 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
844
845 deploy( sprite, src_hw_vdc_sprites_asm );
846
847}
848
849void vdc_sprite_monocolor( Environment * _environment, char * _sprite ) {
850
851 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
852
853 deploy( sprite, src_hw_vdc_sprites_asm );
854
855}
856
857void vdc_sprite_color( Environment * _environment, char * _sprite, char * _color ) {
858
859 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
860 Variable * color = variable_retrieve_or_define( _environment, _color, VT_COLOR, COLOR_WHITE );
861
862 deploy( sprite, src_hw_vdc_sprites_asm );
863
864}
865
866void vdc_sprite_priority( Environment * _environment, char * _sprite, char * _priority ) {
867
868 Variable * sprite = variable_retrieve_or_define( _environment, _sprite, VT_BYTE, 0 );
869 Variable * priority = variable_retrieve_or_define( _environment, _priority, VT_COLOR, COLOR_WHITE );
870
871 deploy( sprite, src_hw_vdc_sprites_asm );
872
873}
874
875void vdc_tiles_at( Environment * _environment, char * _address ) {
876
877}
878
879void vdc_vertical_scroll( Environment * _environment, char * _displacement ) {
880
881}
882
883void vdc_horizontal_scroll( Environment * _environment, char * _displacement ) {
884
885}
886
887void vdc_busy_wait( Environment * _environment, char * _timing ) {
888
889}
890
891void vdc_get_width( Environment * _environment, char *_result ) {
892
893}
894
895void vdc_tiles_get( Environment * _environment, char *_result ) {
896
897}
898
899void vdc_get_height( Environment * _environment, char *_result ) {
900
901}
902
903void vdc_cls( Environment * _environment ) {
904
905}
906
907void vdc_scroll_text( Environment * _environment, int _direction ) {
908
909}
910
911void vdc_text( Environment * _environment, char * _text, char * _text_size, int _raw ) {
912
913 deploy( vdcvars, src_hw_vdc_vars_asm);
914 deploy( vScrollTextUp, src_hw_vdc_vscroll_text_up_asm );
915 deploy( textEncodedAt, src_hw_vdc_text_at_asm );
916
917}
918
919void vdc_initialization( Environment * _environment ) {
920
921}
922
923static RGBi * multicolorSpritePalette[2];
924
925void vdc_finalization( Environment * _environment ) {
926
927 CopperList * copperList = _environment->copperList;
928 if ( copperList ) {
929 while(copperList) {
930 outhead1("COPPERACTIVATE%s:", copperList->name ? copperList->name : "" );
931 outline0("RTS");
932 copperList = copperList->next;
933 }
934 }
935
936}
937
938void vdc_hscroll_line( Environment * _environment, int _direction, int _overlap ) {
939
940 deploy( textHScroll, src_hw_vdc_hscroll_text_asm );
941
942}
943
944void vdc_hscroll_screen( Environment * _environment, int _direction, int _overlap ) {
945
946 deploy( textHScroll, src_hw_vdc_hscroll_text_asm );
947
948}
949
950void vdc_back( Environment * _environment ) {
951
952 deploy( back, src_hw_vdc_back_asm );
953
954}
955
956void vdc_cline( Environment * _environment, char * _characters ) {
957
958 deploy( textCline, src_hw_vdc_cline_asm );
959
960}
961
962static int calculate_image_size( Environment * _environment, int _width, int _height, int _mode ) {
963
964 return 0;
965
966}
967
968Variable * vdc_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 ) {
969
970 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
971
972 return result;
973
974}
975
976Variable * vdc_sprite_converter( Environment * _environment, char * _source, int _width, int _height, int _depth, RGBi * _color, int _flags ) {
977
978 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
979
980 return result;
981
982}
983
984void vdc_put_image( Environment * _environment, char * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _flags ) {
985
986 deploy( vdcvars, src_hw_vdc_vars_asm);
987 deploy( vdcvarsGraphic, src_hw_vdc_vars_graphic_asm );
988 deploy( putimage, src_hw_vdc_put_image_asm );
989
990}
991
992void vdc_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 ) {
993
994 deploy( vdcvars, src_hw_vdc_vars_asm);
995 deploy( vdcvarsGraphic, src_hw_vdc_vars_graphic_asm );
996 deploy( blitimage, src_hw_vdc_blit_image_asm );
997
998}
999
1000void vdc_wait_vbl( Environment * _environment ) {
1001
1002 deploy( vdcvarsGraphic, src_hw_vdc_vars_graphic_asm );
1003 deploy( vbl, src_hw_vdc_vbl_asm);
1004
1005}
1006
1007void vdc_calculate_sequence_frame_offset( Environment * _environment, char * _offset, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
1008
1009}
1010
1011Variable * vdc_new_image( Environment * _environment, int _width, int _height, int _mode ) {
1012
1013 Variable * result = variable_temporary( _environment, VT_IMAGE, "(new image)" );
1014
1015 return result;
1016
1017}
1018
1019Variable * vdc_new_images( Environment * _environment, int _frames, int _width, int _height, int _mode ) {
1020
1021 Variable * result = variable_temporary( _environment, VT_IMAGES, "(new images)" );
1022
1023 result->size = 1;
1024 result->valueBuffer = malloc(1);
1025
1026 return result;
1027
1028}
1029
1030Variable * vdc_new_sequence( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode ) {
1031
1032 Variable * result = variable_temporary( _environment, VT_SEQUENCE, "(new sequence)" );
1033
1034 result->size = 1;
1035 result->valueBuffer = malloc(1);
1036
1037 return result;
1038
1039}
1040
1041void vdc_get_image( Environment * _environment, char * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, int _palette ) {
1042
1043 deploy( vdcvars, src_hw_vdc_vars_asm);
1044 deploy( vdcvarsGraphic, src_hw_vdc_vars_graphic_asm );
1045 deploy( getimage, src_hw_vdc_get_image_asm );
1046
1047}
1048
1049void vdc_scroll( Environment * _environment, int _dx, int _dy ) {
1050
1051 deploy( vdcvars, src_hw_vdc_vars_asm);
1052 deploy( scroll, src_hw_vdc_scroll_asm);
1053 deploy( textHScroll, src_hw_vdc_hscroll_text_asm );
1054 deploy( vScrollTextDown, src_hw_vdc_vscroll_text_down_asm );
1055 deploy( vScrollTextUp, src_hw_vdc_vscroll_text_up_asm );
1056
1057}
1058
1059void vdc_put_tile( Environment * _environment, char * _tile, char * _x, char * _y ) {
1060
1061 deploy( vdcvars, src_hw_vdc_vars_asm);
1062 deploy( tiles, src_hw_vdc_tiles_asm );
1063
1064}
1065
1066void vdc_move_tiles( Environment * _environment, char * _tile, char * _x, char * _y ) {
1067
1068 Variable * tile = variable_retrieve( _environment, _tile );
1069 Variable * x = variable_retrieve( _environment, _x );
1070 Variable * y = variable_retrieve( _environment, _y );
1071
1072 deploy( vdcvars, src_hw_vdc_vars_asm);
1073 deploy( tiles, src_hw_vdc_tiles_asm );
1074
1075}
1076
1077void vdc_put_tiles( Environment * _environment, char * _tile, char * _x, char * _y, char *_w, char *_h ) {
1078
1079 deploy( vdcvars, src_hw_vdc_vars_asm);
1080 deploy( tiles, src_hw_vdc_tiles_asm );
1081
1082}
1083
1084void vdc_tile_at( Environment * _environment, char * _x, char * _y, char * _result ) {
1085
1086 deploy( vdcvars, src_hw_vdc_vars_asm);
1087 deploy( tiles, src_hw_vdc_tiles_asm );
1088
1089}
1090
1091void vdc_use_tileset( Environment * _environment, char * _tileset ) {
1092
1093 deploy( vdcvars, src_hw_vdc_vars_asm);
1094 deploy( tiles, src_hw_vdc_tiles_asm );
1095
1096}
1097
1098Variable * vdc_get_raster_line( Environment * _environment ) {
1099
1100 Variable * result = variable_temporary( _environment, VT_WORD, "(raster line)" );
1101
1102 return result;
1103
1104}
1105
1106void vdc_slice_image( Environment * _environment, char * _image, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _destination ) {
1107
1108}
1109
1110#endif
int lastUsedSlotInCommonPalette
Definition 6847.c:100
#define COLOR_COUNT
Definition 6847.h:72
#define COLOR_WHITE
Definition 6847.h:39
Variable * variable_retrieve(Environment *_environment, char *_name)
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.
Variable * variable_temporary(Environment *_environment, VariableType _type, char *_meaning)
Define a temporary variable.
int offset
Definition _optimizer.c:681
void back(Environment *_environment, char *_color)
Emit ASM code to fill background color.
Definition back.c:53
void color(Environment *_environment, int _index, int _shade)
Emit ASM code for instruction COLOR [int], [int].
Definition color.c:59
void plot(Environment *_environment, char *_x, char *_y, char *_c, int _preserve_color)
Definition plot.c:46
void scroll(Environment *_environment, int _dx, int _dy)
Definition scroll.c:41
Variable * distance(Environment *_environment, char *_x1, char *_y1, char *_x2, char *_y2)
Return the distance between two (screen) positions.
Definition distance.c:76
char * name
Definition ugbc.h:2252
struct _CopperList * next
Definition ugbc.h:2255
int bitmaskNeeded
Definition ugbc.h:2659
CopperList * copperList
Definition ugbc.h:3282
unsigned char red
Definition ugbc.h:433
unsigned char green
Definition ugbc.h:434
unsigned char blue
Definition ugbc.h:435
unsigned char alpha
Definition ugbc.h:436
unsigned char index
Definition ugbc.h:437
unsigned char * valueBuffer
Definition ugbc.h:1061
int size
Definition ugbc.h:1077
void * malloc(YYSIZE_T)
struct _ScreenMode ScreenMode
struct _RGBi RGBi
Structure to store color components (red, green and blue).
#define adilineendbitmap()
Definition ugbc.h:4241
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_WORD
Definition ugbc.h:455
@ VT_POSITION
Definition ugbc.h:468
@ VT_BYTE
Definition ugbc.h:450
@ VT_SBYTE
Definition ugbc.h:452
@ VT_IMAGES
Definition ugbc.h:495
@ VT_COLOR
Definition ugbc.h:471
@ VT_IMAGE
Definition ugbc.h:489
@ VT_SEQUENCE
Definition ugbc.h:513
#define outline0(s)
Definition ugbc.h:4252
#define adilinebeginbitmap(s)
Definition ugbc.h:4231
struct _CopperList CopperList
#define adilinepixel(p)
Definition ugbc.h:4236
#define deploy(s, e)
Definition ugbc.h:4288
#define MAKE_LABEL
Definition ugbc.h:3351
#define outhead1(s, a)
Definition ugbc.h:4247
void vdc_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
void vdc_get_image(Environment *_environment, char *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _palette)
void vdc_background_color_semivars(Environment *_environment, int _index, char *_background_color)
void vdc_sprite_color(Environment *_environment, char *_sprite, char *_color)
Variable * vdc_sprite_converter(Environment *_environment, char *_data, int _width, int _height, int _depth, RGBi *_color, int _flags)
void vdc_next_raster(Environment *_environment)
void vdc_bitmap_disable(Environment *_environment)
void vdc_put_tiles(Environment *_environment, char *_image, char *_x, char *_y, char *_w, char *_h)
void vdc_tiles_get(Environment *_environment, char *_result)
void vdc_finalization(Environment *_environment)
void vdc_tiles_at(Environment *_environment, char *_address)
void vdc_put_tile(Environment *_environment, char *_image, char *_x, char *_y)
void vdc_cline(Environment *_environment, char *_characters)
void vdc_background_color_get_vars(Environment *_environment, char *_index, char *_background_color)
void vdc_sprite_compress_vertical(Environment *_environment, char *_sprite)
void vdc_screen_on(Environment *_environment)
void vdc_tilemap_enable(Environment *_environment, int _width, int _height, int _colors, int _tile_width, int _tile_height)
void vdc_sprite_common_color(Environment *_environment, char *_index, char *_common_color)
void vdc_tile_at(Environment *_environment, char *_x, char *_y, char *_result)
void vdc_wait_vbl(Environment *_environment)
void vdc_hit(Environment *_environment, char *_sprite_mask, char *_result)
void vdc_sprite_compress_horizontal(Environment *_environment, char *_sprite)
void vdc_screen_columns(Environment *_environment, char *_columns)
void vdc_sprite_multicolor(Environment *_environment, char *_sprite)
void vdc_use_tileset(Environment *_environment, char *_tileset)
void vdc_bitmap_at(Environment *_environment, char *_address)
Variable * vdc_new_images(Environment *_environment, int _frames, int _width, int _height, int _mode)
void vdc_sprite_data_from(Environment *_environment, char *_sprite, char *_address)
void vdc_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 vdc_move_tiles(Environment *_environment, char *_image, char *_x, char *_y)
int vdc_screen_mode_enable(Environment *_environment, ScreenMode *_screen_mode)
void vdc_textmap_at(Environment *_environment, char *_address)
void vdc_cls(Environment *_environment)
void vdc_sprite_priority(Environment *_environment, char *_sprite, char *_priority)
Variable * vdc_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 vdc_background_color_vars(Environment *_environment, char *_index, char *_background_color)
Variable * vdc_new_image(Environment *_environment, int _width, int _height, int _mode)
Variable * vdc_collision(Environment *_environment, char *_sprite)
void vdc_sprite_expand_horizontal(Environment *_environment, char *_sprite)
void vdc_screen_off(Environment *_environment)
void vdc_bank_select(Environment *_environment, int _bank)
void vdc_initialization(Environment *_environment)
void vdc_sprite_disable(Environment *_environment, char *_sprite)
void vdc_sprite_at(Environment *_environment, char *_sprite, char *_x, char *_y)
void vdc_scroll_text(Environment *_environment, int _direction, int _overlap)
void vdc_next_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
void vdc_bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
void vdc_horizontal_scroll(Environment *_environment, char *_displacement)
void vdc_slice_image(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
void vdc_put_image(Environment *_environment, char *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_flags)
void vdc_pget_color_vars(Environment *_environment, char *_x, char *_y, char *_result)
void vdc_pset_int(Environment *_environment, int _x, int _y, int *_c)
Variable * vdc_new_sequence(Environment *_environment, int _sequences, int _frames, int _width, int _height, int _mode)
void vdc_hscroll_screen(Environment *_environment, int _direction, int _overlap)
Variable * vdc_get_raster_line(Environment *_environment)
void vdc_busy_wait(Environment *_environment, char *_timing)
void vdc_hscroll_line(Environment *_environment, int _direction, int _overlap)
void vdc_text(Environment *_environment, char *_text, char *_text_size, int _raw)
void vdc_back(Environment *_environment)
void vdc_calculate_sequence_frame_offset(Environment *_environment, char *_offset, char *_sequence, char *_frame, int _frame_size, int _frame_count)
void vdc_pset_vars(Environment *_environment, char *_x, char *_y, char *_c)
void vdc_sprite_data_set(Environment *_environment, char *_sprite, char *_address)
void vdc_scroll(Environment *_environment, int _dx, int _dy)
void vdc_screen_rows(Environment *_environment, char *_rows)
void vdc_colormap_at(Environment *_environment, char *_address)
void vdc_sprite_expand_vertical(Environment *_environment, char *_sprite)
void vdc_sprite_monocolor(Environment *_environment, char *_sprite)
void vdc_get_width(Environment *_environment, char *_result)
void vdc_vertical_scroll(Environment *_environment, char *_displacement)
void vdc_get_height(Environment *_environment, char *_result)
void vdc_sprite_enable(Environment *_environment, char *_sprite)
void vdc_border_color(Environment *_environment, char *_border_color)
void vdc_background_color(Environment *_environment, int _index, int _background_color)