ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
ted.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(__plus4__) || defined(__c16__)
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 { 0xbc, 0x68, 0x59, 0xff, 2, "RED" },
44 { 0x43, 0x97, 0xa6, 0xff, 3, "CYAN" },
45 { 0xbc, 0x52, 0xcc, 0xff, 4, "PURPLE" },
46 { 0x43, 0xad, 0x33, 0xff, 5, "GREEN" },
47 { 0x80, 0x71, 0xcc, 0xff, 6, "BLUE" },
48 { 0x80, 0x8e, 0x33, 0xff, 7, "YELLOW" },
49 { 0xbc, 0x6f, 0x33, 0xff, 8, "ORANGE" },
50 { 0x9e, 0x7f, 0x33, 0xff, 9, "BROWN" },
51 { 0x61, 0x9e, 0x33, 0xff, 10, "YELLOW GREEN" },
52 { 0xbc, 0x61, 0x80, 0xff, 11, "PINK" },
53 { 0x43, 0x9e, 0x80, 0xff, 12, "BLUE GREEN" },
54 { 0x43, 0x90, 0xcc, 0xff, 13, "LIGHT BLUE" },
55 { 0x9e, 0x61, 0xcc, 0xff, 14, "DARK BLUE" },
56 { 0x43, 0xa6, 0x59, 0xff, 15, "LIGHT GREEN" }
57};
58
59static RGBi * commonPalette;
61
62int plotVBase[] = {
63 0x6000+(0*320),0x6000+(1*320),0x6000+(2*320),0x6000+(3*320),
64 0x6000+(4*320),0x6000+(5*320),0x6000+(6*320),0x6000+(7*320),
65 0x6000+(8*320),0x6000+(9*320),0x6000+(10*320),0x6000+(11*320),
66 0x6000+(12*320),0x6000+(13*320),0x6000+(14*320),0x6000+(15*320),
67 0x6000+(16*320),0x6000+(17*320),0x6000+(18*320),0x6000+(19*320),
68 0x6000+(20*320),0x6000+(21*320),0x6000+(22*320),0x6000+(23*320),
69 0x6000+(24*320)
70};
71
72static int plot8[] = {
73 (0*8),(1*8),(2*8),(3*8),(4*8),(5*8),(6*8),(7*8),(8*8),(9*8),
74 (10*8),(11*8),(12*8),(13*8),(14*8),(15*8),(16*8),(17*8),(18*8),(19*8),
75 (20*8),(21*8),(22*8),(23*8),(24*8),(25*8),(26*8),(27*8),(28*8),(29*8),
76 (30*8),(31*8),(32*8),(33*8),(34*8),(35*8),(36*8),(37*8),(38*8),(39*8)
77};
78
79static int plot4[] = {
80 (0*4),(1*4),(2*4),(3*4),(4*4),(5*4),(6*4),(7*4),(8*4),(9*4),
81 (10*4),(11*4),(12*4),(13*4),(14*4),(15*4),(16*4),(17*4),(18*4),(19*4),
82 (20*4),(21*4),(22*4),(23*4),(24*4),(25*4),(26*4),(27*4),(28*4),(29*4),
83 (30*4),(31*4),(32*4),(33*4),(34*4),(35*4),(36*4),(37*4),(38*4),(39*4),
84 (40*4),(41*4),(42*4),(43*4),(44*4),(45*4),(46*4),(47*4),(48*4),(49*4),
85 (50*4),(51*4),(52*4),(53*4),(54*4),(55*4),(56*4),(57*4),(58*4),(59*4),
86 (60*4),(61*4),(62*4),(63*4),(64*4),(65*4),(66*4),(67*4),(68*4),(69*4),
87 (70*4),(71*4),(72*4),(73*4),(74*4),(75*4),(76*4),(77*4),(78*4),(79*4),
88};
89
90/****************************************************************************
91 * CODE SECTION
92 ****************************************************************************/
93
95
96 int minDistance = 0xffff;
97 int colorIndex = 0;
98 for (int j = 0; j < COLOR_COUNT; ++j) {
99 int distance = rgbi_distance(&SYSTEM_PALETTE[j], _color);
100 if (distance < minDistance) {
101 minDistance = distance;
102 colorIndex = j;
103 }
104 }
105
106 return &SYSTEM_PALETTE[colorIndex];
107
108}
109
121static void ted_image_converter_tile( Environment * _environment, char * _source, char * _dest, int _width, int _depth, int _source_width ) {
122
123 int trans = 0;
124 int colorIndexesCount[COLOR_COUNT];
125 memset(colorIndexesCount, 0, COLOR_COUNT * sizeof( int ) );
126
127 char * source = _source;
128
129 // Clear the box and colors
130 memset( _dest, 0, 9 );
131
132 // Loop for all the box surface
133 for (int y=0; y<8; ++y) {
134 for (int x=0; x<8; ++x) {
135
136 RGBi rgb;
137
138 memset( &rgb, 0, sizeof( RGBi ) );
139
140 // Take the color of the pixel
141 rgb.red = *source;
142 rgb.green = *(source + 1);
143 rgb.blue = *(source + 2);
144 if ( _depth > 3 ) {
145 rgb.alpha = *(_source + 3);
146 } else {
147 rgb.alpha = 255;
148 }
149 if ( rgb.alpha == 0 ) {
150 rgb.red = 0;
151 rgb.green = 0;
152 rgb.blue = 0;
153 }
154
155 if ( rgb.alpha < 255 ) {
156 trans = 1;
157 } else {
158 RGBi *systemRgb = ted_image_nearest_system_color( &rgb );
159 ++colorIndexesCount[systemRgb->index];
160 }
161
162 source += _depth;
163
164 }
165
166 source += _depth * ( _source_width - 8 );
167
168 }
169
170 int colorBackground = 0;
171 int colorBackgroundMax = 0;
172 int colorForeground = 0;
173 int colorForegroundMax = 0;
174 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
175 if ( colorIndexesCount[xx] > colorBackgroundMax ) {
176 colorBackground = xx;
177 colorBackgroundMax = colorIndexesCount[xx];
178 };
179 }
180
181 colorIndexesCount[colorBackground] = 0;
182
183 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
184 if ( colorIndexesCount[xx] > colorForegroundMax ) {
185 colorForeground = xx;
186 colorForegroundMax = colorIndexesCount[xx];
187 };
188 }
189
190 if ( trans ) {
191 if ( colorForeground == 0 ) {
192 colorForeground = colorBackground;
193 colorBackground = 0;
194 } else {
195 colorBackground = 0;
196 }
197 }
198
199 if ( colorForeground == colorBackground ) {
200 colorForeground = ( colorBackground == 0 ) ? 1 : 0;
201 }
202
203 source = _source;
204
205 for (int y=0; y<8; ++y) {
206 for (int x=0; x<8; ++x) {
207
208 RGBi rgb;
209
210 memset( &rgb, 0, sizeof( RGBi ) );
211
212 rgb.red = *source;
213 rgb.green = *(source + 1);
214 rgb.blue = *(source + 2);
215 if ( _depth > 3 ) {
216 rgb.alpha = *(_source + 3);
217 } else {
218 rgb.alpha = 255;
219 }
220 if ( rgb.alpha == 0 ) {
221 rgb.red = 0;
222 rgb.green = 0;
223 rgb.blue = 0;
224 }
225
226 RGBi *systemRgb = ted_image_nearest_system_color( &rgb );
227
228 char bitmask = 1 << ( 7 - ((x) & 0x7) );
229
230 if ( rgb.alpha < 255 ) {
231 *( _dest + y ) &= ~bitmask;
232 adilinepixel(colorBackground);
233 } else {
234 if ( systemRgb->index != colorBackground ) {
235 adilinepixel(colorForeground);
236 *( _dest + y ) |= bitmask;
237 // printf("*");
238 } else {
239 adilinepixel(colorBackground);
240 *( _dest + y ) &= ~bitmask;
241 // printf(" ");
242 }
243 }
244
245 source += _depth;
246
247 }
248
249 source += _depth * ( _source_width - 8 );
250
251 }
252
253 *( _dest + 8 ) = ( colorForeground << 4 ) | colorBackground ;
254
255 // printf( "%2.2x ", *( _dest + 8 ) );
256
257}
258
270static void ted_image_converter_tiles( Environment * _environment, char * _source, char * _dest, int _width, int _height, int _depth, int _source_width ) {
271
272 int bitmapSize = ( _width>>3 ) * _height;
273 int colormapSize = ( _width>>3 ) * (_height>>3);
274
275 memset( _dest, 0, bitmapSize + colormapSize );
276
277 adilinebeginbitmap("BMD2");
278
279 for( int y=0; y<_height; y+=8 ) {
280 for( int x=0; x<_width; x+=8 ) {
281
282 char * source = _source + ( ( y * _source_width ) + x ) * _depth;
283 char tile[9];
284
285 ted_image_converter_tile( _environment, source, tile, _width, _depth, _source_width );
286
287 int offset = ((y>>3) * 8 *( _width >> 3 ) ) + ((x>>3) * 8) + ((y) & 0x07);
288 // x = 8, y = 8
289 // offset = ((8 >> 3) * 8 * (16>>3) ) + ((8>>3) * 8) + ((8) & 7)
290 // offset = (1 * 8 * 2 ) + (1 * 8)
291 // offset = 16 + 8 = 24
292
293 char * destBitmap = _dest + offset;
294 char * destColormap = _dest + bitmapSize + ( ( ( y >> 3 ) * ( _width >> 3 ) ) + ( x >> 3 ) );
295 for( int i=0; i<8; ++i ) {
296 *destBitmap = tile[i];
297 ++destBitmap;
298 }
299 // printf("tile at %d,%d color = %2.2x\n", x, y, (unsigned char)(tile[8]) );
300 *destColormap = tile[8];
301 }
302 }
303
305
306}
307
321static void ted_image_converter_tile_multicolor( Environment * _environment, char * _source, char * _dest, int _width, int _depth, int _background, int _source_width ) {
322
323 int colorIndexesCount[COLOR_COUNT];
324 memset(colorIndexesCount, 0, COLOR_COUNT * sizeof( int ) );
325
326 char * source = _source;
327
328 // Clear the box and colors
329 memset( _dest, 0, 10 );
330
331 // Loop for all the box surface
332 for (int y=0; y<8; ++y) {
333 for (int x=0; x<4; ++x) {
334
335 RGBi rgb;
336
337 memset( &rgb, 0, sizeof( RGBi ) );
338
339 // Take the color of the pixel
340 rgb.red = *source;
341 rgb.green = *(source + 1);
342 rgb.blue = *(source + 2);
343 if ( _depth > 3 ) {
344 rgb.alpha = *(_source + 3);
345 } else {
346 rgb.alpha = 255;
347 }
348 if ( rgb.alpha == 0 ) {
349 rgb.red = 0;
350 rgb.green = 0;
351 rgb.blue = 0;
352 }
353
354 RGBi *systemRgb = ted_image_nearest_system_color( &rgb );
355
356 ++colorIndexesCount[systemRgb->index];
357
358 source += _depth;
359
360 }
361
362 source += 3 * ( _source_width - 4 );
363
364 }
365
366 colorIndexesCount[_background] = 0;
367
368 int colorFirst = 0;
369 int colorFirstMax = 0;
370 int colorSecond = 0;
371 int colorSecondMax = 0;
372 int colorThird = 0;
373 int colorThirdMax = 0;
374
375 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
376 if ( colorIndexesCount[xx] > colorFirstMax ) {
377 colorFirst = xx;
378 colorFirstMax = colorIndexesCount[xx];
379 };
380 }
381
382 colorIndexesCount[colorFirst] = 0;
383
384 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
385 if ( colorIndexesCount[xx] > colorSecondMax ) {
386 colorSecond = xx;
387 colorSecondMax = colorIndexesCount[xx];
388 };
389 }
390
391 colorIndexesCount[colorSecond] = 0;
392
393 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
394 if ( colorIndexesCount[xx] > colorThirdMax ) {
395 colorThird = xx;
396 colorThirdMax = colorIndexesCount[xx];
397 };
398 }
399
400 colorIndexesCount[colorThird] = 0;
401
402 source = _source;
403
404 for (int y=0; y<8; ++y) {
405 for (int x=0; x<4; ++x) {
406
407 RGBi rgb;
408
409 memset( &rgb, 0, sizeof( RGBi ) );
410
411 rgb.red = *source;
412 rgb.green = *(source + 1);
413 rgb.blue = *(source + 2);
414 if ( _depth > 3 ) {
415 rgb.alpha = *(_source + 3);
416 } else {
417 rgb.alpha = 255;
418 }
419 if ( rgb.alpha == 0 ) {
420 rgb.red = 0;
421 rgb.green = 0;
422 rgb.blue = 0;
423 }
424
425 RGBi *systemRgb = ted_image_nearest_system_color( &rgb );
426
427 char colorIndex = 0;
428
429 if ( rgb.alpha < 255 ) {
430 adilinepixel(_background);
431 colorIndex = 0;
432 } else {
433
434 RGBi *systemRgb = ted_image_nearest_system_color( &rgb );
435
436 if ( systemRgb->index == colorFirst ) {
437 adilinepixel(colorFirst);
438 colorIndex = 1;
439 } else if ( systemRgb->index == colorSecond ) {
440 adilinepixel(colorSecond);
441 colorIndex = 2;
442 } else if ( systemRgb->index == colorThird ) {
443 adilinepixel(colorThird);
444 colorIndex = 3;
445 } else {
446 adilinepixel(_background);
447 }
448
449 }
450
451 char bitmask = colorIndex << (6 - ((x & 0x3) * 2));
452
453 *(_dest + y) |= bitmask;
454
455 source += _depth;
456
457 }
458
459 source += 3 * ( _source_width - 4 );
460
461 }
462
463 *( _dest + 8 ) = ( colorFirst << 4 ) | colorSecond ;
464 *( _dest + 9 ) = ( _background << 4 ) | colorThird;
465
466}
467
481static void ted_image_converter_tiles_multicolor( Environment * _environment, char * _source, char * _dest, int _width, int _height, int _depth, int _source_width, int _background ) {
482
483 int bitmapSize = ( _width>>2 ) * _height;
484 int colormap1Size = ( _width>>2 ) * (_height>>3);
485 int colormap2Size = ( _width>>2 ) * (_height>>3);
486
487 memset( _dest, 0, bitmapSize + colormap1Size + colormap2Size );
488
489 adilinebeginbitmap("BMD4");
490
491 for( int y=0; y<_height; y+=8 ) {
492 for( int x=0; x<_width; x+=4 ) {
493
494 char * source = _source + ( ( y * _source_width ) + x ) * _depth;
495 char tile[10];
496
497 ted_image_converter_tile_multicolor( _environment, source, tile, _width, _depth, _background, _source_width );
498
499 int offset = ((y>>3) * 8 *( _width >> 2 ) ) + ((x>>2) * 8) + ((y) & 0x07);
500
501 char * destBitmap = _dest + offset;
502 char * destColormap1 = _dest + bitmapSize + ( ( ( y >> 3 ) * ( _width >> 2 ) ) + ( x >> 2 ) );
503 char * destColormap2 = _dest + bitmapSize + colormap1Size + ( ( ( y >> 3 ) * ( _width >> 2 ) ) + ( x >> 2 ) );
504 for( int i=0; i<8; ++i ) {
505 *destBitmap = tile[i];
506 ++destBitmap;
507 }
508 *destColormap1 = tile[8];
509 *destColormap2 = tile[9];
510 }
511 }
512
514
515}
516
517void ted_collision( Environment * _environment, char * _sprite_mask, char * _result ) {
518
519}
520
521void ted_hit( Environment * _environment, char * _sprite_mask, char * _result ) {
522
523}
524
534void ted_border_color( Environment * _environment, char * _border_color ) {
535
536 outline1("LDA %s", _border_color );
537 outline0("AND #$0f" );
538 outline0("STA $FF19");
539
540}
541
552void ted_background_color( Environment * _environment, int _index, int _background_color ) {
553
554 outline1("LDA %2.2x", _background_color);
555 outline0("AND #$0f");
556 outline1("STA $FF15+%d", ( _index & 0x03 ) );
557}
558
569void ted_background_color_vars( Environment * _environment, char * _index, char * _background_color ) {
570
571 outline1("LDA %s", _index);
572 outline0("AND #$03");
573 outline0("TAX");
574 outline1("LDA %s", _background_color );
575 outline0("AND #$0f" );
576 outline0("STA $FF15,X");
577}
578
589void ted_background_color_semivars( Environment * _environment, int _index, char * _background_color ) {
590
591 outline1("LDA #$%2.2x", _index);
592 outline0("AND #$03");
593 outline0("TAX");
594 outline1("LDA %s", _background_color );
595 outline0("AND #$0f" );
596 outline0("STA $FF15,X");
597}
598
609void ted_background_color_get_vars( Environment * _environment, char * _index, char * _background_color ) {
610
611 outline1("LDA %s", _index);
612 outline0("AND #$03");
613 outline0("TAX");
614 outline0("LDA $FF15,X");
615 outline0("AND #$0f" );
616 outline1("STA %s", _background_color );
617
618}
619
620void ted_sprite_common_color( Environment * _environment, char * _index, char * _common_color ) {
621
622}
623
639void ted_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
640
642
643 outline0("SEI");
644 outline1("LDA #<%s", _label);
645 outline0("STA TEDISRSVC+1");
646 outline1("LDA #>%s", _label);
647 outline0("STA TEDISRSVC+2");
648 outline0("LDA #%00000010");
649 outline0("STA $FF0A");
650 outline1("LDA %s", _positionlo );
651 outline0("STA $FF0B");
652 outline1("LDA %s", _positionhi );
653 outline0("AND #%00000001" );
654 cpu_beq(_environment, label);
655 outline0("LDA $FF0A" );
656 outline0("AND #%01111111" );
657 outline0("ORA #%10000000" );
658 outline0("STA $FF0A");
659 outhead1("%s:", label );
660 outline0("CLI");
661
662}
663
674void ted_next_raster( Environment * _environment ) {
675
676 outline0("ASL $FF09"); // acknowledge
677 outline0("JMP $FCB3"); // KERNAL's standard interrupt service routine
678
679}
680
694void ted_next_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
695
697
698 outline1("LDA %s", _positionlo );
699 outline0("STA $FF0B");
700 outline1("LDA %s", _positionhi );
701 outline0("AND #%00000001" );
702 cpu_beq(_environment, label);
703 outline0("LDA $FF0A" );
704 outline0("AND #%01111111" );
705 outline0("ORA #%10000000" );
706 outline0("STA $FF0A");
707 outhead1("%s:", label );
708 outline1("LDA #<%s", _label);
709 outline0("STA TEDISRSVC+1");
710 outline1("LDA #>%s", _label);
711 outline0("STA TEDISRSVC+2");
712
713 ted_next_raster( _environment );
714
715}
716
717void ted_bank_select( Environment * _environment, int _bank ) {
718
719}
720
721static int rgbConverterFunction( int _red, int _green, int _blue ) {
722
723 int colorIndex = 0;
724 unsigned int minDistance = 0xffffffff;
725 int j;
726
727 RGBi rgb;
728 rgb.red = _red;
729 rgb.green = _green;
730 rgb.blue = _blue;
731
732 for (j = 0; j < sizeof(SYSTEM_PALETTE)/sizeof(RGBi); ++j) {
733 int distance = rgbi_distance(&SYSTEM_PALETTE[j], &rgb);
734 if (distance < minDistance) {
735 minDistance = distance;
736 colorIndex = j;
737 }
738 }
739
740 return colorIndex;
741
742}
743
744int ted_screen_mode_enable( Environment * _environment, ScreenMode * _screen_mode ) {
745
746 _screen_mode->selected = 1;
747
748 Variable * colormapAddress = variable_retrieve( _environment, "COLORMAPADDRESS" );
749
750 _environment->screenTiles = 255;
751 switch( _screen_mode->id ) {
753 _environment->fontWidth = 8;
754 _environment->fontHeight = 8;
755 _environment->screenWidth = 320;
756 _environment->screenHeight = 200;
757 _environment->screenColors = 16;
758 // Enable graphics.
759 outline0("LDA $FF06" );
760 outline0("ORA #%00100000");
761 outline0("STA $FF06" );
762
763 // Let's enable monocolor graphics!
764 outline0("LDA $FF07" );
765 outline0("AND #%11101111");
766 outline0("STA $FF07" );
767
768 outline0("LDA #$D8" );
769 outline0("STA $FF12" );
770
771 outline0("LDA $FF14");
772 outline0("AND #%00000111");
773 outline0("LDA #%00001000");
774 outline0("STA $FF14");
775
776 cpu_store_16bit( _environment, colormapAddress->realName, 0x0c00 );
777
778 cpu_store_8bit( _environment, "_PEN", 0x01 );
779 cpu_store_8bit( _environment, "_PAPER", 0x00 );
780 cpu_store_16bit( _environment, "CLIPX1", 0 );
781 cpu_store_16bit( _environment, "CLIPX2", 319 );
782 cpu_store_16bit( _environment, "CLIPY1", 0 );
783 cpu_store_16bit( _environment, "CLIPY2", 199 );
784
785 break;
787 _environment->fontWidth = 4;
788 _environment->fontHeight = 8;
789 _environment->screenWidth = 160;
790 _environment->screenHeight = 200;
791 _environment->screenColors = 16;
792 // Enable graphics.
793 outline0("LDA $FF06" );
794 outline0("ORA #%00100000");
795 outline0("STA $FF06" );
796
797 // Let's enable multicolor graphics!
798 outline0("LDA $FF07" );
799 outline0("ORA #%00010000");
800 outline0("STA $FF07" );
801
802 outline0("LDA #$D8" );
803 outline0("STA $FF12" );
804
805 outline0("LDA $FF14");
806 outline0("AND #%00000111");
807 outline0("LDA #%00001000");
808 outline0("STA $FF14");
809
810 cpu_store_16bit( _environment, colormapAddress->realName, 0x0c00 );
811
812 cpu_store_8bit( _environment, "_PEN", 0x01 );
813 cpu_store_8bit( _environment, "_PAPER", 0x00 );
814 cpu_store_16bit( _environment, "CLIPX1", 0 );
815 cpu_store_16bit( _environment, "CLIPX2", 159 );
816 cpu_store_16bit( _environment, "CLIPY1", 0 );
817 cpu_store_16bit( _environment, "CLIPY2", 199 );
818
819 break;
821 _environment->screenWidth = 320;
822 _environment->screenHeight = 200;
823 _environment->screenColors = 16;
824 // Let's disable graphics (and extended color)!
825 outline0("LDA $FF06" );
826 outline0("AND #%10011111");
827 outline0("STA $FF06" );
828
829 cpu_store_16bit( _environment, colormapAddress->realName, 0x0800 );
830
831 cpu_store_8bit( _environment, "_PEN", 0x01 );
832 cpu_store_8bit( _environment, "_PAPER", 0x00 );
833 cpu_store_16bit( _environment, "CLIPX1", 0 );
834 cpu_store_16bit( _environment, "CLIPX2", 39 );
835 cpu_store_16bit( _environment, "CLIPY1", 0 );
836 cpu_store_16bit( _environment, "CLIPY2", 24 );
837
838 break;
841 _environment->screenWidth = 320;
842 _environment->screenHeight = 200;
843 _environment->screenColors = 16;
844 // Let's disable graphics and enable extended color!
845 outline0("LDA $FF06" );
846 outline0("AND #%11011111");
847 outline0("ORA #%01000000");
848 outline0("STA $FF06" );
849
850 cpu_store_16bit( _environment, colormapAddress->realName, 0x0800 );
851
852 cpu_store_8bit( _environment, "_PEN", 0x01 );
853 cpu_store_8bit( _environment, "_PAPER", 0x00 );
854 cpu_store_16bit( _environment, "CLIPX1", 0 );
855 cpu_store_16bit( _environment, "CLIPX2", 39 );
856 cpu_store_16bit( _environment, "CLIPY1", 0 );
857 cpu_store_16bit( _environment, "CLIPY2", 24 );
858
859 break;
860 default:
861 CRITICAL_SCREEN_UNSUPPORTED( _screen_mode->id );
862 }
863
864 _environment->screenTilesWidth = _environment->screenWidth / 8;
865 _environment->screenTilesHeight = _environment->screenHeight / 8;
866 _environment->consoleTilesWidth = _environment->screenTilesWidth;
867 _environment->consoleTilesHeight = _environment->screenTilesHeight;
868
869 cpu_store_16bit( _environment, "ORIGINX", 0 );
870 cpu_store_16bit( _environment, "ORIGINY", 0 );
871
872 cpu_store_16bit( _environment, "CURRENTWIDTH", _environment->screenWidth );
873 cpu_store_16bit( _environment, "CURRENTHEIGHT", _environment->screenHeight );
874 cpu_move_16bit( _environment, "CURRENTWIDTH", "RESOLUTIONX" );
875 cpu_move_16bit( _environment, "CURRENTHEIGHT", "RESOLUTIONY" );
876 cpu_store_8bit( _environment, "CURRENTTILES", _environment->screenTiles );
877 cpu_store_8bit( _environment, "CURRENTTILESWIDTH", _environment->screenTilesWidth );
878 cpu_store_8bit( _environment, "CURRENTTILESHEIGHT", _environment->screenTilesHeight );
879 cpu_store_8bit( _environment, "FONTWIDTH", _environment->fontWidth );
880 cpu_store_8bit( _environment, "FONTHEIGHT", _environment->fontHeight );
881
882 console_init( _environment );
883
884 if (_environment->vestigialConfig.clsImplicit ) {
885 ted_cls( _environment );
886 }
887
888}
889
890void console_calculate( Environment * _environment ) {
891
892 int consoleSA = 0;
893 int consoleCA = 0;
894
895 switch( _environment->currentMode ) {
897 consoleSA = plotVBase[_environment->activeConsole.y1*8]+plot8[_environment->activeConsole.x1];
898 _environment->currentModeBW = 1;
899 break;
901 consoleSA = plotVBase[_environment->activeConsole.y1*8]+plot4[_environment->activeConsole.x1];
902 _environment->currentModeBW = 2;
903 break;
907 consoleSA = 0x0c00 + (_environment->activeConsole.y1*40)+_environment->activeConsole.x1;
908 consoleCA = 0x0400 + (_environment->activeConsole.y1*40)+_environment->activeConsole.x1;
909 _environment->currentModeBW = 1;
910 break;
911 default:
913 }
914
915 int consoleWB = _environment->activeConsole.width * _environment->currentModeBW;
916 int consoleHB = _environment->activeConsole.height * 8;
917
918 cpu_store_16bit( _environment, "CONSOLESA", consoleSA );
919 cpu_store_16bit( _environment, "CONSOLECA", consoleCA );
920 cpu_store_8bit( _environment, "CONSOLEWB", consoleWB );
921 cpu_store_8bit( _environment, "CONSOLEHB", consoleHB );
922
923}
924
925void console_calculate_vars( Environment * _environment ) {
926
927 _environment->dynamicConsole = 1;
928
929 outline0( "JSR CONSOLECALCULATE" );
930
931}
932
933void ted_bitmap_enable( Environment * _environment, int _width, int _height, int _colors ) {
934
935 ScreenMode * mode = find_screen_mode_by_suggestion( _environment, 1, _width, _height, _colors, 8, 8 );
936
937 if ( mode ) {
938 ted_screen_mode_enable( _environment, mode );
939
940 cpu_store_8bit( _environment, "CURRENTMODE", mode->id );
941 cpu_store_8bit( _environment, "CURRENTTILEMODE", 0 );
942
943 _environment->currentMode = mode->id;
944 _environment->currentTileMode = 0;
945 } else {
947 }
948
949}
950
951void ted_bitmap_disable( Environment * _environment ) {
952
953 Variable * colormapAddress = variable_retrieve( _environment, "COLORMAPADDRESS" );
954
955 // Let's disable graphics!
956 outline0("LDA $FF06" );
957 outline0("AND #%11011111");
958 outline0("STA $FF06" );
959
960 cpu_store_16bit( _environment, colormapAddress->realName, 0xd800 );
961
962}
963
964void ted_tilemap_enable( Environment * _environment, int _width, int _height, int _colors, int _tile_width, int _tile_height ) {
965
966 ScreenMode * mode = find_screen_mode_by_suggestion( _environment, 0, _width, _height, _colors, _tile_width, _tile_height );
967
968 if ( mode ) {
969 ted_screen_mode_enable( _environment, mode );
970
971 cpu_store_8bit( _environment, "CURRENTMODE", mode->id );
972 cpu_store_8bit( _environment, "CURRENTTILEMODE", 1 );
973
974 _environment->currentMode = mode->id;
975 _environment->currentTileMode = 1;
976 } else {
978 }
979
980}
981
982void ted_bitmap_at( Environment * _environment, char * _address ) {
983
984}
985
986void ted_colormap_at( Environment * _environment, char * _address ) {
987
988}
989
990void ted_textmap_at( Environment * _environment, char * _address ) {
991
992}
993
994void ted_charset_uppercase( Environment * _environment ) {
995
996}
997
998void ted_charset_lowercase( Environment * _environment ) {
999
1000}
1001
1002void ted_charset_at( Environment * _environment, char * _address ) {
1003
1004}
1005
1006void ted_pset_int( Environment * _environment, int _x, int _y, int *_c ) {
1007
1008 deploy( tedvars, src_hw_ted_vars_asm );
1009 deploy( tedvarsGraphic, src_hw_ted_vars_graphic_asm );
1010 deploy( plot, src_hw_ted_plot_asm );
1011
1012 outline1("LDA %2.2x", (_x & 0xff ) );
1013 outline0("STA PLOTX");
1014 outline1("LDA %2.2x", ( ( _x >> 8 ) & 0xff ) );
1015 outline0("STA PLOTX+1");
1016 outline1("LDA %2.2x", ( _y & 0xff ) );
1017 outline0("STA PLOTY");
1018 if ( _c ) {
1019 outline1("LDA #$%2.2x", ( *_c & 0xff ) );
1020 } else {
1021 Variable * c = variable_retrieve( _environment, "PEN" );
1022 outline1("LDA %s", c->realName );
1023 }
1024 outline0("ASL");
1025 outline0("ASL");
1026 outline0("ASL");
1027 outline0("ASL");
1028 outline0("STA PLOTCPE");
1029 outline0("LDA #1");
1030 outline0("STA PLOTM");
1031 outline0("JSR PLOT");
1032
1033}
1034
1035void ted_pset_vars( Environment * _environment, char *_x, char *_y, char *_c ) {
1036
1037 Variable * x = variable_retrieve_or_define( _environment, _x, VT_POSITION, 0 );
1038 Variable * y = variable_retrieve_or_define( _environment, _y, VT_POSITION, 0 );
1039 Variable * c;
1040
1041 if ( _c ) {
1042 c = variable_retrieve_or_define( _environment, _c, VT_COLOR, 0 );
1043 } else {
1044 c = variable_retrieve( _environment, "PEN" );
1045 }
1046
1047 deploy( tedvars, src_hw_ted_vars_asm );
1048 deploy( tedvarsGraphic, src_hw_ted_vars_graphic_asm );
1049 deploy( plot, src_hw_ted_plot_asm );
1050
1051 outline1("LDA %s", x->realName );
1052 outline0("STA PLOTX");
1053 if ( VT_BITWIDTH( x->type ) > 8 ) {
1054 outline1("LDA %s", address_displacement(_environment, x->realName, "1") );
1055 } else {
1056 outline0("LDA #0");
1057 }
1058 outline0("STA PLOTX+1");
1059 outline1("LDA %s", y->realName );
1060 outline0("STA PLOTY");
1061 outline1("LDA %s", c->realName );
1062 outline0("ASL");
1063 outline0("ASL");
1064 outline0("ASL");
1065 outline0("ASL");
1066 outline0("STA PLOTCPE");
1067 outline0("LDA #1");
1068 outline0("STA PLOTM");
1069 outline0("JSR PLOT");
1070
1071}
1072
1073void ted_pget_color_vars( Environment * _environment, char *_x, char *_y, char * _result ) {
1074
1075 Variable * x = variable_retrieve( _environment, _x );
1076 Variable * y = variable_retrieve( _environment, _y );
1077 Variable * result = variable_retrieve( _environment, _result );
1078
1079 deploy( tedvars, src_hw_ted_vars_asm );
1080 deploy( tedvarsGraphic, src_hw_ted_vars_graphic_asm );
1081 deploy( plot, src_hw_ted_plot_asm );
1082
1083 outline1("LDA %s", x->realName );
1084 outline0("STA PLOTX");
1085 outline1("LDA %s", address_displacement(_environment, x->realName, "1") );
1086 outline0("STA PLOTX+1");
1087 outline1("LDA %s", y->realName );
1088 outline0("STA PLOTY");
1089 outline0("LDA #3");
1090 outline0("STA PLOTM");
1091 outline0("JSR PLOT");
1092 outline0("LDA PLOTM");
1093 outline1("STA %s", result->realName);
1094
1095}
1096
1097void ted_screen_on( Environment * _environment ) {
1098
1099}
1100
1101void ted_screen_off( Environment * _environment ) {
1102
1103}
1104
1105void ted_screen_rows( Environment * _environment, char * _rows ) {
1106
1108
1109 outline1("LDA %s", _rows);
1110 outline0("CMP #24");
1111 outline1("BEQ %s", label);
1112 outline0("LDA $FF06" );
1113 outline0("ORA #%00001000");
1114 outline0("STA $FF06" );
1115 outline1("JMP %s_2", label);
1116 outhead1("%s:", label );
1117 outline0("LDA $FF06" );
1118 outline0("AND #%11110111");
1119 outline0("STA $FF06" );
1120 outline1("JMP %s_2", label);
1121 outhead1("%s_2:", label );
1122
1123}
1124
1125void ted_screen_columns( Environment * _environment, char * _columns ) {
1126
1128
1129 outline1("LDA %s", _columns);
1130 outline0("CMP #38");
1131 outline1("BEQ %s", label);
1132 outline0("LDA $FF07" );
1133 outline0("ORA #%00010000");
1134 outline0("STA $FF07" );
1135 outline1("JMP %s_2", label);
1136 outhead1("%s:", label );
1137 outline0("LDA $FF07" );
1138 outline0("AND #%11101111");
1139 outline0("STA $FF07" );
1140 outline1("JMP %s_2", label);
1141 outhead1("%s_2:", label );
1142
1143}
1144
1145void ted_sprite_data_from( Environment * _environment, char * _sprite, char * _address ) {
1146
1147}
1148
1149void ted_sprite_data_set( Environment * _environment, char * _sprite, char * _address ) {
1150
1151}
1152
1153void ted_sprite_enable( Environment * _environment, char * _sprite ) {
1154
1155}
1156
1157void ted_sprite_disable( Environment * _environment, char * _sprite ) {
1158
1159}
1160
1161void ted_sprite_at( Environment * _environment, char * _sprite, char * _x, char * _y ) {
1162
1163}
1164
1165void ted_sprite_expand_vertical( Environment * _environment, char * _sprite ) {
1166
1167}
1168
1169void ted_sprite_expand_horizontal( Environment * _environment, char * _sprite ) {
1170
1171}
1172
1173void ted_sprite_compress_vertical( Environment * _environment, char * _sprite ) {
1174
1175}
1176
1177void ted_sprite_compress_horizontal( Environment * _environment, char * _sprite ) {
1178
1179}
1180
1181void ted_sprite_multicolor( Environment * _environment, char * _sprite ) {
1182
1183}
1184
1185void ted_sprite_monocolor( Environment * _environment, char * _sprite ) {
1186
1187}
1188
1189void ted_sprite_color( Environment * _environment, char * _sprite, char * _color ) {
1190
1191}
1192
1193void ted_sprite_priority( Environment * _environment, char * _sprite, char * _priority ) {
1194
1195}
1196
1197void ted_tiles_at( Environment * _environment, char * _address ) {
1198
1199}
1200
1201void ted_vertical_scroll( Environment * _environment, char * _displacement ) {
1202
1203 outline0("LDA $FF06" );
1204 outline0("AND #%11111000");
1205 outline1("ORA %s", _displacement );
1206 outline0("STA $FF06" );
1207
1208}
1209
1210void ted_horizontal_scroll( Environment * _environment, char * _displacement ) {
1211
1212 outline0("LDA $FF07" );
1213 outline0("AND #%11111000");
1214 outline1("ORA %s", _displacement );
1215 outline0("STA $FF07" );
1216
1217}
1218
1219void ted_busy_wait( Environment * _environment, char * _timing ) {
1220
1222
1223 outline0("LDA #$00");
1224 outline0("STA TMPPTR");
1225 outhead1("%sfirst:", label );
1226 outline0("LDA #$01");
1227 outhead1("%ssecond:", label );
1228 outline0("CMP $FF1D");
1229 outline1("BNE %ssecond", label);
1230 outhead1("%sthird:", label );
1231 outline0("CMP $FF1D");
1232 outline1("BEQ %sthird", label);
1233 outline0("INC TMPPTR");
1234 outline0("LDA TMPPTR");
1235 outline1("CMP %s", _timing );
1236 outline1("BNE %sfirst", label );
1237
1238}
1239
1240void ted_get_width( Environment * _environment, char *_result ) {
1241
1242 outline0("LDA CURRENTWIDTH" );
1243 outline1("STA %s", _result );
1244 outline0("LDA CURRENTWIDTH+1" );
1245 outline1("STA %s", address_displacement(_environment, _result, "1") );
1246
1247}
1248
1249void ted_tiles_get( Environment * _environment, char *_result ) {
1250
1251 outline0("LDA CURRENTTILES" );
1252 outline1("STA %s", _result );
1253
1254}
1255
1256void ted_get_height( Environment * _environment, char *_result ) {
1257
1258 outline0("LDA CURRENTHEIGHT" );
1259 outline1("STA %s", _result );
1260 outline0("LDA CURRENTHEIGHT+1" );
1261 outline1("STA %s", address_displacement(_environment, _result, "1") );
1262
1263}
1264
1265void ted_cls( Environment * _environment ) {
1266
1267 if ( _environment->currentMode == 2 || _environment->currentMode == 3 ) {
1268 deploy( clsGraphic, src_hw_ted_cls_graphic_asm );
1269 outline0("JSR CLSG");
1270 } else {
1271 deploy( clsText, src_hw_ted_cls_text_asm );
1272 outline0("JSR CLST");
1273 }
1274
1275}
1276
1277void ted_cls_box( Environment * _environment, char * _x1, char * _y1, char * _w, char * _h ) {
1278
1279 if ( _environment->currentMode == 2 || _environment->currentMode == 3 ) {
1280 deploy( clsBox, src_hw_ted_cls_box_asm );
1281
1282 outline1("LDA %s", _x1);
1283 outline0("STA IMAGEX");
1284 outline1("LDA %s", address_displacement( _environment, _x1, "1" ) );
1285 outline0("STA IMAGEX+1");
1286 outline1("LDA %s", _y1);
1287 outline0("STA IMAGEY");
1288 outline1("LDA %s", _w);
1289 outline0("STA IMAGEW");
1290 outline1("LDA %s", address_displacement( _environment, _w, "1" ) );
1291 outline0("STA IMAGEW+1");
1292 outline1("LDA %s", _h);
1293 outline0("STA IMAGEH");
1294 outline0("JSR CLSBOX");
1295 } else {
1296
1297 }
1298
1299}
1300
1301void ted_scroll_text( Environment * _environment, int _direction, int _overlap ) {
1302
1303 deploy( vScrollText, src_hw_ted_vscroll_text_asm );
1304
1305 outline1("LDA #$%2.2x", ( _overlap & 0xff ) );
1306 outline0("STA PORT" );
1307 if ( _direction > 0 ) {
1308 outline0("JSR VSCROLLTDOWN");
1309 } else {
1310 outline0("JSR VSCROLLTUP");
1311 }
1312
1313
1314}
1315
1316void ted_scroll( Environment * _environment, int _dx, int _dy ) {
1317
1318 deploy( tedvars, src_hw_ted_vars_asm);
1319 deploy( scroll, src_hw_ted_scroll_asm);
1320 deploy( textHScroll, src_hw_ted_hscroll_text_asm );
1321 deploy( vScrollText, src_hw_ted_vscroll_text_asm );
1322
1323 outline1("LDA #$%2.2x", (unsigned char)(_dx&0xff) );
1324 outline0("STA MATHPTR0" );
1325 outline1("LDA #$%2.2x", (unsigned char)(_dy&0xff) );
1326 outline0("STA MATHPTR1" );
1327 outline0("JSR SCROLL");
1328
1329}
1330
1331void ted_text( Environment * _environment, char * _text, char * _text_size, int _raw ) {
1332
1333 deploy( tedvars, src_hw_ted_vars_asm );
1334 deploy( vScrollText, src_hw_ted_vscroll_text_asm );
1335 deploy( textEncodedAt, src_hw_ted_text_at_asm );
1336
1337 outline1("LDA %s", _text);
1338 outline0("STA TEXTPTR" );
1339 outline1("LDA %s", address_displacement(_environment, _text, "1"));
1340 outline0("STA TEXTPTR+1" );
1341 outline1("LDA %s", _text_size);
1342 outline0("STA TEXTSIZE" );
1343
1344 if ( _environment->currentMode == 2 || _environment->currentMode == 3 ) {
1345 deploy( tedvarsGraphic, src_hw_ted_vars_graphic_asm );
1346 deploy( clsGraphic, src_hw_ted_cls_graphic_asm );
1347 deploy_deferred( textEncodedAtGraphic, src_hw_ted_text_at_graphic_asm );
1348 outline0("JSR TEXTATBITMAPMODE");
1349 } else {
1350 deploy( clsText, src_hw_ted_cls_text_asm );
1351 deploy_deferred( textEncodedAtText, src_hw_ted_text_at_text_asm );
1352 outline0("JSR TEXTATTILEMODE");
1353 }
1354
1355}
1356
1357void ted_initialization( Environment * _environment ) {
1358
1359 deploy( tedvars, src_hw_ted_vars_asm );
1360 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
1361
1362 variable_import( _environment, "CURRENTMODE", VT_BYTE, 0 );
1363 variable_global( _environment, "CURRENTMODE" );
1364 variable_import( _environment, "CURRENTTILEMODE", VT_BYTE, 1 );
1365 variable_global( _environment, "CURRENTTILEMODE" );
1366
1367 variable_import( _environment, "CURRENTWIDTH", VT_POSITION, 320 );
1368 variable_global( _environment, "CURRENTWIDTH" );
1369 variable_import( _environment, "CURRENTHEIGHT", VT_POSITION, 200 );
1370 variable_global( _environment, "CURRENTHEIGHT" );
1371 variable_import( _environment, "CURRENTTILESWIDTH", VT_SBYTE, 40 );
1372 variable_global( _environment, "CURRENTTILESWIDTH" );
1373 variable_import( _environment, "CURRENTTILESHEIGHT", VT_SBYTE, 25 );
1374 variable_global( _environment, "CURRENTTILESHEIGHT" );
1375 variable_import( _environment, "FONTWIDTH", VT_BYTE, 8 );
1376 variable_global( _environment, "FONTWIDTH" );
1377 variable_import( _environment, "FONTHEIGHT", VT_BYTE, 8 );
1378 variable_global( _environment, "FONTHEIGHT" );
1379
1380 SCREEN_MODE_DEFINE( BITMAP_MODE_STANDARD, 1, 320, 200, 2, 8, 8, "Standard Bitmap Mode" );
1381 SCREEN_MODE_DEFINE( BITMAP_MODE_MULTICOLOR, 1, 160, 200, 4, 8, 8, "Multicolor Bitmap Mode" );
1382 SCREEN_MODE_DEFINE( TILEMAP_MODE_STANDARD, 0, 40, 25, 16, 8, 8, "Standard Character Mode" );
1383 SCREEN_MODE_DEFINE( TILEMAP_MODE_EXTENDED, 0, 40, 25, 20, 8, 8, "Extended Multicolor Character Mode" );
1384
1385 outline0("JSR TEDSTARTUP");
1386 outline0("JSR TEDUDCCHAR" );
1387
1388 variable_import( _environment, "XGR", VT_POSITION, 0 );
1389 variable_global( _environment, "XGR" );
1390 variable_import( _environment, "YGR", VT_POSITION, 0 );
1391 variable_global( _environment, "YGR" );
1392 variable_import( _environment, "LINE", VT_WORD, (unsigned short) (0xffff) );
1393 variable_global( _environment, "LINE" );
1394 variable_import( _environment, "TABCOUNT", VT_BYTE, 4 );
1395 variable_global( _environment, "TABCOUNT" );
1396
1397 variable_import( _environment, "CLIPX1", VT_POSITION, 0 );
1398 variable_global( _environment, "CLIPX1" );
1399 variable_import( _environment, "CLIPX2", VT_POSITION, 319 );
1400 variable_global( _environment, "CLIPX2" );
1401 variable_import( _environment, "CLIPY1", VT_POSITION, 0 );
1402 variable_global( _environment, "CLIPY1" );
1403 variable_import( _environment, "CLIPY2", VT_POSITION, 199 );
1404 variable_global( _environment, "CLIPY2" );
1405
1406 variable_import( _environment, "ORIGINX", VT_POSITION, 0 );
1407 variable_global( _environment, "ORIGINX" );
1408 variable_import( _environment, "ORIGINY", VT_POSITION, 0 );
1409 variable_global( _environment, "ORIGINY" );
1410
1411 variable_import( _environment, "RESOLUTIONX", VT_POSITION, 0 );
1412 variable_global( _environment, "RESOLUTIONX" );
1413 variable_import( _environment, "RESOLUTIONY", VT_POSITION, 0 );
1414 variable_global( _environment, "RESOLUTIONY" );
1415
1416 ted_tilemap_enable( _environment, 40, 25, 16, 8, 8 );
1417
1418 _environment->currentRgbConverterFunction = rgbConverterFunction;
1419 _environment->screenShades = 16;
1420
1421}
1422
1423void ted_finalization( Environment * _environment ) {
1424
1425 if ( ! _environment->deployed.tedstartup ) {
1426 cpu_label( _environment, "TEDSTARTUP" );
1427 outline0( "RTS" );
1428 cpu_label( _environment, "MUSICPLAYER" );
1429 outline0( "RTS" );
1430 }
1431
1432 if ( _environment->vestigialConfig.clsImplicit ) {
1433 deploy( clsText, src_hw_ted_cls_text_asm );
1434 }
1435
1436 CopperList * copperList = _environment->copperList;
1437 if ( copperList ) {
1438 while(copperList) {
1439 outhead1("COPPERACTIVATE%s:", copperList->name ? copperList->name : "" );
1440 outline0("RTS");
1441 copperList = copperList->next;
1442 }
1443 }
1444
1445}
1446
1447void ted_hscroll_line( Environment * _environment, int _direction, int _overlap ) {
1448
1449 deploy( textHScroll, src_hw_ted_hscroll_text_asm );
1450
1451 Variable * y = variable_retrieve( _environment, "YCURSYS" );
1452 outline1("LDA #$%2.2x", ( _direction & 0xff ) );
1453 outline0("STA DIRECTION" );
1454 outline1("LDA %s", y->realName );
1455 outline0("STA CLINEY");
1456
1457 outline0("JSR HSCROLLLT");
1458
1459}
1460
1461void ted_hscroll_screen( Environment * _environment, int _direction, int _overlap ) {
1462
1463 deploy( textHScroll, src_hw_ted_hscroll_text_asm );
1464
1465 outline1("LDA #$%2.2x", ( _direction & 0xff ) );
1466 outline0("STA DIRECTION" );
1467 outline1("LDA #$%2.2x", ( _overlap & 0xff ) );
1468 outline0("STA PORT" );
1469
1470 outline0("JSR HSCROLLST");
1471}
1472
1473void ted_back( Environment * _environment ) {
1474
1475 deploy( back, src_hw_ted_back_asm );
1476
1477 outline0("JSR BACK");
1478
1479}
1480
1481int ted_image_size( Environment * _environment, int _width, int _height, int _mode ) {
1482
1483 switch( _mode ) {
1485
1486 return 3 + ( ( _width >> 3 ) * _height ) + ( ( _width >> 3 ) * ( _height >> 3 ) );
1487
1489
1490 return 3 + ( ( _width >> 2 ) * _height ) + 2 * ( ( _width >> 2 ) * ( _height >> 3 ) ) + 2;
1491
1495 break;
1496 }
1497
1498 return 0;
1499
1500}
1501
1502static int calculate_images_size( Environment * _environment, int _frames, int _width, int _height, int _mode ) {
1503
1504 switch( _mode ) {
1506
1507 return 3 + ( 3 + ( ( _width >> 3 ) * _height ) + ( ( _width >> 3 ) * ( _height >> 3 ) ) ) * _frames;
1508
1510
1511 return 3 + ( 3 + ( ( _width >> 2 ) * _height ) + 2 * ( ( _width >> 2 ) * ( _height >> 3 ) ) + 2 ) * _frames;
1512
1516 break;
1517 }
1518
1519 return 0;
1520
1521}
1522
1523static int calculate_sequence_size( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode ) {
1524
1525 switch( _mode ) {
1527
1528 return 3 + ( ( 3 + ( ( _width >> 3 ) * _height ) + ( ( _width >> 3 ) * ( _height >> 3 ) ) ) * _frames ) * _sequences;
1529
1531
1532 return 3 + ( ( 3 + ( ( _width >> 2 ) * _height ) + 2 * ( ( _width >> 2 ) * ( _height >> 3 ) ) + 2 ) * _frames ) * _sequences;
1533
1537 break;
1538 }
1539
1540 return 0;
1541
1542}
1543
1544static Variable * ted_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 ) {
1545
1546 image_converter_asserts( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8, 8 );
1547
1548 if ( _environment->freeImageWidth ) {
1549 if ( _width % 8 ) {
1550 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
1551 }
1552 if ( _frame_width % 8 ) {
1553 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
1554 }
1555 }
1556
1557 if ( _environment->freeImageHeight ) {
1558 if ( _height % 8 ) {
1559 _height = ( ( ( _height - 1 ) / 8 ) - 1 ) * 8;
1560 }
1561 if ( _frame_height % 8 ) {
1562 _frame_height = ( ( ( _frame_height - 1 ) / 8 ) - 1 ) * 8;
1563 }
1564 }
1565
1566 RGBi * palette = malloc_palette( MAX_PALETTE );
1567
1568 int paletteColorCount = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
1569
1570 if (paletteColorCount > 16) {
1571 CRITICAL_IMAGE_CONVERTER_TOO_COLORS( paletteColorCount );
1572 }
1573
1574 int i, j, k;
1575
1576 commonPalette = palette_match( palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) );
1577 commonPalette = palette_remove_duplicates( commonPalette, paletteColorCount, &paletteColorCount );
1578 lastUsedSlotInCommonPalette = paletteColorCount;
1579 adilinepalette( "CPM1:%d", paletteColorCount, commonPalette );
1580
1581 adilinepalette( "CPMS:%ld", sizeof(SYSTEM_PALETTE) / sizeof(RGBi), SYSTEM_PALETTE );
1582
1583 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
1585 memcpy( result->originalPalette, commonPalette, lastUsedSlotInCommonPalette * sizeof( RGBi ) );
1586
1587 int bufferSize = ted_image_size( _environment, _frame_width, _frame_height, BITMAP_MODE_STANDARD );
1588 // printf("bufferSize = %d\n", bufferSize );
1589
1590 adiline3("BMP:%4.4x:%4.4x:%2.2x", _frame_width, _frame_height, BITMAP_MODE_STANDARD );
1591
1592 char * buffer = malloc ( bufferSize );
1593 memset( buffer, 0, bufferSize );
1594
1595 // Position of the pixel in the original image
1596 int image_x, image_y;
1597
1598 // Position of the pixel, in terms of tiles
1599 int tile_x, tile_y;
1600
1601 // Position of the pixel, in terms of offset and bitmask
1602 int offset, bitmask;
1603
1604 // Color of the pixel to convert
1605 RGBi rgb;
1606
1607 *(buffer) = (_frame_width & 0xff );
1608 *(buffer+1) = (_frame_width >> 8 ) & 0xff;
1609 *(buffer+2) = _frame_height;
1610
1611 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1612
1613 ted_image_converter_tiles( _environment, _source, buffer+3, _frame_width, _frame_height, _depth, _width );
1614
1615 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
1616
1617 return result;
1618
1619}
1620
1621
1622static Variable * ted_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 ) {
1623
1624 image_converter_asserts( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8, 8 );
1625
1626 if ( _environment->freeImageWidth ) {
1627 if ( _width % 8 ) {
1628 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
1629 }
1630 if ( _frame_width % 8 ) {
1631 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
1632 }
1633 }
1634
1635 if ( _environment->freeImageHeight ) {
1636 if ( _height % 8 ) {
1637 _height = ( ( ( _height - 1 ) / 8 ) - 1 ) * 8;
1638 }
1639 if ( _frame_height % 8 ) {
1640 _frame_height = ( ( ( _frame_height - 1 ) / 8 ) - 1 ) * 8;
1641 }
1642 }
1643
1644 RGBi * palette = malloc_palette( MAX_PALETTE );
1645
1646 int paletteColorCount = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
1647
1648 if (paletteColorCount > 16) {
1649 CRITICAL_IMAGE_CONVERTER_TOO_COLORS( paletteColorCount );
1650 }
1651
1652 int i, j, k;
1653
1654 commonPalette = palette_match( palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) );
1655 commonPalette = palette_remove_duplicates( commonPalette, paletteColorCount, &paletteColorCount );
1656 lastUsedSlotInCommonPalette = paletteColorCount;
1657 adilinepalette( "CPM1:%d", paletteColorCount, commonPalette );
1658
1659 adilinepalette( "CPMS:%ld", sizeof(SYSTEM_PALETTE) / sizeof(RGBi), SYSTEM_PALETTE );
1660
1661 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
1663 memcpy( result->originalPalette, commonPalette, lastUsedSlotInCommonPalette * sizeof( RGBi ) );
1664
1665 int bufferSize = ted_image_size( _environment, _frame_width, _frame_height, BITMAP_MODE_MULTICOLOR );
1666
1667 adiline3("BMP:%4.4x:%4.4x:%2.2x", _frame_width, _frame_height, BITMAP_MODE_MULTICOLOR );
1668
1669 char * buffer = malloc ( bufferSize );
1670 memset( buffer, 0, bufferSize );
1671
1672 // Position of the pixel in the original image
1673 int image_x, image_y;
1674
1675 // Position of the pixel, in terms of tiles
1676 int tile_x, tile_y;
1677
1678 // Position of the pixel, in terms of offset and bitmask
1679 int offset, offsetc, bitmask;
1680
1681 // Color of the pixel to convert
1682 RGBi rgb;
1683
1684 *(buffer) = (_frame_width & 0xff );
1685 *(buffer+1) = (_frame_width >> 8 ) & 0xff;
1686 *(buffer+2) = _frame_height;
1687
1688 _source += ( ( _offset_y * _frame_width ) + _offset_x ) * 3;
1689
1690 ted_image_converter_tiles_multicolor( _environment, _source, buffer+3, _frame_width, _frame_height, _depth, _width, palette[0].index );
1691
1692 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
1693
1694 return result;
1695
1696}
1697
1698Variable * ted_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 ) {
1699
1700 switch( _mode ) {
1702
1703 return ted_image_converter_bitmap_mode_standard( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1704
1706
1707 return ted_image_converter_multicolor_mode_standard( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1708
1712 break;
1713 }
1714
1716
1717 return ted_new_image( _environment, 8, 8, BITMAP_MODE_STANDARD );
1718
1719}
1720
1721void ted_calculate_sequence_frame_offset( Environment * _environment, char * _offset, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
1722
1723 outline0("LDA #0" );
1724 outline1("STA %s", _offset );
1725 outline1("STA %s", address_displacement(_environment, _offset, "1") );
1726
1727 if ( _sequence ) {
1728
1729 outline0("CLC" );
1730 outline1("LDA %s", _offset );
1731 outline0("ADC #3" );
1732 outline1("STA %s", _offset );
1733 outline1("LDA %s", address_displacement(_environment, _offset, "1") );
1734 outline0("ADC #0" );
1735 outline1("STA %s", address_displacement(_environment, _offset, "1") );
1736 if ( strlen(_sequence) == 0 ) {
1737
1738 } else {
1739 outline1("LDA #<OFFSETS%4.4x", _frame_size * _frame_count );
1740 outline0("STA MATHPTR0" );
1741 outline1("LDA #>OFFSETS%4.4x", _frame_size * _frame_count );
1742 outline0("STA MATHPTR0+1" );
1743 outline0("CLC" );
1744 outline1("LDA %s", _sequence );
1745 outline0("ASL" );
1746 outline0("TAY" );
1747 outline1("LDA %s", _offset );
1748 outline0("ADC (MATHPTR0), Y" );
1749 outline1("STA %s", _offset );
1750 outline0("INY" );
1751 outline1("LDA %s", address_displacement(_environment, _offset, "1") );
1752 outline0("ADC (MATHPTR0+1), Y" );
1753 outline1("STA %s", address_displacement(_environment, _offset, "1") );
1754 }
1755
1756 if ( _frame ) {
1757 if ( strlen(_frame) == 0 ) {
1758
1759 } else {
1760 outline1("LDA #<OFFSETS%4.4x", _frame_size );
1761 outline0("STA MATHPTR0" );
1762 outline1("LDA #>OFFSETS%4.4x", _frame_size );
1763 outline0("STA MATHPTR0+1" );
1764 outline0("CLC" );
1765 outline1("LDA %s", _frame );
1766 outline0("ASL" );
1767 outline0("TAY" );
1768 outline1("LDA %s", _offset );
1769 outline0("ADC (MATHPTR0), Y" );
1770 outline1("STA %s", _offset );
1771 outline0("INY" );
1772 outline1("LDA %s", address_displacement(_environment, _offset, "1") );
1773 outline0("ADC (MATHPTR0), Y" );
1774 outline1("STA %s", address_displacement(_environment, _offset, "1") );
1775 }
1776 }
1777
1778 } else {
1779
1780 if ( _frame ) {
1781 outline0("CLC" );
1782 outline1("LDA %s", _offset );
1783 outline0("ADC #3" );
1784 outline1("STA %s", _offset );
1785 outline1("LDA %s", address_displacement(_environment, _offset, "1") );
1786 outline0("ADC #0" );
1787 outline1("STA %s", address_displacement(_environment, _offset, "1") );
1788 if ( strlen(_frame) == 0 ) {
1789
1790 } else {
1791 outline1("LDA #<OFFSETS%4.4x", _frame_size );
1792 outline0("STA MATHPTR0" );
1793 outline1("LDA #>OFFSETS%4.4x", _frame_size );
1794 outline0("STA MATHPTR0+1" );
1795 outline0("CLC" );
1796 outline1("LDA %s", _frame );
1797 outline0("ASL" );
1798 outline0("TAY" );
1799 outline1("LDA %s", _offset );
1800 outline0("ADC (MATHPTR0), Y" );
1801 outline1("STA %s", _offset );
1802 outline0("INY" );
1803 outline1("LDA %s", address_displacement(_environment, _offset, "1") );
1804 outline0("ADC (MATHPTR0), Y" );
1805 outline1("STA %s", address_displacement(_environment, _offset, "1") );
1806 }
1807 }
1808
1809 }
1810
1811}
1812
1813static void ted_load_image_address_to_other_register( Environment * _environment, char * _register, char * _source, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
1814
1815 outline1("LDA #<%s", _source );
1816 outline1("STA %s", _register );
1817 outline1("LDA #>%s", _source );
1818 outline1("STA %s", address_displacement(_environment, _register, "1") );
1819
1820 if ( _sequence ) {
1821
1822 outline0("CLC" );
1823 outline1("LDA %s", _register );
1824 outline0("ADC #3" );
1825 outline1("STA %s", _register );
1826 outline1("LDA %s", address_displacement(_environment, _register, "1") );
1827 outline0("ADC #0" );
1828 outline1("STA %s", address_displacement(_environment, _register, "1") );
1829 if ( strlen(_sequence) == 0 ) {
1830
1831 } else {
1832 outline1("LDA #<OFFSETS%4.4x", _frame_size * _frame_count );
1833 outline0("STA MATHPTR0" );
1834 outline1("LDA #>OFFSETS%4.4x", _frame_size * _frame_count );
1835 outline0("STA MATHPTR0+1" );
1836 outline0("CLC" );
1837 outline1("LDA %s", _sequence );
1838 outline0("ASL" );
1839 outline0("TAY" );
1840 outline1("LDA %s", _register );
1841 outline0("ADC (MATHPTR0), Y" );
1842 outline1("STA %s", _register );
1843 outline0("INY" );
1844 outline1("LDA %s", address_displacement(_environment, _register, "1") );
1845 outline0("ADC (MATHPTR0+1), Y" );
1846 outline1("STA %s", address_displacement(_environment, _register, "1") );
1847 }
1848
1849 if ( _frame ) {
1850 if ( strlen(_frame) == 0 ) {
1851
1852 } else {
1853 outline1("LDA #<OFFSETS%4.4x", _frame_size );
1854 outline0("STA MATHPTR0" );
1855 outline1("LDA #>OFFSETS%4.4x", _frame_size );
1856 outline0("STA MATHPTR0+1" );
1857 outline0("CLC" );
1858 outline1("LDA %s", _frame );
1859 outline0("ASL" );
1860 outline0("TAY" );
1861 outline1("LDA %s", _register );
1862 outline0("ADC (MATHPTR0), Y" );
1863 outline1("STA %s", _register );
1864 outline0("INY" );
1865 outline1("LDA %s", address_displacement(_environment, _register, "1") );
1866 outline0("ADC (MATHPTR0), Y" );
1867 outline1("STA %s", address_displacement(_environment, _register, "1") );
1868 }
1869 }
1870
1871 } else {
1872
1873 if ( _frame ) {
1874 outline0("CLC" );
1875 outline1("LDA %s", _register );
1876 outline0("ADC #3" );
1877 outline1("STA %s", _register );
1878 outline1("LDA %s", address_displacement(_environment, _register, "1") );
1879 outline0("ADC #0" );
1880 outline1("STA %s", address_displacement(_environment, _register, "1") );
1881 if ( strlen(_frame) == 0 ) {
1882
1883 } else {
1884 outline1("LDA #<OFFSETS%4.4x", _frame_size );
1885 outline0("STA MATHPTR0" );
1886 outline1("LDA #>OFFSETS%4.4x", _frame_size );
1887 outline0("STA MATHPTR0+1" );
1888 outline0("CLC" );
1889 outline1("LDA %s", _frame );
1890 outline0("ASL" );
1891 outline0("TAY" );
1892 outline1("LDA %s", _register );
1893 outline0("ADC (MATHPTR0), Y" );
1894 outline1("STA %s", _register );
1895 outline0("INY" );
1896 outline1("LDA %s", address_displacement(_environment, _register, "1") );
1897 outline0("ADC (MATHPTR0), Y" );
1898 outline1("STA %s", address_displacement(_environment, _register, "1") );
1899 }
1900 }
1901
1902 }
1903
1904}
1905
1906static void ted_load_image_address_to_register( Environment * _environment, char * _register, Resource * _source, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
1907
1908 if ( !_sequence && !_frame ) {
1909 if ( _source->isAddress ) {
1910 outline1("LDA %s", _source->realName );
1911 outline1("STA %s", _register );
1912 outline1("LDA %s", address_displacement(_environment, _source->realName, "1") );
1913 outline1("STA %s", address_displacement(_environment, _register, "1") );
1914 } else {
1915 outline1("LDA #<%s", _source->realName );
1916 outline1("STA %s", _register );
1917 outline1("LDA #>%s", _source->realName );
1918 outline1("STA %s", address_displacement(_environment, _register, "1") );
1919 }
1920 } else {
1921 if ( _source->isAddress ) {
1922 outline1("LDA %s", _source->realName );
1923 outline0("STA TMPPTR" );
1924 outline1("LDA %s", address_displacement(_environment, _source->realName, "1") );
1925 outline0("STA TMPPTR+1" );
1926 } else {
1927 outline1("LDA #<%s", _source->realName );
1928 outline0("STA TMPPTR" );
1929 outline1("LDA #>%s", _source->realName );
1930 outline0("STA TMPPTR+1" );
1931 }
1932
1933 if ( _sequence ) {
1934 outline0("CLC" );
1935 outline0("LDA TMPPTR" );
1936 outline0("ADC #3" );
1937 outline0("STA TMPPTR" );
1938 outline0("LDA TMPPTR+1" );
1939 outline0("ADC #0" );
1940 outline0("STA TMPPTR+1" );
1941
1942 if ( strlen(_sequence) == 0 ) {
1943
1944 } else {
1945 outline1("LDA %s", _sequence );
1946 outline0("STA MATHPTR0" );
1947 outline1("JSR %soffsetsequence", _source->realName );
1948 }
1949 if ( _frame ) {
1950 if ( strlen(_frame) == 0 ) {
1951
1952 } else {
1953 outline1("LDA %s", _frame );
1954 outline0("STA MATHPTR0" );
1955 outline1("JSR %soffsetframe", _source->realName );
1956 }
1957 }
1958
1959 } else {
1960
1961 if ( _frame ) {
1962 outline0("CLC" );
1963 outline0("LDA TMPPTR" );
1964 outline0("ADC #3" );
1965 outline0("STA TMPPTR" );
1966 outline0("LDA TMPPTR+1" );
1967 outline0("ADC #0" );
1968 outline0("STA TMPPTR+1" );
1969 if ( strlen(_frame) == 0 ) {
1970
1971 } else {
1972 outline1("LDA %s", _frame );
1973 outline0("STA MATHPTR0" );
1974 outline1("JSR %soffsetframe", _source->realName );
1975 }
1976 }
1977
1978 }
1979
1980 if ( _source->isAddress ) {
1981 outline0("LDA TMPPTR" );
1982 outline1("STA %s", _register );
1983 outline0("LDA TMPPTR+1" );
1984 outline1("STA %s", address_displacement(_environment, _register, "1") );
1985 } else {
1986 outline0("LDA TMPPTR" );
1987 outline1("STA %s", _register );
1988 outline0("LDA TMPPTR+1" );
1989 outline1("STA %s", address_displacement(_environment, _register, "1") );
1990 }
1991
1992 }
1993
1994}
1995
1996void ted_put_image( Environment * _environment, Resource * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _flags ) {
1997
1998 deploy( tedvars, src_hw_ted_vars_asm);
1999 deploy( tedvarsGraphic, src_hw_ted_vars_graphic_asm );
2000 deploy( putimage, src_hw_ted_put_image_asm );
2001
2002 if ( _frame_size ) {
2003 ted_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
2004 }
2005
2006 outline1("LDA %s", _x );
2007 outline0("STA IMAGEX" );
2008 outline1("LDA %s", address_displacement(_environment, _x, "1") );
2009 outline0("STA IMAGEX+1" );
2010 outline1("LDA %s", _y );
2011 outline0("STA IMAGEY" );
2012 outline1("LDA %s", address_displacement(_environment, _y, "1") );
2013 outline0("STA IMAGEY+1" );
2014 if ( strchr( _flags, '#' ) ) {
2015 outline1("LDA #((%s)&255)", _flags+1 );
2016 outline0("STA IMAGEF" );
2017 outline1("LDA #(((%s)>>8)&255)", _flags+1 );
2018 outline0("STA IMAGET" );
2019 } else {
2020 outline1("LDA %s", _flags );
2021 outline0("STA IMAGEF" );
2022 outline1("LDA %s", address_displacement(_environment, _flags, "1") );
2023 outline0("STA IMAGET" );
2024 }
2025
2026 outline0("JSR PUTIMAGE");
2027
2028}
2029
2030void ted_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 ) {
2031
2032 deploy( tedvars, src_hw_ted_vars_asm);
2033 deploy( tedvarsGraphic, src_hw_ted_vars_graphic_asm );
2034 deploy( blitimage, src_hw_ted_blit_image_asm );
2035
2036 if ( _source_count > 2 ) {
2038 }
2039
2041
2042 outhead1("blitimage%s:", label);
2043
2044 outline1("LDA #<%s", _blit );
2045 outline0("STA BLITIMAGEBLITADDR+1" );
2046 outline1("LDA #>%s", _blit );
2047 outline0("STA BLITIMAGEBLITADDR+2" );
2048
2049 if ( _source_count > 0 ) {
2050 Resource resource;
2051 resource.realName = strdup( _sources[0] );
2052 resource.type = VT_IMAGE;
2053 ted_load_image_address_to_register( _environment, "BLITTMPPTR", &resource, _sequence, _frame, _frame_size, _frame_count );
2054 } else {
2055 outline0( "LDA #$0" );
2056 outline0( "STA BLITTMPPTR" );
2057 outline0( "STA BLITTMPPTR+1" );
2058 }
2059
2060 if ( _source_count > 1 ) {
2061 Resource resource;
2062 resource.realName = strdup( _sources[0] );
2063 resource.type = VT_IMAGE;
2064 ted_load_image_address_to_register( _environment, "BLITTMPPTR2", &resource, _sequence, _frame, _frame_size, _frame_count );
2065 } else {
2066 outline0( "LDA #$0" );
2067 outline0( "STA BLITTMPPTR2" );
2068 outline0( "STA BLITTMPPTR2+1" );
2069 }
2070
2071 outline1("LDA %s", _x );
2072 outline0("STA IMAGEX" );
2073 outline1("LDA %s", address_displacement(_environment, _x, "1") );
2074 outline0("STA IMAGEX+1" );
2075 outline1("LDA %s", _y );
2076 outline0("STA IMAGEY" );
2077 outline1("LDA %s", address_displacement(_environment, _y, "1") );
2078 outline0("STA IMAGEY+1" );
2079 outline1("LDA #$%2.2x", ( _flags & 0xff ) );
2080 outline0("STA IMAGEF" );
2081 outline1("LDA #$%2.2x", ( (_flags>>8) & 0xff ) );
2082 outline0("STA IMAGET" );
2083
2084 outline0("JSR BLITIMAGE");
2085
2086}
2087
2088void ted_wait_vbl( Environment * _environment, char * _raster_line ) {
2089
2090 deploy( vbl, src_hw_ted_vbl_asm);
2091
2092 outline0("JSR VBL");
2093
2094}
2095
2096Variable * ted_new_image( Environment * _environment, int _width, int _height, int _mode ) {
2097
2098 int size = ted_image_size( _environment, _width, _height, _mode );
2099
2100 if ( ! size ) {
2102 }
2103
2104 Variable * result = variable_temporary( _environment, VT_IMAGE, "(new image)" );
2105
2106 char * buffer = malloc ( size );
2107 memset( buffer, 0, size );
2108
2109 *(buffer) = ( _width & 0xff );
2110 *(buffer+1) = ( _width >> 8 ) & 0xff;
2111 *(buffer+2) = _height;
2112
2113 result->valueBuffer = buffer;
2114 result->size = size;
2115
2116 return result;
2117
2118}
2119
2120Variable * ted_new_images( Environment * _environment, int _frames, int _width, int _height, int _mode ) {
2121
2122 int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
2123 int frameSize = ted_image_size( _environment, _width, _height, _mode );
2124
2125 if ( ! size ) {
2127 }
2128
2129 Variable * result = variable_temporary( _environment, VT_IMAGES, "(new images)" );
2130
2131 char * buffer = malloc ( size );
2132 memset( buffer, 0, size );
2133
2134 *(buffer) = _frames;
2135 *(buffer+1) = ( _width & 0xff );
2136 *(buffer+2) = ( _width >> 8 ) & 0xff;
2137 for( int i=0; i<_frames; ++i ) {
2138 *(buffer+3+(i*frameSize)) = ( _width & 0xff );
2139 *(buffer+3+(i*frameSize)+1) = ( ( _width >> 8 ) & 0xff );
2140 *(buffer+3+(i*frameSize)+2) = ( _height & 0xff );
2141 }
2142
2143 result->valueBuffer = buffer;
2144 result->frameSize = frameSize;
2145 result->size = size;
2146 result->frameCount = _frames;
2147
2148 return result;
2149
2150}
2151
2152Variable * ted_new_sequence( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode ) {
2153
2154 int size2 = calculate_sequence_size( _environment, _sequences, _frames, _width, _height, _mode );
2155 int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
2156 int frameSize = ted_image_size( _environment, _width, _height, _mode );
2157
2158 if ( ! size ) {
2160 }
2161
2162 Variable * result = variable_temporary( _environment, VT_SEQUENCE, "(new images)" );
2163
2164 char * buffer = malloc ( size2 );
2165 memset( buffer, 0, size2 );
2166
2167 *(buffer) = _frames;
2168 *(buffer+1) = _width;
2169 *(buffer+2) = _sequences;
2170 for( int i=0; i<(_frames*_sequences); ++i ) {
2171 *(buffer+3+(i*frameSize)) = ( _width & 0xff );
2172 *(buffer+3+(i*frameSize)+1) = ( ( _width >> 8 ) & 0xff );
2173 *(buffer+3+(i*frameSize)+2) = ( _height & 0xff );
2174 }
2175
2176 result->valueBuffer = buffer;
2177 result->frameSize = frameSize;
2178 result->size = size;
2179 result->frameCount = _frames;
2180
2181 return result;
2182
2183}
2184
2185void ted_get_image( Environment * _environment, char * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, int _palette ) {
2186
2187 deploy( tedvars, src_hw_ted_vars_asm);
2188 deploy( tedvarsGraphic, src_hw_ted_vars_graphic_asm );
2189 deploy( getimage, src_hw_ted_get_image_asm );
2190
2191 ted_load_image_address_to_other_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
2192
2193 outline1("LDA %s", _x );
2194 outline0("STA IMAGEX" );
2195 outline1("LDA %s", address_displacement(_environment, _x, "1") );
2196 outline0("STA IMAGEX+1" );
2197 outline1("LDA %s", _y );
2198 outline0("STA IMAGEY" );
2199 outline1("LDA %s", address_displacement(_environment, _y, "1") );
2200 outline0("STA IMAGEY+1" );
2201 outline1("LDA #$%2.2x", _palette );
2202 outline0("STA IMAGET" );
2203
2204 outline0("JSR GETIMAGE");
2205
2206}
2207
2208void ted_put_tile( Environment * _environment, char * _tile, char * _x, char * _y ) {
2209
2210 deploy( tedvars, src_hw_ted_vars_asm);
2211 deploy( tiles, src_hw_ted_tiles_asm );
2212
2213 outline1("LDA %s", _tile );
2214 outline0("STA TILET" );
2215 outline1("LDA %s", _x );
2216 outline0("STA TILEX" );
2217 outline1("LDA %s", _y );
2218 outline0("STA TILEY" );
2219 outline0("LDA #1" );
2220 outline0("STA TILEW" );
2221 outline0("STA TILEH" );
2222 outline0("STA TILEW2" );
2223 outline0("STA TILEH2" );
2224
2225 outline0("JSR PUTTILE");
2226
2227}
2228
2229void ted_move_tiles( Environment * _environment, char * _tile, char * _x, char * _y ) {
2230
2231 Variable * tile = variable_retrieve( _environment, _tile );
2232 Variable * x = variable_retrieve( _environment, _x );
2233 Variable * y = variable_retrieve( _environment, _y );
2234
2235 deploy( tedvars, src_hw_ted_vars_asm);
2236 deploy( tiles, src_hw_ted_tiles_asm );
2237
2238 outline1("LDA %s", tile->realName );
2239 outline0("STA TILET" );
2240 outline1("LDA %s", x->realName );
2241 outline0("STA TILEX" );
2242 outline1("LDA %s", y->realName );
2243 outline0("STA TILEY" );
2244 outline1("LDA %s", address_displacement(_environment, tile->realName, "1") );
2245 outline0("STA TILEW" );
2246 outline0("STA TILEW2" );
2247 outline1("LDA %s", address_displacement(_environment, tile->realName, "2") );
2248 outline0("STA TILEH" );
2249 outline0("STA TILEH2" );
2250 outline1("LDA %s", address_displacement(_environment, tile->realName, "3") );
2251 outline0("STA TILEA" );
2252
2253 int size = ( tile->originalWidth >> 3 ) * ( tile->originalHeight >> 3 );
2254
2255 if ( size ) {
2256 outline1("LDA #<OFFSETS%4.4x", size );
2257 outline0("STA TMPPTR2" );
2258 outline1("LDA #>OFFSETS%4.4x", size );
2259 outline0("STA TMPPTR2+1" );
2260 } else {
2261 outline0("LDA #0" );
2262 outline0("STA TMPPTR2" );
2263 outline0("STA TMPPTR2+1" );
2264 }
2265
2266 outline0("JSR MOVETILE");
2267
2268}
2269
2270void ted_put_tiles( Environment * _environment, char * _tile, char * _x, char * _y, char *_w, char *_h ) {
2271
2272 deploy( tedvars, src_hw_ted_vars_asm);
2273 deploy( tiles, src_hw_ted_tiles_asm );
2274
2275 outline1("LDA %s", _tile );
2276 outline0("STA TILET" );
2277 outline1("LDA %s", _x );
2278 outline0("STA TILEX" );
2279 outline1("LDA %s", _y );
2280 outline0("STA TILEY" );
2281 outline1("LDA %s", address_displacement(_environment, _tile, "1") );
2282 outline0("STA TILEW" );
2283 if ( _w ) {
2284 outline1("LDA %s", _w );
2285 }
2286 outline0("STA TILEW2" );
2287 outline1("LDA %s", address_displacement(_environment, _tile, "2") );
2288 outline0("STA TILEH" );
2289 if ( _h ) {
2290 outline1("LDA %s", _h );
2291 }
2292 outline0("STA TILEH2" );
2293
2294 outline0("JSR PUTTILE");
2295
2296}
2297
2298void ted_tile_at( Environment * _environment, char * _x, char * _y, char * _result ) {
2299
2300 deploy( tedvars, src_hw_ted_vars_asm);
2301 deploy( tiles, src_hw_ted_tiles_asm );
2302
2303 outline1("LDA %s", _x );
2304 outline0("STA TILEX" );
2305 outline1("LDA %s", _y );
2306 outline0("STA TILEY" );
2307
2308 outline0("JSR TILEAT");
2309
2310 outline0("LDA TILET" );
2311 outline1("STA %s", _result );
2312
2313}
2314
2315void ted_use_tileset( Environment * _environment, char * _tileset ) {
2316
2317 deploy( tedvars, src_hw_ted_vars_asm);
2318 deploy( tiles, src_hw_ted_tiles_asm );
2319
2320 outline1("LDA %s", _tileset );
2321
2322 outline0("JSR USETILESET");
2323
2324}
2325
2327
2328 Variable * result = variable_temporary( _environment, VT_WORD, "(raster line)" );
2329
2330 outline0( "LDA $FF0B" );
2331 outline1( "STA %s", result->realName );
2332 outline0( "LDA $FF0A" );
2333 outline0( "AND #$01" );
2334 outline1( "STA %s", address_displacement(_environment, result->realName, "1") );
2335
2336 return result;
2337
2338}
2339
2340/* audio */
2341
2342static unsigned int SOUND_FREQUENCIES[] = {
2343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2344 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2345 0, 0, 0, -5816, -5432, -5070, -4728, -4405, -4100, -3812,
2346 -3541, -3285, -3043, -2815, -2599, -2396, -2204, -2026, -1852, -1690,
2347 -1538, -1394, -1258, -1130, -1009, -895, -788, -686, -590, -499,
2348 -414, -333, -257, -185, -117, -53, 7, 64, 118, 169,
2349 217, 262, 305, 345, 383, 419, 453, 485, 516, 544,
2350 571, 597, 621, 643, 665, 685, 704, 722, 739, 755,
2351 770, 784, 798, 810, 822, 834, 844, 854, 864, 873,
2352 881, 889, 897, 904, 911, 917, 923, 929, 934, 939,
2353 944, 948, 953, 957, 960, 964, 967, 971, 974, 976,
2354 979, 982, 984, 986, 988, 990, 992, 994, 996
2355};
2356
2357void ted_start( Environment * _environment, int _channels ) {
2358
2359 deploy( tedvars, src_hw_ted_vars_asm );
2360 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2361
2362 if ( _channels & 0x01 ) {
2363 outline0("JSR TEDSTART0");
2364 }
2365 if ( _channels & 0x02 ) {
2366 outline0("JSR TEDSTART1");
2367 }
2368
2369}
2370
2371void ted_set_volume( Environment * _environment, int _channels, int _volume ) {
2372
2373 deploy( tedvars, src_hw_ted_vars_asm );
2374 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2375
2376 outline1("LDX #%2.2x", ( _volume & 0x0f ) );
2377 outline0("JSR TEDSTARTVOL");
2378
2379}
2380
2381#define FREQTED( f ) ( 1024 - (111841 / (f) ) )
2382
2383#define PROGRAM_FREQUENCY( c, f ) \
2384 outline1("LDX #$%2.2x", ( FREQTED( f ) ) & 0xff ); \
2385 outline1("LDY #$%2.2x", ( ( FREQTED( f ) ) >> 8 ) & 0xff ); \
2386 if ( ( c & 0x01 ) ) \
2387 outline0("JSR TEDPROGFREQ0" ); \
2388 if ( ( c & 0x02 ) ) \
2389 outline0("JSR TEDPROGFREQ1" ); \
2390
2391#define PROGRAM_FREQUENCY_V( c, f ) \
2392 outline1("LDA %s", ( c == NULL ? "#$3" : c ) ); \
2393 outline1("LDX %s", f ); \
2394 outline1("LDY %s", address_displacement(_environment, f, "1") ); \
2395 outline0("JSR TEDFREQ" );
2396
2397#define PROGRAM_FREQUENCY_SV( c, f ) \
2398 outline1("LDX #$%2.2x", ( FREQTED( f ) ) & 0xff ); \
2399 outline1("LDY #$%2.2x", ( ( FREQTED( f ) ) >> 8 ) & 0xff ); \
2400 outline1("LDA %s", ( c == NULL ? "#$3" : c ) ); \
2401 outline0("JSR TEDFREQ2" );
2402
2403#define PROGRAM_DURATION( c, d ) \
2404 outline1("LDX #$%2.2x", ( d ) & 0xff ); \
2405 outline1("LDY #$%2.2x", ( ( d ) >> 8 ) & 0xff ); \
2406 if ( ( c & 0x01 ) ) \
2407 outline0("JSR TEDPROGDUR0" ); \
2408 if ( ( c & 0x02 ) ) \
2409 outline0("JSR TEDPROGDUR1" ); \
2410
2411#define WAIT_DURATION( c ) \
2412 if ( ( c & 0x01 ) ) \
2413 outline0("JSR TEDWAITDUR0" ); \
2414 if ( ( c & 0x02 ) ) \
2415 outline0("JSR TEDWAITDUR1" ); \
2416
2417#define PROGRAM_PITCH( c, f ) \
2418 outline1("LDX #$%2.2x", ( f & 0xff ) ); \
2419 outline1("LDY #$%2.2x", ( ( f >> 8 ) & 0xff ) ); \
2420 if ( ( c & 0x01 ) ) \
2421 outline0("JSR TEDPROGFREQ0" ); \
2422 if ( ( c & 0x02 ) ) \
2423 outline0("JSR TEDPROGFREQ1" ); \
2424
2425#define PROGRAM_PITCH_V( c, f ) \
2426 outline1("LDA %s", ( c == NULL ? "#$3" : c ) ); \
2427 outline1("LDX %s", f ); \
2428 outline1("LDY %s", address_displacement(_environment, f, "1") ); \
2429 outline0("JSR TEDPROGFREQ" );
2430
2431#define PROGRAM_PITCH_SV( c, f ) \
2432 outline1("LDX #$%2.2x", ( f & 0xff ) ); \
2433 outline1("LDY #$%2.2x", ( ( f >> 8 ) & 0xff ) ); \
2434 outline1("LDA %s", ( c == NULL ? "#$3" : c ) ); \
2435 outline0("JSR TEDPROGFREQ" );
2436
2437#define PROGRAM_PULSE( c, p ) \
2438 outline1("LDX #$%2.2x", ( p & 0xff ) ); \
2439 outline1("LDY #$%2.2x", ( ( p >> 8 ) & 0xff ) ); \
2440 if ( ( c & 0x01 ) ) \
2441 outline0("JSR TEDPROGPULSE0" ); \
2442 if ( ( c & 0x02 ) ) \
2443 outline0("JSR TEDPROGPULSE1" ); \
2444
2445#define PROGRAM_PULSE_V( c, p ) \
2446 outline1("LDA %s", ( c == NULL ? "#$3" : c ) ); \
2447 outline1("LDX %s", p ); \
2448 outline1("LDY %s", address_displacement(_environment, p, "1") ); \
2449 outline0("JSR TEDPROGPULSE" );
2450
2451#define PROGRAM_PULSE_SV( c, p ) \
2452 outline1("LDX #$%2.2x", ( p & 0xff ) ); \
2453 outline1("LDY #$%2.2x", ( ( p >> 8 ) & 0xff ) ); \
2454 outline1("LDA %s", ( c == NULL ? "#$3" : c ) ); \
2455 outline0("JSR TEDPROGPULSE" );
2456
2457#define PROGRAM_NOISE( c ) \
2458 outline0("JSR TEDPROGNOISE" );
2459
2460#define PROGRAM_NOISE_V( c, p ) \
2461 outline0("JSR TEDPROGNOISE" );
2462
2463#define PROGRAM_NOISE_SV( c ) \
2464 outline0("JSR TEDPROGNOISE" );
2465
2466#define PROGRAM_SAW( c )
2467
2468#define PROGRAM_SAW_V( c )
2469
2470#define PROGRAM_SAW_SV( c )
2471
2472#define PROGRAM_TRIANGLE( c )
2473
2474#define PROGRAM_TRIANGLE_V( c )
2475
2476#define PROGRAM_TRIANGLE_SV( c )
2477
2478#define PROGRAM_SAW_TRIANGLE( c )
2479
2480#define PROGRAM_SAW_TRIANGLE_V( c )
2481
2482#define PROGRAM_SAW_TRIANGLE_SV( c )
2483
2484#define PROGRAM_ATTACK_DECAY( c, a, d )
2485
2486#define PROGRAM_ATTACK_DECAY_V( c, a, d )
2487
2488#define PROGRAM_ATTACK_DECAY_SV( c, a, d )
2489
2490#define PROGRAM_SUSTAIN_RELEASE( c, s, r )
2491
2492#define PROGRAM_SUSTAIN_RELEASE_V( c, s, r )
2493
2494#define PROGRAM_SUSTAIN_RELEASE_SV( c, s, r )
2495
2496#define STOP_FREQUENCY( c ) \
2497 if ( ( c & 0x01 ) ) \
2498 outline0("JSR TEDSTOP0" ); \
2499 if ( ( c & 0x02 ) ) \
2500 outline0("JSR TEDSTOP1" ); \
2501
2502#define STOP_FREQUENCY_V( c ) \
2503 outline1("LDA %s", ( c == NULL ? "#$3" : c ) ); \
2504 outline0("JSR TEDSTOP" );
2505
2506#define STOP_FREQUENCY_SV( c ) \
2507 outline1("LDA %s", ( c == NULL ? "#$3" : c ) ); \
2508 outline0("JSR TEDSTOP" );
2509
2510void ted_set_program( Environment * _environment, int _channels, int _program ) {
2511
2512 deploy( tedvars, src_hw_ted_vars_asm );
2513 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2514
2515 switch (_program) {
2517 PROGRAM_NOISE(_channels);
2518 PROGRAM_ATTACK_DECAY(_channels, 2, 11);
2519 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 1);
2520 break;
2522 PROGRAM_NOISE(_channels);
2523 PROGRAM_ATTACK_DECAY(_channels, 2, 4);
2524 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 1);
2525 break;
2536 PROGRAM_TRIANGLE(_channels);
2537 PROGRAM_ATTACK_DECAY(_channels, 4, 2);
2538 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 10);
2539 break;
2540
2544 PROGRAM_PULSE(_channels, 1024);
2545 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
2546 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 3);
2547 break;
2548
2557 PROGRAM_TRIANGLE(_channels);
2558 PROGRAM_ATTACK_DECAY(_channels, 2, 10);
2559 PROGRAM_SUSTAIN_RELEASE(_channels, 12, 14);
2560 break;
2561
2562 default:
2572 PROGRAM_TRIANGLE(_channels);
2573 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
2574 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
2575 break;
2576
2584 PROGRAM_PULSE(_channels, 128);
2585 PROGRAM_ATTACK_DECAY(_channels, 10, 10);
2586 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 10);
2587 break;
2588
2590 PROGRAM_PULSE(_channels, 128);
2591 PROGRAM_ATTACK_DECAY(_channels, 1, 2);
2592 PROGRAM_SUSTAIN_RELEASE(_channels, 4, 3);
2593 break;
2594
2604 PROGRAM_TRIANGLE(_channels);
2605 PROGRAM_ATTACK_DECAY(_channels, 2, 10);
2606 PROGRAM_SUSTAIN_RELEASE(_channels, 12, 14);
2607 break;
2608
2621 PROGRAM_PULSE(_channels, 128);
2622 PROGRAM_ATTACK_DECAY(_channels, 10, 10);
2623 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 10);
2624 break;
2625
2645 PROGRAM_NOISE(_channels);
2646 PROGRAM_ATTACK_DECAY(_channels, 1, 14);
2647 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
2648 break;
2649
2677 PROGRAM_SAW(_channels);
2678 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
2679 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
2680 break;
2681
2704 PROGRAM_SAW(_channels);
2705 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
2706 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
2707 break;
2708 }
2709
2710}
2711
2712void ted_set_parameter( Environment * _environment, int _channels, int _parameter, int _value ) {
2713
2714}
2715
2716void ted_set_frequency( Environment * _environment, int _channels, int _frequency ) {
2717
2718 deploy( tedvars, src_hw_ted_vars_asm );
2719 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2720
2721 PROGRAM_FREQUENCY( _channels, _frequency );
2722
2723}
2724
2725void ted_set_pitch( Environment * _environment, int _channels, int _pitch ) {
2726
2727 deploy( tedvars, src_hw_ted_vars_asm );
2728 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2729
2730 PROGRAM_PITCH( _channels, _pitch );
2731
2732}
2733
2734void ted_set_note( Environment * _environment, int _channels, int _note ) {
2735
2736 ted_set_pitch( _environment, _channels, SOUND_FREQUENCIES[_note] );
2737
2738}
2739
2740void ted_stop( Environment * _environment, int _channels ) {
2741
2742 deploy( tedvars, src_hw_ted_vars_asm );
2743 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2744
2745 STOP_FREQUENCY( _channels );
2746
2747}
2748
2749void ted_start_var( Environment * _environment, char * _channels ) {
2750
2751 deploy( tedvars, src_hw_ted_vars_asm );
2752 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2753
2754 if ( _channels ) {
2755 outline1("LDA %s", _channels );
2756 } else {
2757 outline0("LDA #$3" );
2758 }
2759 outline0("JSR TEDSTART");
2760
2761}
2762
2763void ted_set_volume_vars( Environment * _environment, char * _channels, char * _volume ) {
2764
2765 deploy( tedvars, src_hw_ted_vars_asm );
2766 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2767
2768 outline1("LDA %s", _volume );
2769 outline0("LSR" );
2770 outline0("LSR" );
2771 outline0("LSR" );
2772 outline0("LSR" );
2773 outline0("TAX" );
2774 outline0("JSR TEDSTARTVOL");
2775
2776}
2777
2778void ted_set_volume_semi_var( Environment * _environment, char * _channel, int _volume ) {
2779
2780 deploy( tedvars, src_hw_ted_vars_asm );
2781 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2782
2783 outline1("LDX #$%2.2x", _volume );
2784 outline0("JSR TEDSTARTVOL");
2785
2786}
2787
2788void ted_set_program_semi_var( Environment * _environment, char * _channels, int _program ) {
2789
2790 deploy( tedvars, src_hw_ted_vars_asm );
2791 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2792
2793 switch (_program) {
2795 PROGRAM_NOISE_SV(_channels);
2796 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 11);
2797 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 0, 1);
2798 break;
2800 PROGRAM_NOISE_SV(_channels);
2801 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 4);
2802 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 0, 1);
2803 break;
2814 PROGRAM_TRIANGLE_SV(_channels);
2815 PROGRAM_ATTACK_DECAY_SV(_channels, 4, 2);
2816 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
2817 break;
2818
2822 PROGRAM_PULSE_SV(_channels, 1024);
2823 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
2824 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 3);
2825 break;
2826
2835 PROGRAM_TRIANGLE_SV(_channels);
2836 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 10);
2837 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 12, 14);
2838 break;
2839
2840 default:
2850 PROGRAM_TRIANGLE_SV(_channels);
2851 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
2852 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
2853 break;
2854
2862 PROGRAM_PULSE_SV(_channels, 128);
2863 PROGRAM_ATTACK_DECAY_SV(_channels, 10, 10);
2864 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
2865 break;
2866
2868 PROGRAM_PULSE_SV(_channels, 128);
2869 PROGRAM_ATTACK_DECAY_SV(_channels, 1, 2);
2870 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 4, 3);
2871 break;
2872
2882 PROGRAM_TRIANGLE_SV(_channels);
2883 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 10);
2884 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 12, 14);
2885 break;
2886
2899 PROGRAM_PULSE_SV(_channels, 128);
2900 PROGRAM_ATTACK_DECAY_SV(_channels, 10, 10);
2901 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
2902 break;
2903
2923 PROGRAM_NOISE_SV(_channels);
2924 PROGRAM_ATTACK_DECAY_SV(_channels, 1, 14);
2925 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
2926 break;
2927
2955 PROGRAM_SAW_SV(_channels);
2956 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
2957 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
2958 break;
2959
2982 PROGRAM_SAW_SV(_channels);
2983 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
2984 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
2985 break;
2986 }
2987
2988}
2989
2990void ted_set_frequency_vars( Environment * _environment, char * _channels, char * _frequency ) {
2991
2992 deploy( tedvars, src_hw_ted_vars_asm );
2993 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
2994
2995 if ( _channels ) {
2996 outline1("LDA %s", _channels );
2997 } else {
2998 outline0("LDA #$3" );
2999 }
3000 outline1("LDX %s", _frequency );
3001 outline1("LDY %s", address_displacement(_environment, _frequency, "1") );
3002
3003 outline0("JSR TEDFREQ");
3004
3005}
3006
3007void ted_set_pitch_vars( Environment * _environment, char * _channels, char * _pitch ) {
3008
3009 deploy( tedvars, src_hw_ted_vars_asm );
3010 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
3011
3012 if ( _channels ) {
3013 outline1("LDA %s", _channels );
3014 } else {
3015 outline0("LDA #$3" );
3016 }
3017 outline1("LDX %s", _pitch );
3018 outline1("LDY %s", address_displacement(_environment, _pitch, "1") );
3019
3020 outline0("JSR TEDPROGFREQ");
3021
3022}
3023
3024void ted_set_note_vars( Environment * _environment, char * _channels, char * _note ) {
3025
3026 deploy( tedvars, src_hw_ted_vars_asm );
3027 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
3028
3029 outline0("LDA #<TEDFREQTABLE");
3030 outline0("STA TMPPTR");
3031 outline0("LDA #>TEDFREQTABLE");
3032 outline0("STA TMPPTR+1");
3033 outline1("LDY %s", _note);
3034 outline0("TYA");
3035 outline0("ASL");
3036 outline0("TAY");
3037 outline0("LDA (TMPPTR),Y");
3038 outline0("TAX");
3039 outline0("INY");
3040 outline0("LDA (TMPPTR),Y");
3041 outline0("TAY");
3042
3043 if ( _channels ) {
3044 outline1("LDA %s", _channels );
3045 } else {
3046 outline0("LDA #$3" );
3047 }
3048
3049 outline0("JSR TEDPROGFREQ");
3050
3051}
3052
3053void ted_stop_vars( Environment * _environment, char * _channels ) {
3054
3055 deploy( tedvars, src_hw_ted_vars_asm );
3056 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
3057
3058 outline1("LDA %s", _channels );
3059 outline0("JSR TEDSTOP");
3060
3061}
3062
3063void ted_music( Environment * _environment, char * _music, int _size, int _loop ) {
3064
3065 deploy( tedvars, src_hw_ted_vars_asm );
3066 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
3067
3068 outline0("SEI");
3069 outline1("LDA #<%s", _music);
3070 outline0("STA TEDTMPPTR_BACKUP");
3071 outline1("LDA #>%s", _music);
3072 outline0("STA TEDTMPPTR_BACKUP+1");
3073 outline1("LDA #$%2.2x", ( _size>>8 ) & 0xff);
3074 outline0("STA TEDBLOCKS_BACKUP");
3075 outline1("LDA #$%2.2x", _size & 0xff );
3076 outline0("STA TEDLASTBLOCK_BACKUP");
3077 outline1("LDA #$%2.2x", _loop );
3078 outline0("STA TEDMUSICLOOP");
3079 outline0("JSR MUSICPLAYERRESET");
3080 outline0("CLI");
3081
3082}
3083
3084void ted_slice_image( Environment * _environment, char * _image, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _destination ) {
3085
3086}
3087
3088int ted_palette_extract( Environment * _environment, char * _data, int _width, int _height, int _depth, int _flags, RGBi * _palette ) {
3089
3090 int paletteColorCount = rgbi_extract_palette(_environment, _data, _width, _height, _depth, _palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
3091
3092 memcpy( _palette, palette_match( _palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) ), paletteColorCount * sizeof( RGBi ) );
3093
3094 int uniquePaletteCount = 0;
3095
3096 memcpy( _palette, palette_remove_duplicates( _palette, paletteColorCount, &uniquePaletteCount ), paletteColorCount * sizeof( RGBi ) );
3097
3098 return uniquePaletteCount;
3099
3100}
3101
3102void ted_flip_image( Environment * _environment, Resource * _image, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _direction ) {
3103
3104 deploy( tedvars, src_hw_ted_vars_asm);
3105 deploy( tedvarsGraphic, src_hw_ted_vars_graphic_asm );
3106
3107 if ( strcmp( _direction, "#FLIPIMAGEDIRECTION0001" ) == 0 || strcmp( _direction, "#FLIPIMAGEDIRECTION0003" ) == 0 ) {
3108 ted_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
3109 deploy( flipimagex, src_hw_ted_flip_image_x_asm );
3110 outline0("JSR FLIPIMAGEX");
3111 } else {
3112
3114
3115 ted_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
3116 deploy( flipimagex, src_hw_ted_flip_image_x_asm );
3117 outline1("LDA %s", _direction );
3118 outline1("AND #$%2.2x", FLAG_FLIP_X );
3119 outline1("BEQ %s", label );
3120 outline0("JSR FLIPIMAGEX");
3121 outhead1("%s:", label );
3122
3123 }
3124
3125 if ( strcmp( _direction, "#FLIPIMAGEDIRECTION0002" ) == 0 || strcmp( _direction, "#FLIPIMAGEDIRECTION0003" ) == 0 ) {
3126 ted_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
3127 deploy( flipimagey, src_hw_ted_flip_image_y_asm );
3128 outline0("JSR FLIPIMAGEY");
3129 } else {
3130
3132
3133 ted_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
3134 deploy( flipimagey, src_hw_ted_flip_image_y_asm );
3135 outline1("LDA %s", _direction );
3136 outline1("AND #$%2.2x", FLAG_FLIP_Y );
3137 outline1("BEQ %s", label );
3138 outline0("JSR FLIPIMAGEY");
3139 outhead1("%s:", label );
3140
3141 }
3142
3143
3144}
3145
3146void ted_set_duration( Environment * _environment, int _channels, int _duration ) {
3147
3148 deploy( tedvars, src_hw_ted_vars_asm );
3149 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
3150
3151 PROGRAM_DURATION( _channels, _duration );
3152
3153}
3154
3155void ted_wait_duration( Environment * _environment, int _channels ) {
3156
3157 deploy( tedvars, src_hw_ted_vars_asm );
3158 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
3159
3160 WAIT_DURATION( _channels );
3161
3162}
3163
3164void ted_set_duration_vars( Environment * _environment, char * _channels, char * _duration ) {
3165
3166 deploy( tedvars, src_hw_ted_vars_asm );
3167 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
3168
3169 if ( _channels ) {
3170 outline1("LDA %s", _channels );
3171 } else {
3172 outline0("LDA #$3" );
3173 }
3174 if ( _duration ) {
3175 outline1("LDX %s", _duration );
3176 outline1("LDY %s", address_displacement( _environment, _duration, "1" ) );
3177 } else {
3178 outline0("LDX #50" );
3179 outline0("LDY #0" );
3180 }
3181
3182 outline0("JSR TEDPROGDUR");
3183
3184}
3185
3186void ted_wait_duration_vars( Environment * _environment, char * _channels ) {
3187
3188 deploy( tedvars, src_hw_ted_vars_asm );
3189 deploy_preferred( tedstartup, src_hw_ted_startup_asm );
3190
3191 if ( _channels ) {
3192 outline1("LDA %s", _channels );
3193 } else {
3194 outline0("LDA #$3" );
3195 }
3196
3197 outline0("JSR TEDWAITDUR");
3198
3199}
3200
3201
3202void ted_screen( Environment * _environment, char * _x, char * _y, char * _c ) {
3203
3204 deploy( screen, src_hw_ted_screen_asm);
3205
3206 outline1( "LDA %s", _x );
3207 outline0( "STA MATHPTR1" );
3208 outline1( "LDA %s", _y );
3209 outline0( "STA MATHPTR0" );
3210 outline0( "JSR SCREEN" );
3211 outline1( "STA %s", _c );
3212
3213}
3214
3215#endif
void cpu_store_16bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 16 bit
Definition 6309.c:1503
void cpu_label(Environment *_environment, char *_label)
Definition 6309.c:356
void cpu_move_16bit(Environment *_environment, char *_source, char *_destination)
CPU 6309: emit code to move 16 bit
Definition 6309.c:1474
void cpu_store_8bit(Environment *_environment, char *_destination, int _value)
CPU 6309: emit code to store 8 bit
Definition 6309.c:761
void cpu_beq(Environment *_environment, char *_label)
CPU 6309: emit code to make long conditional jump
Definition 6309.c:308
int lastUsedSlotInCommonPalette
Definition 6847.c:100
#define COLOR_COUNT
Definition 6847.h:72
#define BITMAP_MODE_STANDARD
Definition 6847.h:96
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_import(Environment *_environment, char *_name, VariableType _type, int _size_or_value)
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_remove_duplicates(RGBi *_source, int _source_size, int *_unique_size)
Remove duplicates from a palette.
RGBi * palette_match(RGBi *_source, int _source_size, RGBi *_system, int _system_size)
Make a "palette match".
void image_converter_asserts(Environment *_environment, int _width, int _height, int _offset_x, int _offset_y, int *_frame_width, int *_frame_height, int _modulo_x, int _modulo_y)
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
Variable * variable_store_buffer(Environment *_environment, char *_destination, unsigned char *_buffer, int _size, int _at)
int size
Definition _optimizer.c:678
int offset
Definition _optimizer.c:681
void back(Environment *_environment, char *_color)
Emit ASM code to fill background color.
Definition back.c:53
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
#define TILEMAP_MODE_STANDARD
Definition cga.h:80
void console_init(Environment *_environment)
Definition console.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
int width
Definition ugbc.h:2209
int y1
Definition ugbc.h:2206
int x1
Definition ugbc.h:2205
int height
Definition ugbc.h:2210
char * name
Definition ugbc.h:2252
struct _CopperList * next
Definition ugbc.h:2255
int tedstartup
Definition ugbc.h:1755
int screenTilesWidth
Definition ugbc.h:2880
int screenShades
Definition ugbc.h:2865
int fontHeight
Definition ugbc.h:2905
Console activeConsole
Definition ugbc.h:2910
int freeImageWidth
Definition ugbc.h:3088
int currentMode
Definition ugbc.h:2696
int screenTilesHeight
Definition ugbc.h:2885
int consoleTilesHeight
Definition ugbc.h:2895
RgbConverterFunction currentRgbConverterFunction
Definition ugbc.h:2711
int fontWidth
Definition ugbc.h:2900
CopperList * copperList
Definition ugbc.h:3282
int screenColors
Definition ugbc.h:2870
int dynamicConsole
Definition ugbc.h:3298
int currentModeBW
Definition ugbc.h:2701
int screenHeight
Definition ugbc.h:2860
int consoleTilesWidth
Definition ugbc.h:2890
int currentTileMode
Definition ugbc.h:2706
int screenTiles
Definition ugbc.h:2875
int freeImageHeight
Definition ugbc.h:3086
int screenWidth
Definition ugbc.h:2855
Deployed deployed
Definition ugbc.h:2921
VestigialConfig vestigialConfig
Definition ugbc.h:2442
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
int isAddress
Definition ugbc.h:557
VariableType type
Definition ugbc.h:559
char * realName
Definition ugbc.h:555
int selected
Definition ugbc.h:1510
unsigned char * valueBuffer
Definition ugbc.h:1061
int size
Definition ugbc.h:1077
int originalHeight
Definition ugbc.h:1148
char * name
Definition ugbc.h:979
int originalColors
Definition ugbc.h:1154
VariableType type
Definition ugbc.h:988
int frameSize
Definition ugbc.h:1134
int frameCount
Definition ugbc.h:1137
int originalWidth
Definition ugbc.h:1145
RGBi originalPalette[MAX_PALETTE]
Definition ugbc.h:1169
char * realName
Definition ugbc.h:982
char clsImplicit
Definition ugbc.h:2008
void ted_set_note_vars(Environment *_environment, char *_channels, char *_note)
Definition ted.c:3024
int ted_palette_extract(Environment *_environment, char *_data, int _width, int _height, int _depth, int _flags, RGBi *_palette)
Definition ted.c:3088
void ted_screen_columns(Environment *_environment, char *_columns)
Definition ted.c:1125
void ted_sprite_multicolor(Environment *_environment, char *_sprite)
Definition ted.c:1181
void ted_collision(Environment *_environment, char *_sprite_mask, char *_result)
Definition ted.c:517
void ted_wait_duration_vars(Environment *_environment, char *_channels)
Definition ted.c:3186
void ted_set_pitch_vars(Environment *_environment, char *_channels, char *_pitch)
Definition ted.c:3007
#define PROGRAM_DURATION(c, d)
Definition ted.c:2403
#define PROGRAM_TRIANGLE_SV(c)
Definition ted.c:2476
#define PROGRAM_SAW_SV(c)
Definition ted.c:2470
void ted_background_color_semivars(Environment *_environment, int _index, char *_background_color)
TED: emit code to change background color
Definition ted.c:589
void ted_scroll_text(Environment *_environment, int _direction, int _overlap)
Definition ted.c:1301
void ted_colormap_at(Environment *_environment, char *_address)
Definition ted.c:986
void ted_slice_image(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
Definition ted.c:3084
Variable * ted_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)
Definition ted.c:1698
void ted_background_color_vars(Environment *_environment, char *_index, char *_background_color)
TED: emit code to change background color
Definition ted.c:569
#define PROGRAM_FREQUENCY(c, f)
Definition ted.c:2383
Variable * ted_new_images(Environment *_environment, int _frames, int _width, int _height, int _mode)
Definition ted.c:2120
void ted_move_tiles(Environment *_environment, char *_tile, char *_x, char *_y)
Definition ted.c:2229
void ted_hit(Environment *_environment, char *_sprite_mask, char *_result)
Definition ted.c:521
void ted_set_frequency(Environment *_environment, int _channels, int _frequency)
Definition ted.c:2716
void ted_charset_at(Environment *_environment, char *_address)
Definition ted.c:1002
void ted_sprite_priority(Environment *_environment, char *_sprite, char *_priority)
Definition ted.c:1193
void ted_pget_color_vars(Environment *_environment, char *_x, char *_y, char *_result)
Definition ted.c:1073
#define PROGRAM_SAW(c)
Definition ted.c:2466
void ted_sprite_monocolor(Environment *_environment, char *_sprite)
Definition ted.c:1185
void ted_cls(Environment *_environment)
Definition ted.c:1265
#define PROGRAM_NOISE_SV(c)
Definition ted.c:2463
void ted_text(Environment *_environment, char *_text, char *_text_size, int _raw)
Definition ted.c:1331
RGBi * ted_image_nearest_system_color(RGBi *_color)
Definition ted.c:94
void ted_set_duration(Environment *_environment, int _channels, int _duration)
Definition ted.c:3146
void ted_stop_vars(Environment *_environment, char *_channels)
Definition ted.c:3053
void ted_initialization(Environment *_environment)
Definition ted.c:1357
void ted_bitmap_disable(Environment *_environment)
Definition ted.c:951
#define WAIT_DURATION(c)
Definition ted.c:2411
void ted_set_duration_vars(Environment *_environment, char *_channels, char *_duration)
Definition ted.c:3164
Variable * ted_new_sequence(Environment *_environment, int _sequences, int _frames, int _width, int _height, int _mode)
Definition ted.c:2152
void ted_sprite_color(Environment *_environment, char *_sprite, char *_color)
Definition ted.c:1189
void ted_set_pitch(Environment *_environment, int _channels, int _pitch)
Definition ted.c:2725
void ted_sprite_data_from(Environment *_environment, char *_sprite, char *_address)
Definition ted.c:1145
void ted_horizontal_scroll(Environment *_environment, char *_displacement)
Definition ted.c:1210
void ted_set_note(Environment *_environment, int _channels, int _note)
Definition ted.c:2734
void ted_pset_vars(Environment *_environment, char *_x, char *_y, char *_c)
Definition ted.c:1035
void ted_back(Environment *_environment)
Definition ted.c:1473
void ted_calculate_sequence_frame_offset(Environment *_environment, char *_offset, char *_sequence, char *_frame, int _frame_size, int _frame_count)
Definition ted.c:1721
void ted_scroll(Environment *_environment, int _dx, int _dy)
Definition ted.c:1316
void ted_start(Environment *_environment, int _channels)
Definition ted.c:2357
int ted_screen_mode_enable(Environment *_environment, ScreenMode *_screen_mode)
Definition ted.c:744
void ted_sprite_disable(Environment *_environment, char *_sprite)
Definition ted.c:1157
void ted_vertical_scroll(Environment *_environment, char *_displacement)
Definition ted.c:1201
#define STOP_FREQUENCY(c)
Definition ted.c:2496
void ted_hscroll_screen(Environment *_environment, int _direction, int _overlap)
Definition ted.c:1461
void ted_busy_wait(Environment *_environment, char *_timing)
Definition ted.c:1219
void ted_start_var(Environment *_environment, char *_channels)
Definition ted.c:2749
void ted_get_image(Environment *_environment, char *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _palette)
Definition ted.c:2185
void ted_screen_rows(Environment *_environment, char *_rows)
Definition ted.c:1105
#define PROGRAM_ATTACK_DECAY(c, a, d)
Definition ted.c:2484
void ted_tiles_get(Environment *_environment, char *_result)
Definition ted.c:1249
#define PROGRAM_SUSTAIN_RELEASE_SV(c, s, r)
Definition ted.c:2494
void ted_hscroll_line(Environment *_environment, int _direction, int _overlap)
Definition ted.c:1447
void ted_sprite_common_color(Environment *_environment, char *_index, char *_common_color)
Definition ted.c:620
void ted_set_program(Environment *_environment, int _channels, int _program)
Definition ted.c:2510
void ted_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)
Definition ted.c:2030
void ted_cls_box(Environment *_environment, char *_x1, char *_y1, char *_w, char *_h)
Definition ted.c:1277
void ted_sprite_expand_vertical(Environment *_environment, char *_sprite)
Definition ted.c:1165
void ted_bitmap_at(Environment *_environment, char *_address)
Definition ted.c:982
void ted_set_program_semi_var(Environment *_environment, char *_channels, int _program)
Definition ted.c:2788
void ted_set_frequency_vars(Environment *_environment, char *_channels, char *_frequency)
Definition ted.c:2990
void ted_tilemap_enable(Environment *_environment, int _width, int _height, int _colors, int _tile_width, int _tile_height)
Definition ted.c:964
void ted_put_tiles(Environment *_environment, char *_tile, char *_x, char *_y, char *_w, char *_h)
Definition ted.c:2270
void ted_pset_int(Environment *_environment, int _x, int _y, int *_c)
Definition ted.c:1006
void ted_background_color_get_vars(Environment *_environment, char *_index, char *_background_color)
TED: emit code to retrieve background color
Definition ted.c:609
void ted_sprite_enable(Environment *_environment, char *_sprite)
Definition ted.c:1153
void ted_stop(Environment *_environment, int _channels)
Definition ted.c:2740
void ted_charset_uppercase(Environment *_environment)
Definition ted.c:994
#define PROGRAM_SUSTAIN_RELEASE(c, s, r)
Definition ted.c:2490
void ted_screen_on(Environment *_environment)
Definition ted.c:1097
#define PROGRAM_NOISE(c)
Definition ted.c:2457
void ted_finalization(Environment *_environment)
Definition ted.c:1423
void ted_put_tile(Environment *_environment, char *_tile, char *_x, char *_y)
Definition ted.c:2208
void ted_background_color(Environment *_environment, int _index, int _background_color)
TED: emit code to change bac_kground color
Definition ted.c:552
void console_calculate_vars(Environment *_environment)
Definition ted.c:925
#define PROGRAM_PULSE_SV(c, p)
Definition ted.c:2451
void ted_sprite_at(Environment *_environment, char *_sprite, char *_x, char *_y)
Definition ted.c:1161
void ted_get_height(Environment *_environment, char *_result)
Definition ted.c:1256
void ted_textmap_at(Environment *_environment, char *_address)
Definition ted.c:990
void ted_sprite_compress_vertical(Environment *_environment, char *_sprite)
Definition ted.c:1173
void ted_set_parameter(Environment *_environment, int _channels, int _parameter, int _value)
Definition ted.c:2712
#define PROGRAM_PITCH(c, f)
Definition ted.c:2417
void ted_next_raster(Environment *_environment)
TED: emit code to wait for next raster irq
Definition ted.c:674
void ted_get_width(Environment *_environment, char *_result)
Definition ted.c:1240
void ted_next_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
TED: emit code to wait for next raster irq at different position
Definition ted.c:694
void ted_border_color(Environment *_environment, char *_border_color)
TED: emit code to change border color
Definition ted.c:534
void ted_set_volume_vars(Environment *_environment, char *_channels, char *_volume)
Definition ted.c:2763
void ted_bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
Definition ted.c:933
void ted_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
TED: emit code to set raster irq
Definition ted.c:639
Variable * ted_new_image(Environment *_environment, int _width, int _height, int _mode)
Definition ted.c:2096
void ted_use_tileset(Environment *_environment, char *_tileset)
Definition ted.c:2315
void ted_music(Environment *_environment, char *_music, int _size, int _loop)
Definition ted.c:3063
void ted_wait_vbl(Environment *_environment, char *_raster_line)
Definition ted.c:2088
void ted_sprite_expand_horizontal(Environment *_environment, char *_sprite)
Definition ted.c:1169
void ted_flip_image(Environment *_environment, Resource *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_direction)
Definition ted.c:3102
void ted_wait_duration(Environment *_environment, int _channels)
Definition ted.c:3155
void ted_set_volume_semi_var(Environment *_environment, char *_channel, int _volume)
Definition ted.c:2778
void ted_set_volume(Environment *_environment, int _channels, int _volume)
Definition ted.c:2371
#define PROGRAM_PULSE(c, p)
Definition ted.c:2437
Variable * ted_get_raster_line(Environment *_environment)
Definition ted.c:2326
void ted_screen(Environment *_environment, char *_x, char *_y, char *_c)
Definition ted.c:3202
void ted_tile_at(Environment *_environment, char *_x, char *_y, char *_result)
Definition ted.c:2298
void ted_screen_off(Environment *_environment)
Definition ted.c:1101
void ted_put_image(Environment *_environment, Resource *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_flags)
Definition ted.c:1996
void ted_charset_lowercase(Environment *_environment)
Definition ted.c:998
int ted_image_size(Environment *_environment, int _width, int _height, int _mode)
Definition ted.c:1481
void ted_tiles_at(Environment *_environment, char *_address)
Definition ted.c:1197
#define PROGRAM_TRIANGLE(c)
Definition ted.c:2472
void console_calculate(Environment *_environment)
Definition ted.c:890
#define PROGRAM_ATTACK_DECAY_SV(c, a, d)
Definition ted.c:2488
void ted_sprite_data_set(Environment *_environment, char *_sprite, char *_address)
Definition ted.c:1149
void ted_bank_select(Environment *_environment, int _bank)
Definition ted.c:717
void ted_sprite_compress_horizontal(Environment *_environment, char *_sprite)
Definition ted.c:1177
#define TILEMAP_MODE_MULTICOLOR
Definition ted.h:82
#define TILEMAP_MODE_EXTENDED
Definition ted.h:83
#define BITMAP_MODE_MULTICOLOR
Definition ted.h:77
void * malloc(YYSIZE_T)
struct _ScreenMode ScreenMode
#define IMF_INSTRUMENT_LEAD_8_BASS_LEAD
Definition ugbc.h:4661
#define IMF_INSTRUMENT_MARIMBA
Definition ugbc.h:4586
#define CRITICAL_IMAGE_CONVERTER_TOO_COLORS(f)
Definition ugbc.h:3502
struct _Resource Resource
#define IMF_INSTRUMENT_LEAD_6_VOICE
Definition ugbc.h:4659
#define IMF_INSTRUMENT_DRAWBAR_ORGAN
Definition ugbc.h:4590
#define IMF_INSTRUMENT_FRETLESS_BASS
Definition ugbc.h:4609
#define IMF_INSTRUMENT_PAD_1_NEW_AGE
Definition ugbc.h:4662
#define IMF_INSTRUMENT_VIOLIN
Definition ugbc.h:4614
#define IMF_INSTRUMENT_SYNTH_BASS_1
Definition ugbc.h:4612
#define IMF_INSTRUMENT_MELODIC_TOM
Definition ugbc.h:4691
#define IMF_INSTRUMENT_REVERSE_CYMBAL
Definition ugbc.h:4693
#define IMF_INSTRUMENT_ELECTRIC_BASS_FINGER
Definition ugbc.h:4607
#define IMF_INSTRUMENT_HARMONICA
Definition ugbc.h:4596
struct _RGBi RGBi
Structure to store color components (red, green and blue).
#define IMF_INSTRUMENT_BLOWN_BOTTLE
Definition ugbc.h:4650
#define IMF_INSTRUMENT_PAD_3_POLYSYNTH
Definition ugbc.h:4664
#define IMF_INSTRUMENT_FX_8_SCI_FI
Definition ugbc.h:4677
#define IMF_INSTRUMENT_RECORDER
Definition ugbc.h:4648
#define IMF_INSTRUMENT_FX_6_GOBLINS
Definition ugbc.h:4675
#define adilineendbitmap()
Definition ugbc.h:4241
#define IMF_INSTRUMENT_FX_1_RAIN
Definition ugbc.h:4670
#define IMF_INSTRUMENT_SYNTH_VOICE
Definition ugbc.h:4628
#define IMF_INSTRUMENT_TENOR_SAX
Definition ugbc.h:4640
#define IMF_INSTRUMENT_PICCOLO
Definition ugbc.h:4646
#define IMF_INSTRUMENT_LEAD_7_FIFTHS
Definition ugbc.h:4660
#define IMF_INSTRUMENT_SLAP_BASS_1
Definition ugbc.h:4610
#define IMF_INSTRUMENT_MUSIC_BOX
Definition ugbc.h:4584
#define IMF_INSTRUMENT_SOPRANO_SAX
Definition ugbc.h:4638
#define IMF_INSTRUMENT_TRUMPET
Definition ugbc.h:4630
#define IMF_INSTRUMENT_BIRD_TWEET
Definition ugbc.h:4697
#define WARNING_SCREEN_MODE(v1)
Definition ugbc.h:3878
#define IMF_INSTRUMENT_PAD_8_SWEEP
Definition ugbc.h:4669
#define IMF_INSTRUMENT_CHURCH_ORGAN
Definition ugbc.h:4593
#define IMF_INSTRUMENT_HELICOPTER
Definition ugbc.h:4699
#define IMF_INSTRUMENT_BRIGHT_ACOUSTIC_PIANO
Definition ugbc.h:4575
#define IMF_INSTRUMENT_CELESTA
Definition ugbc.h:4582
#define IMF_INSTRUMENT_ACOUSTIC_GUITAR_NYLON
Definition ugbc.h:4598
#define IMF_INSTRUMENT_GLOCKENSPIEL
Definition ugbc.h:4583
#define IMF_INSTRUMENT_ORCHESTRAL_HARP
Definition ugbc.h:4620
#define IMF_INSTRUMENT_BREATH_NOISE
Definition ugbc.h:4695
#define IMF_INSTRUMENT_BAG_PIPE
Definition ugbc.h:4683
#define IMF_INSTRUMENT_ELECTRIC_GUITAR_JAZZ
Definition ugbc.h:4600
#define IMF_INSTRUMENT_ELECTRIC_GRAND_PIANO
Definition ugbc.h:4576
#define IMF_INSTRUMENT_SITAR
Definition ugbc.h:4678
#define IMF_INSTRUMENT_APPLAUSE
Definition ugbc.h:4700
struct _Variable Variable
Structure of a single variable.
#define IMF_INSTRUMENT_WHISTLE
Definition ugbc.h:4652
#define IMF_INSTRUMENT_PERCUSSIVE_ORGAN
Definition ugbc.h:4591
#define IMF_INSTRUMENT_HONKY_TONK_PIANO
Definition ugbc.h:4577
#define IMF_INSTRUMENT_CHOIR_AAHS
Definition ugbc.h:4626
#define IMF_INSTRUMENT_SHANAI
Definition ugbc.h:4685
#define IMF_INSTRUMENT_CELLO
Definition ugbc.h:4616
#define IMF_INSTRUMENT_FX_3_CRYSTAL
Definition ugbc.h:4672
#define IMF_INSTRUMENT_ELECTRIC_GUITAR_MUTED
Definition ugbc.h:4602
#define IMF_INSTRUMENT_HARPSICHORD
Definition ugbc.h:4580
#define IMF_INSTRUMENT_BRASS_SECTION
Definition ugbc.h:4635
#define IMF_INSTRUMENT_ELECTRIC_BASS_PICK
Definition ugbc.h:4608
#define IMF_INSTRUMENT_FX_5_BRIGHTNESS
Definition ugbc.h:4674
#define IMF_INSTRUMENT_FLUTE
Definition ugbc.h:4647
#define deploy_deferred(s, e)
Definition ugbc.h:4302
struct _Environment Environment
Structure of compilation environment.
#define FLAG_FLIP_X
Definition ugbc.h:4553
@ 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 adiline3(s, a, b, c)
Definition ugbc.h:4197
#define IMF_INSTRUMENT_ELECTRIC_GUITAR_CLEAN
Definition ugbc.h:4601
#define IMF_INSTRUMENT_ACOUSTIC_BASS
Definition ugbc.h:4606
#define IMF_INSTRUMENT_GUITAR_FRET_NOISE
Definition ugbc.h:4694
#define IMF_INSTRUMENT_SYNTHSTRINGS_2
Definition ugbc.h:4625
#define IMF_INSTRUMENT_PAD_4_CHOIR
Definition ugbc.h:4665
#define IMF_INSTRUMENT_LEAD_2_SAWTOOTH
Definition ugbc.h:4655
#define deploy_preferred(s, e)
Definition ugbc.h:4299
#define IMF_INSTRUMENT_DULCIMER
Definition ugbc.h:4589
#define IMF_INSTRUMENT_KOTO
Definition ugbc.h:4681
#define IMF_INSTRUMENT_TUBA
Definition ugbc.h:4632
#define IMF_INSTRUMENT_GUITAR_HARMONICS
Definition ugbc.h:4605
#define IMF_INSTRUMENT_CLAVI
Definition ugbc.h:4581
#define IMF_INSTRUMENT_BANJO
Definition ugbc.h:4679
#define IMF_INSTRUMENT_SYNTHBRASS_2
Definition ugbc.h:4637
#define IMF_INSTRUMENT_LEAD_4_CHIFF
Definition ugbc.h:4657
#define IMF_INSTRUMENT_VOICE_OOHS
Definition ugbc.h:4627
#define IMF_INSTRUMENT_TANGO_ACCORDION
Definition ugbc.h:4597
#define SCREEN_MODE_DEFINE(_id, _bitmap, _width, _height, _colors, _tile_width, _tile_height, _description)
Definition ugbc.h:1516
#define IMF_INSTRUMENT_FX_7_ECHOES
Definition ugbc.h:4676
#define MAX_PALETTE
Definition ugbc.h:568
#define IMF_INSTRUMENT_PAD_6_METALLIC
Definition ugbc.h:4667
#define IMF_INSTRUMENT_PAD_5_BOWED
Definition ugbc.h:4666
#define IMF_INSTRUMENT_GUNSHOT
Definition ugbc.h:4701
#define IMF_INSTRUMENT_REED_ORGAN
Definition ugbc.h:4594
#define IMF_INSTRUMENT_ORCHESTRA_HIT
Definition ugbc.h:4629
#define IMF_INSTRUMENT_SYNTH_DRUM
Definition ugbc.h:4692
#define IMF_INSTRUMENT_SEASHORE
Definition ugbc.h:4696
#define IMF_INSTRUMENT_OCARINA
Definition ugbc.h:4653
#define IMF_INSTRUMENT_TELEPHONE_RING
Definition ugbc.h:4698
#define IMF_INSTRUMENT_FX_2_SOUNDTRACK
Definition ugbc.h:4671
#define IMF_INSTRUMENT_ACOUSTIC_GUITAR_STEEL
Definition ugbc.h:4599
#define IMF_INSTRUMENT_SYNTHSTRINGS_1
Definition ugbc.h:4624
#define IMF_INSTRUMENT_MUTED_TRUMPET
Definition ugbc.h:4633
#define IMF_INSTRUMENT_PAN_FLUTE
Definition ugbc.h:4649
#define IMF_INSTRUMENT_TINKLE_BELL
Definition ugbc.h:4686
#define IMF_INSTRUMENT_VIBRAPHONE
Definition ugbc.h:4585
#define CRITICAL_NEW_IMAGES_UNSUPPORTED_MODE(f)
Definition ugbc.h:3688
#define IMF_INSTRUMENT_KALIMBA
Definition ugbc.h:4682
#define IMF_INSTRUMENT_FIDDLE
Definition ugbc.h:4684
#define IMF_INSTRUMENT_PAD_7_HALO
Definition ugbc.h:4668
#define IMF_INSTRUMENT_TUBULAR_BELLS
Definition ugbc.h:4588
#define CRITICAL_SCREEN_UNSUPPORTED(v)
Definition ugbc.h:3496
#define IMF_INSTRUMENT_LEAD_1_SQUARE
Definition ugbc.h:4654
#define IMF_INSTRUMENT_STRING_ENSEMBLE_1
Definition ugbc.h:4622
#define outline0(s)
Definition ugbc.h:4252
#define IMF_INSTRUMENT_DISTORTION_GUITAR
Definition ugbc.h:4604
#define IMF_INSTRUMENT_PAD_2_WARM
Definition ugbc.h:4663
#define IMF_INSTRUMENT_ACCORDION
Definition ugbc.h:4595
#define IMF_INSTRUMENT_SLAP_BASS_2
Definition ugbc.h:4611
#define IMF_INSTRUMENT_LEAD_5_CHARANG
Definition ugbc.h:4658
#define IMF_INSTRUMENT_OBOE
Definition ugbc.h:4642
#define IMF_INSTRUMENT_STEEL_DRUMS
Definition ugbc.h:4688
#define IMF_INSTRUMENT_BASSOON
Definition ugbc.h:4644
#define IMF_INSTRUMENT_TIMPANI
Definition ugbc.h:4621
#define IMF_INSTRUMENT_ROCK_ORGAN
Definition ugbc.h:4592
#define IMF_INSTRUMENT_SHAMISEN
Definition ugbc.h:4680
#define FLAG_FLIP_Y
Definition ugbc.h:4554
#define IMF_INSTRUMENT_CLARINET
Definition ugbc.h:4645
#define IMF_INSTRUMENT_ACOUSTIC_GRAND_PIANO
Definition ugbc.h:4574
#define IMF_INSTRUMENT_ALTO_SAX
Definition ugbc.h:4639
#define IMF_INSTRUMENT_EXPLOSION
Definition ugbc.h:4573
#define IMF_INSTRUMENT_PIZZICATO_STRINGS
Definition ugbc.h:4619
#define IMF_INSTRUMENT_WOODBLOCK
Definition ugbc.h:4689
#define IMF_INSTRUMENT_XYLOPHONE
Definition ugbc.h:4587
#define IMF_INSTRUMENT_AGOGO
Definition ugbc.h:4687
#define IMF_INSTRUMENT_SYNTHBRASS_1
Definition ugbc.h:4636
#define outline1(s, a)
Definition ugbc.h:4253
#define IMF_INSTRUMENT_LEAD_3_CALLIOPE
Definition ugbc.h:4656
#define WARNING_IMAGE_CONVERTER_UNSUPPORTED_MODE(f)
Definition ugbc.h:3880
#define adilinepalette(s, c, p)
Definition ugbc.h:4219
#define VT_BITWIDTH(t)
Definition ugbc.h:595
#define adilinebeginbitmap(s)
Definition ugbc.h:4231
#define IMF_INSTRUMENT_STRING_ENSEMBLE_2
Definition ugbc.h:4623
#define IMF_INSTRUMENT_SYNTH_BASS_2
Definition ugbc.h:4613
#define IMF_INSTRUMENT_ELECTRIC_PIANO2
Definition ugbc.h:4579
struct _CopperList CopperList
#define IMF_INSTRUMENT_FRENCH_HORN
Definition ugbc.h:4634
#define IMF_INSTRUMENT_TREMOLO_STRINGS
Definition ugbc.h:4618
#define IMF_INSTRUMENT_FX_4_ATMOSPHERE
Definition ugbc.h:4673
#define IMF_INSTRUMENT_ENGLISH_HORN
Definition ugbc.h:4643
#define FLAG_EXACT
Definition ugbc.h:4569
#define IMF_INSTRUMENT_BARITONE_SAX
Definition ugbc.h:4641
#define IMF_INSTRUMENT_SHAKUHACHI
Definition ugbc.h:4651
#define IMF_INSTRUMENT_CONTRABASS
Definition ugbc.h:4617
#define adilinepixel(p)
Definition ugbc.h:4236
#define CRITICAL_NEW_IMAGE_UNSUPPORTED_MODE(f)
Definition ugbc.h:3540
#define CRITICAL_BLIT_TOO_MUCH_SOURCES()
Definition ugbc.h:3613
#define IMF_INSTRUMENT_VIOLA
Definition ugbc.h:4615
#define deploy(s, e)
Definition ugbc.h:4288
#define MAKE_LABEL
Definition ugbc.h:3351
#define IMF_INSTRUMENT_TROMBONE
Definition ugbc.h:4631
#define IMF_INSTRUMENT_OVERDRIVEN_GUITAR
Definition ugbc.h:4603
#define IMF_INSTRUMENT_ELECTRIC_PIANO1
Definition ugbc.h:4578
#define IMF_INSTRUMENT_TAIKO_DRUM
Definition ugbc.h:4690
#define outhead1(s, a)
Definition ugbc.h:4247