ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
sidz.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(__c128z__)
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 sidz_initialization( Environment * _environment ) {
51
52 cpu_call( _environment, "SIDZSTARTUP" );
53
54}
55
56void sidz_finalization( Environment * _environment ) {
57
58 if ( !_environment->deployed.sidstartup ) {
59 outhead0( "SIDZSTARTUP:" );
60 outline0( "RET" );
61 }
62
63}
64
65void sidz_start( Environment * _environment, int _channels ) {
66
67 deploy( sidvars, src_hw_sidz_vars_asm );
68 deploy( sidstartup, src_hw_sidz_startup_asm );
69
70 if ( _channels & 0x01 ) {
71 outline0("CALL SIDZSTART0");
72 }
73 if ( _channels & 0x02 ) {
74 outline0("CALL SIDZSTART1");
75 }
76 if ( _channels & 0x04 ) {
77 outline0("CALL SIDZSTART2");
78 }
79
80}
81
82void sidz_set_volume( Environment * _environment, int _channels, int _volume ) {
83
84 deploy( sidvars, src_hw_sidz_vars_asm );
85 deploy( sidstartup, src_hw_sidz_startup_asm );
86
87 outline1("LD C, #%2.2x", ( _volume & 0x0f ) );
88 outline0("CALL SIDZSTARTVOL");
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("LD C, $%2.2x", ( ( ( f * 0xffff ) / 4000 ) & 0xff ) ); \
99 outline1("LD B, $%2.2x", ( ( ( ( f * 0xffff ) / 4000 ) >> 8 ) & 0xff ) ); \
100 if ( ( c & 0x01 ) ) \
101 outline0("CALL SIDZPROGFREQ0" ); \
102 if ( ( c & 0x02 ) ) \
103 outline0("CALL SIDZPROGFREQ1" ); \
104 if ( ( c & 0x04 ) ) \
105 outline0("CALL SIDZPROGFREQ2" );
106
107#define PROGRAM_FREQUENCY_V( c, f ) \
108 outline1("LD A, (%s)", f ); \
109 outline0("LD C, A" ); \
110 outline1("LD A, (%s)", address_displacement(_environment, f, "1") ); \
111 outline0("LD B, A" ); \
112 if ( c == NULL ) { \
113 outline0("LD A, $7"); \
114 } else { \
115 outline1("LD A, (%s)", c ); \
116 } \
117 outline0("CALL SIDZFREQ" );
118
119#define PROGRAM_FREQUENCY_SV( c, f ) \
120 outline1("LD C, $%2.2x", ( ( ( f * 0xffff ) / 4000 ) & 0xff ) ); \
121 outline1("LD B, $%2.2x", ( ( ( ( f * 0xffff ) / 4000 ) >> 8 ) & 0xff ) ); \
122 outline1("LD A, (%s)", ( c == NULL ? "$7" : c ) ); \
123 outline0("CALL SIDZFREQ2" );
124
125#define PROGRAM_PITCH( c, f ) \
126 outline1("LD BC, $%4.4x", ( f & 0xffff ) ); \
127 if ( ( c & 0x01 ) ) \
128 outline0("CALL SIDZPROGFREQ0" ); \
129 if ( ( c & 0x02 ) ) \
130 outline0("CALL SIDZPROGFREQ1" ); \
131 if ( ( c & 0x04 ) ) \
132 outline0("CALL SIDZPROGFREQ2" );
133
134#define PROGRAM_PITCH_V( c, f ) \
135 outline1("LD HL, (%s)", f ); \
136 outline0("LD BC, HL" ); \
137 if ( c == NULL ) { \
138 outline0("LD A, $7"); \
139 } else { \
140 outline1("LD A, (%s)", c ); \
141 } \
142 outline0("CALL SIDZPROGFREQ" );
143
144#define PROGRAM_PITCH_SV( c, f ) \
145 outline1("LD BC, $%4.4x", ( f & 0xffff ) ); \
146 if ( c == NULL ) { \
147 outline0("LD A, $7"); \
148 } else { \
149 outline1("LD A, (%s)", c ); \
150 } \
151 outline0("CALL SIDZPROGFREQ" );
152
153#define PROGRAM_PULSE( c, p ) \
154 outline1("LD C, $%2.2x", ( p & 0xff ) ); \
155 outline1("LD B, $%2.2x", ( ( p >> 8 ) & 0xff ) ); \
156 if ( ( c & 0x01 ) ) \
157 outline0("CALL SIDZPROGPULSE0" ); \
158 if ( ( c & 0x02 ) ) \
159 outline0("CALL SIDZPROGPULSE1" ); \
160 if ( ( c & 0x04 ) ) \
161 outline0("CALL SIDZPROGPULSE2" );
162
163#define PROGRAM_PULSE_V( c, p ) \
164 outline1("LD A, (%s)", address_displacement(_environment, p, "1") ); \
165 outline0("LD B, A" ); \
166 outline1("LD A, (%s)", p ); \
167 outline0("LD C, A" ); \
168 if ( c == NULL ) { \
169 outline0("LD A, $7"); \
170 } else { \
171 outline1("LD A, (%s)", c ); \
172 } \
173 outline0("CALL SIDZPROGPULSE" );
174
175#define PROGRAM_PULSE_SV( c, p ) \
176 outline1("LD C, $%2.2x", ( p & 0xff ) ); \
177 outline1("LD B, $%2.2x", ( ( p >> 8 ) & 0xff ) ); \
178 if ( c == NULL ) { \
179 outline0("LD A, $7"); \
180 } else { \
181 outline1("LD A, (%s)", c ); \
182 } \
183 outline0("CALL SIDZPROGPULSE" );
184
185#define PROGRAM_WAVEFORM( c, w ) \
186 outline1("LD C, $%2.2x", w ); \
187 if ( ( c & 0x01 ) ) \
188 outline0("CALL SIDZPROGCTR0" ); \
189 if ( ( c & 0x02 ) ) \
190 outline0("CALL SIDZPROGCTR1" ); \
191 if ( ( c & 0x04 ) ) \
192 outline0("CALL SIDZPROGCTR2" );
193
194#define PROGRAM_WAVEFORM_V( c, w, p ) \
195 outline1("LD C, $%2.2x", w ); \
196 if ( c == NULL ) { \
197 outline0("LD A, $7"); \
198 } else { \
199 outline1("LD A, (%s)", c ); \
200 } \
201 outline0("CALL SIDZPROGCTR" );
202
203#define PROGRAM_WAVEFORM_VV( c, w, p ) \
204 outline1("LD A, (%s)", w ); \
205 outline0("LD C, A" ); \
206 if ( c == NULL ) { \
207 outline0("LD A, $7"); \
208 } else { \
209 outline1("LD A, (%s)", c ); \
210 } \
211 outline0("CALL SIDZPROGCTR" );
212
213#define PROGRAM_WAVEFORM_SV( c, w ) \
214 outline1("LD C, $%2.2x", w ); \
215 if ( c == NULL ) { \
216 outline0("LD A, $7"); \
217 } else { \
218 outline1("LD A, (%s)", c ); \
219 } \
220 outline0("CALL SIDZPROGCTR" );
221
222#define PROGRAM_ATTACK_DECAY( c, a, d ) \
223 outline1("LD C, $%2.2x", ( a & 0x0f ) ); \
224 outline1("LD B, $%2.2x", ( d & 0x0f ) ); \
225 if ( ( c & 0x01 ) ) \
226 outline0("CALL SIDZPROGAD0" ); \
227 if ( ( c & 0x02 ) ) \
228 outline0("CALL SIDZPROGAD1" ); \
229 if ( ( c & 0x04 ) ) \
230 outline0("CALL SIDZPROGAD2" );
231
232#define PROGRAM_ATTACK_DECAY_V( c, a, d ) \
233 outline1("LD A, (%s)", d ); \
234 outline0("LD B, A" ); \
235 outline1("LD A, (%s)", a ); \
236 outline0("LD C, A" ); \
237 if ( c == NULL ) { \
238 outline0("LD A, $7"); \
239 } else { \
240 outline1("LD A, (%s)", c ); \
241 } \
242 outline0("CALL SIDZPROGAD" );
243
244#define PROGRAM_ATTACK_DECAY_SV( c, a, d ) \
245 outline1("LD C, $%2.2x", ( a & 0x0f ) ); \
246 outline1("LD B, $%2.2x", ( d & 0x0f ) ); \
247 if ( c == NULL ) { \
248 outline0("LD A, $7"); \
249 } else { \
250 outline1("LD A, (%s)", c ); \
251 } \
252 outline0("CALL SIDZPROGAD" );
253
254#define PROGRAM_SUSTAIN_RELEASE( c, s, r ) \
255 outline1("LD C, $%2.2x", ( s & 0x0f ) ); \
256 outline1("LD B, $%2.2x", ( r & 0x0f ) ); \
257 if ( ( c & 0x01 ) ) \
258 outline0("CALL SIDZPROGSR0" ); \
259 if ( ( c & 0x02 ) ) \
260 outline0("CALL SIDZPROGSR1" ); \
261 if ( ( c & 0x04 ) ) \
262 outline0("CALL SIDZPROGSR2" );
263
264#define PROGRAM_SUSTAIN_RELEASE_V( c, s, r ) \
265 outline1("LD A, (%s)", r ); \
266 outline0("LD B, A" ); \
267 outline1("LD A, (%s)", s ); \
268 outline0("LD C, A" ); \
269 if ( c == NULL ) { \
270 outline0("LD A, $7"); \
271 } else { \
272 outline1("LD A, (%s)", c ); \
273 } \
274 outline0("CALL SIDZPROGSR" );
275
276#define PROGRAM_SUSTAIN_RELEASE_SV( c, s, r ) \
277 outline1("LD C, $%2.2x", ( s & 0x0f ) ); \
278 outline1("LD B, $%2.2x", ( r & 0x0f ) ); \
279 if ( c == NULL ) { \
280 outline0("LD A, $7"); \
281 } else { \
282 outline1("LD A, (%s)", c ); \
283 } \
284 outline0("CALL SIDZPROGSR" );
285
286#define STOP_FREQUENCY( c ) \
287 if ( ( c & 0x01 ) ) \
288 outline0("CALL SIDZSTOP0" ); \
289 if ( ( c & 0x02 ) ) \
290 outline0("CALL SIDZSTOP1" ); \
291 if ( ( c & 0x04 ) ) \
292 outline0("CALL SIDZSTOP2" );
293
294#define STOP_FREQUENCY_V( c ) \
295 if ( c == NULL ) { \
296 outline0("LD A, $7"); \
297 } else { \
298 outline1("LD A, (%s)", c ); \
299 } \
300 outline0("CALL SIDZSTOP" );
301
302#define STOP_FREQUENCY_SV( c ) \
303 if ( c == NULL ) { \
304 outline0("LD A, $7"); \
305 } else { \
306 outline1("LD A, (%s)", c ); \
307 } \
308 outline0("CALL SIDZSTOP" );
309
310#define PROGRAM_DURATION( c, d ) \
311 outline1("LD C, $%2.2x", ( d & 0xff ) ); \
312 if ( ( c & 0x01 ) ) \
313 outline0("CALL SIDZSETDURATION0" ); \
314 if ( ( c & 0x02 ) ) \
315 outline0("CALL SIDZSETDURATION1" ); \
316 if ( ( c & 0x04 ) ) \
317 outline0("CALL SIDZSETDURATION2" ); \
318
319#define WAIT_DURATION( c ) \
320 if ( ( c & 0x01 ) ) \
321 outline0("CALL SIDZWAITDURATION0" ); \
322 if ( ( c & 0x02 ) ) \
323 outline0("CALL SIDZWAITDURATION1" ); \
324 if ( ( c & 0x04 ) ) \
325 outline0("CALL SIDZWAITDURATION2" ); \
326
327void sidz_attack_decay_sustain_release( Environment * _environment, char * _voice, char * _attack, char * _decay, char * _sustain, char * _release ) {
328
329 PROGRAM_ATTACK_DECAY_V( _voice, _attack, _decay );
330 PROGRAM_SUSTAIN_RELEASE_V( _voice, _sustain, _release );
331
332}
333
334void sidz_wave( Environment * _environment, char * _voice, char * _bits, char * _pulse ) {
335
336 PROGRAM_WAVEFORM_VV( _voice, _bits, NULL );
337
338 if ( _pulse ) {
339 PROGRAM_PULSE_V( _voice, _pulse );
340 }
341
342}
343
344void sidz_set_program( Environment * _environment, int _channels, int _program ) {
345
346 deploy( sidvars, src_hw_sidz_vars_asm );
347 deploy( sidstartup, src_hw_sidz_startup_asm );
348
349 switch (_program) {
352 PROGRAM_ATTACK_DECAY(_channels, 2, 11);
353 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 1);
354 break;
357 PROGRAM_ATTACK_DECAY(_channels, 2, 4);
358 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 1);
359 break;
373 PROGRAM_PULSE(_channels, 0x600);
374 PROGRAM_ATTACK_DECAY(_channels, 2, 11);
375 PROGRAM_SUSTAIN_RELEASE(_channels, 5, 0);
376 break;
377
386 PROGRAM_PULSE(_channels, 1024);
387 PROGRAM_ATTACK_DECAY(_channels, 0, 9);
388 PROGRAM_SUSTAIN_RELEASE(_channels, 0, 0);
389 break;
390
391 default:
401 PROGRAM_PULSE(_channels, 0x800);
402 PROGRAM_ATTACK_DECAY(_channels, 0, 9);
403 PROGRAM_SUSTAIN_RELEASE(_channels, 9, 0);
404 break;
405
423 PROGRAM_WAVEFORM(_channels, WAVEFORM_SAW);
424 PROGRAM_ATTACK_DECAY(_channels, 0, 9);
425 PROGRAM_SUSTAIN_RELEASE(_channels, 2, 1);
426 break;
427
441 PROGRAM_PULSE(_channels, 128);
442 PROGRAM_ATTACK_DECAY(_channels, 10, 8);
443 PROGRAM_SUSTAIN_RELEASE(_channels, 10, 9);
444 break;
445
466 PROGRAM_ATTACK_DECAY(_channels, 3, 8);
467 PROGRAM_SUSTAIN_RELEASE(_channels, 3, 8);
468 break;
469
497 PROGRAM_WAVEFORM(_channels, WAVEFORM_SAW);
498 PROGRAM_ATTACK_DECAY(_channels, 8, 9);
499 PROGRAM_SUSTAIN_RELEASE(_channels, 4, 1);
500 break;
501
525 PROGRAM_ATTACK_DECAY(_channels, 3, 3);
526 PROGRAM_SUSTAIN_RELEASE(_channels, 14, 14);
527 break;
528 }
529
530}
531
532void sidz_set_parameter( Environment * _environment, int _channels, int _parameter, int _value ) {
533
534}
535
536void sidz_set_frequency( Environment * _environment, int _channels, int _frequency ) {
537
538 deploy( sidvars, src_hw_sidz_vars_asm );
539 deploy( sidstartup, src_hw_sidz_startup_asm );
540
541 PROGRAM_FREQUENCY( _channels, _frequency );
542
543}
544
545void sidz_set_pitch( Environment * _environment, int _channels, int _pitch ) {
546
547 deploy( sidvars, src_hw_sidz_vars_asm );
548 deploy( sidstartup, src_hw_sidz_startup_asm );
549
550 PROGRAM_PITCH( _channels, _pitch );
551
552}
553
554void sidz_set_note( Environment * _environment, int _channels, int _note ) {
555
556 sidz_set_pitch( _environment, _channels, SOUND_FREQUENCIES[_note] );
557
558}
559
560void sidz_stop( Environment * _environment, int _channels ) {
561
562 deploy( sidvars, src_hw_sidz_vars_asm );
563 deploy( sidstartup, src_hw_sidz_startup_asm );
564
565 STOP_FREQUENCY( _channels );
566
567}
568
569void sidz_start_var( Environment * _environment, char * _channels ) {
570
571 deploy( sidvars, src_hw_sidz_vars_asm );
572 deploy( sidstartup, src_hw_sidz_startup_asm );
573
574 if ( _channels ) {
575 outline1("LD A, (%s)", _channels );
576 } else {
577 outline0("LD A, $7" );
578 }
579 outline0("CALL SIDZSTART");
580
581}
582
583void sidz_set_volume_vars( Environment * _environment, char * _channels, char * _volume ) {
584
585 deploy( sidvars, src_hw_sidz_vars_asm );
586 deploy( sidstartup, src_hw_sidz_startup_asm );
587
588 outline1("LD A, (%s)", _volume );
589 outline0("SRL A" );
590 outline0("SRL A" );
591 outline0("SRL A" );
592 outline0("SRL A" );
593 outline0("LD B, A" );
594 outline0("CALL SIDZSTARTVOL");
595
596}
597
598void sidz_set_volume_semi_var( Environment * _environment, char * _channel, int _volume ) {
599
600 deploy( sidvars, src_hw_sidz_vars_asm );
601 deploy( sidstartup, src_hw_sidz_startup_asm );
602
603 outline1("LD C, $%2.2x", _volume );
604 outline0("CALL SIDZSTARTVOL");
605
606}
607
608void sidz_set_program_semi_var( Environment * _environment, char * _channels, int _program ) {
609
610 deploy( sidvars, src_hw_sidz_vars_asm );
611 deploy( sidstartup, src_hw_sidz_startup_asm );
612
613 switch (_program) {
616 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 11);
617 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 0, 1);
618 break;
621 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 4);
622 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 0, 1);
623 break;
635 PROGRAM_ATTACK_DECAY_SV(_channels, 4, 2);
636 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
637 break;
638
642 PROGRAM_PULSE_SV(_channels, 1024);
643 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
644 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 3);
645 break;
646
656 PROGRAM_ATTACK_DECAY_SV(_channels, 0, 6);
657 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 5, 0);
658 break;
659
660 default:
672 PROGRAM_ATTACK_DECAY_SV(_channels, 3, 3);
673 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
674 break;
675
683 PROGRAM_PULSE_SV(_channels, 128);
684 PROGRAM_ATTACK_DECAY_SV(_channels, 10, 10);
685 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
686 break;
687
689 PROGRAM_PULSE_SV(_channels, 128);
690 PROGRAM_ATTACK_DECAY_SV(_channels, 1, 2);
691 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 4, 3);
692 break;
693
704 PROGRAM_ATTACK_DECAY_SV(_channels, 2, 10);
705 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 12, 14);
706 break;
707
720 PROGRAM_PULSE_SV(_channels, 128);
721 PROGRAM_ATTACK_DECAY_SV(_channels, 10, 10);
722 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 10);
723 break;
724
744 PROGRAM_ATTACK_DECAY_SV(_channels, 1, 14);
745 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 14, 14);
746 break;
747
776 PROGRAM_ATTACK_DECAY_SV(_channels, 6, 0);
777 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 8, 0);
778 break;
779
803 PROGRAM_ATTACK_DECAY_SV(_channels, 0, 9);
804 PROGRAM_SUSTAIN_RELEASE_SV(_channels, 2, 1);
805 break;
806 }
807
808}
809
810void sidz_set_frequency_vars( Environment * _environment, char * _channels, char * _frequency ) {
811
812 deploy( sidvars, src_hw_sidz_vars_asm );
813 deploy( sidstartup, src_hw_sidz_startup_asm );
814
815 outline1("LD A, (%s)", address_displacement(_environment, _frequency, "1") ); \
816 outline0("LD B, A" ); \
817 outline1("LD A, (%s)", _frequency );
818 outline0("LD C, A" ); \
819 if ( _channels ) {
820 outline1("LD A, (%s)", _channels );
821 } else {
822 outline0("LD A, $7" );
823 }
824
825 outline0("CALL SIDZFREQ");
826
827}
828
829void sidz_set_pitch_vars( Environment * _environment, char * _channels, char * _pitch ) {
830
831 deploy( sidvars, src_hw_sidz_vars_asm );
832 deploy( sidstartup, src_hw_sidz_startup_asm );
833
834 outline1("LD HL, (%s)", _pitch ); \
835 outline0("LD BC, HL" ); \
836 if ( _channels ) {
837 outline1("LD A, (%s)", _channels );
838 } else {
839 outline0("LD A, $7" );
840 }
841
842 outline0("CALL SIDZPROGFREQ");
843
844}
845
846void sidz_set_note_vars( Environment * _environment, char * _channels, char * _note ) {
847
848 deploy( sidvars, src_hw_sidz_vars_asm );
849 deploy( sidstartup, src_hw_sidz_startup_asm );
850
851 outline1("LD A, (%s)", _note ); \
852 outline0("LD B, A" ); \
853 outline0("LD HL, SIDZFREQTABLE");
854 outline0("LD A, C");
855 outline0("SLA A");
856 outline0("LD D, A");
857 outline0("LD E, 0");
858 outline0("ADD HL, DE");
859 outline0("LD A, (HL)");
860 outline0("LD C, A");
861 outline0("INC HL");
862 outline0("LD A, (HL)");
863 outline0("LD B, A");
864
865 if ( _channels ) {
866 outline1("LD A, (%s)", _channels );
867 } else {
868 outline0("LD A, $7" );
869 }
870
871 outline0("CALL SIDZPROGFREQ");
872
873}
874
875void sidz_stop_vars( Environment * _environment, char * _channels ) {
876
877 deploy( sidvars, src_hw_sidz_vars_asm );
878 deploy( sidstartup, src_hw_sidz_startup_asm );
879
880 if ( _channels ) {
881 outline1("LD A, (%s)", _channels );
882 } else {
883 outline0("LD A, $7" );
884 }
885 outline0("CALL SIDZSTOP");
886
887}
888
889void sidz_music( Environment * _environment, char * _music, int _size, int _loop ) {
890
891 deploy( sidvars, src_hw_sidz_vars_asm );
892 deploy( sidstartup, src_hw_sidz_startup_asm );
893 deploy( music, src_hw_sidz_music_asm );
894
895 outline0("DI");
896 outline1("LD HL, %s", _music);
897 outline0("LD (SIDZTMPPTR_BACKUP), HL");
898 outline1("LD A, $%2.2x", ( _size>>8 ) & 0xff);
899 outline0("LD (SIDZBLOCKS_BACKUP), A");
900 outline1("LD A, $%2.2x", _size & 0xff );
901 outline0("LA (SIDZLASTBLOCK_BACKUP), A");
902 outline1("LD A, $%2.2x", _loop);
903 outline0("LD (SIDZMUSICLOOP), A");
904 outline0("CALL MUSICPLAYERRESET");
905 outline0("EI");
906
907}
908
909void sidz_set_duration( Environment * _environment, int _channels, int _duration ) {
910
911 deploy( sidvars, src_hw_sidz_vars_asm );
912 deploy( sidstartup, src_hw_sidz_startup_asm );
913
914 PROGRAM_DURATION( _channels, _duration );
915
916}
917
918void sidz_wait_duration( Environment * _environment, int _channels ) {
919
920 deploy( sidvars, src_hw_sidz_vars_asm );
921 deploy( sidstartup, src_hw_sidz_startup_asm );
922
923 WAIT_DURATION( _channels );
924
925}
926
927void sidz_set_duration_vars( Environment * _environment, char * _channels, char * _duration ) {
928
929 deploy( sidvars, src_hw_sidz_vars_asm );
930 deploy( sidstartup, src_hw_sidz_startup_asm );
931
932 if ( _duration ) {
933 outline1("LD A, (%s)", _duration );
934 outline0("LD C, A" );
935 } else {
936 outline0("LD C, 50" );
937 }
938 if ( _channels ) {
939 outline1("LD A, (%s)", _channels );
940 } else {
941 outline0("LD A, $f" );
942 }
943
944 outline0("CALL SIDZSETDURATION");
945
946}
947
948void sidz_wait_duration_vars( Environment * _environment, char * _channels ) {
949
950 deploy( sidvars, src_hw_sidz_vars_asm );
951 deploy( sidstartup, src_hw_sidz_startup_asm );
952
953 if ( _channels ) {
954 outline1("LD A, (%s)", _channels );
955 } else {
956 outline0("LD A, $f" );
957 }
958
959 outline0("CALL SIDZWAITDURATION");
960
961}
962
963void sidz_player_init( Environment * _environment, int _init_address ) {
964
965 // deploy( sidplayer, src_hw_sidz_player_asm );
966
967 // outline0( "DI" );
968 // outline1( "CALL $%4.4x", (unsigned int)(_init_address&0xffff) );
969 // outline0( "EI" );
970
971}
972
973void sidz_player_play( Environment * _environment, int _play_address ) {
974
975 // deploy( sidplayer, src_hw_sidz_player_asm );
976
977 // outline0( "DI" );
978 // outline1( "LD HL, $%4.4x", (unsigned short)(_play_address&0xffff) );
979 // outline0( "LD (SIDZPLAYERADDR), HL" );
980 // outline0( "DI" );
981
982}
983
984#endif
void cpu_call(Environment *_environment, char *_label)
Definition 6309.c:3755
char * address_displacement(Environment *_environment, char *_address, char *_displacement)
#define WAVEFORM_NOISE
Definition sid.c:95
#define WAVEFORM_SAW
Definition sid.c:93
#define WAVEFORM_RECTANGLE
Definition sid.c:94
#define WAVEFORM_TRIANGLE
Definition sid.c:92
#define PROGRAM_ATTACK_DECAY_V(c, a, d)
Definition sidz.c:232
void sidz_set_volume_semi_var(Environment *_environment, char *_channel, int _volume)
Definition sidz.c:598
void sidz_wait_duration_vars(Environment *_environment, char *_channels)
Definition sidz.c:948
#define PROGRAM_SUSTAIN_RELEASE_V(c, s, r)
Definition sidz.c:264
#define PROGRAM_DURATION(c, d)
Definition sidz.c:310
void sidz_set_pitch(Environment *_environment, int _channels, int _pitch)
Definition sidz.c:545
#define PROGRAM_FREQUENCY(c, f)
Definition sidz.c:97
#define PROGRAM_WAVEFORM_VV(c, w, p)
Definition sidz.c:203
void sidz_set_program(Environment *_environment, int _channels, int _program)
Definition sidz.c:344
void sidz_set_note_vars(Environment *_environment, char *_channels, char *_note)
Definition sidz.c:846
void sidz_set_frequency(Environment *_environment, int _channels, int _frequency)
Definition sidz.c:536
void sidz_start(Environment *_environment, int _channels)
Definition sidz.c:65
void sidz_set_parameter(Environment *_environment, int _channels, int _parameter, int _value)
Definition sidz.c:532
#define WAIT_DURATION(c)
Definition sidz.c:319
#define PROGRAM_PULSE_V(c, p)
Definition sidz.c:163
void sidz_stop(Environment *_environment, int _channels)
Definition sidz.c:560
void sidz_player_init(Environment *_environment, int _init_address)
Definition sidz.c:963
#define STOP_FREQUENCY(c)
Definition sidz.c:286
#define PROGRAM_ATTACK_DECAY(c, a, d)
Definition sidz.c:222
void sidz_set_note(Environment *_environment, int _channels, int _note)
Definition sidz.c:554
#define PROGRAM_WAVEFORM(c, w)
Definition sidz.c:185
void sidz_music(Environment *_environment, char *_music, int _size, int _loop)
Definition sidz.c:889
#define PROGRAM_SUSTAIN_RELEASE_SV(c, s, r)
Definition sidz.c:276
void sidz_set_pitch_vars(Environment *_environment, char *_channels, char *_pitch)
Definition sidz.c:829
#define PROGRAM_SUSTAIN_RELEASE(c, s, r)
Definition sidz.c:254
void sidz_stop_vars(Environment *_environment, char *_channels)
Definition sidz.c:875
void sidz_initialization(Environment *_environment)
Definition sidz.c:50
void sidz_set_volume(Environment *_environment, int _channels, int _volume)
Definition sidz.c:82
void sidz_set_duration(Environment *_environment, int _channels, int _duration)
Definition sidz.c:909
void sidz_wait_duration(Environment *_environment, int _channels)
Definition sidz.c:918
#define PROGRAM_PULSE_SV(c, p)
Definition sidz.c:175
void sidz_set_duration_vars(Environment *_environment, char *_channels, char *_duration)
Definition sidz.c:927
#define PROGRAM_PITCH(c, f)
Definition sidz.c:125
#define PROGRAM_WAVEFORM_SV(c, w)
Definition sidz.c:213
void sidz_finalization(Environment *_environment)
Definition sidz.c:56
#define PROGRAM_PULSE(c, p)
Definition sidz.c:153
void sidz_set_frequency_vars(Environment *_environment, char *_channels, char *_frequency)
Definition sidz.c:810
void sidz_set_volume_vars(Environment *_environment, char *_channels, char *_volume)
Definition sidz.c:583
void sidz_start_var(Environment *_environment, char *_channels)
Definition sidz.c:569
void sidz_set_program_semi_var(Environment *_environment, char *_channels, int _program)
Definition sidz.c:608
#define PROGRAM_ATTACK_DECAY_SV(c, a, d)
Definition sidz.c:244
void sidz_wave(Environment *_environment, char *_voice, char *_bits, char *_pulse)
Definition sidz.c:334
void sidz_player_play(Environment *_environment, int _play_address)
Definition sidz.c:973
void sidz_attack_decay_sustain_release(Environment *_environment, char *_voice, char *_attack, char *_decay, char *_sustain, char *_release)
Definition sidz.c:327
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