ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
vic1.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#ifdef __vic20__
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 { 0x88, 0x00, 0x00, 0xff, 2, "RED" },
44 { 0xaa, 0xff, 0xe6, 0xff, 3, "CYAN" },
45 { 0xcc, 0x44, 0xcc, 0xff, 4, "VIOLET" },
46 { 0x00, 0xcc, 0x55, 0xff, 5, "GREEN" },
47 { 0x00, 0x00, 0xaa, 0xff, 6, "BLUE" },
48 { 0xee, 0xee, 0x77, 0xff, 7, "YELLOW" },
49 { 0xa1, 0x68, 0x3c, 0xff, 8, "ORANGE" },
50 { 0xdd, 0x88, 0x65, 0xff, 9, "BROWN" },
51 { 0xff, 0x77, 0x77, 0xff, 10, "LIGHT_RED" },
52 { 0x33, 0x33, 0x33, 0xff, 11, "DARK_GREY" },
53 { 0x77, 0x77, 0x77, 0xff, 12, "GREY" },
54 { 0xaa, 0xff, 0x66, 0xff, 13, "LIGHT GREEN" },
55 { 0x00, 0x88, 0xff, 0xff, 14, "LIGHT BLUE" },
56 { 0xbb, 0xbb, 0xbb, 0xff, 15, "LIGHT GREY" }
57};
58
59/****************************************************************************
60 * CODE SECTION
61 ****************************************************************************/
62
64
65 unsigned int minDistance = 0xffff;
66 int colorIndex = 0;
67 for (int j = 0; j < COLOR_COUNT; ++j) {
68 int distance = rgbi_distance(&SYSTEM_PALETTE[j], _color);
69 if (distance < minDistance) {
70 minDistance = distance;
71 colorIndex = j;
72 }
73 }
74
75 return &SYSTEM_PALETTE[colorIndex];
76
77}
78
90void vic1_collision( Environment * _environment, char * _sprite_mask, char * _result ) {
91
92}
93
105void vic1_hit( Environment * _environment, char * _sprite_mask, char * _result ) {
106
107}
108
118void vic1_border_color( Environment * _environment, char * _border_color ) {
119
120 outline0("LDA $900F" );
121 outline0("AND #$F8" );
122 outline0("STA $900F");
123 outline1("LDA %s", _border_color );
124 outline0("AND #$07" );
125 outline0("ORA $900F" );
126 outline0("STA $900F" );
127
128}
129
140void vic1_background_color( Environment * _environment, int _index, int _background_color ) {
141
142 outline1("LDA #$%2.2x", ( _background_color >> 4 ) );
143 outline0("STA MATHPTR0");
144 outline0("LDA $900F");
145 outline0("AND #$0F");
146 outline0("ORA MATHPTR0");
147 outline0("STA $900F");
148}
149
160void vic1_background_color_vars( Environment * _environment, char * _index, char * _background_color ) {
161
162 outline1("LDA %s", _background_color );
163 outline0("ASL A");
164 outline0("ASL A");
165 outline0("ASL A");
166 outline0("ASL A");
167 outline0("STA MATHPTR0");
168 outline0("LDA $900F");
169 outline0("AND #$0F");
170 outline0("ORA MATHPTR0");
171 outline0("STA $900F");
172}
173
184void vic1_background_color_semivars( Environment * _environment, int _index, char * _background_color ) {
185
186 outline1("LDA %s", _background_color );
187 outline0("ASL A");
188 outline0("ASL A");
189 outline0("ASL A");
190 outline0("ASL A");
191 outline0("STA MATHPTR0");
192 outline0("LDA $900F");
193 outline0("AND #$0F");
194 outline0("ORA MATHPTR0");
195 outline0("STA $900F");
196}
197
208void vic1_background_color_get_vars( Environment * _environment, char * _index, char * _background_color ) {
209
210 outline0("LDA $900F");
211 outline0("AND #$F0");
212 outline0("LSR A");
213 outline0("LSR A");
214 outline0("LSR A");
215 outline0("LSR A");
216 outline1("STA %s", _background_color );
217
218}
219
220
231void vic1_sprite_common_color( Environment * _environment, char * _index, char * _common_color ) {
232
233}
234
250void vic1_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
251
252}
253
264void vic1_next_raster( Environment * _environment ) {
265
266}
267
281void vic1_next_raster_at( Environment * _environment, char * _label, char * _positionlo, char * _positionhi ) {
282
283}
284
285void vic1_bank_select( Environment * _environment, int _bank ) {
286
287}
288
289static int rgbConverterFunction( int _red, int _green, int _blue ) {
290
291 int colorIndex = 0;
292 unsigned int minDistance = 0xffffffff;
293 int j;
294
295 RGBi rgb;
296 rgb.red = _red;
297 rgb.green = _green;
298 rgb.blue = _blue;
299
300 for (j = 0; j < sizeof(SYSTEM_PALETTE)/sizeof(RGBi); ++j) {
301 int distance = rgbi_distance(&SYSTEM_PALETTE[j], &rgb);
302 if (distance < minDistance) {
303 minDistance = distance;
304 colorIndex = j;
305 }
306 }
307
308 return colorIndex;
309
310}
311
312int vic1_screen_mode_enable( Environment * _environment, ScreenMode * _screen_mode ) {
313
314 _screen_mode->selected = 1;
315
316 // deploy( bitmap, src_hw_vic1_bitmap_asm );
317 Variable * colormapAddress = variable_retrieve( _environment, "COLORMAPADDRESS" );
318
319 _environment->fontWidth = 8;
320 _environment->fontHeight = 8;
321 _environment->screenTiles = 255;
322 switch( _screen_mode->id ) {
324
325 outline0("LDA $9005");
326 outline0("AND #$F0");
327 outline0("ORA #$0E");
328 outline0("STA $9005");
329
330 _environment->screenTilesWidth = 22;
331 _environment->screenTilesHeight = 23;
332
333 break;
335 _environment->screenTilesWidth = 22;
336 _environment->screenTilesHeight = 23;
337
338 outline0("LDA $9005");
339 outline0("AND #$F0");
340 outline0("STA $9005");
341
342 vic1_cls( _environment );
343
344 break;
345 default:
346 CRITICAL_SCREEN_UNSUPPORTED( _screen_mode->id );
347 }
348
349 _environment->screenWidth = _environment->screenTilesWidth * 8;
350 _environment->screenHeight = _environment->screenTilesHeight * 8;
351 _environment->consoleTilesWidth = _environment->screenTilesWidth;
352 _environment->consoleTilesHeight = _environment->screenTilesHeight;
353
354 _environment->screenColors = 2;
355 _environment->screenShades = 8;
356
357 cpu_store_16bit( _environment, "CURRENTWIDTH", _environment->screenWidth );
358 cpu_store_16bit( _environment, "CURRENTHEIGHT", _environment->screenHeight );
359 cpu_store_8bit( _environment, "CURRENTTILES", _environment->screenTiles );
360 cpu_store_8bit( _environment, "CURRENTTILESWIDTH", _environment->screenTilesWidth );
361 cpu_store_8bit( _environment, "CURRENTTILESHEIGHT", _environment->screenTilesHeight );
362
363 console_init( _environment );
364
365 if (_environment->vestigialConfig.clsImplicit ) {
366 vic1_cls( _environment );
367 }
368
369}
370
371void console_calculate( Environment * _environment ) {
372
373 int consoleSA = 0;
374 int consoleCA = 0;
375
376 switch( _environment->currentMode ) {
379 consoleSA = 0x1000 + (_environment->activeConsole.y1*22)+_environment->activeConsole.x1;
380 consoleCA = 0x9400 + (_environment->activeConsole.y1*22)+_environment->activeConsole.x1;
381 _environment->currentModeBW = 1;
382 break;
383 default:
385 }
386
387 int consoleWB = _environment->activeConsole.width * _environment->currentModeBW;
388 int consoleHB = _environment->activeConsole.height;
389
390 cpu_store_16bit( _environment, "CONSOLESA", consoleSA );
391 cpu_store_16bit( _environment, "CONSOLECA", consoleCA );
392 cpu_store_8bit( _environment, "CONSOLEWB", consoleWB );
393 cpu_store_8bit( _environment, "CONSOLEHB", consoleHB );
394
395}
396
397void console_calculate_vars( Environment * _environment ) {
398
399 _environment->dynamicConsole = 1;
400
401 outline0( "JSR CONSOLECALCULATE" );
402
403}
404
405void vic1_bitmap_enable( Environment * _environment, int _width, int _height, int _colors ) {
406
407 ScreenMode * mode = find_screen_mode_by_suggestion( _environment, 1, _width, _height, _colors, 8, 8 );
408
409 if ( mode ) {
410 vic1_screen_mode_enable( _environment, mode );
411
412 cpu_store_8bit( _environment, "CURRENTMODE", mode->id );
413 cpu_store_8bit( _environment, "CURRENTTILEMODE", 0 );
414
415 _environment->currentMode = mode->id;
416 _environment->currentTileMode = 0;
417 } else {
419 }
420
421}
422
423void vic1_bitmap_disable( Environment * _environment ) {
424
425}
426
427void vic1_tilemap_enable( Environment * _environment, int _width, int _height, int _colors, int _tile_width, int _tile_height ) {
428
429 ScreenMode * mode = find_screen_mode_by_suggestion( _environment, 0, _width, _height, _colors, _tile_width, _tile_height );
430
431 if ( mode ) {
432 vic1_screen_mode_enable( _environment, mode );
433
434 _environment->currentMode = mode->id;
435 _environment->currentTileMode = 1;
436
437 cpu_store_8bit( _environment, "CURRENTMODE", mode->id );
438 cpu_store_8bit( _environment, "CURRENTTILEMODE", 1 );
439
440 } else {
442 }
443
444
445}
446
447void vic1_bitmap_at( Environment * _environment, char * _address ) {
448
449}
450
451void vic1_colormap_at( Environment * _environment, char * _address ) {
452
453}
454
455void vic1_textmap_at( Environment * _environment, char * _address ) {
456
457}
458
459void vic1_pset_int( Environment * _environment, int _x, int _y, int *_c ) {
460
461 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
462 deploy( plot, src_hw_vic1_plot_asm );
463
464 if ( _c ) {
465 outline1("LDA #$%2.2x", ( *_c & 0xff ) );
466 } else {
467 Variable * c = variable_retrieve( _environment, "PEN" );
468 outline1("LDA %s", c->realName );
469 }
470 outline0("STA PLOTCPE");
471 outline1("LDA %2.2x", (_x & 0xff ) );
472 outline0("STA PLOTX");
473 outline1("LDA %2.2x", ( ( _x >> 8 ) & 0xff ) );
474 outline0("STA PLOTX+1");
475 outline1("LDA %2.2x", ( _y & 0xff ) );
476 outline0("STA PLOTY");
477 outline0("LDA #1");
478 outline0("STA PLOTM");
479 outline0("JSR PLOT");
480
481}
482
483void vic1_pset_vars( Environment * _environment, char *_x, char *_y, char *_c ) {
484
485 Variable * x = variable_retrieve_or_define( _environment, _x, VT_POSITION, 0 );
486 Variable * y = variable_retrieve_or_define( _environment, _y, VT_POSITION, 0 );
487 Variable * c;
488
489 if ( _c ) {
490 c = variable_retrieve_or_define( _environment, _c, VT_COLOR, 0 );
491 } else {
492 c = variable_retrieve( _environment, "PEN" );
493 }
494
495 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
496 deploy( plot, src_hw_vic1_plot_asm );
497
498 outline1("LDA %s", c->realName );
499 outline0("STA PLOTCPE");
500 outline1("LDA %s", x->realName );
501 outline0("STA PLOTX");
502 if ( VT_BITWIDTH( x->type ) > 8 ) {
503 outline1("LDA %s", address_displacement(_environment, x->realName, "1") );
504 } else {
505 outline0("LDA #0");
506 }
507 outline0("STA PLOTX+1");
508 outline1("LDA %s", y->realName );
509 outline0("STA PLOTY");
510 outline0("LDA #1");
511 outline0("STA PLOTM");
512 outline0("JSR PLOT");
513
514}
515
516void vic1_pget_color_vars( Environment * _environment, char *_x, char *_y, char * _result ) {
517
518 Variable * x = variable_retrieve( _environment, _x );
519 Variable * y = variable_retrieve( _environment, _y );
520 Variable * result = variable_retrieve( _environment, _result );
521
522 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
523 deploy( plot, src_hw_vic1_plot_asm );
524
525 outline1("LDA %s", x->realName );
526 outline0("STA PLOTX");
527 outline1("LDA %s", address_displacement(_environment, x->realName, "1") );
528 outline0("STA PLOTX+1");
529 outline1("LDA %s", y->realName );
530 outline0("STA PLOTY");
531 outline0("LDA #3");
532 outline0("STA PLOTM");
533 outline0("JSR PLOT");
534 outline0("LDA PLOTM");
535 outline1("STA %s", result->realName);
536
537}
538
539void vic1_screen_on( Environment * _environment ) {
540
541}
542
543void vic1_screen_off( Environment * _environment ) {
544
545}
546
547void vic1_screen_rows( Environment * _environment, char * _rows ) {
548
549}
550
551void vic1_screen_columns( Environment * _environment, char * _columns ) {
552
553}
554
555void vic1_sprite_data_set( Environment * _environment, char * _sprite, char * _address ) {
556
557}
558
559void vic1_sprite_data_from( Environment * _environment, char * _sprite, char * _address ) {
560
561}
562
563void vic1_sprite_enable( Environment * _environment, char * _sprite ) {
564
565}
566
567void vic1_sprite_disable( Environment * _environment, char * _sprite ) {
568
569}
570
571void vic1_sprite_at( Environment * _environment, char * _sprite, char * _x, char * _y ) {
572
573}
574
575void vic1_sprite_expand_vertical( Environment * _environment, char * _sprite ) {
576
577}
578
579void vic1_sprite_expand_horizontal( Environment * _environment, char * _sprite ) {
580
581}
582
583void vic1_sprite_compress_vertical( Environment * _environment, char * _sprite ) {
584
585}
586
587void vic1_sprite_compress_horizontal( Environment * _environment, char * _sprite ) {
588
589}
590
591void vic1_sprite_multicolor( Environment * _environment, char * _sprite ) {
592
593}
594
595void vic1_sprite_monocolor( Environment * _environment, char * _sprite ) {
596
597}
598
599void vic1_sprite_color( Environment * _environment, char * _sprite, char * _color ) {
600
601}
602
603void vic1_sprite_priority( Environment * _environment, char * _sprite, char * _priority ) {
604
605}
606
607void vic1_tiles_at( Environment * _environment, char * _address ) {
608
609}
610
611void vic1_vertical_scroll( Environment * _environment, char * _displacement ) {
612
613}
614
615void vic1_horizontal_scroll( Environment * _environment, char * _displacement ) {
616
617}
618
619void vic1_busy_wait( Environment * _environment, char * _timing ) {
620
622
623 outline0("LDA #$00");
624 outline0("STA TMPPTR");
625 outhead1("%sfirst:", label );
626 outline0("LDA #$01");
627 outhead1("%ssecond:", label );
628 outline0("CMP $9004");
629 outline1("BNE %ssecond", label);
630 outhead1("%sthird:", label );
631 outline0("CMP $9004");
632 outline1("BEQ %sthird", label);
633 outline0("INC TMPPTR");
634 outline0("LDA TMPPTR");
635 outline1("CMP %s", _timing );
636 outline1("BNE %sfirst", label );
637
638}
639
640void vic1_get_width( Environment * _environment, char *_result ) {
641
642 outline0("LDA CURRENTWIDTH" );
643 outline1("STA %s", _result );
644 outline0("LDA CURRENTWIDTH+1" );
645 outline1("STA %s", address_displacement(_environment, _result, "1") );
646
647}
648
649void vic1_tiles_get( Environment * _environment, char *_result ) {
650
651 outline0("LDA CURRENTTILES" );
652 outline1("STA %s", _result );
653
654}
655
656void vic1_get_height( Environment * _environment, char *_result ) {
657
658 outline0("LDA CURRENTHEIGHT" );
659 outline1("STA %s", _result );
660 outline0("LDA CURRENTHEIGHT+1" );
661 outline1("STA %s", address_displacement(_environment, _result, "1") );
662
663}
664
665void vic1_cls( Environment * _environment ) {
666
667 deploy( cls, src_hw_vic1_cls_asm );
668
669 outline0("JSR CLS");
670
671}
672
673void vic1_cls_box( Environment * _environment, char * _x1, char * _y1, char * _w, char * _h ) {
674
675}
676
677void vic1_scroll_text( Environment * _environment, int _direction, int _overlap ) {
678
679 if ( _direction > 0 ) {
680 deploy_preferred( vScrollTextDown, src_hw_vic1_vscroll_text_down_asm );
681 outline1("LDA #$%2.2x", (unsigned char)(_overlap&0xff) );
682 outline0("STA PORT" );
683 outline0("JSR VSCROLLTDOWN");
684 } else {
685 deploy_preferred( vScrollTextUp, src_hw_vic1_vscroll_text_up_asm );
686 outline1("LDA #$%2.2x", (unsigned char)(_overlap&0xff) );
687 outline0("STA PORT" );
688 outline0("JSR VSCROLLTUP");
689 }
690
691}
692
693void vic1_text( Environment * _environment, char * _text, char * _text_size, int _raw ) {
694
695 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
696 deploy_preferred( vScrollTextUp, src_hw_vic1_vscroll_text_up_asm );
697 deploy_preferred( vScrollTextDown, src_hw_vic1_vscroll_text_down_asm );
698 deploy( cls, src_hw_vic1_cls_asm );
699
700 if ( _environment->currentMode > 0 ) {
701 _environment->fontConfig.schema = FONT_SCHEMA_ALPHA;
702 font_descriptors_init( _environment, 0 );
703 }
704
705 outline1("LDA %s", _text);
706 outline0("STA TEXTPTR" );
707 outline1("LDA %s", address_displacement(_environment, _text, "1"));
708 outline0("STA TEXTPTR+1" );
709 outline1("LDA %s", _text_size);
710 outline0("STA TEXTSIZE" );
711
712 if ( _raw ) {
713 deploy_deferred( textEncodedAtTextRaw, src_hw_vic1_text_at_raw_asm );
714 outline0("JSR TEXTATRAW");
715 } else {
716 deploy_deferred( textEncodedAtText, src_hw_vic1_text_at_asm );
717 outline0("JSR TEXTAT");
718 }
719
720}
721
722void vic1_initialization( Environment * _environment ) {
723
724 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
725 deploy_deferred( vic1startup, src_hw_vic1_startup_asm );
726
727 variable_import( _environment, "CURRENTMODE", VT_BYTE, 0 );
728 variable_global( _environment, "CURRENTMODE" );
729 variable_import( _environment, "CURRENTTILEMODE", VT_BYTE, 1 );
730 variable_global( _environment, "CURRENTTILEMODE" );
731
732 variable_import( _environment, "CURRENTWIDTH", VT_POSITION, 166 );
733 variable_global( _environment, "CURRENTWIDTH" );
734 variable_import( _environment, "CURRENTHEIGHT", VT_POSITION, 184 );
735 variable_global( _environment, "CURRENTHEIGHT" );
736 variable_import( _environment, "CURRENTTILES", VT_BYTE, 255 );
737 variable_global( _environment, "CURRENTTILES" );
738 variable_import( _environment, "CURRENTTILESWIDTH", VT_SBYTE, 22 );
739 variable_global( _environment, "CURRENTTILESWIDTH" );
740 variable_import( _environment, "CURRENTTILESHEIGHT", VT_SBYTE, 23 );
741 variable_global( _environment, "CURRENTTILESHEIGHT" );
742 variable_import( _environment, "FONTWIDTH", VT_BYTE, 8 );
743 variable_global( _environment, "FONTWIDTH" );
744 variable_import( _environment, "FONTHEIGHT", VT_BYTE, 8 );
745 variable_global( _environment, "FONTHEIGHT" );
746
747 SCREEN_MODE_DEFINE( TILEMAP_MODE_STANDARD, 0, 22, 23, 8, 8, 8, "Standard Character Mode" );
748 SCREEN_MODE_DEFINE( BITMAP_MODE_STANDARD, 1, 176, 184, 8, 8, 8, "Standard Bitmap Mode (tilemapped)" );
749 // SCREEN_MODE_DEFINE( BITMAP_MODE_EXTENDED, 1, 128, 128, 8, 8, 8, "Extended Bitmap Mode" );
750
751 outline0("JSR VIC1STARTUP");
752
753 variable_import( _environment, "XGR", VT_POSITION, 0 );
754 variable_global( _environment, "XGR" );
755 variable_import( _environment, "YGR", VT_POSITION, 0 );
756 variable_global( _environment, "YGR" );
757 variable_import( _environment, "LINE", VT_WORD, (unsigned short) (0xffff) );
758 variable_global( _environment, "LINE" );
759 variable_import( _environment, "TABCOUNT", VT_BYTE, 4 );
760 variable_global( _environment, "TABCOUNT" );
761
762 variable_import( _environment, "CLIPX1", VT_POSITION, 0 );
763 variable_global( _environment, "CLIPX1" );
764 variable_import( _environment, "CLIPX2", VT_POSITION, 165 );
765 variable_global( _environment, "CLIPX2" );
766 variable_import( _environment, "CLIPY1", VT_POSITION, 0 );
767 variable_global( _environment, "CLIPY1" );
768 variable_import( _environment, "CLIPY2", VT_POSITION, 183 );
769 variable_global( _environment, "CLIPY2" );
770
771 variable_import( _environment, "ORIGINX", VT_POSITION, 0 );
772 variable_global( _environment, "ORIGINX" );
773 variable_import( _environment, "ORIGINY", VT_POSITION, 0 );
774 variable_global( _environment, "ORIGINY" );
775
776 variable_import( _environment, "RESOLUTIONX", VT_POSITION, 0 );
777 variable_global( _environment, "RESOLUTIONX" );
778 variable_import( _environment, "RESOLUTIONY", VT_POSITION, 0 );
779 variable_global( _environment, "RESOLUTIONY" );
780
781 cpu_move_16bit( _environment, "CURRENTWIDTH", "RESOLUTIONX" );
782 cpu_move_16bit( _environment, "CURRENTHEIGHT", "RESOLUTIONY" );
783
784 _environment->fontWidth = 8;
785 _environment->fontHeight = 8;
786 _environment->screenTilesWidth = 22;
787 _environment->screenTilesHeight = 23;
788 _environment->screenWidth = _environment->screenTilesWidth * _environment->fontWidth;
789 _environment->screenHeight = _environment->screenTilesHeight * _environment->fontHeight;
790 _environment->screenColors = 16;
791 _environment->consoleTilesWidth = 22;
792 _environment->consoleTilesHeight = 23;
793
794 console_init( _environment );
795
796 font_descriptors_init( _environment, 1 );
797
798 _environment->currentRgbConverterFunction = rgbConverterFunction;
799 _environment->screenShades = 8;
800
801 if (_environment->vestigialConfig.clsImplicit ) {
802 vic1_cls( _environment );
803 }
804
805}
806
807void vic1_finalization( Environment * _environment ) {
808
809 if ( ! _environment->deployed.vic1startup ) {
810 cpu_label( _environment, "VIC1STARTUP" );
811 outline0( "RTS" );
812 cpu_label( _environment, "MUSICPLAYER" );
813 outline0( "RTS" );
814 }
815
816 if ( _environment->vestigialConfig.clsImplicit ) {
817 deploy( cls, src_hw_vic1_cls_asm );
818 }
819
820}
821
822void vic1_hscroll_line( Environment * _environment, int _direction, int _overlap ) {
823
824 deploy_preferred( textHScroll, src_hw_vic1_hscroll_text_asm );
825
826 Variable * y = variable_retrieve( _environment, "YCURSYS" );
827 outline1("LDA #$%2.2x", ( _direction & 0xff ) );
828 outline0("STA DIRECTION" );
829 outline1("LDA #$%2.2x", ( _overlap & 0xff ) );
830 outline0("STA PORT" );
831 outline1("LDA %s", y->realName );
832 outline0("STA CLINEY");
833
834 outline0("JSR HSCROLLLT");
835
836}
837
838void vic1_hscroll_screen( Environment * _environment, int _direction, int _overlap ) {
839
840 deploy_preferred( textHScroll, src_hw_vic1_hscroll_text_asm );
841
842 outline1("LDA #$%2.2x", ( _direction & 0xff ) );
843 outline0("STA DIRECTION" );
844 outline1("LDA #$%2.2x", ( _overlap & 0xff ) );
845 outline0("STA PORT" );
846
847 outline0("JSR HSCROLLST");
848}
849
850void vic1_back( Environment * _environment ) {
851
852 deploy( back, src_hw_vic1_back_asm );
853
854 outline0("JSR BACK");
855
856}
857
858void vic1_cline( Environment * _environment, char * _characters ) {
859
860 deploy( textCline, src_hw_vic1_cline_asm );
861 Variable * x = variable_retrieve( _environment, "XCURSYS" );
862 Variable * y = variable_retrieve( _environment, "YCURSYS" );
863
864 if ( _characters ) {
865 outline1("LDA %s", _characters);
866 } else {
867 outline0("LDA #0");
868 }
869 outline0("STA CHARACTERS");
870 outline1("LDA %s", x->realName );
871 outline0("STA CLINEX" );
872 outline1("LDA %s", y->realName );
873 outline0("STA CLINEY");
874 outline0("JSR CLINE");
875
876}
877
878int vic1_image_size( Environment * _environment, int _width, int _height, int _mode ) {
879
880 switch( _mode ) {
881
883 return 3 + ( _width >> 3 ) * ( _height );
884 break;
886 break;
887 }
888
889 return 0;
890
891}
892
893static int calculate_images_size( Environment * _environment, int _frames, int _width, int _height, int _mode ) {
894
895 switch( _mode ) {
896
898 return 3 + ( 3 + ( _width >> 3 ) * ( _height ) ) * _frames;
899 break;
901 break;
902 }
903
904 return 0;
905
906}
907
908static int calculate_sequence_size( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode ) {
909
910 switch( _mode ) {
911
913 return 3 + ( ( 3 + ( _width >> 3 ) * ( _height ) ) * _frames ) * _sequences;
914 break;
916 break;
917 }
918
919 return 0;
920
921}
922
923
924static Variable * vic1_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 ) {
925
926 image_converter_asserts( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8, 8 );
927
928 if ( _environment->freeImageWidth ) {
929 if ( _width % 8 ) {
930 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
931 }
932 if ( _frame_width % 8 ) {
933 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
934 }
935 }
936
937 if ( _environment->freeImageHeight ) {
938 if ( _height % 8 ) {
939 _height = ( ( ( _height - 1 ) / 8 ) - 1 ) * 8;
940 }
941 if ( _frame_height % 8 ) {
942 _frame_height = ( ( ( _frame_height - 1 ) / 8 ) - 1 ) * 8;
943 }
944 }
945
946 RGBi palette[MAX_PALETTE];
947
948 int colorUsed = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, 1 /* sorted */);
949
950 if (colorUsed > 2) {
952 }
953
954 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
955 result->originalColors = colorUsed;
956
957 int i, j, k;
958
959 for( i=0; i<colorUsed; ++i ) {
960 int minDistance = 0xffff;
961 int colorIndex = 0;
962 for (j = 0; j < sizeof(SYSTEM_PALETTE)/sizeof(RGBi); ++j) {
963 int distance = rgbi_distance(&SYSTEM_PALETTE[j], &palette[i]);
964 // printf("%d <-> %d [%d] = %d [min = %d]\n", i, j, SYSTEM_PALETTE[j].index, distance, minDistance );
965 if (distance < minDistance) {
966 // printf(" candidated...\n" );
967 for( k=0; k<i; ++k ) {
968 if ( palette[k].index == SYSTEM_PALETTE[j].index ) {
969 // printf(" ...used!\n" );
970 break;
971 }
972 }
973 if ( k>=i ) {
974 // printf(" ...ok! (%d)\n", SYSTEM_PALETTE[j].index );
975 minDistance = distance;
976 colorIndex = j;
977 }
978 }
979 }
980 palette[i].index = SYSTEM_PALETTE[colorIndex].index;
981 strcopy( palette[i].description, SYSTEM_PALETTE[colorIndex].description );
982 // printf("%d) %d %2.2x%2.2x%2.2x\n", i, palette[i].index, palette[i].red, palette[i].green, palette[i].blue);
983 }
984
985 memcpy( result->originalPalette, palette, MAX_PALETTE * sizeof( RGBi ) );
986
987 int bufferSize = vic1_image_size( _environment, _frame_width, _frame_height, BITMAP_MODE_STANDARD );
988
989 // printf("bufferSize = %d\n", bufferSize );
990
991 char * buffer = malloc ( bufferSize );
992 memset( buffer, 0, bufferSize );
993
994 // Position of the pixel in the original image
995 int image_x, image_y;
996
997 // Position of the pixel, in terms of tiles
998 int tile_x, tile_y;
999
1000 // Position of the pixel, in terms of offset and bitmask
1001 int offset, bitmask;
1002
1003 // Color of the pixel to convert
1004 RGBi rgb;
1005
1006 *(buffer) = _frame_width;
1007 *(buffer+1) = _frame_height;
1008
1009 _source += ( ( _offset_y * _width ) + _offset_x ) * 3;
1010
1011 // Loop for all the source surface.
1012 for (image_y = 0; image_y < _frame_height; ++image_y) {
1013 for (image_x = 0; image_x < _frame_width; ++image_x) {
1014
1015 // Take the color of the pixel
1016 rgb.red = *_source;
1017 rgb.green = *(_source + 1);
1018 rgb.blue = *(_source + 2);
1019 if ( _depth > 3 ) {
1020 rgb.alpha = *(_source + 3);
1021 } else {
1022 rgb.alpha = 255;
1023 }
1024
1025 for( i=0; i<colorUsed; ++i ) {
1026 if ( rgbi_equals_rgba( &palette[i], &rgb ) ) {
1027 break;
1028 }
1029 }
1030
1031 // printf("%d", i );
1032
1033 // Calculate the relative tile
1034 tile_y = (image_y >> 3);
1035 tile_x = (image_x >> 3);
1036
1037 // Calculate the offset starting from the tile surface area
1038 // and the bit to set.
1039 offset = (tile_y * 8 *( _frame_width >> 3 ) ) + (tile_x * 8) + (image_y & 0x07);
1040 bitmask = 1 << ( 7 - (image_x & 0x7) );
1041
1042 if ( i == 1 ) {
1043 *( buffer + offset + 2) |= bitmask;
1044 } else {
1045 *( buffer + offset + 2) &= ~bitmask;
1046 }
1047
1048 offset = tile_y * ( _frame_width >> 3 ) + tile_x;
1049 *( buffer + 2 + ( ( _frame_width >> 3 ) * _frame_height ) + offset ) = ( palette[1].index << 4 ) | palette[0].index;
1050
1051 _source += 3;
1052
1053 }
1054
1055 _source += 3 * ( _width - _frame_width );
1056
1057 // printf("\n" );
1058
1059 }
1060
1061 // printf("\n----\n\n");
1062
1063 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
1064
1065 // printf("----\n");
1066
1067 return result;
1068
1069}
1070
1071static Variable * vic1_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 ) {
1072
1073 image_converter_asserts( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8, 8 );
1074
1075 if ( _environment->freeImageWidth ) {
1076 if ( _width % 8 ) {
1077 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
1078 }
1079 if ( _frame_width % 8 ) {
1080 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
1081 }
1082 }
1083
1084 if ( _environment->freeImageHeight ) {
1085 if ( _height % 8 ) {
1086 _height = ( ( ( _height - 1 ) / 8 ) - 1 ) * 8;
1087 }
1088 if ( _frame_height % 8 ) {
1089 _frame_height = ( ( ( _frame_height - 1 ) / 8 ) - 1 ) * 8;
1090 }
1091 }
1092
1093 RGBi palette[MAX_PALETTE];
1094
1095 int colorUsed = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, 1 /* sorted */);
1096
1097 if (colorUsed > 4) {
1099 }
1100
1101 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
1102 result->originalColors = colorUsed;
1103
1104 int i, j, k;
1105
1106 for( i=0; i<colorUsed; ++i ) {
1107 int minDistance = 0xffff;
1108 int colorIndex = 0;
1109 for (j = 0; j < sizeof(SYSTEM_PALETTE)/sizeof(RGBi); ++j) {
1110 int distance = rgbi_distance(&SYSTEM_PALETTE[j], &palette[i]);
1111 // printf("%d <-> %d [%d] = %d [min = %d]\n", i, j, SYSTEM_PALETTE[j].index, distance, minDistance );
1112 if (distance < minDistance) {
1113 // printf(" candidated...\n" );
1114 for( k=0; k<i; ++k ) {
1115 if ( palette[k].index == SYSTEM_PALETTE[j].index ) {
1116 // printf(" ...used!\n" );
1117 break;
1118 }
1119 }
1120 if ( k>=i ) {
1121 // printf(" ...ok! (%d)\n", SYSTEM_PALETTE[j].index );
1122 minDistance = distance;
1123 colorIndex = j;
1124 }
1125 }
1126 }
1127 palette[i].index = SYSTEM_PALETTE[colorIndex].index;
1128 strcopy( palette[i].description, SYSTEM_PALETTE[colorIndex].description );
1129 // printf("%d) %d %2.2x%2.2x%2.2x\n", i, palette[i].index, palette[i].red, palette[i].green, palette[i].blue);
1130 }
1131
1132 memcpy( result->originalPalette, palette, MAX_PALETTE * sizeof( RGBi ) );
1133
1134 int bufferSize = 3 + ( ( _frame_width >> 2 ) * _frame_height ) + 2 * ( ( _frame_width >> 2 ) * ( _frame_height >> 3 ) ) + 1;
1135
1136 char * buffer = malloc ( bufferSize );
1137 memset( buffer, 0, bufferSize );
1138
1139 // Position of the pixel in the original image
1140 int image_x, image_y;
1141
1142 // Position of the pixel, in terms of tiles
1143 int tile_x, tile_y;
1144
1145 // Position of the pixel, in terms of offset and bitmask
1146 int offset, offsetc, bitmask;
1147
1148 // Color of the pixel to convert
1149 RGBi rgb;
1150
1151 *(buffer) = _width;
1152 *(buffer+1) = _height;
1153
1154 _source += ( ( _offset_y * _width ) + _offset_x ) * 3;
1155
1156 // Loop for all the source surface.
1157 for (image_y = _offset_y; image_y < _height; ++image_y) {
1158 for (image_x = _offset_x; image_x < _width; ++image_x) {
1159
1160 // Take the color of the pixel
1161 rgb.red = *_source;
1162 rgb.green = *(_source + 1);
1163 rgb.blue = *(_source + 2);
1164 if ( _depth > 3 ) {
1165 rgb.alpha = *(_source + 3);
1166 } else {
1167 rgb.alpha = 255;
1168 }
1169
1170 // Calculate the relative tile
1171 tile_y = (image_y >> 3);
1172 tile_x = (image_x >> 2);
1173
1174 // Calculate the offset starting from the tile surface area
1175 // and the bit to set.
1176 offset = (tile_y * 8 *( _frame_width >> 2 ) ) + (tile_x * 8) + (image_y & 0x07);
1177 offsetc = (tile_y * ( _frame_width >> 2 ) ) + (tile_x);
1178
1179 int minDistance = 0xffff;
1180 int colorIndex = 0;
1181
1182 for( i=0; i<colorUsed; ++i ) {
1183 if ( rgbi_equals_rgba( &palette[i], &rgb ) ) {
1184 break;
1185 }
1186 }
1187
1188 colorIndex = i;
1189
1190 // printf( "%1.1x", colorIndex );
1191
1192 bitmask = colorIndex << (6 - ((image_x & 0x3) * 2));
1193
1194 switch( colorIndex ) {
1195 case 0:
1196 *(buffer + 2 + ( ( _frame_width >> 2 ) * _frame_height ) + 2 * ( _frame_width >> 2 ) * ( _frame_height >> 3 ) ) = palette[colorIndex].index;
1197 break;
1198 case 1:
1199 *(buffer + 2 + ( ( _frame_width >> 2 ) * _frame_height ) + offsetc ) &= 0x0f;
1200 *(buffer + 2 + ( ( _frame_width >> 2 ) * _frame_height ) + offsetc ) |= ( palette[colorIndex].index << 4 );
1201 break;
1202 case 2:
1203 *(buffer + 2 + ( ( _frame_width >> 2 ) * _frame_height ) + offsetc ) &= 0xf0;
1204 *(buffer + 2 + ( ( _frame_width >> 2 ) * _frame_height ) + offsetc ) |= palette[colorIndex].index;
1205 break;
1206 case 3:
1207 *(buffer + 2 + ( ( _frame_width >> 2 ) * _frame_height ) + ( _frame_width >> 2 ) * ( _frame_height >> 3 ) + offsetc ) = palette[colorIndex].index;
1208 break;
1209
1210 }
1211
1212 *(buffer + 2 + offset) |= bitmask;
1213
1214 _source += 3;
1215
1216 }
1217
1218 _source += ( _width - _frame_width ) * 3;
1219
1220 // printf("\n" );
1221 }
1222
1223 // for(i=0; i<4; ++i ) {
1224 // printf( "%1.1x = %2.2x\n", i, palette[i].index );
1225 // }
1226
1227 // printf("\n" );
1228 // printf("\n" );
1229
1230 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
1231
1232 return result;
1233
1234}
1235
1236
1238
1250static void vic1_image_converter_tile( Environment * _environment, char * _source, char * _dest, int _width, int _depth, int _source_width ) {
1251
1252 int colorIndexesCount[COLOR_COUNT];
1253 memset(colorIndexesCount, 0, COLOR_COUNT * sizeof( int ) );
1254 int trans = 0;
1255
1256 char * source = _source;
1257
1258 // Clear the box and colors
1259 memset( _dest, 0, 9 );
1260
1261 // Loop for all the box surface
1262 for (int y=0; y<8; ++y) {
1263 for (int x=0; x<8; ++x) {
1264
1265 RGBi rgb;
1266
1267 memset( &rgb, 0, sizeof( RGBi ) );
1268
1269 // Take the color of the pixel
1270 rgb.red = *source;
1271 rgb.green = *(source + 1);
1272 rgb.blue = *(source + 2);
1273 if ( _depth > 3 ) {
1274 rgb.alpha = *(_source + 3);
1275 } else {
1276 rgb.alpha = 255;
1277 }
1278 if ( rgb.alpha == 0 ) {
1279 rgb.red = 0;
1280 rgb.green = 0;
1281 rgb.blue = 0;
1282 }
1283
1284 if ( rgb.alpha < 255 ) {
1285 trans = 1;
1286 } else {
1287 RGBi *systemRgb = vic1_image_nearest_system_color( &rgb );
1288 ++colorIndexesCount[systemRgb->index];
1289 }
1290
1291 source += _depth;
1292
1293 }
1294
1295 source += _depth * ( _source_width - 8 );
1296
1297 }
1298
1299 int colorBackground = 0;
1300 int colorBackgroundMax = 0;
1301 int colorForeground = 0;
1302 int colorForegroundMax = 0;
1303 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
1304 if ( colorIndexesCount[xx] > colorBackgroundMax ) {
1305 colorBackground = xx;
1306 colorBackgroundMax = colorIndexesCount[xx];
1307 };
1308 }
1309
1310 colorIndexesCount[colorBackground] = 0;
1311
1312 for( int xx = 0; xx<COLOR_COUNT; ++xx ) {
1313 if ( colorIndexesCount[xx] > colorForegroundMax ) {
1314 colorForeground = xx;
1315 colorForegroundMax = colorIndexesCount[xx];
1316 };
1317 }
1318
1319 if ( colorForeground == 0 ) {
1320 colorForeground = colorBackground;
1321 colorBackground = 0;
1322 }
1323
1324 if ( trans ) {
1325 if ( colorForeground == 0 ) {
1326 colorForeground = colorBackground;
1327 colorBackground = 0;
1328 } else {
1329 colorBackground = 0;
1330 }
1331 }
1332
1333 if ( colorForeground == colorBackground ) {
1334 colorForeground = ( colorBackground == 0 ) ? 1 : 0;
1335 }
1336
1337 source = _source;
1338
1339 for (int y=0; y<8; ++y) {
1340 for (int x=0; x<8; ++x) {
1341
1342 RGBi rgb;
1343
1344 memset( &rgb, 0, sizeof( RGBi ) );
1345
1346 rgb.red = *source;
1347 rgb.green = *(source + 1);
1348 rgb.blue = *(source + 2);
1349 if ( _depth > 3 ) {
1350 rgb.alpha = *(_source + 3);
1351 } else {
1352 rgb.alpha = 255;
1353 }
1354 if ( rgb.alpha == 0 ) {
1355 rgb.red = 0;
1356 rgb.green = 0;
1357 rgb.blue = 0;
1358 }
1359
1360 RGBi *systemRgb = vic1_image_nearest_system_color( &rgb );
1361
1362 char bitmask = 1 << ( 7 - ((x) & 0x7) );
1363
1364 if ( rgb.alpha < 255 ) {
1365 *( _dest + y ) &= ~bitmask;
1366 adilinepixel(colorBackground);
1367 } else {
1368 if ( systemRgb->index != colorBackground ) {
1369 adilinepixel(colorForeground);
1370 *( _dest + y ) |= bitmask;
1371 // printf("*");
1372 } else {
1373 adilinepixel(colorBackground);
1374 *( _dest + y ) &= ~bitmask;
1375 // printf(" ");
1376 }
1377 }
1378
1379 source += _depth;
1380
1381 }
1382
1383 source += _depth * ( _source_width - 8 );
1384
1385 }
1386
1387 *( _dest + 8 ) = colorForeground | ( colorBackground << 4 ) ;
1388
1389}
1390
1402static void vic1_image_converter_tiles( Environment * _environment, char * _source, char * _dest, int _width, int _height, int _depth, int _source_width ) {
1403
1404 int bitmapSize = ( _width>>3 ) * _height;
1405 int colormapSize = ( _width>>3 ) * (_height>>3);
1406
1407 memset( _dest, 0, bitmapSize + colormapSize );
1408
1409 adilinebeginbitmap("BMD2");
1410
1411 for( int y=0; y<_height; y+=8 ) {
1412 for( int x=0; x<_width; x+=8 ) {
1413
1414 char * source = _source + ( ( y * _source_width ) + x ) * _depth;
1415 char tile[9];
1416
1417 vic1_image_converter_tile( _environment, source, tile, _width, _depth, _source_width );
1418
1419 int offset = ((y>>3) * 8 *( _width >> 3 ) ) + ((x>>3) * 8) + ((y) & 0x07);
1420 // x = 8, y = 8
1421 // offset = ((8 >> 3) * 8 * (16>>3) ) + ((8>>3) * 8) + ((8) & 7)
1422 // offset = (1 * 8 * 2 ) + (1 * 8)
1423 // offset = 16 + 8 = 24
1424
1425 char * destBitmap = _dest + offset;
1426 char * destColormap = _dest + bitmapSize + ( ( ( y >> 3 ) * ( _width >> 3 ) ) + ( x >> 3 ) );
1427 for( int i=0; i<8; ++i ) {
1428 *destBitmap = tile[i];
1429 ++destBitmap;
1430 }
1431 // printf("tile at %d,%d color = %2.2x\n", x, y, tile[8] );
1432 *destColormap = tile[8];
1433 }
1434 }
1435
1437
1438}
1439
1441
1442static Variable * OLD__vic1_image_converter_tilemap_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 ) {
1443
1444 image_converter_asserts( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8, 8 );
1445
1446 if ( _environment->freeImageWidth ) {
1447 if ( _width % 8 ) {
1448 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
1449 }
1450 if ( _frame_width % 8 ) {
1451 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
1452 }
1453 }
1454
1455 if ( _environment->freeImageHeight ) {
1456 if ( _height % 8 ) {
1457 _height = ( ( ( _height - 1 ) / 8 ) - 1 ) * 8;
1458 }
1459 if ( _frame_height % 8 ) {
1460 _frame_height = ( ( ( _frame_height - 1 ) / 8 ) - 1 ) * 8;
1461 }
1462 }
1463
1464 RGBi palette[MAX_PALETTE];
1465
1466 int colorUsed = rgbi_extract_palette(_environment, _source, _width, _height, _depth, palette, MAX_PALETTE, 1 /* sorted */);
1467
1468 Variable * result = variable_temporary( _environment, VT_IMAGE, 0 );
1469 result->originalColors = colorUsed;
1470
1471 int i, j, k;
1472
1473 for( i=0; i<colorUsed; ++i ) {
1474 int minDistance = 0xffff;
1475 int colorIndex = 0;
1476 for (j = 0; j < sizeof(SYSTEM_PALETTE)/sizeof(RGBi); ++j) {
1477 int distance = rgbi_distance(&SYSTEM_PALETTE[j], &palette[i]);
1478 // printf("%d <-> %d [%d] = %d [min = %d]\n", i, j, SYSTEM_PALETTE[j].index, distance, minDistance );
1479 if (distance < minDistance) {
1480 // printf(" candidated...\n" );
1481 for( k=0; k<i; ++k ) {
1482 if ( palette[k].index == SYSTEM_PALETTE[j].index ) {
1483 // printf(" ...used!\n" );
1484 break;
1485 }
1486 }
1487 if ( k>=i ) {
1488 // printf(" ...ok! (%d)\n", SYSTEM_PALETTE[j].index );
1489 minDistance = distance;
1490 colorIndex = j;
1491 }
1492 }
1493 }
1494 palette[i].index = SYSTEM_PALETTE[colorIndex].index;
1495 strcopy( palette[i].description, SYSTEM_PALETTE[colorIndex].description );
1496 // printf("%d) %d %2.2x%2.2x%2.2x\n", i, palette[i].index, palette[i].red, palette[i].green, palette[i].blue);
1497 }
1498
1499 memcpy( result->originalPalette, palette, MAX_PALETTE * sizeof( RGBi ) );
1500
1501 int bufferSize;
1502
1503 if ( colorUsed == 2 ) {
1504 bufferSize = 3 + ( ( _frame_width >> 3 ) * ( _frame_height >> 3 ) ) + 2;
1505 } else {
1506 bufferSize = 3 + 2* ( ( _frame_width >> 3 ) * ( _frame_height >> 3 ) );
1507 }
1508
1509 // printf("bufferSize = %d\n", bufferSize );
1510
1511 char * buffer = malloc ( bufferSize );
1512 memset( buffer, 0, bufferSize );
1513
1514 // Position of the pixel in the original image
1515 int image_x, image_y;
1516
1517 // Position of the pixel, in terms of tiles
1518 int tile_x, tile_y;
1519
1520 // Position of the pixel, in terms of offset and bitmask
1521 int offset, bitmask;
1522
1523 // Color of the pixel to convert
1524 RGBi rgb;
1525
1526 *(buffer) = _frame_width;
1527 *(buffer+1) = _frame_height;
1528
1529 if ( colorUsed > 2 ) {
1530 *(buffer+2) = 1;
1531 } else {
1532 *(buffer+2) = 0;
1533 }
1534
1535 int cx=0,cy=0;
1536
1537 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1538
1539 // commonTileDescriptors = precalculate_tile_descriptors_for_font( data_fontvic1_bin );
1540
1541 for( cy=0; cy<(_frame_height >> 3);++cy) {
1542 for( cx=0; cx<(_frame_width >> 3);++cx) {
1543
1544 char *source = _source + ( ( cy * 8 * _width ) + cx * 8 ) * _depth;
1545 char convertedTile[9];
1546
1547 vic1_image_converter_tile( _environment, source, convertedTile, _width, _depth, _width );
1548
1549 TileData tileData;
1550 memset(&tileData,0,sizeof(TileData));
1551 memcpy(&tileData.data[0], convertedTile, 8 );
1552
1553 // printf("\n" );
1554
1555 TileDescriptor * t = calculate_tile_descriptor( &tileData );
1556
1557 if ( ! _environment->descriptors ) {
1559 _environment->descriptors->first = 0;
1560 _environment->descriptors->firstFree = ( (data_font_alpha_bin_len / 8) );
1561 _environment->descriptors->lastFree = 255;
1562 _environment->descriptors->count = _environment->descriptors->firstFree;
1563 }
1564
1565 int tile = calculate_exact_tile( t, _environment->descriptors );
1566
1567 if ( tile == -1 ) {
1568 if ( _environment->descriptors->count < 256 ) {
1569 tile = (_environment->descriptors->count++);
1570 _environment->descriptors->descriptor[tile] = t;
1571 memcpy( &_environment->descriptors->data[tile], &tileData, sizeof( TileData ) );
1572 } else {
1573 tile = calculate_nearest_tile( t, _environment->descriptors );
1574 }
1575 // printf("*** tile = %d\n", tile );
1576 } else {
1577 // printf(" tile = %d\n", tile );
1578 }
1579
1580 *(buffer + 3 + (cy * ( _frame_width >> 3 ) ) + cx ) = tile;
1581 if ( colorUsed > 2 ) {
1582 // printf( "c = %1.1x\n", mostFrequentColorIndex );
1583 *(buffer + 3 + ( ( _frame_width >> 3 ) * ( _frame_height >> 3 ) ) + (cy * ( _frame_width >> 3 ) ) + cx ) = ( convertedTile[8] >> 4 ) & 0x7;
1584 }
1585
1586 // printf("\ntile: %2.2x\n", tile );
1587
1588 }
1589 // printf("\n");
1590 }
1591
1592 if ( colorUsed <= 2 ) {
1593 *(buffer + 3 + ( ( _frame_width >> 3 ) * ( _frame_height >> 3 ) ) ) = palette[1].index;
1594 *(buffer + 3 + ( ( _frame_width >> 3 ) * ( _frame_height >> 3 ) ) + 1 ) = ( palette[0].index << 4 );
1595 } else {
1596 *(buffer + 3 + ( ( _frame_width >> 3 ) * ( _frame_height >> 3 ) ) + ( (_frame_height >> 3 ) * ( _frame_width >> 3 ) ) ) = ( palette[0].index << 4 ) & 0xf0;
1597 }
1598 // printf("----\n");
1599
1600 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
1601
1602 // printf("----\n");
1603
1604 return result;
1605
1606}
1607
1608static Variable * vic1_image_converter_tilemap_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 ) {
1609
1610 _environment->bitmaskNeeded = 1;
1611
1612 image_converter_asserts( _environment, _width, _height, _offset_x, _offset_y, &_frame_width, &_frame_height, 8, 8 );
1613
1614 if ( _environment->freeImageWidth ) {
1615 if ( _width % 8 ) {
1616 _width = ( ( ( _width - 1 ) / 8 ) - 1 ) * 8;
1617 }
1618 if ( _frame_width % 8 ) {
1619 _frame_width = ( ( ( _frame_width - 1 ) / 8 ) - 1 ) * 8;
1620 }
1621 }
1622
1623 if ( _environment->freeImageHeight ) {
1624 if ( _height % 8 ) {
1625 _height = ( ( ( _height - 1 ) / 8 ) - 1 ) * 8;
1626 }
1627 if ( _frame_height % 8 ) {
1628 _frame_height = ( ( ( _frame_height - 1 ) / 8 ) - 1 ) * 8;
1629 }
1630 }
1631
1632 Variable * result = variable_temporary( _environment, VT_IMAGE, "(mage)");
1633 result->locked = 1;
1634
1635 // timeslot: 1 byte
1636 // width: 1 byte
1637 // size: 1 byte
1638 // (indexes): size bytes
1639 // tiles' data
1640
1641 int size = ( ( _frame_width >> 3 ) * ( _frame_height >> 3 ) );
1642
1643 int bufferSize = 3 + size + size * 8 + size;
1644
1645 char * buffer = malloc ( bufferSize );
1646
1647 memset( buffer, 0, bufferSize );
1648
1649 buffer[0] = 0xff; // force update at first PUT IMAGE
1650 buffer[1] = ( _frame_width >> 3 );
1651 buffer[2] = size;
1652
1653 int cx, cy;
1654
1655 _source += ( ( _offset_y * _width ) + _offset_x ) * _depth;
1656
1657 for( cy=0; cy<(_frame_height >> 3);++cy) {
1658 for( cx=0; cx<(_frame_width >> 3);++cx) {
1659
1660 int tileDataOffset = 3 + size + ( (cy * ( _frame_width >> 3 ) ) + cx ) * ( 8 );
1661 int tileColorOffset = 3 + size + size * 8 + ( cy * (_frame_width >> 3) ) + cx;
1662
1663 char * source = _source + ( ( cy * 8 * _width ) + cx * 8 ) * _depth;
1664
1665 char convertedTile[9];
1666
1667 vic1_image_converter_tile( _environment, source, convertedTile, _width, _depth, _width );
1668
1669 memcpy( &buffer[tileDataOffset], convertedTile, 8 );
1670 buffer[tileColorOffset] = convertedTile[8];
1671
1672 }
1673
1674 }
1675
1676 variable_store_buffer( _environment, result->name, buffer, bufferSize, 0 );
1677
1678 return result;
1679
1680}
1681
1682Variable * vic1_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 ) {
1683
1684 switch( _mode ) {
1687 return vic1_image_converter_tilemap_mode_standard( _environment, _data, _width, _height, _depth, _offset_x, _offset_y, _frame_width, _frame_height, _transparent_color, _flags );
1688 break;
1689 }
1690
1692
1693 return vic1_new_image( _environment, 8, 8, BITMAP_MODE_STANDARD );
1694
1695}
1696
1697void vic1_calculate_sequence_frame_offset( Environment * _environment, char * _offset, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
1698
1699}
1700
1701static void vic1_load_image_address_to_register( Environment * _environment, char * _register, Resource * _source, char * _sequence, char * _frame, int _frame_size, int _frame_count ) {
1702
1703 if ( !_sequence && !_frame ) {
1704 if ( _source->isAddress ) {
1705 outline1("LDA %s", _source->realName );
1706 outline1("STA %s", _register );
1707 outline1("LDA %s", address_displacement(_environment, _source->realName, "1") );
1708 outline1("STA %s", address_displacement(_environment, _register, "1") );
1709 } else {
1710 outline1("LDA #<%s", _source->realName );
1711 outline1("STA %s", _register );
1712 outline1("LDA #>%s", _source->realName );
1713 outline1("STA %s", address_displacement(_environment, _register, "1") );
1714 }
1715 } else {
1716 if ( _source->isAddress ) {
1717 outline1("LDA %s", _source->realName );
1718 outline0("STA TMPPTR" );
1719 outline1("LDA %s", address_displacement(_environment, _source->realName, "1") );
1720 outline0("STA TMPPTR+1" );
1721 } else {
1722 outline1("LDA #<%s", _source->realName );
1723 outline0("STA TMPPTR" );
1724 outline1("LDA #>%s", _source->realName );
1725 outline0("STA TMPPTR+1" );
1726 }
1727
1728 if ( _sequence ) {
1729 outline0("CLC" );
1730 outline0("LDA TMPPTR" );
1731 outline0("ADC #3" );
1732 outline0("STA TMPPTR" );
1733 outline0("LDA TMPPTR+1" );
1734 outline0("ADC #0" );
1735 outline0("STA TMPPTR+1" );
1736
1737 if ( strlen(_sequence) == 0 ) {
1738
1739 } else {
1740 outline1("LDA %s", _sequence );
1741 outline0("STA MATHPTR0" );
1742 outline1("JSR %soffsetsequence", _source->realName );
1743 }
1744 if ( _frame ) {
1745 if ( strlen(_frame) == 0 ) {
1746
1747 } else {
1748 outline1("LDA %s", _frame );
1749 outline0("STA MATHPTR0" );
1750 outline1("JSR %soffsetframe", _source->realName );
1751 }
1752 }
1753
1754 } else {
1755
1756 if ( _frame ) {
1757 outline0("CLC" );
1758 outline0("LDA TMPPTR" );
1759 outline0("ADC #3" );
1760 outline0("STA TMPPTR" );
1761 outline0("LDA TMPPTR+1" );
1762 outline0("ADC #0" );
1763 outline0("STA TMPPTR+1" );
1764 if ( strlen(_frame) == 0 ) {
1765
1766 } else {
1767 outline1("LDA %s", _frame );
1768 outline0("STA MATHPTR0" );
1769 outline1("JSR %soffsetframe", _source->realName );
1770 }
1771 }
1772
1773 }
1774
1775 if ( _source->isAddress ) {
1776 outline0("LDA TMPPTR" );
1777 outline1("STA %s", _register );
1778 outline0("LDA TMPPTR+1" );
1779 outline1("STA %s", address_displacement(_environment, _register, "1") );
1780 } else {
1781 outline0("LDA TMPPTR" );
1782 outline1("STA %s", _register );
1783 outline0("LDA TMPPTR+1" );
1784 outline1("STA %s", address_displacement(_environment, _register, "1") );
1785 }
1786
1787 }
1788}
1789
1790void vic1_put_image( Environment * _environment, Resource * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _flags ) {
1791
1792 // currently unused
1793 (void)!_flags;
1794
1795 _environment->bitmaskNeeded = 1;
1796
1797 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
1798 deploy( putimage, src_hw_vic1_put_image_asm );
1799
1800 if ( _frame_size ) {
1801 vic1_load_image_address_to_register( _environment, "TMPPTR", _image, _sequence, _frame, _frame_size, _frame_count );
1802 }
1803
1804 outline1("LDA %s", _x );
1805 outline0("STA IMAGEX" );
1806 outline1("LDA %s", address_displacement(_environment, _x, "1") );
1807 outline0("STA IMAGEX+1" );
1808 outline1("LDA %s", _y );
1809 outline0("STA IMAGEY" );
1810 outline1("LDA %s", address_displacement(_environment, _y, "1") );
1811 outline0("STA IMAGEY+1" );
1812 // outline1("LDA %s", _flags);
1813 // if ( strchr( _flags, '#' ) ) {
1814 // outline1("LDA #((%s)&255)", _flags+1 );
1815 // outline0("STA IMAGEF" );
1816 // outline1("LDA #(((%s)>>8)&255)", _flags+1 );
1817 // outline0("STA IMAGET" );
1818 // } else {
1819 // outline1("LDA %s", _flags );
1820 // outline0("STA IMAGEF" );
1821 // outline1("LDA %s", address_displacement(_environment, _flags, "1") );
1822 // outline0("STA IMAGET" );
1823 // }
1824
1825 outline0("JSR PUTIMAGE");
1826
1827}
1828
1829void vic1_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 ) {
1830
1831 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
1832 deploy( blitimage, src_hw_vic1_blit_image_asm );
1833
1834 if ( _source_count > 2 ) {
1836 }
1837
1839
1840 outhead1("blitimage%s:", label);
1841
1842 outline1("LDA #<%s", _blit );
1843 outline0("STA BLITIMAGEBLITADDR+1" );
1844 outline1("LDA #>%s", _blit );
1845 outline0("STA BLITIMAGEBLITADDR+2" );
1846
1847 if ( _source_count > 0 ) {
1848 Resource resource;
1849 resource.realName = strdup( _sources[0] );
1850 resource.type = VT_IMAGE;
1851 vic1_load_image_address_to_register( _environment, "BLITTMPPTR", &resource, _sequence, _frame, _frame_size, _frame_count );
1852 } else {
1853 outline0( "LDA #$0" );
1854 outline0( "STA BLITTMPPTR" );
1855 outline0( "STA BLITTMPPTR+1" );
1856 }
1857
1858 if ( _source_count > 1 ) {
1859 Resource resource;
1860 resource.realName = strdup( _sources[0] );
1861 resource.type = VT_IMAGE;
1862 vic1_load_image_address_to_register( _environment, "BLITTMPPTR2", &resource, _sequence, _frame, _frame_size, _frame_count );
1863 } else {
1864 outline0( "LDA #$0" );
1865 outline0( "STA BLITTMPPTR2" );
1866 outline0( "STA BLITTMPPTR2+1" );
1867 }
1868
1869 outhead1("putimage%s:", label);
1870
1871 outline1("LDA %s", _x );
1872 outline0("STA IMAGEX" );
1873 outline1("LDA %s", address_displacement(_environment, _x, "1") );
1874 outline0("STA IMAGEX+1" );
1875 outline1("LDA %s", _y );
1876 outline0("STA IMAGEY" );
1877 outline1("LDA %s", address_displacement(_environment, _y, "1") );
1878 outline0("STA IMAGEY+1" );
1879 outline1("LDA #$%2.2x", ( _flags & 0xff ) );
1880 outline0("STA IMAGEF" );
1881 outline1("LDA #$%2.2x", ( (_flags>>8) & 0xff ) );
1882 outline0("STA IMAGET" );
1883
1884 outline0("JSR BLITIMAGE");
1885
1886}
1887
1888void vic1_wait_vbl( Environment * _environment ) {
1889
1890 deploy( vbl, src_hw_vic1_vbl_asm);
1891
1892 outline0("JSR VBL");
1893
1894}
1895
1896Variable * vic1_new_image( Environment * _environment, int _width, int _height, int _mode ) {
1897
1898 int size = vic1_image_size( _environment, _width, _height, _mode );
1899
1900 // if ( ! size ) {
1901 // CRITICAL_NEW_IMAGE_UNSUPPORTED_MODE( _mode );
1902 // }
1903
1904 Variable * result = variable_temporary( _environment, VT_IMAGE, "(new image)" );
1905
1906 result->size = size;
1907 result->valueBuffer = malloc(size);
1908
1909 return result;
1910}
1911
1912Variable * vic1_new_images( Environment * _environment, int _frames, int _width, int _height, int _mode ) {
1913
1914 int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
1915 int frameSize = vic1_image_size( _environment, _width, _height, _mode );
1916
1917 // if ( ! size ) {
1918 // CRITICAL_NEW_IMAGE_UNSUPPORTED_MODE( _mode );
1919 // }
1920
1921 Variable * result = variable_temporary( _environment, VT_IMAGES, "(new images)" );
1922
1923 result->size = size;
1924 result->frameSize = frameSize;
1925 result->frameCount = _frames;
1926 result->valueBuffer = malloc( size );
1927
1928 return result;
1929}
1930
1931Variable * vic1_new_sequence( Environment * _environment, int _sequences, int _frames, int _width, int _height, int _mode ) {
1932
1933 int size2 = calculate_sequence_size( _environment, _sequences, _frames, _width, _height, _mode );
1934 int size = calculate_images_size( _environment, _frames, _width, _height, _mode );
1935 int frameSize = vic1_image_size( _environment, _width, _height, _mode );
1936
1937 // if ( ! size ) {
1938 // CRITICAL_NEW_IMAGE_UNSUPPORTED_MODE( _mode );
1939 // }
1940
1941 Variable * result = variable_temporary( _environment, VT_SEQUENCE, "(new images)" );
1942
1943 result->size = size;
1944 result->frameSize = frameSize;
1945 result->frameCount = _frames;
1946 result->valueBuffer = malloc( size );
1947
1948 return result;
1949}
1950
1951void vic1_get_image( Environment * _environment, char * _image, char * _x, char * _y, char * _frame, char * _sequence, int _frame_size, int _frame_count, int _palette ) {
1952
1953}
1954
1955void vic1_scroll( Environment * _environment, int _dx, int _dy ) {
1956
1957 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
1958 deploy( scroll, src_hw_vic1_scroll_asm);
1959 deploy_preferred( textHScroll, src_hw_vic1_hscroll_text_asm );
1960 deploy_preferred( vScrollTextUp, src_hw_vic1_vscroll_text_up_asm );
1961 deploy_preferred( vScrollTextDown, src_hw_vic1_vscroll_text_down_asm );
1962
1963 outline1("LDA #$%2.2x", (unsigned char)(_dx&0xff) );
1964 outline0("STA MATHPTR0" );
1965 outline1("LDA #$%2.2x", (unsigned char)(_dy&0xff) );
1966 outline0("STA MATHPTR1" );
1967 outline0("JSR SCROLL");
1968
1969}
1970
1971void vic1_put_tile( Environment * _environment, char * _tile, char * _x, char * _y ) {
1972
1973 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
1974 deploy( tiles, src_hw_vic1_tiles_asm );
1975
1976 outline1("LDA %s", _tile );
1977 outline0("STA TILET" );
1978 outline1("LDA %s", _x );
1979 outline0("STA TILEX" );
1980 outline1("LDA %s", _y );
1981 outline0("STA TILEY" );
1982 outline0("LDA #1" );
1983 outline0("STA TILEW" );
1984 outline0("STA TILEH" );
1985 outline0("STA TILEW2" );
1986 outline0("STA TILEH2" );
1987
1988 outline0("JSR PUTTILE");
1989
1990}
1991
1992void vic1_move_tiles( Environment * _environment, char * _tile, char * _x, char * _y ) {
1993
1994 Variable * tile = variable_retrieve( _environment, _tile );
1995 Variable * x = variable_retrieve( _environment, _x );
1996 Variable * y = variable_retrieve( _environment, _y );
1997
1998 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
1999 deploy( tiles, src_hw_vic1_tiles_asm );
2000
2001 outline1("LDA %s", tile->realName );
2002 outline0("STA TILET" );
2003 outline1("LDA %s", x->realName );
2004 outline0("STA TILEX" );
2005 outline1("LDA %s", y->realName );
2006 outline0("STA TILEY" );
2007 outline1("LDA %s", address_displacement(_environment, tile->realName, "1") );
2008 outline0("STA TILEW" );
2009 outline0("STA TILEW2" );
2010 outline1("LDA %s", address_displacement(_environment, tile->realName, "2") );
2011 outline0("STA TILEH" );
2012 outline0("STA TILEH2" );
2013 outline1("LDA %s", address_displacement(_environment, tile->realName, "3") );
2014 outline0("STA TILEA" );
2015
2016 int size = ( tile->originalWidth >> 3 ) * ( tile->originalHeight >> 3 );
2017
2018 if ( size ) {
2019 outline1("LDA #<OFFSETS%4.4x", size );
2020 outline0("STA TMPPTR2" );
2021 outline1("LDA #>OFFSETS%4.4x", size );
2022 outline0("STA TMPPTR2+1" );
2023 } else {
2024 outline0("LDA #0" );
2025 outline0("STA TMPPTR2" );
2026 outline0("STA TMPPTR2+1" );
2027 }
2028
2029 outline0("JSR MOVETILE");
2030
2031}
2032
2033void vic1_put_tiles( Environment * _environment, char * _tile, char * _x, char * _y, char *_w, char *_h ) {
2034
2035 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
2036 deploy( tiles, src_hw_vic1_tiles_asm );
2037
2038 outline1("LDA %s", _tile );
2039 outline0("STA TILET" );
2040 outline1("LDA %s", _x );
2041 outline0("STA TILEX" );
2042 outline1("LDA %s", _y );
2043 outline0("STA TILEY" );
2044 outline1("LDA %s", address_displacement(_environment, _tile, "1") );
2045 outline0("STA TILEW" );
2046 if ( _w ) {
2047 outline1("LDA %s", _w );
2048 }
2049 outline0("STA TILEW2" );
2050 outline1("LDA %s", address_displacement(_environment, _tile, "2") );
2051 outline0("STA TILEH" );
2052 if ( _h ) {
2053 outline1("LDA %s", _h );
2054 }
2055 outline0("STA TILEH2" );
2056
2057 outline0("JSR PUTTILE");
2058
2059}
2060
2061void vic1_tile_at( Environment * _environment, char * _x, char * _y, char * _result ) {
2062
2063 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
2064 deploy( tiles, src_hw_vic1_tiles_asm );
2065
2066 outline1("LDA %s", _x );
2067 outline0("STA TILEX" );
2068 outline1("LDA %s", _y );
2069 outline0("STA TILEY" );
2070
2071 outline0("JSR TILEAT");
2072
2073 outline0("LDA TILET" );
2074 outline1("STA %s", _result );
2075
2076}
2077
2078void vic1_use_tileset( Environment * _environment, char * _tileset ) {
2079
2080 deploy_preferred( vic1vars, src_hw_vic1_vars_asm);
2081 deploy( tiles, src_hw_vic1_tiles_asm );
2082
2083 outline1("LDA %s", _tileset );
2084
2085 outline0("JSR USETILESET");
2086
2087}
2088
2090
2091 Variable * result = variable_temporary( _environment, VT_WORD, "(raster line)" );
2092
2093 outline0( "LDA $9004" );
2094 outline0( "ASL" );
2095 outline1( "STA %s", result->realName );
2096 outline0( "LDA #$0" );
2097 outline0( "ROL" );
2098 outline1( "STA %s", address_displacement(_environment, result->realName, "1") );
2099
2100 return result;
2101
2102}
2103
2104/* audio */
2105
2106static unsigned int SOUND_FREQUENCIES[] = {
2107 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
2108 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
2109 19, 19, 19, 19, 19, 19, 32, 45, 57, 68,
2110 78, 88, 98, 106, 115, 123, 130, 137, 144, 150,
2111 156, 161, 167, 172, 176, 181, 185, 189, 193, 196,
2112 199, 202, 205, 208, 211, 213, 216, 218, 220, 222,
2113 224, 226, 227, 229, 230, 232, 233, 234, 235, 236,
2114 237, 238, 239, 240, 241, 242, 243, 243, 244, 245,
2115 245, 246, 246, 247, 247, 248, 248, 248, 249, 249,
2116 249, 250, 250, 250, 251, 251, 251, 251, 252, 252,
2117 252, 252, 252, 252, 253, 253, 253, 253, 253, 253,
2118 253, 253, 253, 254, 254, 254, 254, 254, 254
2119};
2120
2121void vic1_start( Environment * _environment, int _channels ) {
2122
2123 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2124 deploy_deferred( vic1startup, src_hw_vic1_startup_asm );
2125
2126 if ( _channels & 0x01 ) {
2127 outline0("JSR VIC1START0");
2128 }
2129 if ( _channels & 0x02 ) {
2130 outline0("JSR VIC1START1");
2131 }
2132 if ( _channels & 0x04 ) {
2133 outline0("JSR VIC1START2");
2134 }
2135
2136}
2137
2138void vic1_set_volume( Environment * _environment, int _channels, int _volume ) {
2139
2140 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2141 deploy( vic1startup, src_hw_vic1_startup_asm );
2142
2143 outline1("LDX #%2.2x", ( _volume & 0x0f ) );
2144 outline0("JSR VIC1STARTVOL");
2145
2146}
2147
2148#define PROGRAM_FREQUENCY( c, f ) \
2149 outline1("LDX #$%2.2x", ( ( ( f >> 9 ) & 0xff ) ) ); \
2150 outline1("LDY #$%2.2x", 0 ); \
2151 if ( ( c & 0x01 ) ) \
2152 outline0("JSR VIC1PROGFREQ0" ); \
2153 if ( ( c & 0x02 ) ) \
2154 outline0("JSR VIC1PROGFREQ1" ); \
2155 if ( ( c & 0x04 ) ) \
2156 outline0("JSR VIC1PROGFREQ2" );
2157
2158#define PROGRAM_FREQUENCY_V( c, f ) \
2159 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2160 outline1("LDX %s", f ); \
2161 outline1("LDY %s", address_displacement(_environment, f, "1") ); \
2162 outline0("JSR VIC1FREQ" );
2163
2164#define PROGRAM_FREQUENCY_SV( c, f ) \
2165 outline1("LDX #$%2.2x", ( ( ( f >> 9 ) ) & 0xff ) ); \
2166 outline1("LDY #$%2.2x", 0 ); \
2167 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2168 outline0("JSR VIC1FREQ2" );
2169
2170#define PROGRAM_DURATION( c, d ) \
2171 outline1("LDX #$%2.2x", ( ( d & 0xff ) ) ); \
2172 outline1("LDY #$%2.2x", ( ( ( d >> 9 ) & 0xff ) ) ); \
2173 if ( ( c & 0x01 ) ) \
2174 outline0("JSR VIC1SETDURATION0" ); \
2175 if ( ( c & 0x02 ) ) \
2176 outline0("JSR VIC1SETDURATION1" ); \
2177 if ( ( c & 0x04 ) ) \
2178 outline0("JSR VIC1SETDURATION2" );
2179
2180#define WAIT_DURATION( c ) \
2181 if ( ( c & 0x01 ) ) \
2182 outline0("JSR VIC1WAITDURATION0" ); \
2183 if ( ( c & 0x02 ) ) \
2184 outline0("JSR VIC1WAITDURATION1" ); \
2185 if ( ( c & 0x04 ) ) \
2186 outline0("JSR VIC1WAITDURATION2" );
2187
2188#define PROGRAM_PITCH( c, f ) \
2189 outline1("LDX #$%2.2x", ( f & 0xff ) ); \
2190 outline1("LDY #$%2.2x", 0 ); \
2191 if ( ( c & 0x01 ) ) \
2192 outline0("JSR VIC1PROGFREQ0" ); \
2193 if ( ( c & 0x02 ) ) \
2194 outline0("JSR VIC1PROGFREQ1" ); \
2195 if ( ( c & 0x04 ) ) \
2196 outline0("JSR VIC1PROGFREQ2" );
2197
2198#define PROGRAM_PITCH_V( c, f ) \
2199 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2200 outline1("LDX %s", f ); \
2201 outline1("LDY %s", address_displacement(_environment, f, "1") ); \
2202 outline0("JSR VIC1PROGFREQ" );
2203
2204#define PROGRAM_PITCH_SV( c, f ) \
2205 outline1("LDX #$%2.2x", ( f & 0xff ) ); \
2206 outline1("LDY #$%2.2x", 0 ); \
2207 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2208 outline0("JSR VIC1PROGFREQ" );
2209
2210#define PROGRAM_PULSE( c, p ) \
2211 outline1("LDX #$%2.2x", ( p & 0xff ) ); \
2212 outline1("LDY #$%2.2x", 0 ); \
2213 if ( ( c & 0x01 ) ) \
2214 outline0("JSR VIC1PROGPULSE0" ); \
2215 if ( ( c & 0x02 ) ) \
2216 outline0("JSR VIC1PROGPULSE1" ); \
2217 if ( ( c & 0x04 ) ) \
2218 outline0("JSR VIC1PROGPULSE2" );
2219
2220#define PROGRAM_PULSE_V( c, p ) \
2221 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2222 outline1("LDX %s", p ); \
2223 outline1("LDY %s", address_displacement(_environment, p, "1") ); \
2224 outline0("JSR VIC1PROGPULSE" );
2225
2226#define PROGRAM_PULSE_SV( c, p ) \
2227 outline1("LDX #$%2.2x", ( p & 0xff ) ); \
2228 outline1("LDY #$%2.2x", 0 ); \
2229 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2230 outline0("JSR VIC1PROGPULSE" );
2231
2232#define PROGRAM_NOISE( c ) \
2233 outline0("LDX #$82" ); \
2234 if ( ( c & 0x01 ) ) \
2235 outline0("JSR VIC1PROGCTR0" ); \
2236 if ( ( c & 0x02 ) ) \
2237 outline0("JSR VIC1PROGCTR1" ); \
2238 if ( ( c & 0x04 ) ) \
2239 outline0("JSR VIC1PROGCTR2" );
2240
2241#define PROGRAM_NOISE_V( c, p ) \
2242 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2243 outline0("LDX #$82" ); \
2244 outline0("JSR VIC1PROGCTR" );
2245
2246#define PROGRAM_NOISE_SV( c ) \
2247 outline0("LDX #$82" ); \
2248 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2249 outline0("JSR VIC1PROGCTR" );
2250
2251#define PROGRAM_SAW( c ) \
2252 outline0("LDX #$22" ); \
2253 if ( ( c & 0x01 ) ) \
2254 outline0("JSR VIC1PROGCTR0" ); \
2255 if ( ( c & 0x02 ) ) \
2256 outline0("JSR VIC1PROGCTR1" ); \
2257 if ( ( c & 0x04 ) ) \
2258 outline0("JSR VIC1PROGCTR2" );
2259
2260#define PROGRAM_SAW_V( c) \
2261 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2262 outline0("LDX #$22" ); \
2263 outline0("JSR VIC1PROGCTR" );
2264
2265#define PROGRAM_SAW_SV( c ) \
2266 outline0("LDX #$22" ); \
2267 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2268 outline0("JSR VIC1PROGCTR" );
2269
2270#define PROGRAM_TRIANGLE( c ) \
2271 outline0("LDX #$12" ); \
2272 if ( ( c & 0x01 ) ) \
2273 outline0("JSR VIC1PROGCTR0" ); \
2274 if ( ( c & 0x02 ) ) \
2275 outline0("JSR VIC1PROGCTR1" ); \
2276 if ( ( c & 0x04 ) ) \
2277 outline0("JSR VIC1PROGCTR2" );
2278
2279#define PROGRAM_TRIANGLE_V( c ) \
2280 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2281 outline0("LDX #$12" ); \
2282 outline0("JSR VIC1PROGCTR" );
2283
2284#define PROGRAM_TRIANGLE_SV( c ) \
2285 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2286 outline0("LDX #$12" ); \
2287 outline0("JSR VIC1PROGCTR" );
2288
2289#define PROGRAM_SAW_TRIANGLE( c ) \
2290 outline0("LDX #$32" ); \
2291 if ( ( c & 0x01 ) ) \
2292 outline0("JSR VIC1PROGCTR0" ); \
2293 if ( ( c & 0x02 ) ) \
2294 outline0("JSR VIC1PROGCTR1" ); \
2295 if ( ( c & 0x04 ) ) \
2296 outline0("JSR VIC1PROGCTR2" );
2297
2298#define PROGRAM_SAW_TRIANGLE_V( c ) \
2299 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2300 outline0("LDX #$32" ); \
2301 outline0("JSR VIC1PROGCTR" );
2302
2303#define PROGRAM_SAW_TRIANGLE_SV( c ) \
2304 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2305 outline0("LDX #$32" ); \
2306 outline0("JSR VIC1PROGCTR" );
2307
2308#define PROGRAM_ATTACK_DECAY( c, a, d ) \
2309 outline1("LDX #$%2.2x", ( a & 0x0f ) ); \
2310 outline1("LDY #$%2.2x", ( d & 0x0f ) ); \
2311 if ( ( c & 0x01 ) ) \
2312 outline0("JSR VIC1PROGAD0" ); \
2313 if ( ( c & 0x02 ) ) \
2314 outline0("JSR VIC1PROGAD1" ); \
2315 if ( ( c & 0x04 ) ) \
2316 outline0("JSR VIC1PROGAD2" );
2317
2318#define PROGRAM_ATTACK_DECAY_V( c, a, d ) \
2319 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2320 outline1("LDX %s", a ); \
2321 outline1("LDY %s", d ); \
2322 outline0("JSR VIC1PROGAD" );
2323
2324#define PROGRAM_ATTACK_DECAY_SV( c, a, d ) \
2325 outline1("LDX #$%2.2x", ( a & 0x0f ) ); \
2326 outline1("LDY #$%2.2x", ( d & 0x0f ) ); \
2327 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2328 outline0("JSR VIC1PROGAD" );
2329
2330#define PROGRAM_SUSTAIN_RELEASE( c, s, r ) \
2331 outline1("LDX #$%2.2x", ( s & 0x0f ) ); \
2332 outline1("LDY #$%2.2x", ( r & 0x0f ) ); \
2333 if ( ( c & 0x01 ) ) \
2334 outline0("JSR VIC1PROGSR0" ); \
2335 if ( ( c & 0x02 ) ) \
2336 outline0("JSR VIC1PROGSR1" ); \
2337 if ( ( c & 0x04 ) ) \
2338 outline0("JSR VIC1PROGSR2" );
2339
2340#define PROGRAM_SUSTAIN_RELEASE_V( c, s, r ) \
2341 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2342 outline1("LDX %s", s ); \
2343 outline1("LDY %s", r ); \
2344 outline0("JSR VIC1PROGSR" );
2345
2346#define PROGRAM_SUSTAIN_RELEASE_SV( c, s, r ) \
2347 outline1("LDX #$%2.2x", ( s & 0x0f ) ); \
2348 outline1("LDY #$%2.2x", ( r & 0x0f ) ); \
2349 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2350 outline0("JSR VIC1PROGSR" );
2351
2352#define STOP_FREQUENCY( c ) \
2353 if ( ( c & 0x01 ) ) \
2354 outline0("JSR VIC1STOP0" ); \
2355 if ( ( c & 0x02 ) ) \
2356 outline0("JSR VIC1STOP1" ); \
2357 if ( ( c & 0x04 ) ) \
2358 outline0("JSR VIC1STOP2" );
2359
2360#define STOP_FREQUENCY_V( c ) \
2361 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2362 outline0("JSR VIC1STOP" );
2363
2364#define STOP_FREQUENCY_SV( c ) \
2365 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
2366 outline0("JSR VIC1STOP" );
2367
2368void vic1_set_program( Environment * _environment, int _channels, int _program ) {
2369
2370 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2371 deploy( vic1startup, src_hw_vic1_startup_asm );
2372
2373 switch (_program) {
2375 PROGRAM_NOISE(_channels);
2376 PROGRAM_ATTACK_DECAY(_channels, 2, 11);
2377 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 1);
2378 break;
2380 PROGRAM_NOISE(_channels);
2381 PROGRAM_ATTACK_DECAY(_channels, 2, 4);
2382 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 1);
2383 break;
2394 PROGRAM_TRIANGLE(_channels);
2395 PROGRAM_ATTACK_DECAY(_channels, 4, 2);
2396 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 10);
2397 break;
2398
2402 PROGRAM_PULSE(_channels, 1024);
2403 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
2404 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 3);
2405 break;
2406
2415 PROGRAM_TRIANGLE(_channels);
2416 PROGRAM_ATTACK_DECAY(_channels, 2, 10);
2417 PROGRAM_SUSTAIN_RELEASE(_channels, 12, 14);
2418 break;
2419
2420 default:
2430 PROGRAM_TRIANGLE(_channels);
2431 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
2432 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
2433 break;
2434
2442 PROGRAM_PULSE(_channels, 128);
2443 PROGRAM_ATTACK_DECAY(_channels, 10, 10);
2444 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 10);
2445 break;
2446
2448 PROGRAM_PULSE(_channels, 128);
2449 PROGRAM_ATTACK_DECAY(_channels, 1, 2);
2450 PROGRAM_SUSTAIN_RELEASE(_channels, 4, 3);
2451 break;
2452
2462 PROGRAM_TRIANGLE(_channels);
2463 PROGRAM_ATTACK_DECAY(_channels, 2, 10);
2464 PROGRAM_SUSTAIN_RELEASE(_channels, 12, 14);
2465 break;
2466
2479 PROGRAM_PULSE(_channels, 128);
2480 PROGRAM_ATTACK_DECAY(_channels, 10, 10);
2481 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 10);
2482 break;
2483
2503 PROGRAM_NOISE(_channels);
2504 PROGRAM_ATTACK_DECAY(_channels, 1, 14);
2505 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
2506 break;
2507
2535 PROGRAM_SAW(_channels);
2536 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
2537 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
2538 break;
2539
2562 PROGRAM_SAW(_channels);
2563 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
2564 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
2565 break;
2566 }
2567
2568}
2569
2570void vic1_set_parameter( Environment * _environment, int _channels, int _parameter, int _value ) {
2571
2572}
2573
2574void vic1_set_frequency( Environment * _environment, int _channels, int _frequency ) {
2575
2576 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2577 deploy( vic1startup, src_hw_vic1_startup_asm );
2578
2579 PROGRAM_FREQUENCY( _channels, _frequency );
2580
2581}
2582
2583void vic1_set_pitch( Environment * _environment, int _channels, int _pitch ) {
2584
2585 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2586 deploy( vic1startup, src_hw_vic1_startup_asm );
2587
2588 PROGRAM_PITCH( _channels, _pitch );
2589
2590}
2591
2592void vic1_set_note( Environment * _environment, int _channels, int _note ) {
2593
2594 vic1_set_pitch( _environment, _channels, SOUND_FREQUENCIES[_note] );
2595
2596}
2597
2598void vic1_stop( Environment * _environment, int _channels ) {
2599
2600 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2601 deploy( vic1startup, src_hw_vic1_startup_asm );
2602
2603 STOP_FREQUENCY( _channels );
2604
2605}
2606
2607void vic1_start_var( Environment * _environment, char * _channels ) {
2608
2609 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2610 deploy( vic1startup, src_hw_vic1_startup_asm );
2611
2612 if ( _channels ) {
2613 outline1("LDA %s", _channels );
2614 } else {
2615 outline0("LDA #$7" );
2616 }
2617 outline0("JSR VIC1START");
2618
2619}
2620
2621void vic1_set_volume_vars( Environment * _environment, char * _channels, char * _volume ) {
2622
2623 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2624 deploy( vic1startup, src_hw_vic1_startup_asm );
2625
2626 outline1("LDA %s", _volume );
2627 outline0("LSR" );
2628 outline0("LSR" );
2629 outline0("LSR" );
2630 outline0("LSR" );
2631 outline0("TAX" );
2632 outline0("JSR VIC1STARTVOL");
2633
2634}
2635
2636void vic1_set_volume_semi_var( Environment * _environment, char * _channel, int _volume ) {
2637
2638 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2639 deploy( vic1startup, src_hw_vic1_startup_asm );
2640
2641 outline1("LDX #$%2.2x", _volume );
2642 outline0("JSR VIC1STARTVOL");
2643
2644}
2645
2646void vic1_set_program_semi_var( Environment * _environment, char * _channels, int _program ) {
2647
2648 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2649 deploy( vic1startup, src_hw_vic1_startup_asm );
2650
2651 switch (_program) {
2653 PROGRAM_NOISE_SV(_channels);
2654 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 11);
2655 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 0, 1);
2656 break;
2658 PROGRAM_NOISE_SV(_channels);
2659 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 4);
2660 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 0, 1);
2661 break;
2672 PROGRAM_TRIANGLE_SV(_channels);
2673 PROGRAM_ATTACK_DECAY_SV(_channels, 4, 2);
2674 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
2675 break;
2676
2680 PROGRAM_PULSE_SV(_channels, 1024);
2681 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
2682 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 3);
2683 break;
2684
2693 PROGRAM_TRIANGLE_SV(_channels);
2694 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 10);
2695 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 12, 14);
2696 break;
2697
2698 default:
2708 PROGRAM_TRIANGLE_SV(_channels);
2709 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
2710 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
2711 break;
2712
2720 PROGRAM_PULSE_SV(_channels, 128);
2721 PROGRAM_ATTACK_DECAY_SV(_channels, 10, 10);
2722 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
2723 break;
2724
2726 PROGRAM_PULSE_SV(_channels, 128);
2727 PROGRAM_ATTACK_DECAY_SV(_channels, 1, 2);
2728 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 4, 3);
2729 break;
2730
2740 PROGRAM_TRIANGLE_SV(_channels);
2741 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 10);
2742 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 12, 14);
2743 break;
2744
2757 PROGRAM_PULSE_SV(_channels, 128);
2758 PROGRAM_ATTACK_DECAY_SV(_channels, 10, 10);
2759 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
2760 break;
2761
2781 PROGRAM_NOISE_SV(_channels);
2782 PROGRAM_ATTACK_DECAY_SV(_channels, 1, 14);
2783 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
2784 break;
2785
2813 PROGRAM_SAW_SV(_channels);
2814 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
2815 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
2816 break;
2817
2840 PROGRAM_SAW_SV(_channels);
2841 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
2842 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
2843 break;
2844 }
2845
2846}
2847
2848void vic1_set_frequency_vars( Environment * _environment, char * _channels, char * _frequency ) {
2849
2850 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2851 deploy( vic1startup, src_hw_vic1_startup_asm );
2852
2853 if ( _channels ) {
2854 outline1("LDA %s", _channels );
2855 } else {
2856 outline0("LDA #$7" );
2857 }
2858 outline1("LDX %s", _frequency );
2859 outline1("LDY %s", address_displacement(_environment, _frequency, "1") );
2860
2861 outline0("JSR VIC1FREQ");
2862
2863}
2864
2865void vic1_set_pitch_vars( Environment * _environment, char * _channels, char * _pitch ) {
2866
2867 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2868 deploy( vic1startup, src_hw_vic1_startup_asm );
2869
2870 if ( _channels ) {
2871 outline1("LDA %s", _channels );
2872 } else {
2873 outline0("LDA #$7" );
2874 }
2875 outline1("LDX %s", _pitch );
2876 outline1("LDY %s", address_displacement(_environment, _pitch, "1") );
2877
2878 outline0("JSR VIC1PROGFREQ");
2879
2880}
2881
2882void vic1_set_note_vars( Environment * _environment, char * _channels, char * _note ) {
2883
2884 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2885 deploy( vic1startup, src_hw_vic1_startup_asm );
2886
2887 outline0("LDA #<VIC1FREQTABLE");
2888 outline0("STA TMPPTR");
2889 outline0("LDA #>VIC1FREQTABLE");
2890 outline0("STA TMPPTR+1");
2891 outline1("LDY %s", _note);
2892 outline0("TYA");
2893 outline0("ASL");
2894 outline0("TAY");
2895 outline0("LDA (TMPPTR),Y");
2896 outline0("TAX");
2897 outline0("INY");
2898 outline0("LDA (TMPPTR),Y");
2899 outline0("TAY");
2900
2901 if ( _channels ) {
2902 outline1("LDA %s", _channels );
2903 } else {
2904 outline0("LDA #$7" );
2905 }
2906
2907 outline0("JSR VIC1PROGFREQ");
2908
2909}
2910
2911void vic1_stop_vars( Environment * _environment, char * _channels ) {
2912
2913 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2914 deploy( vic1startup, src_hw_vic1_startup_asm );
2915
2916 outline1("LDA %s", _channels );
2917 outline0("JSR VIC1STOP");
2918
2919}
2920
2921void vic1_music( Environment * _environment, char * _music, int _size, int _loop ) {
2922
2923 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2924 deploy( vic1startup, src_hw_vic1_startup_asm );
2925
2926 outline0("SEI");
2927 outline1("LDA #<%s", _music);
2928 outline0("STA VIC1TMPPTR_BACKUP");
2929 outline1("LDA #>%s", _music);
2930 outline0("STA VIC1TMPPTR_BACKUP+1");
2931 outline1("LDA #$%2.2x", ( _size>>8 ) & 0xff);
2932 outline0("STA VIC1BLOCKS_BACKUP");
2933 outline1("LDA #$%2.2x", _size & 0xff );
2934 outline0("STA VIC1LASTBLOCK_BACKUP");
2935 outline1("LDA #$%2.2x", _loop);
2936 outline0("STA VIC1MUSICLOOP");
2937 outline0("JSR MUSICPLAYERRESET");
2938 outline0("CLI");
2939
2940}
2941
2942void vic1_slice_image( Environment * _environment, char * _image, char * _frame, char * _sequence, int _frame_size, int _frame_count, char * _destination ) {
2943
2944}
2945
2946int vic1_palette_extract( Environment * _environment, char * _data, int _width, int _height, int _depth, int _flags, RGBi * _palette ) {
2947
2948 int paletteColorCount = rgbi_extract_palette(_environment, _data, _width, _height, _depth, _palette, MAX_PALETTE, ( ( _flags & FLAG_EXACT ) ? 0 : 1 ) /* sorted */);
2949
2950 memcpy( _palette, palette_match( _palette, paletteColorCount, SYSTEM_PALETTE, sizeof(SYSTEM_PALETTE) / sizeof(RGBi) ), paletteColorCount * sizeof( RGBi ) );
2951
2952 int uniquePaletteCount = 0;
2953
2954 memcpy( _palette, palette_remove_duplicates( _palette, paletteColorCount, &uniquePaletteCount ), paletteColorCount * sizeof( RGBi ) );
2955
2956 return uniquePaletteCount;
2957
2958}
2959
2960void vic1_set_duration( Environment * _environment, int _channels, int _duration ) {
2961
2962 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2963 deploy( vic1startup, src_hw_vic1_startup_asm );
2964
2965 PROGRAM_DURATION( _channels, _duration );
2966
2967}
2968
2969void vic1_wait_duration( Environment * _environment, int _channels ) {
2970
2971 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2972 deploy( vic1startup, src_hw_vic1_startup_asm );
2973
2974 WAIT_DURATION( _channels );
2975
2976}
2977
2978void vic1_set_duration_vars( Environment * _environment, char * _channels, char * _duration ) {
2979
2980 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
2981 deploy( vic1startup, src_hw_vic1_startup_asm );
2982
2983 if ( _channels ) {
2984 outline1("LDA %s", _channels );
2985 } else {
2986 outline0("LDA #$f" );
2987 }
2988 if ( _duration ) {
2989 outline1("LDX %s", _duration );
2990 } else {
2991 outline0("LDX #50" );
2992 }
2993
2994 outline0("JSR VIC1SETDURATION");
2995
2996}
2997
2998void vic1_wait_duration_vars( Environment * _environment, char * _channels ) {
2999
3000 deploy_preferred( vic1vars, src_hw_vic1_vars_asm );
3001 deploy( vic1startup, src_hw_vic1_startup_asm );
3002
3003 if ( _channels ) {
3004 outline1("LDA %s", _channels );
3005 } else {
3006 outline0("LDA #$f" );
3007 }
3008
3009 outline0("JSR VIC1WAITDURATION");
3010
3011}
3012
3013void vic1_screen( Environment * _environment, char * _x, char * _y, char * _c ) {
3014
3015 deploy( screen, src_hw_vic1_screen_asm);
3016
3017 outline1( "LDA %s", _x );
3018 outline0( "STA MATHPTR1" );
3019 outline1( "LDA %s", _y );
3020 outline0( "STA MATHPTR0" );
3021 outline0( "JSR SCREEN" );
3022 outline1( "STA %s", _c );
3023
3024}
3025
3026void vic1_flash_begin( Environment * _environment, char * _index, char * _register ) {
3027
3028 deploy( flash, src_hw_vic1_flash_asm );
3029
3030 outline0("JSR FLASHBEGIN");
3031 if ( _register ) {
3032 outline1("LDA %s", _index );
3033 outline0("ASL" );
3034 outline0("TAX" );
3035 outline0("LDA FLASHREGISTERADDRESSES, X" );
3036 outline0("STA TMPPTR" );
3037 outline0("INX" );
3038 outline0("LDA FLASHREGISTERADDRESSES, X" );
3039 outline0("STA TMPPTR+1" );
3040 outline0("LDY #0" );
3041 outline1("LDA %s", _register );
3042 outline0("STA (TMPPTR), Y" );
3043 outline0("INY" );
3044 outline1("LDA %s", address_displacement( _environment, _register, "+1" ) );
3045 outline0("STA (TMPPTR), Y" );
3046 }
3047
3048}
3049
3050void vic1_flash_register( Environment * _environment, char * _index, char * _timer, char * _color ) {
3051
3052 deploy( flash, src_hw_vic1_flash_asm );
3053
3054 outline1("LDX %s", _index );
3055 outline1("LDY %s", _color );
3056 outline1("LDA %s", _timer );
3057 outline0("JSR FLASHREGISTER");
3058
3059}
3060
3061void vic1_flash_end( Environment * _environment ) {
3062
3063 deploy( flash, src_hw_vic1_flash_asm );
3064
3065 outline0("JSR FLASHEND");
3066
3067}
3068
3069void vic1_flash_off( Environment * _environment, char * _index ) {
3070
3071 deploy( flash, src_hw_vic1_flash_asm );
3072
3073 outline1("LDX %s", _index );
3074 outline0("JSR FLASHOFF");
3075
3076}
3077
3078#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
#define COLOR_COUNT
Definition 6847.h:72
#define BITMAP_MODE_STANDARD
Definition 6847.h:96
int calculate_nearest_tile(TileDescriptor *_tile, TileDescriptors *_tiles)
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.
int rgbi_equals_rgba(RGBi *_first, RGBi *_second)
TileDescriptor * calculate_tile_descriptor(TileData *_tileData)
TileDescriptors * precalculate_tile_descriptors_for_font(char *_fontData, int _fontSize)
Variable * variable_import(Environment *_environment, char *_name, VariableType _type, int _size_or_value)
int calculate_exact_tile(TileDescriptor *_tile, TileDescriptors *_tiles)
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.
void font_descriptors_init(Environment *_environment, int _embedded_present)
RGBi * palette_match(RGBi *_source, int _source_size, RGBi *_system, int _system_size)
Make a "palette match".
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 cls(Environment *_environment, char *_paper)
Emit code for CLS.
Definition cls.c:48
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 flash(Environment *_environment, char *_index, char *_register)
Definition flash.c:44
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
unsigned int data_font_alpha_bin_len
Definition font_alpha.c:89
unsigned char data_font_alpha_bin[]
Definition font_alpha.c:1
unsigned int data_font_standard_bin_len
int width
Definition ugbc.h:2209
int y1
Definition ugbc.h:2206
int x1
Definition ugbc.h:2205
int height
Definition ugbc.h:2210
int vic1startup
Definition ugbc.h:1740
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
int bitmaskNeeded
Definition ugbc.h:2659
int screenColors
Definition ugbc.h:2870
int dynamicConsole
Definition ugbc.h:3298
FontConfig fontConfig
Definition ugbc.h:2415
int currentModeBW
Definition ugbc.h:2701
int screenHeight
Definition ugbc.h:2860
int consoleTilesWidth
Definition ugbc.h:2890
int currentTileMode
Definition ugbc.h:2706
TileDescriptors * descriptors
Definition ugbc.h:2939
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
int schema
Definition ugbc.h:2063
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
char data[8]
Definition ugbc.h:2141
TileData data[512]
Definition ugbc.h:2153
TileDescriptor * descriptor[512]
Definition ugbc.h:2152
unsigned char * valueBuffer
Definition ugbc.h:1061
int locked
Definition ugbc.h:1009
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 * 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.
@ 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 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 FONT_SCHEMA_ALPHA
Definition ugbc.h:581
#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 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
struct _TileDescriptor TileDescriptor
#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 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 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
#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_BLIT_TOO_MUCH_SOURCES()
Definition ugbc.h:3613
struct _TileData TileData
#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
char * strcopy(char *_dest, char *_source)
void vic1_tiles_get(Environment *_environment, char *_result)
Definition vic1.c:649
void vic1_sprite_data_set(Environment *_environment, char *_sprite, char *_address)
Definition vic1.c:555
void vic1_set_frequency_vars(Environment *_environment, char *_channels, char *_frequency)
Definition vic1.c:2848
void vic1_flash_end(Environment *_environment)
Definition vic1.c:3061
void vic1_set_program_semi_var(Environment *_environment, char *_channels, int _program)
Definition vic1.c:2646
#define PROGRAM_DURATION(c, d)
Definition vic1.c:2170
#define PROGRAM_TRIANGLE_SV(c)
Definition vic1.c:2284
#define PROGRAM_SAW_SV(c)
Definition vic1.c:2265
void vic1_slice_image(Environment *_environment, char *_image, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_destination)
Definition vic1.c:2942
void vic1_textmap_at(Environment *_environment, char *_address)
Definition vic1.c:455
void vic1_set_parameter(Environment *_environment, int _channels, int _parameter, int _value)
Definition vic1.c:2570
void vic1_cls_box(Environment *_environment, char *_x1, char *_y1, char *_w, char *_h)
Definition vic1.c:673
RGBi * vic1_image_nearest_system_color(RGBi *_color)
Definition vic1.c:63
void vic1_cls(Environment *_environment)
Definition vic1.c:665
void vic1_tiles_at(Environment *_environment, char *_address)
Definition vic1.c:607
void vic1_start_var(Environment *_environment, char *_channels)
Definition vic1.c:2607
void vic1_start(Environment *_environment, int _channels)
Definition vic1.c:2121
void vic1_sprite_color(Environment *_environment, char *_sprite, char *_color)
Definition vic1.c:599
void vic1_hscroll_screen(Environment *_environment, int _direction, int _overlap)
Definition vic1.c:838
int vic1_image_size(Environment *_environment, int _width, int _height, int _mode)
Definition vic1.c:878
#define PROGRAM_FREQUENCY(c, f)
Definition vic1.c:2148
void vic1_wait_vbl(Environment *_environment)
Definition vic1.c:1888
void vic1_background_color_vars(Environment *_environment, char *_index, char *_background_color)
VIC: emit code to change background color
Definition vic1.c:160
void vic1_sprite_expand_horizontal(Environment *_environment, char *_sprite)
Definition vic1.c:579
#define PROGRAM_SAW(c)
Definition vic1.c:2251
void vic1_calculate_sequence_frame_offset(Environment *_environment, char *_offset, char *_sequence, char *_frame, int _frame_size, int _frame_count)
Definition vic1.c:1697
void vic1_sprite_common_color(Environment *_environment, char *_index, char *_common_color)
VIC: emit code to change common sprite's color
Definition vic1.c:231
#define PROGRAM_NOISE_SV(c)
Definition vic1.c:2246
void vic1_set_duration(Environment *_environment, int _channels, int _duration)
Definition vic1.c:2960
void vic1_get_height(Environment *_environment, char *_result)
Definition vic1.c:656
void vic1_bitmap_enable(Environment *_environment, int _width, int _height, int _colors)
Definition vic1.c:405
void vic1_busy_wait(Environment *_environment, char *_timing)
Definition vic1.c:619
void vic1_scroll(Environment *_environment, int _dx, int _dy)
Definition vic1.c:1955
void vic1_tilemap_enable(Environment *_environment, int _width, int _height, int _colors, int _tile_width, int _tile_height)
Definition vic1.c:427
void vic1_stop(Environment *_environment, int _channels)
Definition vic1.c:2598
void vic1_get_width(Environment *_environment, char *_result)
Definition vic1.c:640
Variable * vic1_new_images(Environment *_environment, int _frames, int _width, int _height, int _mode)
Definition vic1.c:1912
int vic1_palette_extract(Environment *_environment, char *_data, int _width, int _height, int _depth, int _flags, RGBi *_palette)
Definition vic1.c:2946
#define WAIT_DURATION(c)
Definition vic1.c:2180
void vic1_put_tile(Environment *_environment, char *_tile, char *_x, char *_y)
Definition vic1.c:1971
void vic1_next_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
VIC: emit code to wait for next raster irq at different position
Definition vic1.c:281
Variable * vic1_new_image(Environment *_environment, int _width, int _height, int _mode)
Definition vic1.c:1896
void vic1_set_frequency(Environment *_environment, int _channels, int _frequency)
Definition vic1.c:2574
void vic1_music(Environment *_environment, char *_music, int _size, int _loop)
Definition vic1.c:2921
void vic1_screen(Environment *_environment, char *_x, char *_y, char *_c)
Definition vic1.c:3013
void vic1_sprite_data_from(Environment *_environment, char *_sprite, char *_address)
Definition vic1.c:559
void vic1_hscroll_line(Environment *_environment, int _direction, int _overlap)
Definition vic1.c:822
void vic1_sprite_monocolor(Environment *_environment, char *_sprite)
Definition vic1.c:595
void vic1_flash_begin(Environment *_environment, char *_index, char *_register)
Definition vic1.c:3026
void vic1_sprite_at(Environment *_environment, char *_sprite, char *_x, char *_y)
Definition vic1.c:571
void vic1_bitmap_at(Environment *_environment, char *_address)
Definition vic1.c:447
void vic1_finalization(Environment *_environment)
Definition vic1.c:807
void vic1_hit(Environment *_environment, char *_sprite_mask, char *_result)
VIC: emit code to check for collision
Definition vic1.c:105
void vic1_put_tiles(Environment *_environment, char *_tile, char *_x, char *_y, char *_w, char *_h)
Definition vic1.c:2033
void vic1_set_note_vars(Environment *_environment, char *_channels, char *_note)
Definition vic1.c:2882
void vic1_screen_off(Environment *_environment)
Definition vic1.c:543
void vic1_scroll_text(Environment *_environment, int _direction, int _overlap)
Definition vic1.c:677
void vic1_stop_vars(Environment *_environment, char *_channels)
Definition vic1.c:2911
#define STOP_FREQUENCY(c)
Definition vic1.c:2352
void vic1_use_tileset(Environment *_environment, char *_tileset)
Definition vic1.c:2078
void vic1_flash_register(Environment *_environment, char *_index, char *_timer, char *_color)
Definition vic1.c:3050
void vic1_set_pitch_vars(Environment *_environment, char *_channels, char *_pitch)
Definition vic1.c:2865
#define PROGRAM_ATTACK_DECAY(c, a, d)
Definition vic1.c:2308
void vic1_set_volume_semi_var(Environment *_environment, char *_channel, int _volume)
Definition vic1.c:2636
void vic1_sprite_expand_vertical(Environment *_environment, char *_sprite)
Definition vic1.c:575
void vic1_background_color_get_vars(Environment *_environment, char *_index, char *_background_color)
VIC: emit code to retrieve background color
Definition vic1.c:208
#define PROGRAM_SUSTAIN_RELEASE_SV(c, s, r)
Definition vic1.c:2346
void vic1_set_duration_vars(Environment *_environment, char *_channels, char *_duration)
Definition vic1.c:2978
void vic1_raster_at(Environment *_environment, char *_label, char *_positionlo, char *_positionhi)
VIC: emit code to set raster irq
Definition vic1.c:250
void vic1_wait_duration_vars(Environment *_environment, char *_channels)
Definition vic1.c:2998
void vic1_pset_vars(Environment *_environment, char *_x, char *_y, char *_c)
Definition vic1.c:483
void vic1_vertical_scroll(Environment *_environment, char *_displacement)
Definition vic1.c:611
void vic1_sprite_disable(Environment *_environment, char *_sprite)
Definition vic1.c:567
void vic1_text(Environment *_environment, char *_text, char *_text_size, int _raw)
Definition vic1.c:693
#define PROGRAM_SUSTAIN_RELEASE(c, s, r)
Definition vic1.c:2330
#define PROGRAM_NOISE(c)
Definition vic1.c:2232
void vic1_colormap_at(Environment *_environment, char *_address)
Definition vic1.c:451
void console_calculate_vars(Environment *_environment)
Definition vic1.c:397
#define PROGRAM_PULSE_SV(c, p)
Definition vic1.c:2226
void vic1_sprite_compress_horizontal(Environment *_environment, char *_sprite)
Definition vic1.c:587
void vic1_wait_duration(Environment *_environment, int _channels)
Definition vic1.c:2969
void vic1_screen_rows(Environment *_environment, char *_rows)
Definition vic1.c:547
void vic1_set_volume_vars(Environment *_environment, char *_channels, char *_volume)
Definition vic1.c:2621
void vic1_put_image(Environment *_environment, Resource *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, char *_flags)
Definition vic1.c:1790
void vic1_set_program(Environment *_environment, int _channels, int _program)
Definition vic1.c:2368
Variable * vic1_get_raster_line(Environment *_environment)
Definition vic1.c:2089
#define PROGRAM_PITCH(c, f)
Definition vic1.c:2188
void vic1_pset_int(Environment *_environment, int _x, int _y, int *_c)
Definition vic1.c:459
void vic1_horizontal_scroll(Environment *_environment, char *_displacement)
Definition vic1.c:615
void vic1_set_volume(Environment *_environment, int _channels, int _volume)
Definition vic1.c:2138
void vic1_sprite_compress_vertical(Environment *_environment, char *_sprite)
Definition vic1.c:583
int vic1_screen_mode_enable(Environment *_environment, ScreenMode *_screen_mode)
Definition vic1.c:312
void vic1_move_tiles(Environment *_environment, char *_tile, char *_x, char *_y)
Definition vic1.c:1992
void vic1_sprite_enable(Environment *_environment, char *_sprite)
Definition vic1.c:563
void vic1_bitmap_disable(Environment *_environment)
Definition vic1.c:423
void vic1_tile_at(Environment *_environment, char *_x, char *_y, char *_result)
Definition vic1.c:2061
void vic1_get_image(Environment *_environment, char *_image, char *_x, char *_y, char *_frame, char *_sequence, int _frame_size, int _frame_count, int _palette)
Definition vic1.c:1951
void vic1_collision(Environment *_environment, char *_sprite_mask, char *_result)
VIC: emit code to check for collision
Definition vic1.c:90
void vic1_back(Environment *_environment)
Definition vic1.c:850
void vic1_screen_on(Environment *_environment)
Definition vic1.c:539
#define PROGRAM_PULSE(c, p)
Definition vic1.c:2210
void vic1_sprite_priority(Environment *_environment, char *_sprite, char *_priority)
Definition vic1.c:603
void vic1_pget_color_vars(Environment *_environment, char *_x, char *_y, char *_result)
Definition vic1.c:516
void vic1_background_color(Environment *_environment, int _index, int _background_color)
VIC: emit code to change background color
Definition vic1.c:140
void vic1_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 vic1.c:1829
void vic1_flash_off(Environment *_environment, char *_index)
Definition vic1.c:3069
Variable * vic1_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 vic1.c:1682
void vic1_sprite_multicolor(Environment *_environment, char *_sprite)
Definition vic1.c:591
void vic1_bank_select(Environment *_environment, int _bank)
Definition vic1.c:285
void vic1_background_color_semivars(Environment *_environment, int _index, char *_background_color)
VIC: emit code to change background color
Definition vic1.c:184
void vic1_cline(Environment *_environment, char *_characters)
Definition vic1.c:858
void vic1_screen_columns(Environment *_environment, char *_columns)
Definition vic1.c:551
#define PROGRAM_TRIANGLE(c)
Definition vic1.c:2270
void vic1_next_raster(Environment *_environment)
VIC: emit code to wait for next raster irq
Definition vic1.c:264
void console_calculate(Environment *_environment)
Definition vic1.c:371
void vic1_initialization(Environment *_environment)
Definition vic1.c:722
void vic1_set_pitch(Environment *_environment, int _channels, int _pitch)
Definition vic1.c:2583
#define PROGRAM_ATTACK_DECAY_SV(c, a, d)
Definition vic1.c:2324
Variable * vic1_new_sequence(Environment *_environment, int _sequences, int _frames, int _width, int _height, int _mode)
Definition vic1.c:1931
void vic1_border_color(Environment *_environment, char *_border_color)
VIC: emit code to change border color
Definition vic1.c:118
void vic1_set_note(Environment *_environment, int _channels, int _note)
Definition vic1.c:2592