ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
sid.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#if defined(__c64__) || defined(__c128__) || defined(__c64reu__)
32
33#include "../ugbc.h"
34
35static unsigned int SOUND_FREQUENCIES[] = {
36 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
37 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
38 0, 0, 0, 268, 284, 301, 318, 337, 358, 379,
39 401, 425, 451, 477, 506, 536, 568, 602, 637, 675,
40 716, 758, 803, 851, 902, 955, 1012, 1072, 1136, 1204,
41 1275, 1351, 1432, 1517, 1607, 1703, 1804, 1911, 2026, 2145,
42 2273, 2408, 2551, 2703, 2864, 3034, 3215, 3406, 3608, 3823,
43 4050, 4291, 4547, 4817, 5103, 5407, 5728, 6069, 6430, 6812,
44 7217, 7647, 8101, 8583, 9094, 9634, 10207, 10814, 11457, 12139,
45 12860, 13625, 14435, 15294, 16203, 17167, 18188, 19269, 20415, 21629,
46 22915, 24278, 25721, 27251, 28871, 30588, 32407, 34334, 36376, 38539,
47 40830, 43258, 45830, 48556, 51443, 54502, 57743, 61176, 64814
48};
49
50void sid_initialization( Environment * _environment ) {
51
52 cpu_call( _environment, "SIDSTARTUP" );
53
54}
55
56void sid_finalization( Environment * _environment ) {
57
58 if ( !_environment->deployed.sidstartup ) {
59 outhead0( "SIDSTARTUP:" );
60 outline0( "RTS" );
61 }
62
63}
64
65void sid_start( Environment * _environment, int _channels ) {
66
67 deploy( sidvars, src_hw_sid_vars_asm );
68 deploy( sidstartup, src_hw_sid_startup_asm );
69
70 if ( _channels & 0x01 ) {
71 outline0("JSR SIDSTART0");
72 }
73 if ( _channels & 0x02 ) {
74 outline0("JSR SIDSTART1");
75 }
76 if ( _channels & 0x04 ) {
77 outline0("JSR SIDSTART2");
78 }
79
80}
81
82void sid_set_volume( Environment * _environment, int _channels, int _volume ) {
83
84 deploy( sidvars, src_hw_sid_vars_asm );
85 deploy( sidstartup, src_hw_sid_startup_asm );
86
87 outline1("LDX #%2.2x", ( _volume & 0x0f ) );
88 outline0("JSR SIDSTARTVOL");
89
90}
91
92#define WAVEFORM_TRIANGLE 0x10
93#define WAVEFORM_SAW 0x20
94#define WAVEFORM_RECTANGLE 0x40
95#define WAVEFORM_NOISE 0x80
96
97#define PROGRAM_FREQUENCY( c, f ) \
98 outline1("LDX #$%2.2x", ( ( ( f * 0xffff ) / 4000 ) & 0xff ) ); \
99 outline1("LDY #$%2.2x", ( ( ( ( f * 0xffff ) / 4000 ) >> 8 ) & 0xff ) ); \
100 if ( ( c & 0x01 ) ) \
101 outline0("JSR SIDPROGFREQ0" ); \
102 if ( ( c & 0x02 ) ) \
103 outline0("JSR SIDPROGFREQ1" ); \
104 if ( ( c & 0x04 ) ) \
105 outline0("JSR SIDPROGFREQ2" );
106
107#define PROGRAM_FREQUENCY_V( c, f ) \
108 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
109 outline1("LDX %s", f ); \
110 outline1("LDY %s", address_displacement(_environment, f, "1") ); \
111 outline0("JSR SIDFREQ" );
112
113#define PROGRAM_FREQUENCY_SV( c, f ) \
114 outline1("LDX #$%2.2x", ( ( ( f * 0xffff ) / 4000 ) & 0xff ) ); \
115 outline1("LDY #$%2.2x", ( ( ( ( f * 0xffff ) / 4000 ) >> 8 ) & 0xff ) ); \
116 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
117 outline0("JSR SIDFREQ2" );
118
119#define PROGRAM_PITCH( c, f ) \
120 outline1("LDX #$%2.2x", ( f & 0xff ) ); \
121 outline1("LDY #$%2.2x", ( ( f >> 8 ) & 0xff ) ); \
122 if ( ( c & 0x01 ) ) \
123 outline0("JSR SIDPROGFREQ0" ); \
124 if ( ( c & 0x02 ) ) \
125 outline0("JSR SIDPROGFREQ1" ); \
126 if ( ( c & 0x04 ) ) \
127 outline0("JSR SIDPROGFREQ2" );
128
129#define PROGRAM_PITCH_V( c, f ) \
130 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
131 outline1("LDX %s", f ); \
132 outline1("LDY %s", address_displacement(_environment, f, "1") ); \
133 outline0("JSR SIDPROGFREQ" );
134
135#define PROGRAM_PITCH_SV( c, f ) \
136 outline1("LDX #$%2.2x", ( f & 0xff ) ); \
137 outline1("LDY #$%2.2x", ( ( f >> 8 ) & 0xff ) ); \
138 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
139 outline0("JSR SIDPROGFREQ" );
140
141#define PROGRAM_PULSE( c, p ) \
142 outline1("LDX #$%2.2x", ( p & 0xff ) ); \
143 outline1("LDY #$%2.2x", ( ( p >> 8 ) & 0xff ) ); \
144 if ( ( c & 0x01 ) ) \
145 outline0("JSR SIDPROGPULSE0" ); \
146 if ( ( c & 0x02 ) ) \
147 outline0("JSR SIDPROGPULSE1" ); \
148 if ( ( c & 0x04 ) ) \
149 outline0("JSR SIDPROGPULSE2" );
150
151#define PROGRAM_PULSE_V( c, p ) \
152 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
153 outline1("LDX %s", p ); \
154 outline1("LDY %s", address_displacement(_environment, p, "1") ); \
155 outline0("JSR SIDPROGPULSE" );
156
157#define PROGRAM_PULSE_SV( c, p ) \
158 outline1("LDX #$%2.2x", ( p & 0xff ) ); \
159 outline1("LDY #$%2.2x", ( ( p >> 8 ) & 0xff ) ); \
160 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
161 outline0("JSR SIDPROGPULSE" );
162
163#define PROGRAM_WAVEFORM( c, w ) \
164 outline1("LDX #$%2.2x", w ); \
165 if ( ( c & 0x01 ) ) \
166 outline0("JSR SIDPROGCTR0" ); \
167 if ( ( c & 0x02 ) ) \
168 outline0("JSR SIDPROGCTR1" ); \
169 if ( ( c & 0x04 ) ) \
170 outline0("JSR SIDPROGCTR2" );
171
172#define PROGRAM_WAVEFORM_V( c, w, p ) \
173 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
174 outline1("LDX #$%2.2x", w ); \
175 outline0("JSR SIDPROGCTR" );
176
177#define PROGRAM_WAVEFORM_VV( c, w, p ) \
178 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
179 outline1("LDX %s", w ); \
180 outline0("JSR SIDPROGCTR" );
181
182#define PROGRAM_WAVEFORM_SV( c, w ) \
183 outline1("LDX #$%2.2x", w ); \
184 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
185 outline0("JSR SIDPROGCTR" );
186
187#define PROGRAM_ATTACK_DECAY( c, a, d ) \
188 outline1("LDX #$%2.2x", ( a & 0x0f ) ); \
189 outline1("LDY #$%2.2x", ( d & 0x0f ) ); \
190 if ( ( c & 0x01 ) ) \
191 outline0("JSR SIDPROGAD0" ); \
192 if ( ( c & 0x02 ) ) \
193 outline0("JSR SIDPROGAD1" ); \
194 if ( ( c & 0x04 ) ) \
195 outline0("JSR SIDPROGAD2" );
196
197#define PROGRAM_ATTACK_DECAY_V( c, a, d ) \
198 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
199 outline1("LDX %s", a ); \
200 outline1("LDY %s", d ); \
201 outline0("JSR SIDPROGAD" );
202
203#define PROGRAM_ATTACK_DECAY_SV( c, a, d ) \
204 outline1("LDX #$%2.2x", ( a & 0x0f ) ); \
205 outline1("LDY #$%2.2x", ( d & 0x0f ) ); \
206 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
207 outline0("JSR SIDPROGAD" );
208
209#define PROGRAM_SUSTAIN_RELEASE( c, s, r ) \
210 outline1("LDX #$%2.2x", ( s & 0x0f ) ); \
211 outline1("LDY #$%2.2x", ( r & 0x0f ) ); \
212 if ( ( c & 0x01 ) ) \
213 outline0("JSR SIDPROGSR0" ); \
214 if ( ( c & 0x02 ) ) \
215 outline0("JSR SIDPROGSR1" ); \
216 if ( ( c & 0x04 ) ) \
217 outline0("JSR SIDPROGSR2" );
218
219#define PROGRAM_SUSTAIN_RELEASE_V( c, s, r ) \
220 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
221 outline1("LDX %s", s ); \
222 outline1("LDY %s", r ); \
223 outline0("JSR SIDPROGSR" );
224
225#define PROGRAM_SUSTAIN_RELEASE_SV( c, s, r ) \
226 outline1("LDX #$%2.2x", ( s & 0x0f ) ); \
227 outline1("LDY #$%2.2x", ( r & 0x0f ) ); \
228 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
229 outline0("JSR SIDPROGSR" );
230
231#define STOP_FREQUENCY( c ) \
232 if ( ( c & 0x01 ) ) \
233 outline0("JSR SIDSTOP0" ); \
234 if ( ( c & 0x02 ) ) \
235 outline0("JSR SIDSTOP1" ); \
236 if ( ( c & 0x04 ) ) \
237 outline0("JSR SIDSTOP2" );
238
239#define STOP_FREQUENCY_V( c ) \
240 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
241 outline0("JSR SIDSTOP" );
242
243#define STOP_FREQUENCY_SV( c ) \
244 outline1("LDA %s", ( c == NULL ? "#$7" : c ) ); \
245 outline0("JSR SIDSTOP" );
246
247#define PROGRAM_DURATION( c, d ) \
248 outline1("LDX #$%2.2x", ( d & 0xff ) ); \
249 if ( ( c & 0x01 ) ) \
250 outline0("JSR SIDSETDURATION0" ); \
251 if ( ( c & 0x02 ) ) \
252 outline0("JSR SIDSETDURATION1" ); \
253 if ( ( c & 0x04 ) ) \
254 outline0("JSR SIDSETDURATION2" ); \
255
256#define WAIT_DURATION( c ) \
257 if ( ( c & 0x01 ) ) \
258 outline0("JSR SIDWAITDURATION0" ); \
259 if ( ( c & 0x02 ) ) \
260 outline0("JSR SIDWAITDURATION1" ); \
261 if ( ( c & 0x04 ) ) \
262 outline0("JSR SIDWAITDURATION2" ); \
263
264void sid_attack_decay_sustain_release( Environment * _environment, char * _voice, char * _attack, char * _decay, char * _sustain, char * _release ) {
265
266 PROGRAM_ATTACK_DECAY_V( _voice, _attack, _decay );
267 PROGRAM_SUSTAIN_RELEASE_V( _voice, _sustain, _release );
268
269}
270
271void sid_wave( Environment * _environment, char * _voice, char * _bits, char * _pulse ) {
272
273 PROGRAM_WAVEFORM_VV( _voice, _bits, NULL );
274
275 if ( _pulse ) {
276 PROGRAM_PULSE_V( _voice, _pulse );
277 }
278
279}
280
281void sid_set_program( Environment * _environment, int _channels, int _program ) {
282
283 deploy( sidvars, src_hw_sid_vars_asm );
284 deploy( sidstartup, src_hw_sid_startup_asm );
285
286 switch (_program) {
289 PROGRAM_ATTACK_DECAY(_channels, 2, 11);
290 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 1);
291 break;
294 PROGRAM_ATTACK_DECAY(_channels, 2, 4);
295 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 1);
296 break;
310 PROGRAM_PULSE(_channels, 0x600);
311 PROGRAM_ATTACK_DECAY(_channels, 2, 11);
312 PROGRAM_SUSTAIN_RELEASE(_channels, 5, 0);
313 break;
314
323 PROGRAM_PULSE(_channels, 1024);
324 PROGRAM_ATTACK_DECAY(_channels, 0, 9);
325 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 0);
326 break;
327
328 default:
338 PROGRAM_PULSE(_channels, 0x800);
339 PROGRAM_ATTACK_DECAY(_channels, 0, 9);
340 PROGRAM_SUSTAIN_RELEASE(_channels, 9, 0);
341 break;
342
360 PROGRAM_WAVEFORM(_channels, WAVEFORM_SAW);
361 PROGRAM_ATTACK_DECAY(_channels, 0, 9);
362 PROGRAM_SUSTAIN_RELEASE(_channels, 2, 1);
363 break;
364
378 PROGRAM_PULSE(_channels, 128);
379 PROGRAM_ATTACK_DECAY(_channels, 10, 8);
380 PROGRAM_SUSTAIN_RELEASE(_channels, 10, 9);
381 break;
382
403 PROGRAM_ATTACK_DECAY(_channels, 3, 8);
404 PROGRAM_SUSTAIN_RELEASE(_channels, 3, 8);
405 break;
406
434 PROGRAM_WAVEFORM(_channels, WAVEFORM_SAW);
435 PROGRAM_ATTACK_DECAY(_channels, 8, 9);
436 PROGRAM_SUSTAIN_RELEASE(_channels, 4, 1);
437 break;
438
462 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
463 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
464 break;
465 }
466
467}
468
469void sid_set_parameter( Environment * _environment, int _channels, int _parameter, int _value ) {
470
471}
472
473void sid_set_frequency( Environment * _environment, int _channels, int _frequency ) {
474
475 deploy( sidvars, src_hw_sid_vars_asm );
476 deploy( sidstartup, src_hw_sid_startup_asm );
477
478 PROGRAM_FREQUENCY( _channels, _frequency );
479
480}
481
482void sid_set_pitch( Environment * _environment, int _channels, int _pitch ) {
483
484 deploy( sidvars, src_hw_sid_vars_asm );
485 deploy( sidstartup, src_hw_sid_startup_asm );
486
487 PROGRAM_PITCH( _channels, _pitch );
488
489}
490
491void sid_set_note( Environment * _environment, int _channels, int _note ) {
492
493 sid_set_pitch( _environment, _channels, SOUND_FREQUENCIES[_note] );
494
495}
496
497void sid_stop( Environment * _environment, int _channels ) {
498
499 deploy( sidvars, src_hw_sid_vars_asm );
500 deploy( sidstartup, src_hw_sid_startup_asm );
501
502 STOP_FREQUENCY( _channels );
503
504}
505
506void sid_start_var( Environment * _environment, char * _channels ) {
507
508 deploy( sidvars, src_hw_sid_vars_asm );
509 deploy( sidstartup, src_hw_sid_startup_asm );
510
511 if ( _channels ) {
512 outline1("LDA %s", _channels );
513 } else {
514 outline0("LDA #$7" );
515 }
516 outline0("JSR SIDSTART");
517
518}
519
520void sid_set_volume_vars( Environment * _environment, char * _channels, char * _volume ) {
521
522 deploy( sidvars, src_hw_sid_vars_asm );
523 deploy( sidstartup, src_hw_sid_startup_asm );
524
525 outline1("LDA %s", _volume );
526 outline0("LSR" );
527 outline0("LSR" );
528 outline0("LSR" );
529 outline0("LSR" );
530 outline0("TAX" );
531 outline0("JSR SIDSTARTVOL");
532
533}
534
535void sid_set_volume_semi_var( Environment * _environment, char * _channel, int _volume ) {
536
537 deploy( sidvars, src_hw_sid_vars_asm );
538 deploy( sidstartup, src_hw_sid_startup_asm );
539
540 outline1("LDX #$%2.2x", _volume );
541 outline0("JSR SIDSTARTVOL");
542
543}
544
545void sid_set_program_semi_var( Environment * _environment, char * _channels, int _program ) {
546
547 deploy( sidvars, src_hw_sid_vars_asm );
548 deploy( sidstartup, src_hw_sid_startup_asm );
549
550 switch (_program) {
553 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 11);
554 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 0, 1);
555 break;
558 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 4);
559 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 0, 1);
560 break;
572 PROGRAM_ATTACK_DECAY_SV(_channels, 4, 2);
573 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
574 break;
575
579 PROGRAM_PULSE_SV(_channels, 1024);
580 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
581 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 3);
582 break;
583
593 PROGRAM_ATTACK_DECAY_SV(_channels, 0, 6);
594 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 5, 0);
595 break;
596
597 default:
609 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
610 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
611 break;
612
620 PROGRAM_PULSE_SV(_channels, 128);
621 PROGRAM_ATTACK_DECAY_SV(_channels, 10, 10);
622 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
623 break;
624
626 PROGRAM_PULSE_SV(_channels, 128);
627 PROGRAM_ATTACK_DECAY_SV(_channels, 1, 2);
628 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 4, 3);
629 break;
630
641 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 10);
642 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 12, 14);
643 break;
644
657 PROGRAM_PULSE_SV(_channels, 128);
658 PROGRAM_ATTACK_DECAY_SV(_channels, 10, 10);
659 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
660 break;
661
681 PROGRAM_ATTACK_DECAY_SV(_channels, 1, 14);
682 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
683 break;
684
713 PROGRAM_ATTACK_DECAY_SV(_channels, 6, 0);
714 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 8, 0);
715 break;
716
740 PROGRAM_ATTACK_DECAY_SV(_channels, 0, 9);
741 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 2, 1);
742 break;
743 }
744
745}
746
747void sid_set_frequency_vars( Environment * _environment, char * _channels, char * _frequency ) {
748
749 deploy( sidvars, src_hw_sid_vars_asm );
750 deploy( sidstartup, src_hw_sid_startup_asm );
751
752 if ( _channels ) {
753 outline1("LDA %s", _channels );
754 } else {
755 outline0("LDA #$7" );
756 }
757 outline1("LDX %s", _frequency );
758 outline1("LDY %s", address_displacement(_environment, _frequency, "1") );
759
760 outline0("JSR SIDFREQ");
761
762}
763
764void sid_set_pitch_vars( Environment * _environment, char * _channels, char * _pitch ) {
765
766 deploy( sidvars, src_hw_sid_vars_asm );
767 deploy( sidstartup, src_hw_sid_startup_asm );
768
769 if ( _channels ) {
770 outline1("LDA %s", _channels );
771 } else {
772 outline0("LDA #$7" );
773 }
774 outline1("LDX %s", _pitch );
775 outline1("LDY %s", address_displacement(_environment, _pitch, "1") );
776
777 outline0("JSR SIDPROGFREQ");
778
779}
780
781void sid_set_note_vars( Environment * _environment, char * _channels, char * _note ) {
782
783 deploy( sidvars, src_hw_sid_vars_asm );
784 deploy( sidstartup, src_hw_sid_startup_asm );
785
786 outline0("LDA #<SIDFREQTABLE");
787 outline0("STA TMPPTR");
788 outline0("LDA #>SIDFREQTABLE");
789 outline0("STA TMPPTR+1");
790 outline1("LDY %s", _note);
791 outline0("TYA");
792 outline0("ASL");
793 outline0("TAY");
794 outline0("LDA (TMPPTR),Y");
795 outline0("TAX");
796 outline0("INY");
797 outline0("LDA (TMPPTR),Y");
798 outline0("TAY");
799
800 if ( _channels ) {
801 outline1("LDA %s", _channels );
802 } else {
803 outline0("LDA #$7" );
804 }
805
806 outline0("JSR SIDPROGFREQ");
807
808}
809
810void sid_stop_vars( Environment * _environment, char * _channels ) {
811
812 deploy( sidvars, src_hw_sid_vars_asm );
813 deploy( sidstartup, src_hw_sid_startup_asm );
814
815 if ( _channels ) {
816 outline1("LDA %s", _channels );
817 } else {
818 outline0("LDA #$7" );
819 }
820 outline0("JSR SIDSTOP");
821
822}
823
824void sid_music( Environment * _environment, char * _music, int _size, int _loop ) {
825
826 deploy( sidvars, src_hw_sid_vars_asm );
827 deploy( sidstartup, src_hw_sid_startup_asm );
829
830 outline0("SEI");
831 outline1("LDA #<%s", _music);
832 outline0("STA SIDTMPPTR_BACKUP");
833 outline1("LDA #>%s", _music);
834 outline0("STA SIDTMPPTR_BACKUP+1");
835 outline1("LDA #$%2.2x", ( _size>>8 ) & 0xff);
836 outline0("STA SIDBLOCKS_BACKUP");
837 outline1("LDA #$%2.2x", _size & 0xff );
838 outline0("STA SIDLASTBLOCK_BACKUP");
839 outline1("LDA #$%2.2x", _loop);
840 outline0("STA SIDMUSICLOOP");
841 outline0("JSR MUSICPLAYERRESET");
842 outline0("CLI");
843
844}
845
846void sid_set_duration( Environment * _environment, int _channels, int _duration ) {
847
848 deploy( sidvars, src_hw_sid_vars_asm );
849 deploy( sidstartup, src_hw_sid_startup_asm );
850
851 PROGRAM_DURATION( _channels, _duration );
852
853}
854
855void sid_wait_duration( Environment * _environment, int _channels ) {
856
857 deploy( sidvars, src_hw_sid_vars_asm );
858 deploy( sidstartup, src_hw_sid_startup_asm );
859
860 WAIT_DURATION( _channels );
861
862}
863
864void sid_set_duration_vars( Environment * _environment, char * _channels, char * _duration ) {
865
866 deploy( sidvars, src_hw_sid_vars_asm );
867 deploy( sidstartup, src_hw_sid_startup_asm );
868
869 if ( _channels ) {
870 outline1("LDA %s", _channels );
871 } else {
872 outline0("LDA #$f" );
873 }
874 if ( _duration ) {
875 outline1("LDX %s", _duration );
876 } else {
877 outline0("LDX #50" );
878 }
879
880 outline0("JSR SIDSETDURATION");
881
882}
883
884void sid_wait_duration_vars( Environment * _environment, char * _channels ) {
885
886 deploy( sidvars, src_hw_sid_vars_asm );
887 deploy( sidstartup, src_hw_sid_startup_asm );
888
889 if ( _channels ) {
890 outline1("LDA %s", _channels );
891 } else {
892 outline0("LDA #$f" );
893 }
894
895 outline0("JSR SIDWAITDURATION");
896
897}
898
899void sid_player_init( Environment * _environment, int _init_address ) {
900
901 deploy( sidplayer, src_hw_sid_player_asm );
902
903 outline0( "SEI" );
904 outline1( "JSR $%4.4x", (unsigned int)(_init_address&0xffff) );
905 outline0( "CLI" );
906
907}
908
909void sid_player_play( Environment * _environment, int _play_address ) {
910
911 deploy( sidplayer, src_hw_sid_player_asm );
912
913 outline0( "SEI" );
914 outline1( "LDA #$%2.2x", (unsigned char)(_play_address&0xff) );
915 outline0( "STA SIDPLAYERADDR+1" );
916 outline1( "LDA #$%2.2x", (unsigned char)((_play_address>>8)&0xff) );
917 outline0( "STA SIDPLAYERADDR+2" );
918 outline0( "CLI" );
919
920}
921
922#endif
void cpu_call(Environment *_environment, char *_label)
Definition 6309.c:3755
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
unsigned char src_hw_sid_vars_asm[]
unsigned char src_hw_sid_music_asm[]
unsigned char src_hw_sid_startup_asm[]
unsigned char src_hw_sid_player_asm[]
#define PROGRAM_ATTACK_DECAY_V(c, a, d)
Definition sid.c:197
void sid_set_pitch(Environment *_environment, int _channels, int _pitch)
Definition sid.c:482
#define PROGRAM_SUSTAIN_RELEASE_V(c, s, r)
Definition sid.c:219
void sid_wave(Environment *_environment, char *_voice, char *_bits, char *_pulse)
Definition sid.c:271
#define PROGRAM_DURATION(c, d)
Definition sid.c:247
#define WAVEFORM_NOISE
Definition sid.c:95
void sid_set_frequency(Environment *_environment, int _channels, int _frequency)
Definition sid.c:473
#define WAVEFORM_SAW
Definition sid.c:93
#define PROGRAM_FREQUENCY(c, f)
Definition sid.c:97
#define PROGRAM_WAVEFORM_VV(c, w, p)
Definition sid.c:177
#define WAVEFORM_RECTANGLE
Definition sid.c:94
void sid_set_note(Environment *_environment, int _channels, int _note)
Definition sid.c:491
void sid_set_volume(Environment *_environment, int _channels, int _volume)
Definition sid.c:82
#define WAIT_DURATION(c)
Definition sid.c:256
void sid_player_play(Environment *_environment, int _play_address)
Definition sid.c:909
#define WAVEFORM_TRIANGLE
Definition sid.c:92
#define PROGRAM_PULSE_V(c, p)
Definition sid.c:151
void sid_wait_duration(Environment *_environment, int _channels)
Definition sid.c:855
#define STOP_FREQUENCY(c)
Definition sid.c:231
void sid_set_program(Environment *_environment, int _channels, int _program)
Definition sid.c:281
#define PROGRAM_ATTACK_DECAY(c, a, d)
Definition sid.c:187
#define PROGRAM_WAVEFORM(c, w)
Definition sid.c:163
void sid_set_pitch_vars(Environment *_environment, char *_channels, char *_pitch)
Definition sid.c:764
#define PROGRAM_SUSTAIN_RELEASE_SV(c, s, r)
Definition sid.c:225
void sid_start_var(Environment *_environment, char *_channels)
Definition sid.c:506
void sid_set_program_semi_var(Environment *_environment, char *_channels, int _program)
Definition sid.c:545
void sid_initialization(Environment *_environment)
Definition sid.c:50
void sid_set_volume_semi_var(Environment *_environment, char *_channel, int _volume)
Definition sid.c:535
void sid_start(Environment *_environment, int _channels)
Definition sid.c:65
#define PROGRAM_SUSTAIN_RELEASE(c, s, r)
Definition sid.c:209
void sid_wait_duration_vars(Environment *_environment, char *_channels)
Definition sid.c:884
#define PROGRAM_PULSE_SV(c, p)
Definition sid.c:157
#define PROGRAM_PITCH(c, f)
Definition sid.c:119
void sid_set_frequency_vars(Environment *_environment, char *_channels, char *_frequency)
Definition sid.c:747
void sid_stop(Environment *_environment, int _channels)
Definition sid.c:497
void sid_set_duration_vars(Environment *_environment, char *_channels, char *_duration)
Definition sid.c:864
void sid_stop_vars(Environment *_environment, char *_channels)
Definition sid.c:810
#define PROGRAM_WAVEFORM_SV(c, w)
Definition sid.c:182
void sid_set_volume_vars(Environment *_environment, char *_channels, char *_volume)
Definition sid.c:520
#define PROGRAM_PULSE(c, p)
Definition sid.c:141
void sid_player_init(Environment *_environment, int _init_address)
Definition sid.c:899
void sid_music(Environment *_environment, char *_music, int _size, int _loop)
Definition sid.c:824
void sid_set_parameter(Environment *_environment, int _channels, int _parameter, int _value)
Definition sid.c:469
void sid_attack_decay_sustain_release(Environment *_environment, char *_voice, char *_attack, char *_decay, char *_sustain, char *_release)
Definition sid.c:264
void sid_finalization(Environment *_environment)
Definition sid.c:56
void sid_set_duration(Environment *_environment, int _channels, int _duration)
Definition sid.c:846
#define PROGRAM_ATTACK_DECAY_SV(c, a, d)
Definition sid.c:203
void sid_set_note_vars(Environment *_environment, char *_channels, char *_note)
Definition sid.c:781
int sidstartup
Definition ugbc.h:1827
Deployed deployed
Definition ugbc.h:2921
#define IMF_INSTRUMENT_LEAD_8_BASS_LEAD
Definition ugbc.h:4661
#define IMF_INSTRUMENT_MARIMBA
Definition ugbc.h:4586
#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
#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 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 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
#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
struct _Environment Environment
Structure of compilation environment.
#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 IMF_INSTRUMENT_DULCIMER
Definition ugbc.h:4589
#define IMF_INSTRUMENT_KOTO
Definition ugbc.h:4681
#define outhead0(s)
Definition ugbc.h:4246
#define IMF_INSTRUMENT_TUBA
Definition ugbc.h:4632
#define IMF_INSTRUMENT_GUITAR_HARMONICS
Definition ugbc.h:4605
#define IMF_INSTRUMENT_CLAVI
Definition ugbc.h:4581
#define IMF_INSTRUMENT_BANJO
Definition ugbc.h:4679
#define IMF_INSTRUMENT_SYNTHBRASS_2
Definition ugbc.h:4637
#define IMF_INSTRUMENT_LEAD_4_CHIFF
Definition ugbc.h:4657
#define IMF_INSTRUMENT_VOICE_OOHS
Definition ugbc.h:4627
#define IMF_INSTRUMENT_TANGO_ACCORDION
Definition ugbc.h:4597
#define IMF_INSTRUMENT_FX_7_ECHOES
Definition ugbc.h:4676
#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 IMF_INSTRUMENT_LEAD_1_SQUARE
Definition ugbc.h:4654
#define IMF_INSTRUMENT_STRING_ENSEMBLE_1
Definition ugbc.h:4622
#define outline0(s)
Definition ugbc.h:4252
#define IMF_INSTRUMENT_DISTORTION_GUITAR
Definition ugbc.h:4604
#define IMF_INSTRUMENT_PAD_2_WARM
Definition ugbc.h:4663
#define IMF_INSTRUMENT_ACCORDION
Definition ugbc.h:4595
#define IMF_INSTRUMENT_SLAP_BASS_2
Definition ugbc.h:4611
#define IMF_INSTRUMENT_LEAD_5_CHARANG
Definition ugbc.h:4658
#define IMF_INSTRUMENT_OBOE
Definition ugbc.h:4642
#define IMF_INSTRUMENT_STEEL_DRUMS
Definition ugbc.h:4688
#define IMF_INSTRUMENT_BASSOON
Definition ugbc.h:4644
#define IMF_INSTRUMENT_TIMPANI
Definition ugbc.h:4621
#define IMF_INSTRUMENT_ROCK_ORGAN
Definition ugbc.h:4592
#define IMF_INSTRUMENT_SHAMISEN
Definition ugbc.h:4680
#define 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 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 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 IMF_INSTRUMENT_VIOLA
Definition ugbc.h:4615
#define deploy(s, e)
Definition ugbc.h:4288
#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