Mercurial > pmdwin
comparison pmdwin.cpp @ 0:c55ea9478c80
Hello Gensokyo!
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 21 May 2013 10:29:21 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c55ea9478c80 |
---|---|
1 //============================================================================= | |
2 // Professional Music Driver [P.M.D.] version 4.8 | |
3 // Programmed By M.Kajihara | |
4 // Windows Converted by C60 | |
5 //============================================================================= | |
6 | |
7 #include <stdint.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <math.h> | |
11 #include <limits.h> | |
12 #include <fcntl.h> | |
13 #include <unistd.h> | |
14 #include <sys/time.h> | |
15 #if defined(WIN32) || defined(WIN64) | |
16 #include <stdarg.h> | |
17 #include <windef.h> | |
18 #include <winbase.h> | |
19 #include <winnt.h> | |
20 #else | |
21 #include <sys/mman.h> | |
22 #endif | |
23 #include "jisx0208.h" | |
24 #include "pmdwin.h" | |
25 | |
26 /****************************************************************************** | |
27 ; Part Table | |
28 ******************************************************************************/ | |
29 static const uint8_t part_table[][3] = { // for PMDB2 | |
30 // Part<94>ヤ<8d><86>,Partb,<89>ケ<8c>ケ<94>ヤ<8d><86> | |
31 { 0, 1, 0 }, //A | |
32 { 1, 2, 0 }, //B | |
33 { 2, 3, 0 }, //C | |
34 { 3, 1, 1 }, //D | |
35 { 4, 2, 1 }, //E | |
36 { 5, 3, 1 }, //F | |
37 { 6, 1, 2 }, //G | |
38 { 7, 2, 2 }, //H | |
39 { 8, 3, 2 }, //I | |
40 { 9, 1, 3 }, //J | |
41 { 10, 3, 4 }, //K | |
42 { 11, 3, 0 }, //c2 | |
43 { 12, 3, 0 }, //c3 | |
44 { 13, 3, 0 }, //c4 | |
45 { 255, 0, 255 }, //Rhythm | |
46 { 22, 3, 1 }, //Effect | |
47 }; | |
48 | |
49 static char *notes[12] = { | |
50 "C ", "Db", "D ", "Eb", "E ", "F ", "F#", "G ", "G#", "A ", "Bb", "B " | |
51 }; | |
52 | |
53 static char *drums[6] = { | |
54 "Bass ", "Snare ", "RideCym", "Hi-Hat ", "Tom-Tom", "Rim " | |
55 }; | |
56 | |
57 static inline unsigned int av_log2(unsigned int x) { | |
58 unsigned int ret; | |
59 __asm__ volatile("or $1, %1 \n\t" | |
60 "bsr %1, %0 \n\t" | |
61 :"=a"(ret) : "D"(x)); | |
62 return ret; | |
63 } | |
64 | |
65 /****************************************************************************** | |
66 ; <89>ケ<8a>KDATA(FM) | |
67 ******************************************************************************/ | |
68 static const uint16_t fnum_data[] = { | |
69 0x026a, // C | |
70 0x028f, // D- | |
71 0x02b6, // D | |
72 0x02df, // E- | |
73 0x030b, // E | |
74 0x0339, // F | |
75 0x036a, // G- | |
76 0x039e, // G | |
77 0x03d5, // A- | |
78 0x0410, // A | |
79 0x044e, // B- | |
80 0x048f // B | |
81 }; | |
82 | |
83 /****************************************************************************** | |
84 ; <89>ケ<8a>KDATA(PSG) | |
85 ******************************************************************************/ | |
86 static const uint16_t psg_tune_data[] = { | |
87 0x0ee8, // C | |
88 0x0e12, // D- | |
89 0x0d48, // D | |
90 0x0c89, // E- | |
91 0x0bd5, // E | |
92 0x0b2b, // F | |
93 0x0a8a, // G- | |
94 0x09f3, // G | |
95 0x0964, // A- | |
96 0x08dd, // A | |
97 0x085e, // B- | |
98 0x07e6, // B | |
99 }; | |
100 | |
101 | |
102 /****************************************************************************** | |
103 ; <82>e<82>l<89>ケ<90>F<82>フ<83>L<83><83><83><8a><83>A<82>フ<83>e<81>[<83>u<83><8b> | |
104 ******************************************************************************/ | |
105 static const uint8_t carrier_table[] = { | |
106 0x80, 0x80, 0x80, 0x80, 0xa0, 0xe0, 0xe0, 0xf0, | |
107 0xee, 0xee, 0xee, 0xee, 0xcc, 0x88, 0x88, 0x00 | |
108 }; | |
109 | |
110 /****************************************************************************** | |
111 ; <83>h<83><89><83><80><83>X<97>p<83><8a><83>Y<83><80><83>f<81>[<83>^ | |
112 ******************************************************************************/ | |
113 static const uint8_t rhydat[][3] = { | |
114 // PT,PAN/VOLUME,KEYON | |
115 { 0x18, 0xdf, 0x01 }, // <83>o<83>X | |
116 { 0x19, 0xdf, 0x02 }, // <83>X<83>l<83>A | |
117 { 0x1c, 0x5f, 0x10 }, // <83>^<83><80>[LOW] | |
118 { 0x1c, 0xdf, 0x10 }, // <83>^<83><80>[MID] | |
119 { 0x1c, 0x9f, 0x10 }, // <83>^<83><80>[HIGH] | |
120 { 0x1d, 0xd3, 0x20 }, // <83><8a><83><80> | |
121 { 0x19, 0xdf, 0x02 }, // <83>N<83><89><83>b<83>v | |
122 { 0x1b, 0x9c, 0x88 }, // C<83>n<83>C<83>n<83>b<83>g | |
123 { 0x1a, 0x9d, 0x04 }, // O<83>n<83>C<83>n<83>b<83>g | |
124 { 0x1a, 0xdf, 0x04 }, // <83>V<83><93><83>o<83><8b> | |
125 { 0x1a, 0x5e, 0x04 } // RIDE<83>V<83><93><83>o<83><8b> | |
126 }; | |
127 | |
128 | |
129 //============================================================================= | |
130 // TimerAの処理[メイン] | |
131 //============================================================================= | |
132 void PMDWIN::TimerA_main(void) | |
133 { | |
134 open_work.TimerAflag = 1; | |
135 open_work.TimerAtime++; | |
136 | |
137 if(effwork.effon) { | |
138 effplay(); // SSG効果音処理 | |
139 } | |
140 | |
141 open_work.TimerAflag = 0; | |
142 } | |
143 | |
144 | |
145 //============================================================================= | |
146 // TimerBの処理[メイン] | |
147 //============================================================================= | |
148 void PMDWIN::TimerB_main(void) | |
149 { | |
150 open_work.TimerBflag = 1; | |
151 if(pmdwork.music_flag) { | |
152 if(pmdwork.music_flag & 1) { | |
153 mstart(); | |
154 } | |
155 | |
156 if(pmdwork.music_flag & 2) { | |
157 mstop(); | |
158 } | |
159 } | |
160 | |
161 if(open_work.play_flag) { | |
162 mmain(); | |
163 settempo_b(); | |
164 syousetu_count(); | |
165 pmdwork.lastTimerAtime = open_work.TimerAtime; | |
166 } | |
167 open_work.TimerBflag = 0; | |
168 } | |
169 | |
170 | |
171 //============================================================================= | |
172 // MUSIC PLAYER MAIN [FROM TIMER-B] | |
173 //============================================================================= | |
174 void PMDWIN::mmain(void) | |
175 { | |
176 int i; | |
177 | |
178 pmdwork.loop_work = 3; | |
179 for(i = 0; i < 3; i++) { | |
180 pmdwork.partb = i + 1; | |
181 psgmain(&SSGPart[i]); | |
182 } | |
183 | |
184 pmdwork.fmsel = 0x100; | |
185 for(i = 0; i < 3; i++) { | |
186 pmdwork.partb = i + 1; | |
187 fmmain(&FMPart[i+3]); | |
188 } | |
189 | |
190 pmdwork.fmsel = 0; | |
191 for(i = 0; i < 3; i++) { | |
192 pmdwork.partb = i + 1; | |
193 fmmain(&FMPart[i]); | |
194 } | |
195 rhythmmain(&RhythmPart); | |
196 | |
197 for(i = 0; i < 8; i++) { | |
198 pmdwork.partb = i; | |
199 } | |
200 if(pmdwork.loop_work == 0) return; | |
201 | |
202 for(i = 0; i < 6; i++) { | |
203 if(FMPart[i].loopcheck != 3) FMPart[i].loopcheck = 0; | |
204 } | |
205 | |
206 for(i = 0; i < 3; i++) { | |
207 if(SSGPart[i].loopcheck != 3) SSGPart[i].loopcheck = 0; | |
208 } | |
209 if(RhythmPart.loopcheck != 3) RhythmPart.loopcheck = 0; | |
210 | |
211 if(pmdwork.loop_work != 3) { | |
212 open_work.status2++; | |
213 if(open_work.status2 == 255) open_work.status2 = 1; | |
214 } else { | |
215 open_work.status2 = -1; | |
216 } | |
217 } | |
218 | |
219 //============================================================================= | |
220 // FM音源演奏メイン | |
221 //============================================================================= | |
222 void PMDWIN::fmmain(QQ *qq) | |
223 { | |
224 uchar *si; | |
225 | |
226 if(qq->address == NULL) return; | |
227 | |
228 si = qq->address; | |
229 | |
230 qq->leng--; | |
231 | |
232 if(qq->partmask) { | |
233 qq->keyoff_flag = -1; | |
234 } else { | |
235 // KEYOFF CHECK & Keyoff | |
236 if((qq->keyoff_flag & 3) == 0) { // 既にkeyoffしたか? | |
237 if(qq->leng <= qq->qdat) { | |
238 keyoff(qq); | |
239 qq->keyoff_flag = -1; | |
240 } | |
241 } | |
242 } | |
243 | |
244 // LENGTH CHECK | |
245 if(qq->leng == 0) { | |
246 if(qq->partmask == 0) qq->lfoswi &= 0xf7; | |
247 | |
248 while(1) { | |
249 if(*si > 0x80 && *si != 0xda) { | |
250 si = commands(qq, si); | |
251 } else if(*si == 0x80) { | |
252 qq->address = si; | |
253 qq->loopcheck = 3; | |
254 qq->onkai = 255; | |
255 if(qq->partloop == NULL) { | |
256 if(qq->partmask) { | |
257 pmdwork.tieflag = 0; | |
258 pmdwork.volpush_flag = 0; | |
259 pmdwork.loop_work &= qq->loopcheck; | |
260 return; | |
261 } else { | |
262 break; | |
263 } | |
264 } | |
265 // "L"があった時 | |
266 si = qq->partloop; | |
267 qq->loopcheck = 1; | |
268 } else { | |
269 if(*si == 0xda) { // ポルタメント | |
270 si = porta(qq, ++si); | |
271 pmdwork.loop_work &= qq->loopcheck; | |
272 return; | |
273 } else if(qq->partmask == 0) { | |
274 // TONE SET | |
275 lfoinit(qq, *si); | |
276 fnumset(qq, oshift(qq, *si++)); | |
277 | |
278 qq->leng = *si++; | |
279 si = calc_q(qq, si); | |
280 | |
281 if(qq->volpush && qq->onkai != 255) { | |
282 if(--pmdwork.volpush_flag) { | |
283 pmdwork.volpush_flag = 0; | |
284 qq->volpush = 0; | |
285 } | |
286 } | |
287 | |
288 volset(qq); | |
289 otodasi(qq); | |
290 keyon(qq); | |
291 | |
292 qq->keyon_flag++; | |
293 qq->address = si; | |
294 | |
295 pmdwork.tieflag = 0; | |
296 pmdwork.volpush_flag = 0; | |
297 | |
298 if(*si == 0xfb) { // '&'が直後にあったらkeyoffしない | |
299 qq->keyoff_flag = 2; | |
300 } else { | |
301 qq->keyoff_flag = 0; | |
302 } | |
303 pmdwork.loop_work &= qq->loopcheck; | |
304 return; | |
305 } else { | |
306 si++; | |
307 qq->fnum = 0; //休符に設定 | |
308 qq->onkai = 255; | |
309 qq->onkai_def = 255; | |
310 qq->leng = *si++; | |
311 qq->keyon_flag++; | |
312 qq->address = si; | |
313 | |
314 if(--pmdwork.volpush_flag) { | |
315 qq->volpush = 0; | |
316 } | |
317 | |
318 pmdwork.tieflag = 0; | |
319 pmdwork.volpush_flag = 0; | |
320 break; | |
321 } | |
322 } | |
323 } | |
324 } | |
325 | |
326 if(qq->partmask == 0) { | |
327 | |
328 // LFO & Portament & Fadeout 処理 をして終了 | |
329 if(qq->hldelay_c) { | |
330 if(--qq->hldelay_c == 0) { | |
331 OPNASetReg(&opna, pmdwork.fmsel + | |
332 (pmdwork.partb - 1 + 0xb4), qq->fmpan); | |
333 } | |
334 } | |
335 | |
336 if(qq->sdelay_c) { | |
337 if(--qq->sdelay_c == 0) { | |
338 if((qq->keyoff_flag & 1) == 0) { // 既にkeyoffしたか? | |
339 keyon(qq); | |
340 } | |
341 } | |
342 } | |
343 | |
344 if(qq->lfoswi) { | |
345 pmdwork.lfo_switch = qq->lfoswi & 8; | |
346 if(qq->lfoswi & 3) { | |
347 if(lfo(qq)) { | |
348 pmdwork.lfo_switch |= (qq->lfoswi & 3); | |
349 } | |
350 } | |
351 | |
352 if(qq->lfoswi & 0x30) { | |
353 lfo_change(qq); | |
354 if(lfo(qq)) { | |
355 lfo_change(qq); | |
356 pmdwork.lfo_switch |= (qq->lfoswi & 0x30); | |
357 } else { | |
358 lfo_change(qq); | |
359 } | |
360 } | |
361 | |
362 if(pmdwork.lfo_switch & 0x19) { | |
363 if(pmdwork.lfo_switch & 8) { | |
364 porta_calc(qq); | |
365 | |
366 } | |
367 otodasi(qq); | |
368 } | |
369 | |
370 if(pmdwork.lfo_switch & 0x22) { | |
371 volset(qq); | |
372 pmdwork.loop_work &= qq->loopcheck; | |
373 return; | |
374 } | |
375 } | |
376 } | |
377 | |
378 pmdwork.loop_work &= qq->loopcheck; | |
379 } | |
380 | |
381 | |
382 //============================================================================= | |
383 // KEY OFF | |
384 //============================================================================= | |
385 void PMDWIN::keyoff(QQ *qq) | |
386 { | |
387 if(qq->onkai == 255) return; | |
388 kof1(qq); | |
389 } | |
390 | |
391 | |
392 void PMDWIN::kof1(QQ *qq) | |
393 { | |
394 if(pmdwork.fmsel == 0) { | |
395 pmdwork.omote_key[pmdwork.partb-1] | |
396 = (~qq->slotmask) & (pmdwork.omote_key[pmdwork.partb-1]); | |
397 OPNASetReg(&opna, 0x28, (pmdwork.partb-1) | pmdwork.omote_key[pmdwork.partb-1]); | |
398 } else { | |
399 pmdwork.ura_key[pmdwork.partb-1] | |
400 = (~qq->slotmask) & (pmdwork.ura_key[pmdwork.partb-1]); | |
401 OPNASetReg(&opna, 0x28, ((pmdwork.partb-1) | pmdwork.ura_key[pmdwork.partb-1]) | 4); | |
402 } | |
403 } | |
404 | |
405 | |
406 //============================================================================= | |
407 // FM KEYON | |
408 //============================================================================= | |
409 void PMDWIN::keyon(QQ *qq) | |
410 { | |
411 int al; | |
412 | |
413 if(qq->onkai == 255) return; // キュウフ ノ トキ | |
414 uint32_t op = ((pmdwork.partb-1)&7)|(!!pmdwork.fmsel << 2); | |
415 switch(op) { | |
416 case 0: | |
417 pmdstatus[0] = (qq->onkai & 0x0f); | |
418 break; | |
419 case 1: | |
420 pmdstatus[1] = (qq->onkai & 0x0f); | |
421 break; | |
422 case 2: | |
423 pmdstatus[2] = (qq->onkai & 0x0f); | |
424 break; | |
425 case 4: | |
426 pmdstatus[3] = (qq->onkai & 0x0f); | |
427 break; | |
428 case 5: | |
429 pmdstatus[4] = (qq->onkai & 0x0f); | |
430 break; | |
431 case 6: | |
432 pmdstatus[5] = (qq->onkai & 0x0f); | |
433 break; | |
434 default: | |
435 break; | |
436 } | |
437 | |
438 if(pmdwork.fmsel == 0) { | |
439 al = pmdwork.omote_key[pmdwork.partb-1] | qq->slotmask; | |
440 if(qq->sdelay_c) { | |
441 al &= qq->sdelay_m; | |
442 } | |
443 | |
444 pmdwork.omote_key[pmdwork.partb-1] = al; | |
445 OPNASetReg(&opna, 0x28, (pmdwork.partb-1) | al); | |
446 } else { | |
447 al = pmdwork.ura_key[pmdwork.partb-1] | qq->slotmask; | |
448 if(qq->sdelay_c) { | |
449 al &= qq->sdelay_m; | |
450 } | |
451 | |
452 pmdwork.ura_key[pmdwork.partb-1] = al; | |
453 OPNASetReg(&opna, 0x28, ((pmdwork.partb-1) | al) | 4); | |
454 } | |
455 } | |
456 | |
457 | |
458 //============================================================================= | |
459 // Set [ FNUM/BLOCK + DETUNE + LFO ] | |
460 //============================================================================= | |
461 void PMDWIN::otodasi(QQ *qq) | |
462 { | |
463 int ax, cx; | |
464 | |
465 if(qq->fnum == 0) return; | |
466 if(qq->slotmask == 0) return; | |
467 | |
468 cx = (qq->fnum & 0x3800); // cx=BLOCK | |
469 ax = (qq->fnum) & 0x7ff; // ax=FNUM | |
470 | |
471 // Portament/LFO/Detune SET | |
472 ax += qq->porta_num + qq->detune; | |
473 | |
474 if(pmdwork.partb == 3 && pmdwork.fmsel == 0 && open_work.ch3mode != 0x3f) { | |
475 ch3_special(qq, ax, cx); | |
476 } else { | |
477 if(qq->lfoswi & 1) { | |
478 ax += qq->lfodat; | |
479 } | |
480 | |
481 if(qq->lfoswi & 0x10) { | |
482 ax += qq->_lfodat; | |
483 } | |
484 | |
485 fm_block_calc(&cx, &ax); | |
486 | |
487 // SET BLOCK/FNUM TO OPN | |
488 | |
489 ax |= cx; | |
490 | |
491 OPNASetReg(&opna, pmdwork.fmsel + pmdwork.partb+0xa4-1, ax >> 8); | |
492 OPNASetReg(&opna, pmdwork.fmsel + pmdwork.partb+0xa4-5, ax & 0xff); | |
493 } | |
494 } | |
495 | |
496 | |
497 //============================================================================= | |
498 // FM音源のdetuneでオクターブが変わる時の修正 | |
499 // input CX:block / AX:fnum+detune | |
500 // output CX:block / AX:fnum | |
501 //============================================================================= | |
502 void PMDWIN::fm_block_calc(int *cx, int *ax) | |
503 { | |
504 while(*ax >= 0x26a) { | |
505 if(*ax < (0x26a*2)) return; | |
506 | |
507 *cx += 0x800; // oct.up | |
508 if(*cx != 0x4000) { | |
509 *ax -= 0x26a; // 4d2h-26ah | |
510 } else { // モウ コレイジョウ アガンナイヨン | |
511 *cx = 0x3800; | |
512 if(*ax >= 0x800) | |
513 *ax = 0x7ff; // 4d2h | |
514 return; | |
515 } | |
516 } | |
517 | |
518 while(*ax < 0x26a) { | |
519 *cx -= 0x800; // oct.down | |
520 if(*cx >= 0) { | |
521 *ax += 0x26a; // 4d2h-26ah | |
522 } else { // モウ コレイジョウ サガンナイヨン | |
523 *cx = 0; | |
524 if(*ax < 8) { | |
525 *ax = 8; | |
526 } | |
527 return; | |
528 } | |
529 } | |
530 } | |
531 | |
532 | |
533 //============================================================================= | |
534 // パートを判別してch3ならmode設定 | |
535 //============================================================================= | |
536 int PMDWIN::ch3_setting(QQ *qq) | |
537 { | |
538 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
539 ch3mode_set(qq); | |
540 return 1; | |
541 } else { | |
542 return 0; | |
543 } | |
544 } | |
545 | |
546 | |
547 void PMDWIN::cm_clear(int *ah, int *al) | |
548 { | |
549 *al ^= 0xff; | |
550 if((pmdwork.slot3_flag &= *al) == 0) { | |
551 if(pmdwork.slotdetune_flag != 1) { | |
552 *ah = 0x3f; | |
553 } else { | |
554 *ah = 0x7f; | |
555 } | |
556 } else { | |
557 *ah = 0x7f; | |
558 } | |
559 } | |
560 | |
561 | |
562 //============================================================================= | |
563 // FM3のmodeを設定する | |
564 //============================================================================= | |
565 void PMDWIN::ch3mode_set(QQ *qq) | |
566 { | |
567 int ah, al; | |
568 | |
569 if(qq == &FMPart[3-1]) { | |
570 al = 1; | |
571 } else { | |
572 al = 8; | |
573 } | |
574 | |
575 if((qq->slotmask & 0xf0) == 0) { // s0 | |
576 cm_clear(&ah, &al); | |
577 } else if(qq->slotmask != 0xf0) { | |
578 pmdwork.slot3_flag |= al; | |
579 ah = 0x7f; | |
580 } else if((qq->volmask & 0x0f) == 0) { | |
581 cm_clear(&ah, &al); | |
582 } else if((qq->lfoswi & 1) != 0) { | |
583 pmdwork.slot3_flag |= al; | |
584 ah = 0x7f; | |
585 } else if((qq->_volmask & 0x0f) == 0) { | |
586 cm_clear(&ah, &al); | |
587 } else if(qq->lfoswi & 0x10) { | |
588 pmdwork.slot3_flag |= al; | |
589 ah = 0x7f; | |
590 } else { | |
591 cm_clear(&ah, &al); | |
592 } | |
593 | |
594 if(ah == open_work.ch3mode) return; // 以前と変更無しなら何もしない | |
595 open_work.ch3mode = ah; | |
596 OPNASetReg(&opna, 0x27, ah & 0xcf); // Resetはしない | |
597 | |
598 // 効果音モードに移った場合はそれ以前のFM3パートで音程書き換え | |
599 if(ah == 0x3f || qq == &FMPart[2]) return; | |
600 if(FMPart[2].partmask == 0) otodasi(&FMPart[2]); | |
601 } | |
602 | |
603 | |
604 //============================================================================= | |
605 // ch3=効果音モード を使用する場合の音程設定 | |
606 // input CX:block AX:fnum | |
607 //============================================================================= | |
608 void PMDWIN::ch3_special(QQ *qq, int ax, int cx) | |
609 { | |
610 int ax_, bh, ch, si; | |
611 int shiftmask = 0x80; | |
612 | |
613 si = cx; | |
614 | |
615 if((qq->volmask & 0x0f) == 0) { | |
616 bh = 0xf0; // all | |
617 } else { | |
618 bh = qq->volmask; // bh=lfo1 mask 4321xxxx | |
619 } | |
620 | |
621 if((qq->_volmask & 0x0f) == 0) { | |
622 ch = 0xf0; // all | |
623 } else { | |
624 ch = qq->_volmask; // ch=lfo2 mask 4321xxxx | |
625 } | |
626 | |
627 // slot 4 | |
628 if(qq->slotmask & 0x80) { | |
629 ax_ = ax; | |
630 ax += open_work.slot_detune4; | |
631 if((bh & shiftmask) && (qq->lfoswi & 0x01)) ax += qq->lfodat; | |
632 if((ch & shiftmask) && (qq->lfoswi & 0x10)) ax += qq->_lfodat; | |
633 shiftmask >>= 1; | |
634 | |
635 cx = si; | |
636 fm_block_calc(&cx, &ax); | |
637 ax |= cx; | |
638 | |
639 OPNASetReg(&opna, 0xa6, ax >> 8); | |
640 OPNASetReg(&opna, 0xa2, ax & 0xff); | |
641 | |
642 ax = ax_; | |
643 } | |
644 | |
645 // slot 3 | |
646 if(qq->slotmask & 0x40) { | |
647 ax_ = ax; | |
648 ax += open_work.slot_detune3; | |
649 if((bh & shiftmask) && (qq->lfoswi & 0x01)) ax += qq->lfodat; | |
650 if((ch & shiftmask) && (qq->lfoswi & 0x10)) ax += qq->_lfodat; | |
651 shiftmask >>= 1; | |
652 | |
653 cx = si; | |
654 fm_block_calc(&cx, &ax); | |
655 ax |= cx; | |
656 | |
657 OPNASetReg(&opna, 0xac, ax >> 8); | |
658 OPNASetReg(&opna, 0xa8, ax & 0xff); | |
659 | |
660 ax = ax_; | |
661 } | |
662 | |
663 // slot 2 | |
664 if(qq->slotmask & 0x20) { | |
665 ax_ = ax; | |
666 ax += open_work.slot_detune2; | |
667 if((bh & shiftmask) && (qq->lfoswi & 0x01)) ax += qq->lfodat; | |
668 if((ch & shiftmask) && (qq->lfoswi & 0x10)) ax += qq->_lfodat; | |
669 shiftmask >>= 1; | |
670 | |
671 cx = si; | |
672 fm_block_calc(&cx, &ax); | |
673 ax |= cx; | |
674 | |
675 OPNASetReg(&opna, 0xae, ax >> 8); | |
676 OPNASetReg(&opna, 0xaa, ax & 0xff); | |
677 | |
678 ax = ax_; | |
679 } | |
680 | |
681 // slot 1 | |
682 if(qq->slotmask & 0x10) { | |
683 ax_ = ax; | |
684 ax += open_work.slot_detune1; | |
685 if((bh & shiftmask) && (qq->lfoswi & 0x01)) ax += qq->lfodat; | |
686 if((ch & shiftmask) && (qq->lfoswi & 0x10)) ax += qq->_lfodat; | |
687 cx = si; | |
688 fm_block_calc(&cx, &ax); | |
689 ax |= cx; | |
690 | |
691 OPNASetReg(&opna, 0xad, ax >> 8); | |
692 OPNASetReg(&opna, 0xa9, ax & 0xff); | |
693 | |
694 ax = ax_; | |
695 } | |
696 } | |
697 | |
698 | |
699 //============================================================================= | |
700 // 'p' COMMAND [FM PANNING SET] | |
701 //============================================================================= | |
702 uchar * PMDWIN::panset(QQ *qq, uchar *si) | |
703 { | |
704 panset_main(qq, *si++); | |
705 return si; | |
706 } | |
707 | |
708 | |
709 void PMDWIN::panset_main(QQ *qq, int al) | |
710 { | |
711 qq->fmpan = ((qq->fmpan & 0x3f) | ((al << 6) & 0xc0)); | |
712 | |
713 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
714 // FM3の場合は 4つのパート総て設定 | |
715 FMPart[2].fmpan = qq->fmpan; | |
716 } | |
717 | |
718 if(qq->partmask == 0) { // パートマスクされているか? | |
719 // dl = al; | |
720 OPNASetReg(&opna, pmdwork.fmsel + pmdwork.partb+0xb4-1, | |
721 calc_panout(qq)); | |
722 } | |
723 } | |
724 | |
725 | |
726 //============================================================================= | |
727 // 0b4h〜に設定するデータを取得 out.dl | |
728 //============================================================================= | |
729 uchar PMDWIN::calc_panout(QQ *qq) | |
730 { | |
731 int dl; | |
732 | |
733 dl = qq->fmpan; | |
734 if(qq->hldelay_c) dl &= 0xc0; // HLFO Delayが残ってる場合はパンのみ設定 | |
735 return dl; | |
736 } | |
737 | |
738 | |
739 //============================================================================= | |
740 // Pan setting Extend | |
741 //============================================================================= | |
742 uchar * PMDWIN::panset_ex(QQ *qq, uchar *si) | |
743 { | |
744 int al; | |
745 | |
746 al = *(char *)si++; | |
747 si++; // 逆走flagは読み飛ばす | |
748 | |
749 if(al > 0) { | |
750 al = 2; | |
751 panset_main(qq, al); | |
752 } else if(al == 0) { | |
753 al = 3; | |
754 panset_main(qq, al); | |
755 } else { | |
756 al = 1; | |
757 panset_main(qq, al); | |
758 } | |
759 return si; | |
760 } | |
761 | |
762 | |
763 //============================================================================= | |
764 // FM音源用 Entry | |
765 //============================================================================= | |
766 void PMDWIN::lfoinit(QQ *qq, int al) | |
767 { | |
768 int ah; | |
769 | |
770 ah = al & 0x0f; | |
771 if(ah == 0x0c) { | |
772 al = qq->onkai_def; | |
773 ah = al & 0x0f; | |
774 } | |
775 | |
776 qq->onkai_def = al; | |
777 | |
778 if(ah == 0x0f) { // キューフ ノ トキ ハ INIT シナイヨ | |
779 lfo_exit(qq); | |
780 return; | |
781 } | |
782 | |
783 qq->porta_num = 0; // ポルタメントは初期化 | |
784 | |
785 if((pmdwork.tieflag & 1) == 0) { | |
786 lfin1(qq); | |
787 } else { | |
788 lfo_exit(qq); | |
789 } | |
790 } | |
791 | |
792 | |
793 //============================================================================= | |
794 // FM BLOCK,F-NUMBER SET | |
795 // INPUTS -- AL [KEY#,0-7F] | |
796 //============================================================================= | |
797 void PMDWIN::fnumset(QQ *qq, int al) | |
798 { | |
799 int ax,bx; | |
800 | |
801 if((al & 0x0f) != 0x0f) { // 音符の場合 | |
802 qq->onkai = al; | |
803 | |
804 // BLOCK/FNUM CALICULATE | |
805 bx = al & 0x0f; // bx=onkai | |
806 ax = fnum_data[bx]; | |
807 | |
808 // BLOCK SET | |
809 ax |= (((al >> 1) & 0x38) << 8); | |
810 qq->fnum = ax; | |
811 } else { // 休符の場合 | |
812 qq->onkai = 255; | |
813 if((qq->lfoswi & 0x11) == 0) { | |
814 qq->fnum = 0; // 音程LFO未使用 | |
815 } | |
816 } | |
817 } | |
818 | |
819 | |
820 //============================================================================= | |
821 // FM音量設定メイン | |
822 //============================================================================= | |
823 void PMDWIN::volset(QQ *qq) | |
824 { | |
825 int bh, bl, cl, dh; | |
826 uchar vol_tbl[4] = {0, 0, 0, 0}; | |
827 | |
828 if(qq->slotmask == 0) return; | |
829 if(qq->volpush) { | |
830 cl = qq->volpush - 1; | |
831 } else { | |
832 cl = qq->volume; | |
833 } | |
834 | |
835 //-------------------------------------------------------------------- | |
836 // 音量down計算 | |
837 //-------------------------------------------------------------------- | |
838 if(open_work.fm_voldown) { | |
839 cl = ((256-open_work.fm_voldown) * cl) >> 8; | |
840 } | |
841 | |
842 //------------------------------------------------------------------------ | |
843 // 音量をcarrierに設定 & 音量LFO処理 | |
844 // input cl to Volume[0-127] | |
845 // bl to SlotMask | |
846 //------------------------------------------------------------------------ | |
847 | |
848 bh=0; // Vol Slot Mask | |
849 bl=qq->slotmask; // ch=SlotMask Push | |
850 | |
851 vol_tbl[0] = 0x80; | |
852 vol_tbl[1] = 0x80; | |
853 vol_tbl[2] = 0x80; | |
854 vol_tbl[3] = 0x80; | |
855 | |
856 cl = 255-cl; // cl=carrierに設定する音量+80H(add) | |
857 bl &= qq->carrier; // bl=音量を設定するSLOT xxxx0000b | |
858 bh |= bl; | |
859 | |
860 if(bl & 0x80) vol_tbl[0] = cl; | |
861 if(bl & 0x40) vol_tbl[1] = cl; | |
862 if(bl & 0x20) vol_tbl[2] = cl; | |
863 if(bl & 0x10) vol_tbl[3] = cl; | |
864 | |
865 if(cl != 255) { | |
866 if(qq->lfoswi & 2) { | |
867 bl = qq->volmask; | |
868 bl &= qq->slotmask; // bl=音量LFOを設定するSLOT xxxx0000b | |
869 bh |= bl; | |
870 fmlfo_sub(qq, qq->lfodat, bl, vol_tbl); | |
871 } | |
872 | |
873 if(qq->lfoswi & 0x20) { | |
874 bl = qq->_volmask; | |
875 bl &= qq->slotmask; | |
876 bh |= bl; | |
877 fmlfo_sub(qq, qq->_lfodat, bl, vol_tbl); | |
878 } | |
879 } | |
880 | |
881 dh = 0x4c - 1 + pmdwork.partb; // dh=FM Port Address | |
882 | |
883 if(bh & 0x80) volset_slot(dh, qq->slot4, vol_tbl[0]); | |
884 if(bh & 0x40) volset_slot(dh-8, qq->slot3, vol_tbl[1]); | |
885 if(bh & 0x20) volset_slot(dh-4, qq->slot2, vol_tbl[2]); | |
886 if(bh & 0x10) volset_slot(dh-12, qq->slot1, vol_tbl[3]); | |
887 } | |
888 | |
889 | |
890 //----------------------------------------------------------------------------- | |
891 // スロット毎の計算 & 出力 マクロ | |
892 // in. dl 元のTL値 | |
893 // dh Outするレジスタ | |
894 // al 音量変動値 中心=80h | |
895 //----------------------------------------------------------------------------- | |
896 void PMDWIN::volset_slot(int dh, int dl, int al) | |
897 { | |
898 if((al += dl) > 255) al = 255; | |
899 if((al -= 0x80) < 0) al = 0; | |
900 OPNASetReg(&opna, pmdwork.fmsel + dh, al); | |
901 } | |
902 | |
903 | |
904 //----------------------------------------------------------------------------- | |
905 // 音量LFO用サブ | |
906 //----------------------------------------------------------------------------- | |
907 void PMDWIN::fmlfo_sub(QQ *qq, int al, int bl, uchar *vol_tbl) | |
908 { | |
909 if(bl & 0x80) vol_tbl[0] = Limit(vol_tbl[0] - al, 255, 0); | |
910 if(bl & 0x40) vol_tbl[1] = Limit(vol_tbl[1] - al, 255, 0); | |
911 if(bl & 0x20) vol_tbl[2] = Limit(vol_tbl[2] - al, 255, 0); | |
912 if(bl & 0x10) vol_tbl[3] = Limit(vol_tbl[3] - al, 255, 0); | |
913 } | |
914 | |
915 | |
916 //============================================================================= | |
917 // SSG音源 演奏 メイン | |
918 //============================================================================= | |
919 void PMDWIN::psgmain(QQ *qq) | |
920 { | |
921 uchar *si; | |
922 int temp; | |
923 | |
924 if(qq->address == NULL) return; | |
925 si = qq->address; | |
926 | |
927 qq->leng--; | |
928 | |
929 // KEYOFF CHECK & Keyoff | |
930 if(qq->partmask) { | |
931 qq->keyoff_flag = -1; | |
932 } else { | |
933 if((qq->keyoff_flag & 3) == 0) { // 既にkeyoffしたか? | |
934 if(qq->leng <= qq->qdat) { | |
935 keyoffp(qq); | |
936 qq->keyoff_flag = -1; | |
937 } | |
938 } | |
939 } | |
940 | |
941 // LENGTH CHECK | |
942 if(qq->leng == 0) { | |
943 qq->lfoswi &= 0xf7; | |
944 | |
945 // DATA READ | |
946 while(1) { | |
947 if(*si == 0xda && ssgdrum_check(qq, *si) < 0) { | |
948 si++; | |
949 } else if(*si > 0x80 && *si != 0xda) { | |
950 si = commandsp(qq, si); | |
951 } else if(*si == 0x80) { | |
952 qq->address = si; | |
953 qq->loopcheck = 3; | |
954 qq->onkai = 255; | |
955 if(qq->partloop == NULL) { | |
956 if(qq->partmask) { | |
957 pmdwork.tieflag = 0; | |
958 pmdwork.volpush_flag = 0; | |
959 pmdwork.loop_work &= qq->loopcheck; | |
960 return; | |
961 } else { | |
962 break; | |
963 } | |
964 } | |
965 // "L"があった時 | |
966 si = qq->partloop; | |
967 qq->loopcheck = 1; | |
968 } else { | |
969 if(*si == 0xda) { // ポルタメント | |
970 si = portap(qq, ++si); | |
971 pmdwork.loop_work &= qq->loopcheck; | |
972 return; | |
973 } else if(qq->partmask) { | |
974 if(ssgdrum_check(qq, *si) == 0) { | |
975 si++; | |
976 qq->fnum = 0; //休符に設定 | |
977 qq->onkai = 255; | |
978 qq->leng = *si++; | |
979 qq->keyon_flag++; | |
980 qq->address = si; | |
981 | |
982 if(--pmdwork.volpush_flag) { | |
983 qq->volpush = 0; | |
984 } | |
985 | |
986 pmdwork.tieflag = 0; | |
987 pmdwork.volpush_flag = 0; | |
988 break; | |
989 } | |
990 } | |
991 | |
992 // TONE SET | |
993 lfoinitp(qq, *si); | |
994 fnumsetp(qq, oshiftp(qq, *si++)); | |
995 | |
996 qq->leng = *si++; | |
997 si = calc_q(qq, si); | |
998 | |
999 if(qq->volpush && qq->onkai != 255) { | |
1000 if(--pmdwork.volpush_flag) { | |
1001 pmdwork.volpush_flag = 0; | |
1002 qq->volpush = 0; | |
1003 } | |
1004 } | |
1005 | |
1006 volsetp(qq); | |
1007 otodasip(qq); | |
1008 keyonp(qq); | |
1009 | |
1010 qq->keyon_flag++; | |
1011 qq->address = si; | |
1012 | |
1013 pmdwork.tieflag = 0; | |
1014 pmdwork.volpush_flag = 0; | |
1015 qq->keyoff_flag = 0; | |
1016 | |
1017 if(*si == 0xfb) { // '&'が直後にあったらkeyoffしない | |
1018 qq->keyoff_flag = 2; | |
1019 } | |
1020 pmdwork.loop_work &= qq->loopcheck; | |
1021 return; | |
1022 } | |
1023 } | |
1024 } | |
1025 | |
1026 pmdwork.lfo_switch = (qq->lfoswi & 8); | |
1027 | |
1028 if(qq->lfoswi) { | |
1029 if(qq->lfoswi & 3) { | |
1030 if(lfo(qq)) { | |
1031 pmdwork.lfo_switch |= (qq->lfoswi & 3); | |
1032 } | |
1033 } | |
1034 | |
1035 if(qq->lfoswi & 0x30) { | |
1036 lfo_change(qq); | |
1037 if(lfo(qq)) { | |
1038 lfo_change(qq); | |
1039 pmdwork.lfo_switch |= (qq->lfoswi & 0x30); | |
1040 } else { | |
1041 lfo_change(qq); | |
1042 } | |
1043 } | |
1044 | |
1045 if(pmdwork.lfo_switch & 0x19) { | |
1046 if(pmdwork.lfo_switch & 0x08) { | |
1047 porta_calc(qq); | |
1048 } | |
1049 | |
1050 // SSG 3ch で休符かつ SSG Drum 発音中は操作しない | |
1051 if(!(qq == &SSGPart[2] && qq->onkai == 255 && open_work.kshot_dat)) { | |
1052 otodasip(qq); | |
1053 } | |
1054 } | |
1055 } | |
1056 | |
1057 temp = soft_env(qq); | |
1058 if(temp || pmdwork.lfo_switch & 0x22) { | |
1059 // SSG 3ch で休符かつ SSG Drum 発音中は volume set しない | |
1060 if(!(qq == &SSGPart[2] && qq->onkai == 255 && open_work.kshot_dat)) { | |
1061 volsetp(qq); | |
1062 } | |
1063 } | |
1064 | |
1065 pmdwork.loop_work &= qq->loopcheck; | |
1066 } | |
1067 | |
1068 | |
1069 void PMDWIN::keyoffp(QQ *qq) | |
1070 { | |
1071 if(qq->onkai == 255) return; // キュウフ ノ トキ | |
1072 if(qq->envf != -1) { | |
1073 qq->envf = 2; | |
1074 } else { | |
1075 qq->eenv_count = 4; | |
1076 } | |
1077 } | |
1078 | |
1079 | |
1080 //============================================================================= | |
1081 // リズムパート 演奏 メイン | |
1082 //============================================================================= | |
1083 void PMDWIN::rhythmmain(QQ *qq) | |
1084 { | |
1085 uchar *si, *bx; | |
1086 int al, result; | |
1087 | |
1088 if(qq->address == NULL) return; | |
1089 | |
1090 si = qq->address; | |
1091 | |
1092 if(--qq->leng == 0) { | |
1093 bx = open_work.rhyadr; | |
1094 | |
1095 rhyms00: | |
1096 do { | |
1097 result = 1; | |
1098 al = *bx++; | |
1099 if(al != 0xff) { | |
1100 if(al & 0x80) { | |
1101 bx = rhythmon(qq, bx, al, &result); | |
1102 if(result == 0) continue; | |
1103 } else { | |
1104 open_work.kshot_dat = 0; //rest | |
1105 } | |
1106 | |
1107 al = *bx++; | |
1108 open_work.rhyadr = bx; | |
1109 qq->leng = al; | |
1110 qq->keyon_flag++; | |
1111 pmdwork.tieflag = 0; | |
1112 pmdwork.volpush_flag = 0; | |
1113 pmdwork.loop_work &= qq->loopcheck; | |
1114 return; | |
1115 } | |
1116 }while(result == 0); | |
1117 | |
1118 while(1) { | |
1119 while((al = *si++) != 0x80) { | |
1120 if(al < 0x80) { | |
1121 qq->address = si; | |
1122 | |
1123 // bx = (ushort *)&open_work.radtbl[al]; | |
1124 // bx = open_work.rhyadr = &open_work.mmlbuf[*bx]; | |
1125 bx = open_work.rhyadr = &open_work.mmlbuf[open_work.radtbl[al]]; | |
1126 goto rhyms00; | |
1127 } | |
1128 | |
1129 // al > 0x80 | |
1130 si = commandsr(qq, si-1); | |
1131 } | |
1132 | |
1133 qq->address = --si; | |
1134 qq->loopcheck = 3; | |
1135 bx = qq->partloop; | |
1136 if(bx == NULL) { | |
1137 open_work.rhyadr = (uchar *)&pmdwork.rhydmy; | |
1138 pmdwork.tieflag = 0; | |
1139 pmdwork.volpush_flag = 0; | |
1140 pmdwork.loop_work &= qq->loopcheck; | |
1141 return; | |
1142 } else { // "L"があった時 | |
1143 si = bx; | |
1144 qq->loopcheck = 1; | |
1145 } | |
1146 } | |
1147 } | |
1148 | |
1149 pmdwork.loop_work &= qq->loopcheck; | |
1150 } | |
1151 | |
1152 | |
1153 //============================================================================= | |
1154 // PSGリズム ON | |
1155 //============================================================================= | |
1156 uchar * PMDWIN::rhythmon(QQ *qq, uchar *bx, int al, int *result) | |
1157 { | |
1158 int cl, dl, bx_; | |
1159 | |
1160 if(al & 0x40) { | |
1161 bx = commandsr(qq, bx-1); | |
1162 *result = 0; | |
1163 return bx; | |
1164 } | |
1165 | |
1166 *result = 1; | |
1167 | |
1168 if(qq->partmask) { // maskされている場合 | |
1169 open_work.kshot_dat = 0; | |
1170 return ++bx; | |
1171 } | |
1172 | |
1173 al = ((al << 8) + *bx++) & 0x3fff; | |
1174 open_work.kshot_dat = al; | |
1175 if(al == 0) return bx; | |
1176 open_work.rhyadr = bx; | |
1177 | |
1178 for(cl = 0; cl < 11; cl++) { | |
1179 if(al & (1 << cl)) { | |
1180 OPNASetReg(&opna, rhydat[cl][0], rhydat[cl][1]); | |
1181 if((dl = (rhydat[cl][2] & open_work.rhythmmask))) { | |
1182 if(dl < 0x80) { | |
1183 OPNASetReg(&opna, 0x10, dl); | |
1184 } else { | |
1185 OPNASetReg(&opna, 0x10, 0x84); | |
1186 dl = open_work.rhythmmask & 8; | |
1187 if(dl) { | |
1188 OPNASetReg(&opna, 0x10, dl); | |
1189 } | |
1190 } | |
1191 } | |
1192 } | |
1193 } | |
1194 | |
1195 bx_ = al; | |
1196 al = 0; | |
1197 do { | |
1198 while((bx_ & 1) == 0) { | |
1199 bx_ >>= 1; | |
1200 al++; | |
1201 } | |
1202 eff_main(al); | |
1203 bx_ >>= 1; | |
1204 }while(pmdwork.ppsdrv_flag && bx_); // PPSDRVなら2音目以上も鳴らしてみる | |
1205 | |
1206 return open_work.rhyadr; | |
1207 } | |
1208 | |
1209 | |
1210 //============================================================================= | |
1211 // PSG ドラムス&効果音 ルーチン | |
1212 // From WT298 | |
1213 // | |
1214 // AL に 効果音No.を入れて CALLする | |
1215 // ppsdrvがあるならそっちを鳴らす | |
1216 //============================================================================= | |
1217 void PMDWIN::eff_main(int al) | |
1218 { | |
1219 int priority; | |
1220 pmdstatus[8] = al; | |
1221 effwork.psgefcnum = al; | |
1222 if (al == 7 || al == 8) return; // PSG hihat sounds godawful, don't play it at all | |
1223 priority = ((al > 10) ? 2 : 1); | |
1224 if(effwork.effon <= priority) { | |
1225 SSGPart[2].partmask |= 2; // Part Mask | |
1226 efffor(efftbl[al]); // 1発目を発音 | |
1227 effwork.effon = priority; | |
1228 // 優先順位を設定(発音開始) | |
1229 } | |
1230 } | |
1231 | |
1232 | |
1233 //============================================================================= | |
1234 // こーかおん えんそう めいん | |
1235 // From VRTC | |
1236 //============================================================================= | |
1237 void PMDWIN::effplay(void) | |
1238 { | |
1239 if(--effwork.effcnt) { | |
1240 effsweep(); // 新しくセットされない | |
1241 } else { | |
1242 efffor(effwork.effadr); | |
1243 } | |
1244 } | |
1245 | |
1246 | |
1247 void PMDWIN::efffor(const int *si) | |
1248 { | |
1249 int al, ch, cl; | |
1250 | |
1251 al = *si++; | |
1252 if(al == -1) { | |
1253 effend(); | |
1254 } else { | |
1255 effwork.effcnt = al; // カウント数 | |
1256 cl = *si; | |
1257 PSGSetReg(&(opna.psg), 4, *si++); // 周波数セット | |
1258 ch = *si; | |
1259 PSGSetReg(&(opna.psg), 5, *si++); // 周波数セット | |
1260 effwork.eswthz = (ch << 8) + cl; | |
1261 | |
1262 open_work.psnoi_last = effwork.eswnhz = *si; | |
1263 PSGSetReg(&(opna.psg), 6, *si++); // ノイズ | |
1264 | |
1265 PSGSetReg(&(opna.psg), 7, ((*si++ << 2) & 0x24) | (PSGGetReg(&(opna.psg), 0x07) & 0xdb)); | |
1266 | |
1267 PSGSetReg(&(opna.psg), 10, *si++); // ボリューム | |
1268 PSGSetReg(&(opna.psg), 11, *si++); // エンベロープ周波数 | |
1269 PSGSetReg(&(opna.psg), 12, *si++); // | |
1270 PSGSetReg(&(opna.psg), 13, *si++); // エンベロープPATTERN | |
1271 | |
1272 effwork.eswtst = *si++; // スイープ増分 (TONE) | |
1273 effwork.eswnst = *si++; // スイープ増分 (NOISE) | |
1274 | |
1275 effwork.eswnct = effwork.eswnst & 15; // スイープカウント (NOISE) | |
1276 | |
1277 effwork.effadr = (int *)si; | |
1278 } | |
1279 } | |
1280 | |
1281 | |
1282 void PMDWIN::effend(void) | |
1283 { | |
1284 PSGSetReg(&(opna.psg), 0x0a, 0x00); | |
1285 PSGSetReg(&(opna.psg), 0x07, ((PSGGetReg(&(opna.psg), 0x07)) & 0xdb) | 0x24); | |
1286 effwork.effon = 0; | |
1287 effwork.psgefcnum = -1; | |
1288 } | |
1289 | |
1290 | |
1291 // 普段の処理 | |
1292 void PMDWIN::effsweep(void) | |
1293 { | |
1294 int dl; | |
1295 | |
1296 effwork.eswthz += effwork.eswtst; | |
1297 PSGSetReg(&(opna.psg), 4, effwork.eswthz & 0xff); | |
1298 PSGSetReg(&(opna.psg), 5, effwork.eswthz >> 8); | |
1299 | |
1300 if(effwork.eswnst == 0) return; // ノイズスイープ無し | |
1301 if(--effwork.eswnct) return; | |
1302 | |
1303 dl = effwork.eswnst; | |
1304 effwork.eswnct = dl & 15; | |
1305 | |
1306 effwork.eswnhz += dl / 16; | |
1307 | |
1308 PSGSetReg(&(opna.psg), 6, effwork.eswnhz); | |
1309 open_work.psnoi_last = effwork.eswnhz; | |
1310 } | |
1311 | |
1312 | |
1313 //============================================================================= | |
1314 // SSGドラムを消してSSGを復活させるかどうかcheck | |
1315 // input AL <- Command | |
1316 // output cy=1 : 復活させる | |
1317 //============================================================================= | |
1318 int PMDWIN::ssgdrum_check(QQ *qq, int al) | |
1319 { | |
1320 // SSGマスク中はドラムを止めない | |
1321 // SSGドラムは鳴ってない | |
1322 if((qq->partmask & 1) || ((qq->partmask & 2) == 0)) return 0; | |
1323 | |
1324 // 普通の効果音は消さない | |
1325 if(effwork.effon >= 2) return 0; | |
1326 | |
1327 al = (al & 0x0f); | |
1328 | |
1329 // 休符の時はドラムは止めない | |
1330 if(al == 0x0f) return 0; | |
1331 | |
1332 // SSGドラムはまだ再生中か? | |
1333 if(effwork.effon == 1) { | |
1334 effend(); // SSGドラムを消す | |
1335 } | |
1336 | |
1337 if((qq->partmask &= 0xfd) == 0) return -1; | |
1338 return 0; | |
1339 } | |
1340 | |
1341 | |
1342 //============================================================================= | |
1343 // 各種特殊コマンド処理 | |
1344 //============================================================================= | |
1345 uchar * PMDWIN::commands(QQ *qq, uchar *si) | |
1346 { | |
1347 int al; | |
1348 | |
1349 al = *si++; | |
1350 switch(al) { | |
1351 case 0xff : si = comat(qq, si); break; | |
1352 case 0xfe : qq->qdata = *si++; qq->qdat3 = 0; break; | |
1353 case 0xfd : qq->volume = *si++; break; | |
1354 case 0xfc : si = comt(si); break; | |
1355 | |
1356 case 0xfb : pmdwork.tieflag |= 1; break; | |
1357 case 0xfa : qq->detune = *(short *)si; si+=2; break; | |
1358 case 0xf9 : si = comstloop(qq, si); break; | |
1359 case 0xf8 : si = comedloop(qq, si); break; | |
1360 case 0xf7 : si = comexloop(qq, si); break; | |
1361 case 0xf6 : qq->partloop = si; break; | |
1362 case 0xf5 : qq->shift = *(char *)si++; break; | |
1363 case 0xf4 : if((qq->volume+=4) > 127) qq->volume = 127; break; | |
1364 case 0xf3 : if(qq->volume < 4) qq->volume=0; else qq->volume-=4; break; | |
1365 case 0xf2 : si = lfoset(qq, si); break; | |
1366 case 0xf1 : si = lfoswitch(qq, si); ch3_setting(qq); break; | |
1367 case 0xf0 : si+=4; break; | |
1368 | |
1369 case 0xef : OPNASetReg(&opna, pmdwork.fmsel + *si, *(si+1)); si+=2; break; | |
1370 case 0xee : si++; break; | |
1371 case 0xed : si++; break; | |
1372 case 0xec : si = panset(qq, si); break; // FOR SB2 | |
1373 case 0xeb : si = rhykey(si); break; | |
1374 case 0xea : si = rhyvs(si); break; | |
1375 case 0xe9 : si = rpnset(si); break; | |
1376 case 0xe8 : si = rmsvs(si); break; | |
1377 // | |
1378 case 0xe7 : qq->shift += *(char *)si++; break; | |
1379 case 0xe6 : si = rmsvs_sft(si); break; | |
1380 case 0xe5 : si = rhyvs_sft(si); break; | |
1381 // | |
1382 case 0xe4 : qq->hldelay = *si++; break; | |
1383 //追加 for V2.3 | |
1384 case 0xe3 : if((qq->volume += *si++) > 127) qq->volume = 127; break; | |
1385 case 0xe2 : | |
1386 if(qq->volume < *si) qq->volume = 0; else qq->volume -= *si; | |
1387 si++; | |
1388 break; | |
1389 // | |
1390 case 0xe1 : si = hlfo_set(qq, si); break; | |
1391 case 0xe0 : open_work.port22h = *si; OPNASetReg(&opna, 0x22, *si++); break; | |
1392 // | |
1393 case 0xdf : open_work.syousetu_lng = *si++; break; | |
1394 // | |
1395 case 0xde : si = vol_one_up_fm(qq, si); break; | |
1396 case 0xdd : si = vol_one_down(qq, si); break; | |
1397 // | |
1398 case 0xdc : open_work.status = *si++; break; | |
1399 case 0xdb : open_work.status += *si++; break; | |
1400 // | |
1401 case 0xda : si = porta(qq, si); break; | |
1402 // | |
1403 case 0xd9 : si++; break; | |
1404 case 0xd8 : si++; break; | |
1405 case 0xd7 : si++; break; | |
1406 // | |
1407 case 0xd6 : qq->mdspd = qq->mdspd2 = *si++; qq->mdepth = *(char *)si++; break; | |
1408 case 0xd5 : qq->detune += *(short *)si; si+=2; break; | |
1409 // | |
1410 case 0xd4 : si++; break; | |
1411 case 0xd3 : si++; break; | |
1412 case 0xd2 : | |
1413 si++; | |
1414 break; | |
1415 // | |
1416 case 0xd1 : si++; break; | |
1417 case 0xd0 : si++; break; | |
1418 // | |
1419 case 0xcf : si = slotmask_set(qq, si); break; | |
1420 case 0xce : si+=6; break; | |
1421 case 0xcd : si+=5; break; | |
1422 case 0xcc : si++; break; | |
1423 case 0xcb : qq->lfo_wave = *si++; break; | |
1424 case 0xca : | |
1425 qq->extendmode = (qq->extendmode & 0xfd) | ((*si++ & 1) << 1); | |
1426 break; | |
1427 | |
1428 case 0xc9 : si++; break; | |
1429 case 0xc8 : si = slotdetune_set(qq, si); break; | |
1430 case 0xc7 : si = slotdetune_set2(qq, si); break; | |
1431 case 0xc6 : break; | |
1432 case 0xc5 : si = volmask_set(qq, si); break; | |
1433 case 0xc4 : qq->qdatb = *si++; break; | |
1434 case 0xc3 : si = panset_ex(qq, si); break; | |
1435 case 0xc2 : qq->delay = qq->delay2 = *si++; lfoinit_main(qq); break; | |
1436 case 0xc1 : break; | |
1437 case 0xc0 : si = fm_mml_part_mask(qq, si); break; | |
1438 case 0xbf : lfo_change(qq); si = lfoset(qq, si); lfo_change(qq);break; | |
1439 case 0xbe : si = _lfoswitch(qq, si); ch3_setting(qq); break; | |
1440 case 0xbd : | |
1441 lfo_change(qq); | |
1442 qq->mdspd = qq->mdspd2 = *si++; | |
1443 qq->mdepth = *(char *)si++; | |
1444 lfo_change(qq); | |
1445 break; | |
1446 | |
1447 case 0xbc : lfo_change(qq); qq->lfo_wave=*si++; lfo_change(qq); break; | |
1448 case 0xbb : | |
1449 lfo_change(qq); | |
1450 qq->extendmode = (qq->extendmode & 0xfd) | ((*si++ & 1) << 1); | |
1451 lfo_change(qq); | |
1452 break; | |
1453 | |
1454 case 0xba : si = _volmask_set(qq, si); break; | |
1455 case 0xb9 : | |
1456 lfo_change(qq); | |
1457 qq->delay = qq->delay2 = *si++; lfoinit_main(qq); | |
1458 lfo_change(qq); | |
1459 break; | |
1460 | |
1461 case 0xb8 : si = tl_set(qq, si); break; | |
1462 case 0xb7 : si = mdepth_count(qq, si); break; | |
1463 case 0xb6 : si = fb_set(qq, si); break; | |
1464 case 0xb5 : | |
1465 qq->sdelay_m = (~(*si++) << 4) & 0xf0; | |
1466 qq->sdelay_c = qq->sdelay = *si++; | |
1467 break; | |
1468 | |
1469 case 0xb4 : si+=16; break; | |
1470 case 0xb3 : qq->qdat2 = *si++; break; | |
1471 case 0xb2 : qq->shift_def = *(char *)si++; break; | |
1472 case 0xb1 : qq->qdat3 = *si++; break; | |
1473 | |
1474 default : | |
1475 si--; | |
1476 *si = 0x80; | |
1477 } | |
1478 | |
1479 return si; | |
1480 } | |
1481 | |
1482 | |
1483 uchar * PMDWIN::commandsp(QQ *qq, uchar *si) | |
1484 { | |
1485 int al; | |
1486 | |
1487 al = *si++; | |
1488 switch(al) { | |
1489 case 0xff : si++; break; | |
1490 case 0xfe : qq->qdata = *si++; qq->qdat3 = 0; break; | |
1491 case 0xfd : qq->volume = *si++; break; | |
1492 case 0xfc : si = comt(si); break; | |
1493 | |
1494 case 0xfb : pmdwork.tieflag |= 1; break; | |
1495 case 0xfa : qq->detune = *(short *)si; si+=2; break; | |
1496 case 0xf9 : si = comstloop(qq, si); break; | |
1497 case 0xf8 : si = comedloop(qq, si); break; | |
1498 case 0xf7 : si = comexloop(qq, si); break; | |
1499 case 0xf6 : qq->partloop = si; break; | |
1500 case 0xf5 : qq->shift = *(char *)si++; break; | |
1501 case 0xf4 : if(qq->volume < 15) qq->volume++; break; | |
1502 case 0xf3 : if(qq->volume > 0) qq->volume--; break; | |
1503 case 0xf2 : si = lfoset(qq, si); break; | |
1504 case 0xf1 : si = lfoswitch(qq, si); break; | |
1505 case 0xf0 : si = psgenvset(qq, si); break; | |
1506 | |
1507 case 0xef : OPNASetReg(&opna, *si, *(si+1)); si+=2; break; | |
1508 case 0xee : open_work.psnoi = *si++; break; | |
1509 case 0xed : qq->psgpat = *si++; break; | |
1510 // | |
1511 case 0xec : si++; break; | |
1512 case 0xeb : si = rhykey(si); break; | |
1513 case 0xea : si = rhyvs(si); break; | |
1514 case 0xe9 : si = rpnset(si); break; | |
1515 case 0xe8 : si = rmsvs(si); break; | |
1516 // | |
1517 case 0xe7 : qq->shift += *(char *)si++; break; | |
1518 case 0xe6 : si = rmsvs_sft(si); break; | |
1519 case 0xe5 : si = rhyvs_sft(si); break; | |
1520 // | |
1521 case 0xe4 : si++; break; | |
1522 //追加 for V2.3 | |
1523 case 0xe3 : if((qq->volume + *si) < 16) qq->volume += *si; si++;break; | |
1524 case 0xe2 : if((qq->volume - *si) >= 0) qq->volume -= *si; si++;break; | |
1525 // | |
1526 case 0xe1 : si++; break; | |
1527 case 0xe0 : si++; break; | |
1528 // | |
1529 case 0xdf : open_work.syousetu_lng = *si++; break; | |
1530 // | |
1531 case 0xde : si = vol_one_up_psg(qq, si); break; | |
1532 case 0xdd : si = vol_one_down(qq, si); break; | |
1533 // | |
1534 case 0xdc : open_work.status = *si++; break; | |
1535 case 0xdb : open_work.status += *si++; break; | |
1536 // | |
1537 case 0xda : si = portap(qq, si); break; | |
1538 // | |
1539 case 0xd9 : si++; break; | |
1540 case 0xd8 : si++; break; | |
1541 case 0xd7 : si++; break; | |
1542 // | |
1543 case 0xd6 : qq->mdspd = qq->mdspd2 = *si++; qq->mdepth = *(char *)si++; break; | |
1544 case 0xd5 : qq->detune += *(short *)si; si+=2; break; | |
1545 // | |
1546 case 0xd4 : si++; break; | |
1547 case 0xd3 : si++; break; | |
1548 case 0xd2 : | |
1549 si++; | |
1550 break; | |
1551 // | |
1552 case 0xd1 : si++; break; | |
1553 case 0xd0 : si = psgnoise_move(si); break; | |
1554 // | |
1555 case 0xcf : si++; break; | |
1556 case 0xce : si+=6; break; | |
1557 case 0xcd : si = extend_psgenvset(qq, si); break; | |
1558 case 0xcc : | |
1559 qq->extendmode = (qq->extendmode & 0xfe) | (*si++ & 1); | |
1560 break; | |
1561 | |
1562 case 0xcb : qq->lfo_wave = *si++; break; | |
1563 case 0xca : | |
1564 qq->extendmode = (qq->extendmode & 0xfd) | ((*si++ & 1) << 1); | |
1565 break; | |
1566 | |
1567 case 0xc9 : | |
1568 qq->extendmode = (qq->extendmode & 0xfb) | ((*si++ & 1) << 2); | |
1569 break; | |
1570 | |
1571 case 0xc8 : si+=3; break; | |
1572 case 0xc7 : si+=3; break; | |
1573 case 0xc6 : si+=6; break; | |
1574 case 0xc5 : si++; break; | |
1575 case 0xc4 : qq->qdatb = *si++; break; | |
1576 case 0xc3 : si+=2; break; | |
1577 case 0xc2 : qq->delay = qq->delay2 = *si++; lfoinit_main(qq); break; | |
1578 case 0xc1 : break; | |
1579 case 0xc0 : si = ssg_mml_part_mask(qq, si); break; | |
1580 case 0xbf : lfo_change(qq); si = lfoset(qq, si); lfo_change(qq);break; | |
1581 case 0xbe : | |
1582 qq->lfoswi = (qq->lfoswi & 0x8f) | ((*si++ & 7) << 4); | |
1583 lfo_change(qq); lfoinit_main(qq); lfo_change(qq); | |
1584 break; | |
1585 | |
1586 case 0xbd : | |
1587 lfo_change(qq); | |
1588 qq->mdspd = qq->mdspd2 = *si++; | |
1589 qq->mdepth = *(char *)si++; | |
1590 lfo_change(qq); | |
1591 break; | |
1592 | |
1593 case 0xbc : lfo_change(qq); qq->lfo_wave=*si++; lfo_change(qq); break; | |
1594 case 0xbb : | |
1595 lfo_change(qq); | |
1596 qq->extendmode = (qq->extendmode & 0xfd) | ((*si++ & 1) << 1); | |
1597 lfo_change(qq); | |
1598 break; | |
1599 | |
1600 case 0xba : si++; break; | |
1601 case 0xb9 : | |
1602 lfo_change(qq); | |
1603 qq->delay = qq->delay2 = *si++; lfoinit_main(qq); break; | |
1604 lfo_change(qq); | |
1605 break; | |
1606 | |
1607 case 0xb8 : si+=2; break; | |
1608 case 0xb7 : si = mdepth_count(qq, si); break; | |
1609 case 0xb6 : si++; break; | |
1610 case 0xb5 : si+= 2; break; | |
1611 case 0xb4 : si+=16; break; | |
1612 case 0xb3 : qq->qdat2 = *si++; break; | |
1613 case 0xb2 : qq->shift_def = *(char *)si++; break; | |
1614 case 0xb1 : qq->qdat3 = *si++; break; | |
1615 | |
1616 default : | |
1617 si--; | |
1618 *si = 0x80; | |
1619 } | |
1620 | |
1621 return si; | |
1622 } | |
1623 | |
1624 | |
1625 uchar * PMDWIN::commandsr(QQ *qq, uchar *si) | |
1626 { | |
1627 int al; | |
1628 | |
1629 al = *si++; | |
1630 switch(al) { | |
1631 case 0xff : si++; break; | |
1632 case 0xfe : si++; break; | |
1633 case 0xfd : qq->volume = *si++; break; | |
1634 case 0xfc : si = comt(si); break; | |
1635 | |
1636 case 0xfb : pmdwork.tieflag |= 1; break; | |
1637 case 0xfa : qq->detune = *(short *)si; si+=2; break; | |
1638 case 0xf9 : si = comstloop(qq, si); break; | |
1639 case 0xf8 : si = comedloop(qq, si); break; | |
1640 case 0xf7 : si = comexloop(qq, si); break; | |
1641 case 0xf6 : qq->partloop = si; break; | |
1642 case 0xf5 : si++; break; | |
1643 case 0xf4 : if(qq->volume < 15) qq->volume++; break; | |
1644 case 0xf3 : if(qq->volume > 0) qq->volume--; break; | |
1645 case 0xf2 : si+=4; break; | |
1646 case 0xf1 : si++; break; | |
1647 case 0xf0 : si+=4; break; | |
1648 | |
1649 case 0xef : OPNASetReg(&opna, *si, *(si+1)); si+=2; break; | |
1650 case 0xee : si++; break; | |
1651 case 0xed : si++; break; | |
1652 // | |
1653 case 0xec : si++; break; | |
1654 case 0xeb : si = rhykey(si); break; | |
1655 case 0xea : si = rhyvs(si); break; | |
1656 case 0xe9 : si = rpnset(si); break; | |
1657 case 0xe8 : si = rmsvs(si); break; | |
1658 // | |
1659 case 0xe7 : si++; break; | |
1660 case 0xe6 : si = rmsvs_sft(si); break; | |
1661 case 0xe5 : si = rhyvs_sft(si); break; | |
1662 // | |
1663 case 0xe4 : si++; break; | |
1664 //追加 for V2.3 | |
1665 case 0xe3 : if((qq->volume + *si) < 16) qq->volume += *si; si++;break; | |
1666 case 0xe2 : if((qq->volume - *si) >= 0) qq->volume -= *si; si++;break; | |
1667 // | |
1668 case 0xe1 : si++; break; | |
1669 case 0xe0 : si++; break; | |
1670 // | |
1671 case 0xdf : open_work.syousetu_lng = *si++; break; | |
1672 // | |
1673 case 0xde : si = vol_one_up_psg(qq, si); break; | |
1674 case 0xdd : si = vol_one_down(qq, si); break; | |
1675 // | |
1676 case 0xdc : open_work.status = *si++; break; | |
1677 case 0xdb : open_work.status += *si++; break; | |
1678 // | |
1679 case 0xda : si++; break; | |
1680 // | |
1681 case 0xd9 : si++; break; | |
1682 case 0xd8 : si++; break; | |
1683 case 0xd7 : si++; break; | |
1684 // | |
1685 case 0xd6 : si+=2; break; | |
1686 case 0xd5 : qq->detune += *(short *)si; si+=2; break; | |
1687 // | |
1688 case 0xd4 : si++; break; | |
1689 case 0xd3 : si++; break; | |
1690 case 0xd2 : | |
1691 si++; | |
1692 break; | |
1693 // | |
1694 case 0xd1 : si++; break; | |
1695 case 0xd0 : si++; break; | |
1696 // | |
1697 case 0xcf : si++; break; | |
1698 case 0xce : si+=6; break; | |
1699 case 0xcd : si+=5; break; | |
1700 case 0xcc : si++; break; | |
1701 case 0xcb : si++; break; | |
1702 case 0xca : si++; break; | |
1703 case 0xc9 : si++; break; | |
1704 case 0xc8 : si+=3; break; | |
1705 case 0xc7 : si+=3; break; | |
1706 case 0xc6 : si+=6; break; | |
1707 case 0xc5 : si++; break; | |
1708 case 0xc4 : si++; break; | |
1709 case 0xc3 : si+=2; break; | |
1710 case 0xc2 : si++; break; | |
1711 case 0xc1 : break; | |
1712 case 0xc0 : si = rhythm_mml_part_mask(qq, si); break; | |
1713 case 0xbf : si+=4; break; | |
1714 case 0xbe : si++; break; | |
1715 case 0xbd : si+=2; break; | |
1716 case 0xbc : si++; break; | |
1717 case 0xbb : si++; break; | |
1718 case 0xba : si++; break; | |
1719 case 0xb9 : si++; break; | |
1720 case 0xb8 : si+=2; break; | |
1721 case 0xb7 : si++; break; | |
1722 case 0xb6 : si++; break; | |
1723 case 0xb5 : si+= 2; break; | |
1724 case 0xb4 : si+=16; break; | |
1725 case 0xb3 : si++; break; | |
1726 case 0xb2 : si++; break; | |
1727 case 0xb1 : si++; break; | |
1728 | |
1729 default : | |
1730 si--; | |
1731 *si = 0x80; | |
1732 } | |
1733 | |
1734 return si; | |
1735 } | |
1736 | |
1737 //============================================================================= | |
1738 // COMMAND '@' [PROGRAM CHANGE] | |
1739 //============================================================================= | |
1740 uchar * PMDWIN::comat(QQ *qq, uchar *si) | |
1741 { | |
1742 uchar *bx; | |
1743 int al, dl; | |
1744 | |
1745 qq->voicenum = al = *si++; | |
1746 dl = qq->voicenum; | |
1747 | |
1748 if(qq->partmask == 0) { // パートマスクされているか? | |
1749 neiroset(qq, dl); | |
1750 return si; | |
1751 } else { | |
1752 bx = toneadr_calc(qq, dl); | |
1753 qq->alg_fb = dl = bx[24]; | |
1754 bx += 4; | |
1755 | |
1756 // tl設定 | |
1757 qq->slot1 = bx[0]; | |
1758 qq->slot3 = bx[1]; | |
1759 qq->slot2 = bx[2]; | |
1760 qq->slot4 = bx[3]; | |
1761 | |
1762 // FM3chで、マスクされていた場合、fm3_alg_fbを設定 | |
1763 if(pmdwork.partb == 3 && qq->neiromask) { | |
1764 if(pmdwork.fmsel == 0) { | |
1765 // in. dl = alg/fb | |
1766 if((qq->slotmask & 0x10) == 0) { | |
1767 al = pmdwork.fm3_alg_fb & 0x38; // fbは前の値を使用 | |
1768 dl = (dl & 7) | al; | |
1769 } | |
1770 | |
1771 pmdwork.fm3_alg_fb = dl; | |
1772 qq->alg_fb = al; | |
1773 } | |
1774 } | |
1775 | |
1776 } | |
1777 return si; | |
1778 } | |
1779 | |
1780 //============================================================================= | |
1781 // 音色の設定 | |
1782 // INPUTS -- [PARTB] | |
1783 // -- dl [TONE_NUMBER] | |
1784 // -- di [PART_DATA_ADDRESS] | |
1785 //============================================================================= | |
1786 void PMDWIN::neiroset(QQ *qq, int dl) | |
1787 { | |
1788 uchar *bx; | |
1789 int ah, al, dh; | |
1790 | |
1791 bx = toneadr_calc(qq, dl); | |
1792 if(silence_fmpart(qq)) { | |
1793 // neiromask=0の時 (TLのworkのみ設定) | |
1794 bx += 4; | |
1795 | |
1796 // tl設定 | |
1797 qq->slot1 = bx[0]; | |
1798 qq->slot3 = bx[1]; | |
1799 qq->slot2 = bx[2]; | |
1800 qq->slot4 = bx[3]; | |
1801 return; | |
1802 } | |
1803 | |
1804 //========================================================================= | |
1805 // 音色設定メイン | |
1806 //========================================================================= | |
1807 //------------------------------------------------------------------------- | |
1808 // AL/FBを設定 | |
1809 //------------------------------------------------------------------------- | |
1810 | |
1811 dh = 0xb0 - 1 + pmdwork.partb; | |
1812 | |
1813 if(pmdwork.af_check) { // ALG/FBは設定しないmodeか? | |
1814 dl = qq->alg_fb; | |
1815 } else { | |
1816 dl = bx[24]; | |
1817 } | |
1818 | |
1819 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
1820 if(pmdwork.af_check != 0) { // ALG/FBは設定しないmodeか? | |
1821 dl = pmdwork.fm3_alg_fb; | |
1822 } else { | |
1823 if((qq->slotmask & 0x10) == 0) { // slot1を使用しているか? | |
1824 dl = (pmdwork.fm3_alg_fb & 0x38) | (dl & 7); | |
1825 } | |
1826 pmdwork.fm3_alg_fb = dl; | |
1827 } | |
1828 } | |
1829 | |
1830 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1831 qq->alg_fb = dl; | |
1832 dl &= 7; // dl = algo | |
1833 | |
1834 //------------------------------------------------------------------------- | |
1835 // Carrierの位置を調べる (VolMaskにも設定) | |
1836 //------------------------------------------------------------------------- | |
1837 | |
1838 if((qq->volmask & 0x0f) == 0) { | |
1839 qq->volmask = carrier_table[dl]; | |
1840 } | |
1841 | |
1842 if((qq->_volmask & 0x0f) == 0) { | |
1843 qq->_volmask = carrier_table[dl]; | |
1844 } | |
1845 | |
1846 qq->carrier = carrier_table[dl]; | |
1847 ah = carrier_table[dl+8]; // slot2/3の逆転データ(not済み) | |
1848 al = qq->neiromask; | |
1849 ah &= al; // AH=TL用のmask / AL=その他用のmask | |
1850 | |
1851 //------------------------------------------------------------------------- | |
1852 // 各音色パラメータを設定 (TLはモジュレータのみ) | |
1853 //------------------------------------------------------------------------- | |
1854 | |
1855 dh = 0x30 - 1 + pmdwork.partb; | |
1856 dl = *bx++; // DT/ML | |
1857 if(al & 0x80) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1858 dh+=4; | |
1859 | |
1860 dl = *bx++; | |
1861 if(al & 0x40) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1862 dh+=4; | |
1863 | |
1864 dl = *bx++; | |
1865 if(al & 0x20) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1866 dh+=4; | |
1867 | |
1868 dl = *bx++; | |
1869 if(al & 0x10) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1870 dh+=4; | |
1871 | |
1872 dl = *bx++; // TL | |
1873 if(ah & 0x80) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1874 dh+=4; | |
1875 | |
1876 dl = *bx++; | |
1877 if(ah & 0x40) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1878 dh+=4; | |
1879 | |
1880 dl = *bx++; | |
1881 if(ah & 0x20) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1882 dh+=4; | |
1883 | |
1884 dl = *bx++; | |
1885 if(ah & 0x10) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1886 dh+=4; | |
1887 | |
1888 dl = *bx++; // KS/AR | |
1889 if(al & 0x08) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1890 dh+=4; | |
1891 | |
1892 dl = *bx++; | |
1893 if(al & 0x04) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1894 dh+=4; | |
1895 | |
1896 dl = *bx++; | |
1897 if(al & 0x02) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1898 dh+=4; | |
1899 | |
1900 dl = *bx++; | |
1901 if(al & 0x01) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1902 dh+=4; | |
1903 | |
1904 dl = *bx++; // AM/DR | |
1905 if(al & 0x80) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1906 dh+=4; | |
1907 | |
1908 dl = *bx++; | |
1909 if(al & 0x40) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1910 dh+=4; | |
1911 | |
1912 dl = *bx++; | |
1913 if(al & 0x20) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1914 dh+=4; | |
1915 | |
1916 dl = *bx++; | |
1917 if(al & 0x10) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1918 dh+=4; | |
1919 | |
1920 dl = *bx++; // SR | |
1921 if(al & 0x08) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1922 dh+=4; | |
1923 | |
1924 dl = *bx++; | |
1925 if(al & 0x04) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1926 dh+=4; | |
1927 | |
1928 dl = *bx++; | |
1929 if(al & 0x02) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1930 dh+=4; | |
1931 | |
1932 dl = *bx++; | |
1933 if(al & 0x01) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1934 dh+=4; | |
1935 | |
1936 dl = *bx++; // SL/RR | |
1937 if(al & 0x80) { | |
1938 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1939 } | |
1940 dh+=4; | |
1941 | |
1942 dl = *bx++; | |
1943 if(al & 0x40) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1944 dh+=4; | |
1945 | |
1946 dl = *bx++; | |
1947 if(al & 0x20) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1948 dh+=4; | |
1949 | |
1950 dl = *bx++; | |
1951 if(al & 0x10) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1952 dh+=4; | |
1953 | |
1954 /* | |
1955 dl = *bx++; // SL/RR | |
1956 if(al & 0x80) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1957 dh+=4; | |
1958 | |
1959 dl = *bx++; | |
1960 if(al & 0x40) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1961 dh+=4; | |
1962 | |
1963 dl = *bx++; | |
1964 if(al & 0x20) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1965 dh+=4; | |
1966 | |
1967 dl = *bx++; | |
1968 if(al & 0x10) OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
1969 dh+=4; | |
1970 */ | |
1971 | |
1972 //------------------------------------------------------------------------- | |
1973 // SLOT毎のTLをワークに保存 | |
1974 //------------------------------------------------------------------------- | |
1975 bx -= 20; | |
1976 qq->slot1 = bx[0]; | |
1977 qq->slot3 = bx[1]; | |
1978 qq->slot2 = bx[2]; | |
1979 qq->slot4 = bx[3]; | |
1980 } | |
1981 | |
1982 | |
1983 //============================================================================= | |
1984 // [PartB]のパートの音を完璧に消す (TL=127 and RR=15 and KEY-OFF) | |
1985 // cy=1 ・・・ 全スロットneiromaskされている | |
1986 //============================================================================= | |
1987 int PMDWIN::silence_fmpart(QQ *qq) | |
1988 { | |
1989 int dh; | |
1990 | |
1991 if(qq->neiromask == 0) { | |
1992 return 1; | |
1993 } | |
1994 | |
1995 dh = pmdwork.partb + 0x40 - 1; | |
1996 | |
1997 if(qq->neiromask & 0x80) { | |
1998 OPNASetReg(&opna, pmdwork.fmsel + dh, 127); | |
1999 OPNASetReg(&opna, (pmdwork.fmsel + 0x40) + dh, 127); | |
2000 } | |
2001 dh += 4; | |
2002 | |
2003 if(qq->neiromask & 0x40) { | |
2004 OPNASetReg(&opna, pmdwork.fmsel + dh, 127); | |
2005 OPNASetReg(&opna, pmdwork.fmsel + 0x40 + dh, 127); | |
2006 } | |
2007 dh += 4; | |
2008 | |
2009 if(qq->neiromask & 0x20) { | |
2010 OPNASetReg(&opna, pmdwork.fmsel + dh, 127); | |
2011 OPNASetReg(&opna, pmdwork.fmsel + 0x40 + dh, 127); | |
2012 } | |
2013 dh += 4; | |
2014 | |
2015 if(qq->neiromask & 0x10) { | |
2016 OPNASetReg(&opna, pmdwork.fmsel + dh, 127); | |
2017 OPNASetReg(&opna, pmdwork.fmsel + 0x40 + dh, 127); | |
2018 } | |
2019 | |
2020 kof1(qq); | |
2021 return 0; | |
2022 } | |
2023 | |
2024 | |
2025 //============================================================================= | |
2026 // TONE DATA START ADDRESS を計算 | |
2027 // input dl tone_number | |
2028 // output bx address | |
2029 //============================================================================= | |
2030 uchar * PMDWIN::toneadr_calc(QQ *qq, int dl) | |
2031 { | |
2032 uchar *bx; | |
2033 | |
2034 if(open_work.prg_flg == 0) { | |
2035 return NULL; | |
2036 //return open_work.tondat + (dl << 5); | |
2037 } else { | |
2038 bx = open_work.prgdat_adr; | |
2039 | |
2040 while(*bx != dl) { | |
2041 bx += 26; | |
2042 } | |
2043 | |
2044 return bx+1; | |
2045 } | |
2046 } | |
2047 | |
2048 | |
2049 //============================================================================= | |
2050 // FM音源ハードLFOの設定(V2.4拡張分) | |
2051 //============================================================================= | |
2052 uchar * PMDWIN::hlfo_set(QQ *qq, uchar *si) | |
2053 { | |
2054 qq->fmpan = (qq->fmpan & 0xc0) | *si++; | |
2055 | |
2056 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
2057 // 2608の時のみなので part_eはありえない | |
2058 // FM3の場合は 4つのパート総て設定 | |
2059 FMPart[2].fmpan = qq->fmpan; | |
2060 } | |
2061 | |
2062 if(qq->partmask == 0) { // パートマスクされているか? | |
2063 OPNASetReg(&opna, pmdwork.fmsel + pmdwork.partb + 0xb4 - 1, | |
2064 calc_panout(qq)); | |
2065 } | |
2066 return si; | |
2067 } | |
2068 | |
2069 | |
2070 //============================================================================= | |
2071 // ボリュームを次の一個だけ変更(V2.7拡張分) | |
2072 //============================================================================= | |
2073 uchar * PMDWIN::vol_one_up_fm(QQ *qq, uchar *si) | |
2074 { | |
2075 int al; | |
2076 | |
2077 al = (int)qq->volume + 1 + *si++; | |
2078 if(al > 128) al = 128; | |
2079 | |
2080 qq->volpush = al; | |
2081 pmdwork.volpush_flag = 1; | |
2082 return si; | |
2083 } | |
2084 | |
2085 | |
2086 //============================================================================= | |
2087 // ポルタメント(FM) | |
2088 //============================================================================= | |
2089 uchar * PMDWIN::porta(QQ *qq, uchar *si) | |
2090 { | |
2091 int ax, cx, cl, bx, bh; | |
2092 | |
2093 if(qq->partmask) { | |
2094 qq->fnum = 0; //休符に設定 | |
2095 qq->onkai = 255; | |
2096 qq->leng = *(si+2); | |
2097 qq->keyon_flag++; | |
2098 qq->address = si+3; | |
2099 | |
2100 if(--pmdwork.volpush_flag) { | |
2101 qq->volpush = 0; | |
2102 } | |
2103 | |
2104 pmdwork.tieflag = 0; | |
2105 pmdwork.volpush_flag = 0; | |
2106 pmdwork.loop_work &= qq->loopcheck; | |
2107 | |
2108 return si+3; // 読み飛ばす (Mask時) | |
2109 } | |
2110 | |
2111 lfoinit(qq, *si); | |
2112 fnumset(qq, oshift(qq, *si++)); | |
2113 | |
2114 cx = qq->fnum; | |
2115 cl = qq->onkai; | |
2116 fnumset(qq, oshift(qq, *si++)); | |
2117 bx = qq->fnum; // bx=ポルタメント先のfnum値 | |
2118 qq->onkai = cl; | |
2119 qq->fnum = cx; // cx=ポルタメント元のfnum値 | |
2120 | |
2121 bh = (int)((bx / 256) & 0x38) - ((cx / 256) & 0x38); // 先のoctarb - 元のoctarb | |
2122 if(bh) { | |
2123 bh /= 8; | |
2124 ax = bh * 0x26a; // ax = 26ah * octarb差 | |
2125 } else { | |
2126 ax = 0; | |
2127 } | |
2128 | |
2129 bx = (bx & 0x7ff) - (cx & 0x7ff); | |
2130 ax += bx; // ax=26ah*octarb差 + 音程差 | |
2131 | |
2132 qq->leng = *si++; | |
2133 si = calc_q(qq, si); | |
2134 | |
2135 qq->porta_num2 = ax / qq->leng; // 商 | |
2136 qq->porta_num3 = ax % qq->leng; // 余り | |
2137 qq->lfoswi |= 8; // Porta ON | |
2138 | |
2139 if(qq->volpush && qq->onkai != 255) { | |
2140 if(--pmdwork.volpush_flag) { | |
2141 pmdwork.volpush_flag = 0; | |
2142 qq->volpush = 0; | |
2143 } | |
2144 } | |
2145 | |
2146 volset(qq); | |
2147 otodasi(qq); | |
2148 keyon(qq); | |
2149 | |
2150 qq->keyon_flag++; | |
2151 qq->address = si; | |
2152 | |
2153 pmdwork.tieflag = 0; | |
2154 pmdwork.volpush_flag = 0; | |
2155 | |
2156 if(*si == 0xfb) { // '&'が直後にあったらkeyoffしない | |
2157 qq->keyoff_flag = 2; | |
2158 } else { | |
2159 qq->keyoff_flag = 0; | |
2160 } | |
2161 pmdwork.loop_work &= qq->loopcheck; | |
2162 return si; | |
2163 } | |
2164 | |
2165 | |
2166 //============================================================================= | |
2167 // FM slotmask set | |
2168 //============================================================================= | |
2169 uchar * PMDWIN::slotmask_set(QQ *qq, uchar *si) | |
2170 { | |
2171 uchar *bx; | |
2172 int ah, al, bl; | |
2173 | |
2174 ah = al = *si++; | |
2175 | |
2176 if(al &= 0x0f) { | |
2177 qq->carrier = al << 4; | |
2178 } else { | |
2179 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
2180 bl = pmdwork.fm3_alg_fb; | |
2181 } else { | |
2182 bx = toneadr_calc(qq, qq->voicenum); | |
2183 bl = bx[24]; | |
2184 } | |
2185 qq->carrier = carrier_table[bl & 7]; | |
2186 } | |
2187 | |
2188 ah &= 0xf0; | |
2189 if(qq->slotmask != ah) { | |
2190 qq->slotmask = ah; | |
2191 if((ah & 0xf0) == 0) { | |
2192 qq->partmask |= 0x20; // s0の時パートマスク | |
2193 } else { | |
2194 qq->partmask &= 0xdf; // s0以外の時パートマスク解除 | |
2195 } | |
2196 | |
2197 if(ch3_setting(qq)) { // FM3chの場合のみ ch3modeの変更処理 | |
2198 // ch3なら、それ以前のFM3パートでkeyon処理 | |
2199 if(qq != &FMPart[2]) { | |
2200 if(FMPart[2].partmask == 0 && | |
2201 (FMPart[2].keyoff_flag & 1) == 0) { | |
2202 keyon(&FMPart[2]); | |
2203 } | |
2204 } | |
2205 } | |
2206 | |
2207 ah = 0; | |
2208 if(qq->slotmask & 0x80) ah += 0x11; // slot4 | |
2209 if(qq->slotmask & 0x40) ah += 0x44; // slot3 | |
2210 if(qq->slotmask & 0x20) ah += 0x22; // slot2 | |
2211 if(qq->slotmask & 0x10) ah += 0x88; // slot1 | |
2212 qq->neiromask = ah; | |
2213 } | |
2214 return si; | |
2215 } | |
2216 | |
2217 | |
2218 //============================================================================= | |
2219 // Slot Detune Set | |
2220 //============================================================================= | |
2221 uchar * PMDWIN::slotdetune_set(QQ *qq, uchar *si) | |
2222 { | |
2223 int ax, bl; | |
2224 | |
2225 if(pmdwork.partb != 3 || pmdwork.fmsel) { | |
2226 return si+3; | |
2227 } | |
2228 | |
2229 bl = *si++; | |
2230 ax = *(short *)si; | |
2231 si+=2; | |
2232 | |
2233 if(bl & 1) { | |
2234 open_work.slot_detune1 = ax; | |
2235 } | |
2236 | |
2237 if(bl & 2) { | |
2238 open_work.slot_detune2 = ax; | |
2239 } | |
2240 | |
2241 if(bl & 4) { | |
2242 open_work.slot_detune3 = ax; | |
2243 } | |
2244 | |
2245 if(bl & 8) { | |
2246 open_work.slot_detune4 = ax; | |
2247 } | |
2248 | |
2249 if(open_work.slot_detune1 || open_work.slot_detune2 || | |
2250 open_work.slot_detune3 || open_work.slot_detune4) { | |
2251 pmdwork.slotdetune_flag = 1; | |
2252 } else { | |
2253 pmdwork.slotdetune_flag = 0; | |
2254 open_work.slot_detune1 = 0; | |
2255 } | |
2256 ch3mode_set(qq); | |
2257 return si; | |
2258 } | |
2259 | |
2260 | |
2261 //============================================================================= | |
2262 // Slot Detune Set(相対) | |
2263 //============================================================================= | |
2264 uchar * PMDWIN::slotdetune_set2(QQ *qq, uchar *si) | |
2265 { | |
2266 int ax, bl; | |
2267 | |
2268 if(pmdwork.partb != 3 || pmdwork.fmsel) { | |
2269 return si+3; | |
2270 } | |
2271 | |
2272 bl = *si++; | |
2273 ax = *(short *)si; | |
2274 si+=2; | |
2275 | |
2276 if(bl & 1) { | |
2277 open_work.slot_detune1 += ax; | |
2278 } | |
2279 | |
2280 if(bl & 2) { | |
2281 open_work.slot_detune2 += ax; | |
2282 } | |
2283 | |
2284 if(bl & 4) { | |
2285 open_work.slot_detune3 += ax; | |
2286 } | |
2287 | |
2288 if(bl & 8) { | |
2289 open_work.slot_detune4 += ax; | |
2290 } | |
2291 | |
2292 if(open_work.slot_detune1 || open_work.slot_detune2 || | |
2293 open_work.slot_detune3 || open_work.slot_detune4) { | |
2294 pmdwork.slotdetune_flag = 1; | |
2295 } else { | |
2296 pmdwork.slotdetune_flag = 0; | |
2297 open_work.slot_detune1 = 0; | |
2298 } | |
2299 ch3mode_set(qq); | |
2300 return si; | |
2301 } | |
2302 | |
2303 | |
2304 //============================================================================= | |
2305 // 音量マスクslotの設定 | |
2306 //============================================================================= | |
2307 uchar * PMDWIN::volmask_set(QQ *qq, uchar *si) | |
2308 { | |
2309 int al; | |
2310 | |
2311 al = *si++ & 0x0f; | |
2312 if(al) { | |
2313 al = (al << 4) | 0x0f; | |
2314 qq->volmask = al; | |
2315 } else { | |
2316 qq->volmask = qq->carrier; | |
2317 } | |
2318 ch3_setting(qq); | |
2319 return si; | |
2320 } | |
2321 | |
2322 | |
2323 //============================================================================= | |
2324 // 0c0hの追加special命令 | |
2325 //============================================================================= | |
2326 uchar * PMDWIN::special_0c0h(QQ *qq, uchar *si, uchar al) | |
2327 { | |
2328 switch(al) { | |
2329 case 0xff : open_work.fm_voldown = *si++; break; | |
2330 case 0xfe : si = _vd_fm(qq, si); break; | |
2331 case 0xfd : open_work.ssg_voldown = *si++; break; | |
2332 case 0xfc : si = _vd_ssg(qq, si); break; | |
2333 case 0xfb : si++; break; | |
2334 case 0xfa : si = NULL; break; | |
2335 case 0xf9 : open_work.rhythm_voldown = *si++; break; | |
2336 case 0xf8 : si = _vd_rhythm(qq, si); break; | |
2337 case 0xf7 : si++; break; | |
2338 case 0xf6 : si++; break; | |
2339 case 0xf5 : break; | |
2340 default : | |
2341 si--; | |
2342 *si = 0x80; | |
2343 } | |
2344 return si; | |
2345 } | |
2346 | |
2347 | |
2348 uchar * PMDWIN::_vd_fm(QQ *qq, uchar *si) | |
2349 { | |
2350 int al; | |
2351 | |
2352 al = *(char *)si++; | |
2353 if(al) { | |
2354 open_work.fm_voldown = Limit(al + open_work.fm_voldown, 255, 0); | |
2355 } else { | |
2356 open_work.fm_voldown = open_work._fm_voldown; | |
2357 } | |
2358 return si; | |
2359 } | |
2360 | |
2361 | |
2362 uchar * PMDWIN::_vd_ssg(QQ *qq, uchar *si) | |
2363 { | |
2364 int al; | |
2365 | |
2366 al = *(char *)si++; | |
2367 if(al) { | |
2368 open_work.ssg_voldown = Limit(al + open_work.ssg_voldown, 255, 0); | |
2369 } else { | |
2370 open_work.ssg_voldown = open_work._ssg_voldown; | |
2371 } | |
2372 return si; | |
2373 } | |
2374 | |
2375 | |
2376 uchar * PMDWIN::_vd_rhythm(QQ *qq, uchar *si) | |
2377 { | |
2378 int al; | |
2379 | |
2380 al = *(char *)si++; | |
2381 if(al) { | |
2382 open_work.rhythm_voldown = Limit(al + open_work.rhythm_voldown, 255, 0); | |
2383 } else { | |
2384 open_work.rhythm_voldown = open_work._rhythm_voldown; | |
2385 } | |
2386 return si; | |
2387 } | |
2388 | |
2389 | |
2390 //============================================================================= | |
2391 // 演奏中パートのマスクon/off | |
2392 //============================================================================= | |
2393 uchar * PMDWIN::fm_mml_part_mask(QQ *qq, uchar *si) | |
2394 { | |
2395 int al; | |
2396 | |
2397 al = *si++; | |
2398 if(al >= 2) { | |
2399 si = special_0c0h(qq, si, al); | |
2400 } else if(al) { | |
2401 qq->partmask |= 0x40; | |
2402 if(qq->partmask == 0x40) { | |
2403 silence_fmpart(qq); // 音消去 | |
2404 } | |
2405 } else { | |
2406 if((qq->partmask &= 0xbf) == 0) { | |
2407 neiro_reset(qq); // 音色再設定 | |
2408 } | |
2409 } | |
2410 return si; | |
2411 } | |
2412 | |
2413 | |
2414 uchar * PMDWIN::ssg_mml_part_mask(QQ *qq, uchar *si) | |
2415 { | |
2416 int ah, al; | |
2417 | |
2418 al = *si++; | |
2419 if(al >= 2) { | |
2420 si = special_0c0h(qq, si, al); | |
2421 } else if(al) { | |
2422 qq->partmask |= 0x40; | |
2423 if(qq->partmask == 0x40) { | |
2424 ah = ((1 << (pmdwork.partb-1)) | (4 << pmdwork.partb)); | |
2425 al = PSGGetReg(&(opna.psg), 0x07); | |
2426 PSGSetReg(&(opna.psg), 0x07, ah | al); // PSG keyoff | |
2427 } | |
2428 } else { | |
2429 qq->partmask &= 0xbf; | |
2430 } | |
2431 return si; | |
2432 } | |
2433 | |
2434 | |
2435 uchar * PMDWIN::rhythm_mml_part_mask(QQ *qq, uchar *si) | |
2436 { | |
2437 int al; | |
2438 | |
2439 al = *si++; | |
2440 if(al >= 2) { | |
2441 si = special_0c0h(qq, si, al); | |
2442 } else if(al) { | |
2443 qq->partmask |= 0x40; | |
2444 } else { | |
2445 qq->partmask &= 0xbf; | |
2446 } | |
2447 return si; | |
2448 } | |
2449 | |
2450 | |
2451 //============================================================================= | |
2452 // FM音源の音色を再設定 | |
2453 //============================================================================= | |
2454 void PMDWIN::neiro_reset(QQ *qq) | |
2455 { | |
2456 int dh, al, s1, s2, s3, s4; | |
2457 | |
2458 if(qq->neiromask == 0) return; | |
2459 | |
2460 s1 = qq->slot1; | |
2461 s2 = qq->slot2; | |
2462 s3 = qq->slot3; | |
2463 s4 = qq->slot4; | |
2464 pmdwork.af_check = 1; | |
2465 neiroset(qq, qq->voicenum); // 音色復帰 | |
2466 pmdwork.af_check = 0; | |
2467 qq->slot1 = s1; | |
2468 qq->slot2 = s2; | |
2469 qq->slot3 = s3; | |
2470 qq->slot4 = s4; | |
2471 | |
2472 al = ((~qq->carrier) & qq->slotmask) & 0xf0; | |
2473 // al<- TLを再設定していいslot 4321xxxx | |
2474 if(al) { | |
2475 dh = 0x4c - 1 + pmdwork.partb; // dh=TL FM Port Address | |
2476 if(al & 0x80) OPNASetReg(&opna, pmdwork.fmsel + dh, s4); | |
2477 | |
2478 dh -= 8; | |
2479 if(al & 0x40) OPNASetReg(&opna, pmdwork.fmsel + dh, s3); | |
2480 | |
2481 dh += 4; | |
2482 if(al & 0x20) OPNASetReg(&opna, pmdwork.fmsel + dh, s2); | |
2483 | |
2484 dh -= 8; | |
2485 if(al & 0x10) OPNASetReg(&opna, pmdwork.fmsel + dh, s1); | |
2486 } | |
2487 | |
2488 dh = pmdwork.partb + 0xb4 - 1; | |
2489 OPNASetReg(&opna, pmdwork.fmsel + dh, calc_panout(qq)); | |
2490 } | |
2491 | |
2492 | |
2493 uchar * PMDWIN::_lfoswitch(QQ *qq, uchar *si) | |
2494 { | |
2495 qq->lfoswi = (qq->lfoswi & 0x8f) | ((*si++ & 7) << 4); | |
2496 lfo_change(qq); | |
2497 lfoinit_main(qq); | |
2498 lfo_change(qq); | |
2499 return si; | |
2500 } | |
2501 | |
2502 | |
2503 uchar * PMDWIN::_volmask_set(QQ *qq, uchar *si) | |
2504 { | |
2505 int al; | |
2506 | |
2507 al = *si++ & 0x0f; | |
2508 if(al) { | |
2509 al = (al << 4) | 0x0f; | |
2510 qq->_volmask = al; | |
2511 } else { | |
2512 qq->_volmask = qq->carrier; | |
2513 } | |
2514 ch3_setting(qq); | |
2515 return si; | |
2516 } | |
2517 | |
2518 | |
2519 //============================================================================= | |
2520 // TL変化 | |
2521 //============================================================================= | |
2522 uchar * PMDWIN::tl_set(QQ *qq, uchar *si) | |
2523 { | |
2524 int ah, al, ch, dh, dl; | |
2525 | |
2526 dh = 0x40 - 1 + pmdwork.partb; // dh=TL FM Port Address | |
2527 al = *(char *)si++; | |
2528 ah = al & 0x0f; | |
2529 ch = (qq->slotmask >> 4) | ((qq->slotmask << 4) & 0xf0); | |
2530 ah &= ch; // ah=変化させるslot 00004321 | |
2531 dl = *(char *)si++; | |
2532 | |
2533 if(al >= 0) { | |
2534 dl &= 127; | |
2535 if(ah & 1) { | |
2536 qq->slot1 = dl; | |
2537 if(qq->partmask == 0) { | |
2538 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2539 } | |
2540 } | |
2541 | |
2542 dh += 8; | |
2543 if(ah & 2) { | |
2544 qq->slot2 = dl; | |
2545 if(qq->partmask == 0) { | |
2546 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2547 } | |
2548 } | |
2549 | |
2550 dh -= 4; | |
2551 if(ah & 4) { | |
2552 qq->slot3 = dl; | |
2553 if(qq->partmask == 0) { | |
2554 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2555 } | |
2556 } | |
2557 | |
2558 dh += 8; | |
2559 if(ah & 8) { | |
2560 qq->slot4 = dl; | |
2561 if(qq->partmask == 0) { | |
2562 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2563 } | |
2564 } | |
2565 } else { | |
2566 // 相対変化 | |
2567 al = dl; | |
2568 if(ah & 1) { | |
2569 if((dl = (int)qq->slot1 + al) < 0) { | |
2570 dl = 0; | |
2571 if(al >= 0) dl = 127; | |
2572 } | |
2573 if(qq->partmask == 0) { | |
2574 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2575 } | |
2576 qq->slot1 = dl; | |
2577 } | |
2578 | |
2579 dh += 8; | |
2580 if(ah & 2) { | |
2581 if((dl = (int)qq->slot2 + al) < 0) { | |
2582 dl = 0; | |
2583 if(al >= 0) dl = 127; | |
2584 } | |
2585 if(qq->partmask == 0) { | |
2586 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2587 } | |
2588 qq->slot2 = dl; | |
2589 } | |
2590 | |
2591 dh -= 4; | |
2592 if(ah & 4) { | |
2593 if((dl = (int)qq->slot3 + al) < 0) { | |
2594 dl = 0; | |
2595 if(al >= 0) dl = 127; | |
2596 } | |
2597 if(qq->partmask == 0) { | |
2598 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2599 } | |
2600 qq->slot3 = dl; | |
2601 } | |
2602 | |
2603 dh += 8; | |
2604 if(ah & 8) { | |
2605 if((dl = (int)qq->slot4 + al) < 0) { | |
2606 dl = 0; | |
2607 if(al >= 0) dl = 127; | |
2608 } | |
2609 if(qq->partmask == 0) { | |
2610 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2611 } | |
2612 qq->slot4 = dl; | |
2613 } | |
2614 } | |
2615 return si; | |
2616 } | |
2617 | |
2618 | |
2619 //============================================================================= | |
2620 // FB変化 | |
2621 //============================================================================= | |
2622 uchar * PMDWIN::fb_set(QQ *qq, uchar *si) | |
2623 { | |
2624 int al, dh, dl; | |
2625 | |
2626 | |
2627 dh = pmdwork.partb + 0xb0 - 1; // dh=ALG/FB port address | |
2628 al = *(char *)si++; | |
2629 if(al >= 0) { | |
2630 // in al 00000xxx 設定するFB | |
2631 al = ((al << 3) & 0xff) | (al >> 5); | |
2632 | |
2633 // in al 00xxx000 設定するFB | |
2634 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
2635 if((qq->slotmask & 0x10) == 0) return si; | |
2636 dl = (pmdwork.fm3_alg_fb & 7) | al; | |
2637 pmdwork.fm3_alg_fb = dl; | |
2638 } else { | |
2639 dl = (qq->alg_fb & 7) | al; | |
2640 } | |
2641 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2642 qq->alg_fb = dl; | |
2643 return si; | |
2644 } else { | |
2645 if((al & 0x40) == 0) al &= 7; | |
2646 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
2647 dl = pmdwork.fm3_alg_fb; | |
2648 } else { | |
2649 dl = qq->alg_fb; | |
2650 | |
2651 } | |
2652 | |
2653 dl = (dl >> 3) & 7; | |
2654 if((al += dl) >= 0) { | |
2655 if(al >= 8) { | |
2656 al = 0x38; | |
2657 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
2658 if((qq->slotmask & 0x10) == 0) return si; | |
2659 | |
2660 dl = (pmdwork.fm3_alg_fb & 7) | al; | |
2661 pmdwork.fm3_alg_fb = dl; | |
2662 } else { | |
2663 dl = (qq->alg_fb & 7) | al; | |
2664 } | |
2665 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2666 qq->alg_fb = dl; | |
2667 return si; | |
2668 } else { | |
2669 // in al 00000xxx 設定するFB | |
2670 al = ((al << 3) & 0xff) | (al >> 5); | |
2671 | |
2672 // in al 00xxx000 設定するFB | |
2673 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
2674 if((qq->slotmask & 0x10) == 0) return si; | |
2675 dl = (pmdwork.fm3_alg_fb & 7) | al; | |
2676 pmdwork.fm3_alg_fb = dl; | |
2677 } else { | |
2678 dl = (qq->alg_fb & 7) | al; | |
2679 } | |
2680 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2681 qq->alg_fb = dl; | |
2682 return si; | |
2683 } | |
2684 } else { | |
2685 al = 0; | |
2686 if(pmdwork.partb == 3 && pmdwork.fmsel == 0) { | |
2687 if((qq->slotmask & 0x10) == 0) return si; | |
2688 | |
2689 dl = (pmdwork.fm3_alg_fb & 7) | al; | |
2690 pmdwork.fm3_alg_fb = dl; | |
2691 } else { | |
2692 dl = (qq->alg_fb & 7) | al; | |
2693 } | |
2694 OPNASetReg(&opna, pmdwork.fmsel + dh, dl); | |
2695 qq->alg_fb = dl; | |
2696 return si; | |
2697 } | |
2698 } | |
2699 } | |
2700 | |
2701 | |
2702 //============================================================================= | |
2703 // COMMAND 't' [TEMPO CHANGE1] | |
2704 // COMMAND 'T' [TEMPO CHANGE2] | |
2705 // COMMAND 't±' [TEMPO CHANGE 相対1] | |
2706 // COMMAND 'T±' [TEMPO CHANGE 相対2] | |
2707 //============================================================================= | |
2708 uchar * PMDWIN::comt(uchar *si) | |
2709 { | |
2710 int al; | |
2711 | |
2712 al = *si++; | |
2713 if(al < 251) { | |
2714 open_work.tempo_d = al; // T (FC) | |
2715 open_work.tempo_d_push = al; | |
2716 calc_tb_tempo(); | |
2717 | |
2718 } else if(al == 0xff) { | |
2719 al = *si++; // t (FC FF) | |
2720 if(al < 18) al = 18; | |
2721 open_work.tempo_48 = al; | |
2722 open_work.tempo_48_push = al; | |
2723 calc_tempo_tb(); | |
2724 | |
2725 } else if(al == 0xfe) { | |
2726 al = char(*si++); // T± (FC FE) | |
2727 if(al >= 0) { | |
2728 al += open_work.tempo_d_push; | |
2729 } else { | |
2730 al += open_work.tempo_d_push; | |
2731 if(al < 0) { | |
2732 al = 0; | |
2733 } | |
2734 } | |
2735 | |
2736 if(al > 250) al = 250; | |
2737 | |
2738 open_work.tempo_d = al; | |
2739 open_work.tempo_d_push = al; | |
2740 calc_tb_tempo(); | |
2741 | |
2742 } else { | |
2743 al = char(*si++); // t± (FC FD) | |
2744 if(al >= 0) { | |
2745 al += open_work.tempo_48_push; | |
2746 if(al > 255) { | |
2747 al = 255; | |
2748 } | |
2749 } else { | |
2750 al += open_work.tempo_48_push; | |
2751 if(al < 0) al = 18; | |
2752 } | |
2753 open_work.tempo_48 = al; | |
2754 open_work.tempo_48_push = al; | |
2755 calc_tempo_tb(); | |
2756 } | |
2757 return si; | |
2758 } | |
2759 | |
2760 | |
2761 //============================================================================= | |
2762 // COMMAND '[' [ループ スタート] | |
2763 //============================================================================= | |
2764 uchar * PMDWIN::comstloop(QQ *qq, uchar *si) | |
2765 { | |
2766 uchar *ax = open_work.mmlbuf; | |
2767 ax[*(ushort *)si+1] = 0; | |
2768 si+=2; | |
2769 return si; | |
2770 } | |
2771 | |
2772 | |
2773 //============================================================================= | |
2774 // COMMAND ']' [ループ エンド] | |
2775 //============================================================================= | |
2776 uchar * PMDWIN::comedloop(QQ *qq, uchar *si) | |
2777 { | |
2778 int ah, al, ax; | |
2779 ah = *si++; | |
2780 | |
2781 if(ah) { | |
2782 (*si)++; | |
2783 al = *si++; | |
2784 if(ah == al) { | |
2785 si+=2; | |
2786 return si; | |
2787 } | |
2788 } else { // 0 ナラ ムジョウケン ループ | |
2789 si++; | |
2790 qq->loopcheck = 1; | |
2791 } | |
2792 | |
2793 ax = *(ushort *)si + 2; | |
2794 si = open_work.mmlbuf + ax; | |
2795 return si; | |
2796 } | |
2797 | |
2798 | |
2799 //============================================================================= | |
2800 // COMMAND ':' [ループ ダッシュツ] | |
2801 //============================================================================= | |
2802 uchar * PMDWIN::comexloop(QQ *qq, uchar *si) | |
2803 { | |
2804 uchar *bx; | |
2805 int dl; | |
2806 bx = open_work.mmlbuf; | |
2807 bx += *(ushort *)si; | |
2808 si+=2; | |
2809 | |
2810 dl = *bx++ - 1; | |
2811 if(dl != *bx) return si; | |
2812 si = bx + 3; | |
2813 return si; | |
2814 } | |
2815 | |
2816 | |
2817 //============================================================================= | |
2818 // LFO パラメータ セット | |
2819 //============================================================================= | |
2820 uchar * PMDWIN::lfoset(QQ *qq, uchar *si) | |
2821 { | |
2822 qq->delay = *si; | |
2823 qq->delay2 = *si++; | |
2824 qq->speed = *si; | |
2825 qq->speed2 = *si++; | |
2826 qq->step = *(char *)si; | |
2827 qq->step2 = *(char *)si++; | |
2828 qq->time = *si; | |
2829 qq->time2 = *si++; | |
2830 lfoinit_main(qq); | |
2831 return si; | |
2832 } | |
2833 | |
2834 | |
2835 //============================================================================= | |
2836 // LFO SWITCH | |
2837 //============================================================================= | |
2838 uchar * PMDWIN::lfoswitch(QQ *qq, uchar *si) | |
2839 { | |
2840 int al; | |
2841 | |
2842 al = *si++; | |
2843 | |
2844 if(al & 0xf8) { | |
2845 al = 1; | |
2846 } | |
2847 al &= 7; | |
2848 qq->lfoswi = (qq->lfoswi & 0xf8) | al; | |
2849 lfoinit_main(qq); | |
2850 return si; | |
2851 } | |
2852 | |
2853 | |
2854 //============================================================================= | |
2855 // PSG ENVELOPE SET | |
2856 //============================================================================= | |
2857 uchar * PMDWIN::psgenvset(QQ *qq, uchar *si) | |
2858 { | |
2859 qq->eenv_ar = *si; qq->eenv_arc = *si++; | |
2860 qq->eenv_dr = *(char *)si++; | |
2861 qq->eenv_sr = *si; qq->eenv_src = *si++; | |
2862 qq->eenv_rr = *si; qq->eenv_rrc = *si++; | |
2863 if(qq->envf == -1) { | |
2864 qq->envf = 2; // RR | |
2865 qq->eenv_volume = -15; // volume | |
2866 } | |
2867 return si; | |
2868 } | |
2869 | |
2870 | |
2871 //============================================================================= | |
2872 // "¥?" COMMAND [ OPNA Rhythm Keyon/Dump ] | |
2873 //============================================================================= | |
2874 uchar * PMDWIN::rhykey(uchar *si) | |
2875 { | |
2876 int dl; | |
2877 | |
2878 if((dl = (*si++ & open_work.rhythmmask)) == 0) { | |
2879 return si; | |
2880 } | |
2881 | |
2882 if(dl < 0x80) { | |
2883 if(dl & 0x01) OPNASetReg(&opna, 0x18, open_work.rdat[0]); | |
2884 if(dl & 0x02) OPNASetReg(&opna, 0x19, open_work.rdat[1]); | |
2885 if(dl & 0x04) OPNASetReg(&opna, 0x1a, open_work.rdat[2]); | |
2886 if(dl & 0x08) OPNASetReg(&opna, 0x1b, open_work.rdat[3]); | |
2887 if(dl & 0x10) OPNASetReg(&opna, 0x1c, open_work.rdat[4]); | |
2888 if(dl & 0x20) OPNASetReg(&opna, 0x1d, open_work.rdat[5]); | |
2889 } | |
2890 | |
2891 OPNASetReg(&opna, 0x10, dl); | |
2892 if(dl >= 0x80) { | |
2893 open_work.rshot_dat &= (~dl); | |
2894 } else { | |
2895 open_work.rshot_dat |= dl; | |
2896 } | |
2897 | |
2898 return si; | |
2899 } | |
2900 | |
2901 | |
2902 //============================================================================= | |
2903 // "¥v?n" COMMAND | |
2904 //============================================================================= | |
2905 uchar * PMDWIN::rhyvs(uchar *si) | |
2906 { | |
2907 int *bx; | |
2908 int dh, dl; | |
2909 | |
2910 dl = *si & 0x1f; | |
2911 dh = *si++ >> 5; | |
2912 bx = &open_work.rdat[dh-1]; | |
2913 dh = 0x18 - 1 + dh; | |
2914 dl |= (*bx & 0xc0); | |
2915 *bx = dl; | |
2916 | |
2917 OPNASetReg(&opna, dh, dl); | |
2918 | |
2919 return si; | |
2920 } | |
2921 | |
2922 | |
2923 uchar * PMDWIN::rhyvs_sft(uchar *si) | |
2924 { | |
2925 int *bx; | |
2926 int al, dh, dl; | |
2927 | |
2928 bx = &open_work.rdat[*si-1]; | |
2929 dh = *si++ + 0x18 - 1; | |
2930 dl = *bx & 0x1f; | |
2931 | |
2932 al = (*(char *)si++ + dl); | |
2933 if(al >= 32) { | |
2934 al = 31; | |
2935 } else if(al < 0) { | |
2936 al = 0; | |
2937 } | |
2938 | |
2939 dl = (al &= 0x1f); | |
2940 dl = *bx = ((*bx & 0xe0) | dl); | |
2941 OPNASetReg(&opna, dh, dl); | |
2942 | |
2943 return si; | |
2944 } | |
2945 | |
2946 | |
2947 //============================================================================= | |
2948 // "¥p?" COMMAND | |
2949 //============================================================================= | |
2950 uchar * PMDWIN::rpnset(uchar *si) | |
2951 { | |
2952 int *bx; | |
2953 int dh, dl; | |
2954 | |
2955 dl = (*si & 3) << 6; | |
2956 | |
2957 dh = (*si++ >> 5) & 0x07; | |
2958 bx = &open_work.rdat[dh-1]; | |
2959 | |
2960 dh += 0x18 - 1; | |
2961 dl |= (*bx & 0x1f); | |
2962 *bx = dl; | |
2963 OPNASetReg(&opna, dh, dl); | |
2964 | |
2965 return si; | |
2966 } | |
2967 | |
2968 | |
2969 //============================================================================= | |
2970 // "¥Vn" COMMAND | |
2971 //============================================================================= | |
2972 uchar * PMDWIN::rmsvs(uchar *si) | |
2973 { | |
2974 int dl; | |
2975 dl = *si++; | |
2976 if(open_work.rhythm_voldown) { | |
2977 dl = ((256 - open_work.rhythm_voldown) * dl) >> 8; | |
2978 } | |
2979 open_work.rhyvol = dl; | |
2980 OPNASetReg(&opna, 0x11, dl); | |
2981 return si; | |
2982 } | |
2983 | |
2984 | |
2985 uchar *PMDWIN::rmsvs_sft(uchar *si) | |
2986 { | |
2987 int dl; | |
2988 dl = open_work.rhyvol + *(char *)si++; | |
2989 if(dl >= 64) { | |
2990 if(dl & 0x80) { | |
2991 dl = 0; | |
2992 } else { | |
2993 dl = 63; | |
2994 } | |
2995 } | |
2996 open_work.rhyvol = dl; | |
2997 OPNASetReg(&opna, 0x11, dl); | |
2998 return si; | |
2999 } | |
3000 | |
3001 | |
3002 //============================================================================= | |
3003 // ボリュームを次の一個だけ変更(V2.7拡張分) | |
3004 //============================================================================= | |
3005 uchar * PMDWIN::vol_one_up_psg(QQ *qq, uchar *si) | |
3006 { | |
3007 int al; | |
3008 | |
3009 al = qq->volume + *si++; | |
3010 if(al > 15) al = 15; | |
3011 qq->volpush = ++al; | |
3012 pmdwork.volpush_flag = 1; | |
3013 return si; | |
3014 } | |
3015 | |
3016 | |
3017 uchar * PMDWIN::vol_one_down(QQ *qq, uchar *si) | |
3018 { | |
3019 int al; | |
3020 | |
3021 al = qq->volume - *si++; | |
3022 if(al < 0) { | |
3023 al = 0; | |
3024 } else { | |
3025 if(al >= 255) al = 254; | |
3026 } | |
3027 | |
3028 qq->volpush = ++al; | |
3029 pmdwork.volpush_flag = 1; | |
3030 return si; | |
3031 } | |
3032 | |
3033 | |
3034 //============================================================================= | |
3035 // ポルタメント(PSG) | |
3036 //============================================================================= | |
3037 uchar * PMDWIN::portap(QQ *qq, uchar *si) | |
3038 { | |
3039 int ax, al_, bx_; | |
3040 | |
3041 if(qq->partmask) { | |
3042 qq->fnum = 0; //休符に設定 | |
3043 qq->onkai = 255; | |
3044 qq->leng = *(si+2); | |
3045 qq->keyon_flag++; | |
3046 qq->address = si+3; | |
3047 | |
3048 if(--pmdwork.volpush_flag) { | |
3049 qq->volpush = 0; | |
3050 } | |
3051 | |
3052 pmdwork.tieflag = 0; | |
3053 pmdwork.volpush_flag = 0; | |
3054 pmdwork.loop_work &= qq->loopcheck; | |
3055 return si+3; // 読み飛ばす (Mask時) | |
3056 } | |
3057 | |
3058 lfoinitp(qq, *si); | |
3059 fnumsetp(qq, oshiftp(qq, *si++)); | |
3060 | |
3061 bx_ = qq->fnum; | |
3062 al_ = qq->onkai; | |
3063 fnumsetp(qq, oshiftp(qq, *si++)); | |
3064 ax = qq->fnum; // ax = ポルタメント先のpsg_tune値 | |
3065 | |
3066 qq->onkai = al_; | |
3067 qq->fnum = bx_; // bx = ポルタメント元のpsg_tune値 | |
3068 ax -= bx_; | |
3069 | |
3070 qq->leng = *si++; | |
3071 si = calc_q(qq, si); | |
3072 | |
3073 qq->porta_num2 = ax / qq->leng; // 商 | |
3074 qq->porta_num3 = ax % qq->leng; // 余り | |
3075 qq->lfoswi |= 8; // Porta ON | |
3076 | |
3077 if(qq->volpush && qq->onkai != 255) { | |
3078 if(--pmdwork.volpush_flag) { | |
3079 pmdwork.volpush_flag = 0; | |
3080 qq->volpush = 0; | |
3081 } | |
3082 } | |
3083 | |
3084 volsetp(qq); | |
3085 otodasip(qq); | |
3086 keyonp(qq); | |
3087 | |
3088 qq->keyon_flag++; | |
3089 qq->address = si; | |
3090 | |
3091 pmdwork.tieflag = 0; | |
3092 pmdwork.volpush_flag = 0; | |
3093 qq->keyoff_flag = 0; | |
3094 | |
3095 if(*si == 0xfb) { // '&'が直後にあったらkeyoffしない | |
3096 qq->keyoff_flag = 2; | |
3097 } | |
3098 | |
3099 pmdwork.loop_work &= qq->loopcheck; | |
3100 return si; | |
3101 } | |
3102 | |
3103 | |
3104 //============================================================================= | |
3105 // 'w' COMMAND [PSG NOISE ヘイキン シュウハスウ] | |
3106 //============================================================================= | |
3107 uchar * PMDWIN::psgnoise_move(uchar *si) | |
3108 { | |
3109 open_work.psnoi += *(char *)si++; | |
3110 if(open_work.psnoi < 0) open_work.psnoi = 0; | |
3111 if(open_work.psnoi > 31) open_work.psnoi = 31; | |
3112 return si; | |
3113 } | |
3114 | |
3115 | |
3116 //============================================================================= | |
3117 // PSG Envelope set (Extend) | |
3118 //============================================================================= | |
3119 uchar * PMDWIN::extend_psgenvset(QQ *qq, uchar *si) | |
3120 { | |
3121 qq->eenv_ar = *si++ & 0x1f; | |
3122 qq->eenv_dr = *si++ & 0x1f; | |
3123 qq->eenv_sr = *si++ & 0x1f; | |
3124 qq->eenv_rr = *si & 0x0f; | |
3125 qq->eenv_sl = ((*si++ >> 4) & 0x0f) ^ 0x0f; | |
3126 qq->eenv_al = *si++ & 0x0f; | |
3127 | |
3128 if(qq->envf != -1) { // ノーマル>拡張に移行したか? | |
3129 qq->envf = -1; | |
3130 qq->eenv_count = 4; // RR | |
3131 qq->eenv_volume = 0; // Volume | |
3132 } | |
3133 return si; | |
3134 } | |
3135 | |
3136 | |
3137 uchar * PMDWIN::mdepth_count(QQ *qq, uchar *si) | |
3138 { | |
3139 int al; | |
3140 | |
3141 al = *si++; | |
3142 | |
3143 if(al >= 0x80) { | |
3144 if((al &= 0x7f) == 0) al = 255; | |
3145 qq->_mdc = al; | |
3146 qq->_mdc2 = al; | |
3147 return si; | |
3148 } | |
3149 | |
3150 if(al == 0) al = 255; | |
3151 qq->mdc = al; | |
3152 qq->mdc2 = al; | |
3153 return si; | |
3154 } | |
3155 | |
3156 | |
3157 //============================================================================= | |
3158 // LFOとPSG/PCMのソフトウエアエンベロープの初期化 | |
3159 //============================================================================= | |
3160 //============================================================================= | |
3161 // PSG/PCM音源用 Entry | |
3162 //============================================================================= | |
3163 void PMDWIN::lfoinitp(QQ *qq, int al) | |
3164 { | |
3165 int ah; | |
3166 | |
3167 ah = al & 0x0f; | |
3168 | |
3169 if(ah == 0x0c) { | |
3170 al = qq->onkai_def; | |
3171 ah = al & 0x0f; | |
3172 } | |
3173 | |
3174 qq->onkai_def = al; | |
3175 | |
3176 if(ah == 0x0f) { // キューフ ノ トキ ハ INIT シナイヨ | |
3177 lfo_exit(qq); | |
3178 return; | |
3179 } | |
3180 | |
3181 qq->porta_num = 0; // ポルタメントは初期化 | |
3182 | |
3183 if(pmdwork.tieflag & 1) { | |
3184 lfo_exit(qq); | |
3185 return; | |
3186 } | |
3187 | |
3188 //------------------------------------------------------------------------ | |
3189 // ソフトウエアエンベロープ初期化 | |
3190 //------------------------------------------------------------------------ | |
3191 if(qq->envf != -1) { | |
3192 qq->envf = 0; | |
3193 qq->eenv_volume = 0; | |
3194 qq->eenv_ar = qq->eenv_arc; | |
3195 | |
3196 if(qq->eenv_ar == 0) { | |
3197 qq->envf = 1; // ATTACK=0 ... スグ Decay ニ | |
3198 qq->eenv_volume = qq->eenv_dr; | |
3199 } | |
3200 | |
3201 qq->eenv_sr = qq->eenv_src; | |
3202 qq->eenv_rr = qq->eenv_rrc; | |
3203 lfin1(qq); | |
3204 | |
3205 } else { | |
3206 // 拡張ssg_envelope用 | |
3207 | |
3208 qq->eenv_arc = qq->eenv_ar - 16; | |
3209 if(qq->eenv_dr < 16) { | |
3210 qq->eenv_drc = (qq->eenv_dr-16)*2; | |
3211 } else { | |
3212 qq->eenv_drc = qq->eenv_dr-16; | |
3213 } | |
3214 | |
3215 if(qq->eenv_sr < 16) { | |
3216 qq->eenv_src = (qq->eenv_sr-16)*2; | |
3217 } else { | |
3218 qq->eenv_src = qq->eenv_sr-16; | |
3219 } | |
3220 | |
3221 qq->eenv_rrc = (qq->eenv_rr) * 2 - 16; | |
3222 qq->eenv_volume = qq->eenv_al; | |
3223 qq->eenv_count = 1; | |
3224 if(qq->eenv_arc > 0) { | |
3225 qq->eenv_volume += qq->eenv_arc; | |
3226 if(qq->eenv_volume < 15) { | |
3227 qq->eenv_arc = qq->eenv_ar-16; | |
3228 } else { | |
3229 qq->eenv_volume = 15; | |
3230 qq->eenv_count++; | |
3231 if(qq->eenv_sl == 15) qq->eenv_count++; // SL=0の場合はすぐSRに | |
3232 } | |
3233 } else { | |
3234 if(qq->eenv_ar != 0) qq->eenv_arc++; | |
3235 } | |
3236 lfin1(qq); | |
3237 } | |
3238 } | |
3239 | |
3240 | |
3241 void PMDWIN::lfo_exit(QQ *qq) | |
3242 { | |
3243 if((qq->lfoswi & 3) != 0) { // 前が & の場合 -> 1回 LFO処理 | |
3244 lfo(qq); | |
3245 } | |
3246 | |
3247 if((qq->lfoswi & 0x30) != 0) { // 前が & の場合 -> 1回 LFO処理 | |
3248 lfo_change(qq); | |
3249 lfo(qq); | |
3250 lfo_change(qq); | |
3251 } | |
3252 } | |
3253 | |
3254 | |
3255 //============================================================================= | |
3256 // LFO初期化 | |
3257 //============================================================================= | |
3258 void PMDWIN::lfin1(QQ *qq) | |
3259 { | |
3260 qq->hldelay_c = qq->hldelay; | |
3261 | |
3262 if(qq->hldelay) { | |
3263 OPNASetReg(&opna, pmdwork.fmsel + pmdwork.partb+0xb4-1, (qq->fmpan) & 0xc0); | |
3264 } | |
3265 | |
3266 qq->sdelay_c = qq->sdelay; | |
3267 | |
3268 if(qq->lfoswi & 3) { // LFOは未使用 | |
3269 if((qq->lfoswi & 4) == 0) { //keyon非同期か? | |
3270 lfoinit_main(qq); | |
3271 } | |
3272 lfo(qq); | |
3273 } | |
3274 | |
3275 if(qq->lfoswi & 0x30) { // LFOは未使用 | |
3276 if((qq->lfoswi & 0x40) == 0) { //keyon非同期か? | |
3277 lfo_change(qq); | |
3278 lfoinit_main(qq); | |
3279 lfo_change(qq); | |
3280 } | |
3281 | |
3282 lfo_change(qq); | |
3283 lfo(qq); | |
3284 lfo_change(qq); | |
3285 } | |
3286 } | |
3287 | |
3288 | |
3289 void PMDWIN::lfoinit_main(QQ *qq) | |
3290 { | |
3291 qq->lfodat = 0; | |
3292 qq->delay = qq->delay2; | |
3293 qq->speed = qq->speed2; | |
3294 qq->step = qq->step2; | |
3295 qq->time = qq->time2; | |
3296 qq->mdc = qq->mdc2; | |
3297 | |
3298 if(qq->lfo_wave == 2 || qq->lfo_wave == 3) { // 矩形波 or ランダム波? | |
3299 qq->speed = 1; // delay直後にLFOが掛かるようにする | |
3300 } else { | |
3301 qq->speed++; // それ以外の場合はdelay直後のspeed値を +1 | |
3302 } | |
3303 } | |
3304 | |
3305 | |
3306 //============================================================================= | |
3307 // SHIFT[di] 分移調する | |
3308 //============================================================================= | |
3309 int PMDWIN::oshiftp(QQ *qq, int al) | |
3310 { | |
3311 return oshift(qq, al); | |
3312 } | |
3313 | |
3314 | |
3315 int PMDWIN::oshift(QQ *qq, int al) | |
3316 { | |
3317 int bl, bh, dl; | |
3318 | |
3319 if(al == 0x0f) return al; | |
3320 | |
3321 if(al == 0x0c) { | |
3322 if((al = qq->onkai) >= 0x80) { | |
3323 return 0x0f; | |
3324 } else { | |
3325 return al; //@暫定対応 | |
3326 } | |
3327 } | |
3328 | |
3329 dl = qq->shift + qq->shift_def; | |
3330 if(dl == 0) return al; | |
3331 | |
3332 bl = (al & 0x0f); // bl = ONKAI | |
3333 bh = (al & 0xf0) >> 4; // bh = OCT | |
3334 | |
3335 if(dl < 0) { | |
3336 // - ホウコウ シフト | |
3337 if((bl += dl) < 0) { | |
3338 do { | |
3339 bh--; | |
3340 } while((bl+=12) < 0); | |
3341 } | |
3342 if(bh < 0) bh = 0; | |
3343 return (bh << 4) | bl; | |
3344 | |
3345 } else { | |
3346 // + ホウコウ シフト | |
3347 bl += dl; | |
3348 while(bl >= 0x0c) { | |
3349 bh++; | |
3350 bl -= 12; | |
3351 } | |
3352 | |
3353 if(bh > 7) bh = 7; | |
3354 return (bh << 4) | bl; | |
3355 } | |
3356 } | |
3357 | |
3358 | |
3359 //============================================================================= | |
3360 // PSG TUNE SET | |
3361 //============================================================================= | |
3362 void PMDWIN::fnumsetp(QQ *qq, int al) | |
3363 { | |
3364 int ax, bx, cl; | |
3365 | |
3366 if((al & 0x0f) == 0x0f) { // キュウフ ナラ FNUM ニ 0 ヲ セット | |
3367 qq->onkai = 255; | |
3368 if(qq->lfoswi & 0x11) return; | |
3369 qq->fnum = 0; // 音程LFO未使用 | |
3370 return; | |
3371 } | |
3372 | |
3373 qq->onkai = al; | |
3374 | |
3375 cl = (al >> 4) & 0x0f; // cl=oct | |
3376 bx = al & 0x0f; // bx=onkai | |
3377 | |
3378 ax = psg_tune_data[bx]; | |
3379 if(cl > 0) { | |
3380 ax = (ax + 1) >> cl; | |
3381 } | |
3382 | |
3383 qq->fnum = ax; | |
3384 } | |
3385 | |
3386 | |
3387 //============================================================================= | |
3388 // Q値の計算 | |
3389 // break dx | |
3390 //============================================================================= | |
3391 uchar * PMDWIN::calc_q(QQ *qq, uchar *si) | |
3392 { | |
3393 int dh, dl; | |
3394 | |
3395 if(*si == 0xc1) { // && | |
3396 si++; | |
3397 qq->qdat = 0; | |
3398 return si; | |
3399 } | |
3400 | |
3401 dl = qq->qdata; | |
3402 if(qq->qdatb) { | |
3403 dl += (qq->leng * qq->qdatb) >> 8; | |
3404 } | |
3405 | |
3406 #if 0 | |
3407 if(qq->qdat3) { // Random-Q | |
3408 ax = rand() % ((qq->qdat3 & 0x7f) + 1); | |
3409 if((qq->qdat3 & 0x80) == 0) { | |
3410 dl += ax; | |
3411 } else { | |
3412 dl -= ax; | |
3413 if(dl < 0) dl = 0; | |
3414 } | |
3415 } | |
3416 #endif | |
3417 | |
3418 if(qq->qdat2) { | |
3419 if((dh = qq->leng - qq->qdat2) < 0) { | |
3420 qq->qdat = 0; | |
3421 return si; | |
3422 } | |
3423 | |
3424 if(dl < dh) { | |
3425 qq->qdat = dl; | |
3426 } else { | |
3427 qq->qdat = dh; | |
3428 } | |
3429 } else { | |
3430 qq->qdat = dl; | |
3431 } | |
3432 | |
3433 return si; | |
3434 } | |
3435 | |
3436 | |
3437 //============================================================================= | |
3438 // PSG VOLUME SET | |
3439 //============================================================================= | |
3440 void PMDWIN::volsetp(QQ *qq) | |
3441 { | |
3442 int ax, dl; | |
3443 | |
3444 if(qq->envf == 3 || (qq->envf == -1 && qq->eenv_count == 0)) return; | |
3445 | |
3446 if(qq->volpush) { | |
3447 dl = qq->volpush-1; | |
3448 } else { | |
3449 dl = qq->volume; | |
3450 } | |
3451 | |
3452 //------------------------------------------------------------------------ | |
3453 // 音量down計算 | |
3454 //------------------------------------------------------------------------ | |
3455 dl = ((256-open_work.ssg_voldown) * dl) >> 8; | |
3456 | |
3457 //------------------------------------------------------------------------ | |
3458 // ENVELOPE 計算 | |
3459 //------------------------------------------------------------------------ | |
3460 if(dl <= 0) { | |
3461 OPNASetReg(&opna, pmdwork.partb+8-1, 0); | |
3462 return; | |
3463 } | |
3464 | |
3465 if(qq->envf == -1) { | |
3466 if(qq->eenv_volume == 0) { | |
3467 OPNASetReg(&opna, pmdwork.partb+8-1, 0); | |
3468 return; | |
3469 } | |
3470 dl = ((((dl * (qq->eenv_volume + 1))) >> 3) + 1) >> 1; | |
3471 } else { | |
3472 dl += qq->eenv_volume; | |
3473 if(dl <= 0) { | |
3474 OPNASetReg(&opna, pmdwork.partb+8-1, 0); | |
3475 return; | |
3476 } | |
3477 if(dl > 15) dl = 15; | |
3478 } | |
3479 | |
3480 //-------------------------------------------------------------------- | |
3481 // 音量LFO計算 | |
3482 //-------------------------------------------------------------------- | |
3483 if((qq->lfoswi & 0x22) == 0) { | |
3484 OPNASetReg(&opna, pmdwork.partb+8-1, dl); | |
3485 return; | |
3486 } | |
3487 | |
3488 if(qq->lfoswi & 2) { | |
3489 ax = qq->lfodat; | |
3490 } else { | |
3491 ax = 0; | |
3492 } | |
3493 | |
3494 if(qq->lfoswi & 0x20) { | |
3495 ax += qq->_lfodat; | |
3496 } | |
3497 | |
3498 dl = dl + ax; | |
3499 if(dl < 0) { | |
3500 OPNASetReg(&opna, pmdwork.partb+8-1, 0); | |
3501 return; | |
3502 } | |
3503 if(dl > 15) dl = 15; | |
3504 | |
3505 //------------------------------------------------------------------------ | |
3506 // 出力 | |
3507 //------------------------------------------------------------------------ | |
3508 OPNASetReg(&opna, pmdwork.partb+8-1, dl); | |
3509 } | |
3510 | |
3511 | |
3512 //============================================================================= | |
3513 // PSG 音程設定 | |
3514 //============================================================================= | |
3515 void PMDWIN::otodasip(QQ *qq) | |
3516 { | |
3517 int ax, dx; | |
3518 | |
3519 if(qq->fnum == 0) return; | |
3520 | |
3521 // PSG Portament set | |
3522 | |
3523 ax = qq->fnum + qq->porta_num; | |
3524 dx = 0; | |
3525 | |
3526 // PSG Detune/LFO set | |
3527 if((qq->extendmode & 1) == 0) { | |
3528 ax -= qq->detune; | |
3529 if(qq->lfoswi & 1) { | |
3530 ax -= qq->lfodat; | |
3531 } | |
3532 | |
3533 if(qq->lfoswi & 0x10) { | |
3534 ax -= qq->_lfodat; | |
3535 } | |
3536 } else { | |
3537 // 拡張DETUNE(DETUNE)の計算 | |
3538 if(qq->detune) { | |
3539 dx = (ax * qq->detune) >> 12; // dx:ax=ax * qq->detune | |
3540 if(dx >= 0) { | |
3541 dx++; | |
3542 } else { | |
3543 dx--; | |
3544 } | |
3545 ax -= dx; | |
3546 } | |
3547 // 拡張DETUNE(LFO)の計算 | |
3548 if(qq->lfoswi & 0x11) { | |
3549 if(qq->lfoswi & 1) { | |
3550 dx = qq->lfodat; | |
3551 } else { | |
3552 dx = 0; | |
3553 } | |
3554 | |
3555 if(qq->lfoswi & 0x10) { | |
3556 dx += qq->_lfodat; | |
3557 } | |
3558 | |
3559 if(dx) { | |
3560 dx = (ax * dx) >> 12; | |
3561 if(dx >= 0) { | |
3562 dx++; | |
3563 } else { | |
3564 dx--; | |
3565 } | |
3566 } | |
3567 ax -= dx; | |
3568 } | |
3569 } | |
3570 | |
3571 // TONE SET | |
3572 | |
3573 if(ax >= 0x1000) { | |
3574 if(ax >= 0) { | |
3575 ax = 0xfff; | |
3576 } else { | |
3577 ax = 0; | |
3578 } | |
3579 } | |
3580 | |
3581 OPNASetReg(&opna, (pmdwork.partb-1) * 2, ax & 0xff); | |
3582 OPNASetReg(&opna, (pmdwork.partb-1) * 2 + 1, ax >> 8); | |
3583 } | |
3584 | |
3585 | |
3586 //============================================================================= | |
3587 // PSG KEYON | |
3588 //============================================================================= | |
3589 void PMDWIN::keyonp(QQ *qq) | |
3590 { | |
3591 int ah, al; | |
3592 | |
3593 if(qq->onkai == 255) return; // キュウフ ノ トキ | |
3594 int op = ((pmdwork.partb-1)&3); | |
3595 switch(op) { | |
3596 case 0: | |
3597 pmdstatus[6] = (qq->onkai & 0x0f); | |
3598 break; | |
3599 case 1: | |
3600 pmdstatus[7] = (qq->onkai & 0x0f); | |
3601 break; | |
3602 case 2: | |
3603 pmdstatus[8] = (qq->onkai & 0x0f); | |
3604 break; | |
3605 default: | |
3606 break; | |
3607 } | |
3608 | |
3609 ah=(1 << (pmdwork.partb -1)) | (1 << (pmdwork.partb +2)); | |
3610 al = PSGGetReg(&(opna.psg), 0x07) | ah; | |
3611 ah = ~(ah & qq->psgpat); | |
3612 al &= ah; | |
3613 PSGSetReg(&(opna.psg), 7, al); | |
3614 | |
3615 // PSG ノイズ シュウハスウ ノ セット | |
3616 if(open_work.psnoi != open_work.psnoi_last && effwork.effon == 0) { | |
3617 PSGSetReg(&(opna.psg), 6, open_work.psnoi); | |
3618 open_work.psnoi_last = open_work.psnoi; | |
3619 } | |
3620 } | |
3621 | |
3622 | |
3623 //============================================================================= | |
3624 // LFO処理 | |
3625 // Don't Break cl | |
3626 // output cy=1 変化があった | |
3627 //============================================================================= | |
3628 int PMDWIN::lfo(QQ *qq) | |
3629 { | |
3630 int ax, ch; | |
3631 | |
3632 if(qq->delay) { | |
3633 qq->delay--; | |
3634 return 0; | |
3635 } | |
3636 | |
3637 if(qq->extendmode & 2) { // TimerAと合わせるか? | |
3638 // そうじゃないなら無条件にlfo処理 | |
3639 ch = open_work.TimerAtime - pmdwork.lastTimerAtime; | |
3640 if(ch == 0) return 0; | |
3641 ax = qq->lfodat; | |
3642 | |
3643 for(; ch > 0; ch--) { | |
3644 lfo_main(qq); | |
3645 } | |
3646 } else { | |
3647 | |
3648 ax = qq->lfodat; | |
3649 lfo_main(qq); | |
3650 } | |
3651 | |
3652 if(ax == qq->lfodat) { | |
3653 return 0; | |
3654 } | |
3655 return 1; | |
3656 } | |
3657 | |
3658 | |
3659 void PMDWIN::lfo_main(QQ *qq) | |
3660 { | |
3661 int al, ax; | |
3662 | |
3663 if(qq->speed != 1) { | |
3664 if(qq->speed != 255) qq->speed--; | |
3665 return; | |
3666 } | |
3667 | |
3668 qq->speed = qq->speed2; | |
3669 | |
3670 if(qq->lfo_wave == 0 || qq->lfo_wave == 4 || qq->lfo_wave == 5) { | |
3671 // 三角波 lfowave = 0,4,5 | |
3672 if(qq->lfo_wave == 5) { | |
3673 ax = abs(qq->step) * qq->step; | |
3674 } else { | |
3675 ax = qq->step; | |
3676 } | |
3677 | |
3678 if((qq->lfodat += ax) == 0) { | |
3679 md_inc(qq); | |
3680 } | |
3681 | |
3682 al = qq->time; | |
3683 if(al != 255) { | |
3684 if(--al == 0) { | |
3685 al = qq->time2; | |
3686 if(qq->lfo_wave != 4) { | |
3687 al += al; // lfowave=0,5の場合 timeを反転時2倍にする | |
3688 } | |
3689 qq->time = al; | |
3690 qq->step = -qq->step; | |
3691 return; | |
3692 } | |
3693 } | |
3694 qq->time = al; | |
3695 | |
3696 } else if(qq->lfo_wave == 2) { | |
3697 // 矩形波 lfowave = 2 | |
3698 qq->lfodat = (qq->step * qq->time); | |
3699 md_inc(qq); | |
3700 qq->step = -qq->step; | |
3701 | |
3702 } else if(qq->lfo_wave == 6) { | |
3703 // ワンショット lfowave = 6 | |
3704 if(qq->time) { | |
3705 if(qq->time != 255) { | |
3706 qq->time--; | |
3707 } | |
3708 qq->lfodat += qq->step; | |
3709 } | |
3710 } else if(qq->lfo_wave == 1) { | |
3711 //ノコギリ波 lfowave = 1 | |
3712 qq->lfodat += qq->step; | |
3713 al = qq->time; | |
3714 if(al != -1) { | |
3715 al--; | |
3716 if(al == 0) { | |
3717 qq->lfodat = -qq->lfodat; | |
3718 md_inc(qq); | |
3719 al = (qq->time2) * 2; | |
3720 } | |
3721 } | |
3722 qq->time = al; | |
3723 | |
3724 } else { | |
3725 // ランダム波 lfowave = 3 | |
3726 ax = abs(qq->step) * qq->time; | |
3727 qq->lfodat = ax - (lfg_rand() % (ax * 2)); | |
3728 md_inc(qq); | |
3729 } | |
3730 } | |
3731 | |
3732 | |
3733 //============================================================================= | |
3734 // MDコマンドの値によってSTEP値を変更 | |
3735 //============================================================================= | |
3736 void PMDWIN::md_inc(QQ *qq) | |
3737 { | |
3738 int al; | |
3739 | |
3740 if(--qq->mdspd) return; | |
3741 | |
3742 qq->mdspd = qq->mdspd2; | |
3743 | |
3744 if(qq->mdc == 0) return; // count = 0 | |
3745 if(qq->mdc <= 127) { | |
3746 qq->mdc--; | |
3747 } | |
3748 | |
3749 if(qq->step < 0) { | |
3750 al = qq->mdepth - qq->step; | |
3751 if(al >= 0) { | |
3752 qq->step = -al; | |
3753 } else { | |
3754 if(qq->mdepth < 0) { | |
3755 qq->step = 0; | |
3756 } else { | |
3757 qq->step = -127; | |
3758 } | |
3759 } | |
3760 } else { | |
3761 al = qq->step + qq->mdepth; | |
3762 if(al >= 0) { | |
3763 qq->step = al; | |
3764 } else { | |
3765 if(qq->mdepth < 0) { | |
3766 qq->step = 0; | |
3767 } else { | |
3768 qq->step = 127; | |
3769 } | |
3770 } | |
3771 } | |
3772 } | |
3773 | |
3774 | |
3775 void PMDWIN::swap(int *a, int *b) | |
3776 { | |
3777 int temp; | |
3778 | |
3779 temp = *a; | |
3780 *a = *b; | |
3781 *b = temp; | |
3782 } | |
3783 | |
3784 | |
3785 //============================================================================= | |
3786 // LFO1<->LFO2 change | |
3787 //============================================================================= | |
3788 void PMDWIN::lfo_change(QQ *qq) | |
3789 { | |
3790 swap(&qq->lfodat, &qq->_lfodat); | |
3791 qq->lfoswi = ((qq->lfoswi & 0x0f) << 4) + (qq->lfoswi >> 4); | |
3792 qq->extendmode = ((qq->extendmode & 0x0f) << 4) + (qq->extendmode >> 4); | |
3793 | |
3794 swap(&qq->delay, &qq->_delay); | |
3795 swap(&qq->speed, &qq->_speed); | |
3796 swap(&qq->step, &qq->_step); | |
3797 swap(&qq->time, &qq->_time); | |
3798 swap(&qq->delay2, &qq->_delay2); | |
3799 swap(&qq->speed2, &qq->_speed2); | |
3800 swap(&qq->step2, &qq->_step2); | |
3801 swap(&qq->time2, &qq->_time2); | |
3802 swap(&qq->mdepth, &qq->_mdepth); | |
3803 swap(&qq->mdspd, &qq->_mdspd); | |
3804 swap(&qq->mdspd2, &qq->_mdspd2); | |
3805 swap(&qq->lfo_wave, &qq->_lfo_wave); | |
3806 swap(&qq->mdc, &qq->_mdc); | |
3807 swap(&qq->mdc2, &qq->_mdc2); | |
3808 } | |
3809 | |
3810 | |
3811 //============================================================================= | |
3812 // ポルタメント計算なのね | |
3813 //============================================================================= | |
3814 void PMDWIN::porta_calc(QQ *qq) | |
3815 { | |
3816 qq->porta_num += qq->porta_num2; | |
3817 if(qq->porta_num3 == 0) return; | |
3818 if(qq->porta_num3 > 0) { | |
3819 qq->porta_num3--; | |
3820 qq->porta_num++; | |
3821 } else { | |
3822 qq->porta_num3++; | |
3823 qq->porta_num--; | |
3824 } | |
3825 } | |
3826 | |
3827 | |
3828 //============================================================================= | |
3829 // PSG/PCMのソフトウエアエンベロープ | |
3830 //============================================================================= | |
3831 int PMDWIN::soft_env(QQ *qq) | |
3832 { | |
3833 int i, cl; | |
3834 | |
3835 if(qq->extendmode & 4) { | |
3836 if(open_work.TimerAtime == pmdwork.lastTimerAtime) return 0; | |
3837 | |
3838 cl = 0; | |
3839 for(i = 0; i < open_work.TimerAtime - pmdwork.lastTimerAtime; i++) { | |
3840 if(soft_env_main(qq)) { | |
3841 cl = 1; | |
3842 } | |
3843 } | |
3844 return cl; | |
3845 } else { | |
3846 return soft_env_main(qq); | |
3847 } | |
3848 } | |
3849 | |
3850 | |
3851 int PMDWIN::soft_env_main(QQ *qq) | |
3852 { | |
3853 int dl; | |
3854 | |
3855 if(qq->envf == -1) { | |
3856 return ext_ssgenv_main(qq); | |
3857 } | |
3858 | |
3859 dl = qq->eenv_volume; | |
3860 soft_env_sub(qq); | |
3861 if(dl == qq->eenv_volume) { | |
3862 return 0; | |
3863 } else { | |
3864 return -1; | |
3865 } | |
3866 } | |
3867 | |
3868 | |
3869 int PMDWIN::soft_env_sub(QQ *qq) | |
3870 { | |
3871 if(qq->envf == 0) { | |
3872 // Attack | |
3873 if(--qq->eenv_ar != 0) { | |
3874 return 0; | |
3875 } | |
3876 | |
3877 qq->envf = 1; | |
3878 qq->eenv_volume = qq->eenv_dr; | |
3879 return 1; | |
3880 } | |
3881 | |
3882 if(qq->envf != 2) { | |
3883 // Decay | |
3884 if(qq->eenv_sr == 0) return 0; // DR=0の時は減衰しない | |
3885 if(--qq->eenv_sr != 0) return 0; | |
3886 qq->eenv_sr = qq->eenv_src; | |
3887 qq->eenv_volume--; | |
3888 | |
3889 if(qq->eenv_volume >= -15 || qq->eenv_volume < 15) return 0; | |
3890 qq->eenv_volume = -15; | |
3891 return 0; | |
3892 } | |
3893 | |
3894 | |
3895 // Release | |
3896 if(qq->eenv_rr == 0) { // RR=0の時はすぐに音消し | |
3897 qq->eenv_volume = -15; | |
3898 return 0; | |
3899 } | |
3900 | |
3901 if(--qq->eenv_rr != 0) return 0; | |
3902 qq->eenv_rr = qq->eenv_rrc; | |
3903 qq->eenv_volume--; | |
3904 | |
3905 if(qq->eenv_volume >= -15 && qq->eenv_volume < 15) return 0; | |
3906 qq->eenv_volume = -15; | |
3907 return 0; | |
3908 } | |
3909 | |
3910 | |
3911 // 拡張版 | |
3912 int PMDWIN::ext_ssgenv_main(QQ *qq) | |
3913 { | |
3914 int dl; | |
3915 | |
3916 if(qq->eenv_count == 0) return 0; | |
3917 | |
3918 dl = qq->eenv_volume; | |
3919 esm_sub(qq, qq->eenv_count); | |
3920 | |
3921 if(dl == qq->eenv_volume) return 0; | |
3922 return -1; | |
3923 } | |
3924 | |
3925 | |
3926 void PMDWIN::esm_sub(QQ *qq, int ah) | |
3927 { | |
3928 if(--ah == 0) { | |
3929 // [[[ Attack Rate ]]] | |
3930 if(qq->eenv_arc > 0) { | |
3931 qq->eenv_volume += qq->eenv_arc; | |
3932 if(qq->eenv_volume < 15) { | |
3933 qq->eenv_arc = qq->eenv_ar-16; | |
3934 return; | |
3935 } | |
3936 | |
3937 qq->eenv_volume = 15; | |
3938 qq->eenv_count++; | |
3939 if(qq->eenv_sl != 15) return; // SL=0の場合はすぐSRに | |
3940 qq->eenv_count++; | |
3941 return; | |
3942 } else { | |
3943 if(qq->eenv_ar == 0) return; | |
3944 qq->eenv_arc++; | |
3945 return; | |
3946 } | |
3947 } | |
3948 | |
3949 if(--ah == 0) { | |
3950 // [[[ Decay Rate ]]] | |
3951 if(qq->eenv_drc > 0) { // 0以下の場合はカウントCHECK | |
3952 qq->eenv_volume -= qq->eenv_drc; | |
3953 if(qq->eenv_volume < 0 || qq->eenv_volume < qq->eenv_sl) { | |
3954 qq->eenv_volume = qq->eenv_sl; | |
3955 qq->eenv_count++; | |
3956 return; | |
3957 } | |
3958 | |
3959 if(qq->eenv_dr < 16) { | |
3960 qq->eenv_drc = (qq->eenv_dr - 16) * 2; | |
3961 } else { | |
3962 qq->eenv_drc = qq->eenv_dr - 16; | |
3963 } | |
3964 return; | |
3965 } | |
3966 | |
3967 if(qq->eenv_dr == 0) return; | |
3968 qq->eenv_drc++; | |
3969 return; | |
3970 } | |
3971 | |
3972 if(--ah == 0) { | |
3973 // [[[ Sustain Rate ]]] | |
3974 if(qq->eenv_src > 0) { // 0以下の場合はカウントCHECK | |
3975 if((qq->eenv_volume -= qq->eenv_src) < 0) { | |
3976 qq->eenv_volume = 0; | |
3977 } | |
3978 | |
3979 if(qq->eenv_sr < 16) { | |
3980 qq->eenv_src = (qq->eenv_sr - 16) * 2; | |
3981 } else { | |
3982 qq->eenv_src = qq->eenv_sr - 16; | |
3983 } | |
3984 return; | |
3985 } | |
3986 | |
3987 if(qq->eenv_sr == 0) return; // SR=0? | |
3988 qq->eenv_src++; | |
3989 return; | |
3990 } | |
3991 | |
3992 // [[[ Release Rate ]]] | |
3993 if(qq->eenv_rrc > 0) { // 0以下の場合はカウントCHECK | |
3994 if((qq->eenv_volume -= qq->eenv_rrc) < 0) { | |
3995 qq->eenv_volume = 0; | |
3996 } | |
3997 | |
3998 qq->eenv_rrc = (qq->eenv_rr) * 2 - 16; | |
3999 return; | |
4000 } | |
4001 | |
4002 if(qq->eenv_rr == 0) return; | |
4003 qq->eenv_rrc++; | |
4004 } | |
4005 | |
4006 | |
4007 //============================================================================= | |
4008 // テンポ設定 | |
4009 //============================================================================= | |
4010 void PMDWIN::settempo_b(void) | |
4011 { | |
4012 if(open_work.tempo_d != open_work.TimerB_speed) { | |
4013 open_work.TimerB_speed = open_work.tempo_d; | |
4014 OPNASetReg(&opna, 0x26, open_work.TimerB_speed); | |
4015 } | |
4016 } | |
4017 | |
4018 | |
4019 //============================================================================= | |
4020 // 小節のカウント | |
4021 //============================================================================= | |
4022 void PMDWIN::syousetu_count(void) | |
4023 { | |
4024 if(open_work.opncount + 1 == open_work.syousetu_lng) { | |
4025 open_work.syousetu++; | |
4026 open_work.opncount = 0; | |
4027 } else { | |
4028 open_work.opncount++; | |
4029 } | |
4030 } | |
4031 | |
4032 | |
4033 //============================================================================= | |
4034 // OPN割り込み許可処理 | |
4035 //============================================================================= | |
4036 void PMDWIN::opnint_start(void) | |
4037 { | |
4038 memset(FMPart, 0, sizeof(FMPart)); | |
4039 memset(SSGPart, 0, sizeof(SSGPart)); | |
4040 memset(&RhythmPart, 0, sizeof(RhythmPart)); | |
4041 | |
4042 open_work.rhythmmask = 255; | |
4043 pmdwork.rhydmy = 255; | |
4044 data_init(); | |
4045 opn_init(); | |
4046 | |
4047 PSGSetReg(&(opna.psg), 0x07, 0xbf); | |
4048 mstop(); | |
4049 setint(); | |
4050 OPNASetReg(&opna, 0x29, 0x83); | |
4051 } | |
4052 | |
4053 | |
4054 //============================================================================= | |
4055 // DATA AREA の イニシャライズ | |
4056 //============================================================================= | |
4057 void PMDWIN::data_init(void) | |
4058 { | |
4059 int i; | |
4060 int partmask, keyon_flag; | |
4061 | |
4062 for(i = 0; i < 6; i++) { | |
4063 partmask = FMPart[i].partmask; | |
4064 keyon_flag = FMPart[i].keyon_flag; | |
4065 memset(&FMPart[i], 0, sizeof(QQ)); | |
4066 FMPart[i].partmask = partmask & 0x0f; | |
4067 FMPart[i].keyon_flag = keyon_flag; | |
4068 FMPart[i].onkai = 255; | |
4069 FMPart[i].onkai_def = 255; | |
4070 } | |
4071 | |
4072 for(i = 0; i < 3; i++) { | |
4073 partmask = SSGPart[i].partmask; | |
4074 keyon_flag = SSGPart[i].keyon_flag; | |
4075 memset(&SSGPart[i], 0, sizeof(QQ)); | |
4076 SSGPart[i].partmask = partmask & 0x0f; | |
4077 SSGPart[i].keyon_flag = keyon_flag; | |
4078 SSGPart[i].onkai = 255; | |
4079 SSGPart[i].onkai_def = 255; | |
4080 } | |
4081 | |
4082 partmask = RhythmPart.partmask; | |
4083 keyon_flag = RhythmPart.keyon_flag; | |
4084 memset(&RhythmPart, 0, sizeof(QQ)); | |
4085 RhythmPart.partmask = partmask & 0x0f; | |
4086 RhythmPart.keyon_flag = keyon_flag; | |
4087 RhythmPart.onkai = 255; | |
4088 RhythmPart.onkai_def = 255; | |
4089 | |
4090 pmdwork.tieflag = 0; | |
4091 open_work.status = 0; | |
4092 open_work.status2 = 0; | |
4093 open_work.syousetu = 0; | |
4094 open_work.opncount = 0; | |
4095 open_work.TimerAtime = 0; | |
4096 pmdwork.lastTimerAtime = 0; | |
4097 | |
4098 pmdwork.omote_key[0] = 0; | |
4099 pmdwork.omote_key[1] = 0; | |
4100 pmdwork.omote_key[2] = 0; | |
4101 pmdwork.ura_key[0] = 0; | |
4102 pmdwork.ura_key[1] = 0; | |
4103 pmdwork.ura_key[2] = 0; | |
4104 | |
4105 pmdwork.fm3_alg_fb = 0; | |
4106 pmdwork.af_check = 0; | |
4107 | |
4108 open_work.kshot_dat = 0; | |
4109 open_work.rshot_dat = 0; | |
4110 | |
4111 pmdwork.slotdetune_flag = 0; | |
4112 open_work.slot_detune1 = 0; | |
4113 open_work.slot_detune2 = 0; | |
4114 open_work.slot_detune3 = 0; | |
4115 open_work.slot_detune4 = 0; | |
4116 | |
4117 pmdwork.slot3_flag = 0; | |
4118 open_work.ch3mode = 0x3f; | |
4119 | |
4120 pmdwork.fmsel = 0; | |
4121 | |
4122 open_work.syousetu_lng = 96; | |
4123 | |
4124 open_work.fm_voldown = open_work._fm_voldown; | |
4125 open_work.ssg_voldown = open_work._ssg_voldown; | |
4126 open_work.rhythm_voldown = open_work._rhythm_voldown; | |
4127 } | |
4128 | |
4129 | |
4130 //============================================================================= | |
4131 // OPN INIT | |
4132 //============================================================================= | |
4133 void PMDWIN::opn_init(void) | |
4134 { | |
4135 int i; | |
4136 OPNASetReg(&opna, 0x29, 0x83); | |
4137 open_work.psnoi = 0; | |
4138 //@ if(effwork.effon == 0) { | |
4139 PSGSetReg(&(opna.psg), 0x06, 0x00); | |
4140 open_work.psnoi_last = 0; | |
4141 //@ } | |
4142 | |
4143 //------------------------------------------------------------------------ | |
4144 // PAN/HARDLFO DEFAULT | |
4145 //------------------------------------------------------------------------ | |
4146 OPNASetReg(&opna, 0xb4, 0xc0); | |
4147 OPNASetReg(&opna, 0xb5, 0xc0); | |
4148 OPNASetReg(&opna, 0xb6, 0xc0); | |
4149 OPNASetReg(&opna, 0x1b4, 0xc0); | |
4150 OPNASetReg(&opna, 0x1b5, 0xc0); | |
4151 OPNASetReg(&opna, 0x1b6, 0xc0); | |
4152 | |
4153 open_work.port22h = 0x00; | |
4154 OPNASetReg(&opna, 0x22, 0x00); | |
4155 | |
4156 //------------------------------------------------------------------------ | |
4157 // Rhythm Default = Pan : Mid , Vol : 15 | |
4158 //------------------------------------------------------------------------ | |
4159 for(i = 0; i < 6; i++) { | |
4160 open_work.rdat[i] = 0xcf; | |
4161 } | |
4162 OPNASetReg(&opna, 0x10, 0xff); | |
4163 | |
4164 //------------------------------------------------------------------------ | |
4165 // リズムトータルレベル セット | |
4166 //------------------------------------------------------------------------ | |
4167 open_work.rhyvol = 48*4*(256-open_work.rhythm_voldown)/1024; | |
4168 OPNASetReg(&opna, 0x11, open_work.rhyvol); | |
4169 } | |
4170 | |
4171 | |
4172 //============================================================================= | |
4173 // MUSIC STOP | |
4174 //============================================================================= | |
4175 void PMDWIN::mstop_f(void) | |
4176 { | |
4177 int i; | |
4178 if(open_work.TimerAflag || open_work.TimerBflag) { | |
4179 pmdwork.music_flag |= 2; | |
4180 } else { | |
4181 mstop(); | |
4182 } | |
4183 | |
4184 //memset(wavbuf2, 0, sizeof(wavbuf2)); | |
4185 for(i=0; i<nbufsample; i++) wavbuf2[i].left = 0; | |
4186 upos = 0; | |
4187 } | |
4188 | |
4189 | |
4190 void PMDWIN::mstop(void) | |
4191 { | |
4192 pmdwork.music_flag &= 0xfd; | |
4193 open_work.play_flag = 0; | |
4194 open_work.status2 = -1; | |
4195 silence(); | |
4196 } | |
4197 | |
4198 | |
4199 //============================================================================= | |
4200 // ALL SILENCE | |
4201 //============================================================================= | |
4202 void PMDWIN::silence(void) | |
4203 { | |
4204 OPNASetReg(&opna, 0x80, 0xff); // FM Release = 15 | |
4205 OPNASetReg(&opna, 0x81, 0xff); | |
4206 OPNASetReg(&opna, 0x82, 0xff); | |
4207 OPNASetReg(&opna, 0x84, 0xff); | |
4208 OPNASetReg(&opna, 0x85, 0xff); | |
4209 OPNASetReg(&opna, 0x86, 0xff); | |
4210 OPNASetReg(&opna, 0x88, 0xff); | |
4211 OPNASetReg(&opna, 0x89, 0xff); | |
4212 OPNASetReg(&opna, 0x8a, 0xff); | |
4213 OPNASetReg(&opna, 0x8c, 0xff); | |
4214 OPNASetReg(&opna, 0x8d, 0xff); | |
4215 OPNASetReg(&opna, 0x8e, 0xff); | |
4216 | |
4217 OPNASetReg(&opna, 0x180, 0xff); | |
4218 OPNASetReg(&opna, 0x181, 0xff); | |
4219 OPNASetReg(&opna, 0x184, 0xff); | |
4220 OPNASetReg(&opna, 0x185, 0xff); | |
4221 OPNASetReg(&opna, 0x188, 0xff); | |
4222 OPNASetReg(&opna, 0x189, 0xff); | |
4223 OPNASetReg(&opna, 0x18c, 0xff); | |
4224 OPNASetReg(&opna, 0x18d, 0xff); | |
4225 | |
4226 OPNASetReg(&opna, 0x182, 0xff); | |
4227 OPNASetReg(&opna, 0x186, 0xff); | |
4228 OPNASetReg(&opna, 0x18a, 0xff); | |
4229 OPNASetReg(&opna, 0x18e, 0xff); | |
4230 | |
4231 OPNASetReg(&opna, 0x28, 0x00); // FM KEYOFF | |
4232 OPNASetReg(&opna, 0x28, 0x01); | |
4233 OPNASetReg(&opna, 0x28, 0x02); | |
4234 OPNASetReg(&opna, 0x28, 0x04); // FM KEYOFF [URA] | |
4235 OPNASetReg(&opna, 0x28, 0x05); | |
4236 OPNASetReg(&opna, 0x28, 0x06); | |
4237 | |
4238 // 2003.11.30 プチノイズ対策のため | |
4239 //@ if(effwork.effon == 0) { | |
4240 PSGSetReg(&(opna.psg), 0x07, 0xbf); | |
4241 PSGSetReg(&(opna.psg), 0x08, 0); // 2003.11.30 プチノイズ対策のため | |
4242 PSGSetReg(&(opna.psg), 0x09, 0); // 2003.11.30 プチノイズ対策のため | |
4243 PSGSetReg(&(opna.psg), 0x0a, 0); // 2003.11.30 プチノイズ対策のため | |
4244 //@ } else { | |
4245 //@ PSGSetReg(&(opna.psg), 0x07, (PSGGetReg(&(opna.psg), 0x07) & 0x3f) | 0x9b); | |
4246 //@ } | |
4247 | |
4248 OPNASetReg(&opna, 0x10, 0xff); // Rhythm dump | |
4249 OPNASetReg(&opna, 0x110, 0x80); // TA/TB/EOS を RESET | |
4250 OPNASetReg(&opna, 0x110, 0x18); // TIMERB/A/EOSのみbit変化あり | |
4251 } | |
4252 | |
4253 | |
4254 //============================================================================= | |
4255 // 演奏開始(function) | |
4256 //============================================================================= | |
4257 void PMDWIN::mstart_f(void) | |
4258 { | |
4259 if(open_work.TimerAflag || open_work.TimerBflag) { | |
4260 pmdwork.music_flag |= 1; // TA/TB処理中は 実行しない | |
4261 return; | |
4262 } | |
4263 | |
4264 mstart(); | |
4265 } | |
4266 | |
4267 | |
4268 //============================================================================= | |
4269 // 演奏開始 | |
4270 //============================================================================= | |
4271 void PMDWIN::mstart(void) | |
4272 { | |
4273 // TimerB = 0 に設定し、Timer Reset(曲の長さを毎回そろえるため) | |
4274 open_work.tempo_d = 0; | |
4275 settempo_b(); | |
4276 OPNASetReg(&opna, 0x27, 0); // TIMER RESET(timerA,Bとも) | |
4277 | |
4278 //------------------------------------------------------------------------ | |
4279 // 演奏停止 | |
4280 //------------------------------------------------------------------------ | |
4281 pmdwork.music_flag &= 0xfe; | |
4282 mstop(); | |
4283 | |
4284 //------------------------------------------------------------------------ | |
4285 // バッファ初期化 | |
4286 //------------------------------------------------------------------------ | |
4287 pos2 = (char *)wavbuf2; // buf に余っているサンプルの先頭位置 | |
4288 us2 = 0; // buf に余っているサンプル数 | |
4289 upos = 0; // 演奏開始からの時間(μsec) | |
4290 | |
4291 //------------------------------------------------------------------------ | |
4292 // 演奏準備 | |
4293 //------------------------------------------------------------------------ | |
4294 data_init(); | |
4295 play_init(); | |
4296 | |
4297 //------------------------------------------------------------------------ | |
4298 // OPN初期化 | |
4299 //------------------------------------------------------------------------ | |
4300 opn_init(); | |
4301 | |
4302 //------------------------------------------------------------------------ | |
4303 // 音楽の演奏を開始 | |
4304 //------------------------------------------------------------------------ | |
4305 setint(); | |
4306 open_work.play_flag = 1; | |
4307 } | |
4308 | |
4309 | |
4310 //============================================================================= | |
4311 // 各パートのスタートアドレス及び初期値をセット | |
4312 //============================================================================= | |
4313 void PMDWIN::play_init(void) | |
4314 { | |
4315 int i; | |
4316 ushort *p; | |
4317 | |
4318 //2.6追加分 | |
4319 if(*open_work.mmlbuf != 2*(max_part2+1)) { | |
4320 open_work.prgdat_adr = open_work.mmlbuf + *(ushort *)(&open_work.mmlbuf[2*(max_part2+1)]); | |
4321 open_work.prg_flg = 1; | |
4322 } else { | |
4323 open_work.prg_flg = 0; | |
4324 } | |
4325 | |
4326 p = (ushort *)open_work.mmlbuf; | |
4327 | |
4328 // Part 0,1,2,3,4,5(FM1〜6)の時 | |
4329 for(i = 0; i < 6; i++) { | |
4330 if(open_work.mmlbuf[*p] == 0x80) { //先頭が80hなら演奏しない | |
4331 FMPart[i].address = NULL; | |
4332 } else { | |
4333 FMPart[i].address = &open_work.mmlbuf[*p]; | |
4334 } | |
4335 | |
4336 FMPart[i].leng = 1; | |
4337 FMPart[i].keyoff_flag = -1; // 現在keyoff中 | |
4338 FMPart[i].mdc = -1; // MDepth Counter (無限) | |
4339 FMPart[i].mdc2 = -1; // 同上 | |
4340 FMPart[i]._mdc = -1; // 同上 | |
4341 FMPart[i]._mdc2 = -1; // 同上 | |
4342 FMPart[i].onkai = 255; // rest | |
4343 FMPart[i].onkai_def = 255; // rest | |
4344 FMPart[i].volume = 108; // FM VOLUME DEFAULT= 108 | |
4345 FMPart[i].fmpan = 0xc0; // FM PAN = Middle | |
4346 FMPart[i].slotmask = 0xf0; // FM SLOT MASK | |
4347 FMPart[i].neiromask = 0xff; // FM Neiro MASK | |
4348 p++; | |
4349 } | |
4350 | |
4351 // Part 6,7,8(PSG1〜3)の時 | |
4352 for(i = 0; i < 3; i++) { | |
4353 if(open_work.mmlbuf[*p] == 0x80) { //先頭が80hなら演奏しない | |
4354 SSGPart[i].address = NULL; | |
4355 } else { | |
4356 SSGPart[i].address = &open_work.mmlbuf[*p]; | |
4357 } | |
4358 | |
4359 SSGPart[i].leng = 1; | |
4360 SSGPart[i].keyoff_flag = -1; // 現在keyoff中 | |
4361 SSGPart[i].mdc = -1; // MDepth Counter (無限) | |
4362 SSGPart[i].mdc2 = -1; // 同上 | |
4363 SSGPart[i]._mdc = -1; // 同上 | |
4364 SSGPart[i]._mdc2 = -1; // 同上 | |
4365 SSGPart[i].onkai = 255; // rest | |
4366 SSGPart[i].onkai_def = 255; // rest | |
4367 SSGPart[i].volume = 8; // PSG VOLUME DEFAULT= 8 | |
4368 SSGPart[i].psgpat = 7; // PSG = TONE | |
4369 SSGPart[i].envf = 3; // PSG ENV = NONE/normal | |
4370 p++; | |
4371 } | |
4372 p++; | |
4373 | |
4374 // Part 10(Rhythm)の時 | |
4375 if(open_work.mmlbuf[*p] == 0x80) { //先頭が80hなら演奏しない | |
4376 RhythmPart.address = NULL; | |
4377 } else { | |
4378 RhythmPart.address = &open_work.mmlbuf[*p]; | |
4379 } | |
4380 | |
4381 RhythmPart.leng = 1; | |
4382 RhythmPart.keyoff_flag = -1; // 現在keyoff中 | |
4383 RhythmPart.mdc = -1; // MDepth Counter (無限) | |
4384 RhythmPart.mdc2 = -1; // 同上 | |
4385 RhythmPart._mdc = -1; // 同上 | |
4386 RhythmPart._mdc2 = -1; // 同上 | |
4387 RhythmPart.onkai = 255; // rest | |
4388 RhythmPart.onkai_def = 255; // rest | |
4389 RhythmPart.volume = 15; // PPSDRV volume | |
4390 p++; | |
4391 | |
4392 //------------------------------------------------------------------------ | |
4393 // Rhythm のアドレステーブルをセット | |
4394 //------------------------------------------------------------------------ | |
4395 | |
4396 open_work.radtbl = (ushort *)&open_work.mmlbuf[*p]; | |
4397 open_work.rhyadr = (uchar *)&pmdwork.rhydmy; | |
4398 } | |
4399 | |
4400 | |
4401 //============================================================================= | |
4402 // インタラプト 設定 | |
4403 // FM音源専用 | |
4404 //============================================================================= | |
4405 void PMDWIN::setint(void) | |
4406 { | |
4407 // | |
4408 // OPN割り込み初期設定 | |
4409 // | |
4410 | |
4411 open_work.tempo_d = 200; | |
4412 open_work.tempo_d_push = 200; | |
4413 | |
4414 calc_tb_tempo(); | |
4415 settempo_b(); | |
4416 | |
4417 OPNASetReg(&opna, 0x25, 0x00); // TIMER A SET (9216μs固定) | |
4418 OPNASetReg(&opna, 0x24, 0x00); // 一番遅くて丁度いい | |
4419 OPNASetReg(&opna, 0x27, 0x3f); // TIMER ENABLE | |
4420 | |
4421 // | |
4422 // 小節カウンタリセット | |
4423 // | |
4424 | |
4425 open_work.opncount = 0; | |
4426 open_work.syousetu = 0; | |
4427 open_work.syousetu_lng = 96; | |
4428 } | |
4429 | |
4430 | |
4431 //============================================================================= | |
4432 // T->t 変換 | |
4433 // input [tempo_d] | |
4434 // output [tempo_48] | |
4435 //============================================================================= | |
4436 void PMDWIN::calc_tb_tempo(void) | |
4437 { | |
4438 // TEMPO = 0x112C / [ 256 - TB ] timerB -> tempo | |
4439 int temp; | |
4440 | |
4441 if(256 - open_work.tempo_d == 0) { | |
4442 temp = 255; | |
4443 } else { | |
4444 temp = (0x112c * 2 / (256 - open_work.tempo_d) + 1) / 2; | |
4445 if(temp > 255) temp = 255; | |
4446 } | |
4447 | |
4448 open_work.tempo_48 = temp; | |
4449 open_work.tempo_48_push = temp; | |
4450 } | |
4451 | |
4452 | |
4453 //============================================================================= | |
4454 // t->T 変換 | |
4455 // input [tempo_48] | |
4456 // output [tempo_d] | |
4457 //============================================================================= | |
4458 void PMDWIN::calc_tempo_tb(void) | |
4459 { | |
4460 int al; | |
4461 | |
4462 // TB = 256 - [ 112CH / TEMPO ] tempo -> timerB | |
4463 | |
4464 if(open_work.tempo_48 >= 18) { | |
4465 al = 256 - 0x112c / open_work.tempo_48; | |
4466 if(0x112c % open_work.tempo_48 >= 128) { | |
4467 al--; | |
4468 } | |
4469 //al = 256 - (0x112c * 2 / open_work.tempo_48 + 1) / 2; | |
4470 } else { | |
4471 al = 0; | |
4472 } | |
4473 open_work.tempo_d = al; | |
4474 open_work.tempo_d_push = al; | |
4475 } | |
4476 | |
4477 | |
4478 //============================================================================= | |
4479 // 曲の読み込みその3(メモリから、カレントディレクトリあり) | |
4480 //============================================================================= | |
4481 int PMDWIN::music_load3(uchar *musdata, unsigned int size) | |
4482 { | |
4483 if(size > sizeof(mdataarea)) { | |
4484 return ERR_WRONG_MUSIC_FILE; | |
4485 } | |
4486 | |
4487 // 020120 ヘッダ解析のみ Towns に対応 | |
4488 if((musdata[0] > 0x0f && musdata[0] != 0xff) || (musdata[1] != 0x18 && musdata[1] != 0x1a) || musdata[2]) { | |
4489 return ERR_WRONG_MUSIC_FILE; // not PMD data | |
4490 } | |
4491 | |
4492 // メモリを 0x00 で初期化する | |
4493 //memset(mdataarea, 0x00, sizeof(mdataarea)); | |
4494 memcpy(mdataarea, musdata, size); | |
4495 return PMDWIN_OK; | |
4496 } | |
4497 | |
4498 | |
4499 //============================================================================= | |
4500 // 初期化 | |
4501 //============================================================================= | |
4502 bool PMDWIN::init(void) | |
4503 { | |
4504 int i; | |
4505 struct timeval tv; | |
4506 open_work.rate = SOUND_44K; | |
4507 | |
4508 // OPEN_WORK メンバの初期化 | |
4509 open_work.rhyvol = 0x3c; | |
4510 open_work.TimerBflag = 0; | |
4511 open_work.TimerAflag = 0; | |
4512 open_work.TimerB_speed = 0x100; | |
4513 open_work.port22h = 0; | |
4514 | |
4515 if(OPNAInit(&opna, OPNAClock, SOUND_44K, true) == false) return false; | |
4516 SetVolumeFM(&opna, 0); | |
4517 SetVolumePSG(&(opna.psg), 0); | |
4518 | |
4519 // Init RNG state | |
4520 gettimeofday(&tv, NULL); | |
4521 lfg_srand(tv.tv_sec); | |
4522 | |
4523 for(i=0; i<nbufsample; i++) { | |
4524 wavbuf2[i].left = 0; | |
4525 } | |
4526 pos2 = (char *)wavbuf2; | |
4527 us2 = 0; | |
4528 upos = 0; | |
4529 | |
4530 //---------------------------------------------------------------- | |
4531 // 変数の初期化 | |
4532 //---------------------------------------------------------------- | |
4533 | |
4534 open_work.MusPart[ 0] = &FMPart[0]; | |
4535 open_work.MusPart[ 1] = &FMPart[1]; | |
4536 open_work.MusPart[ 2] = &FMPart[2]; | |
4537 open_work.MusPart[ 3] = &FMPart[3]; | |
4538 open_work.MusPart[ 4] = &FMPart[4]; | |
4539 open_work.MusPart[ 5] = &FMPart[5]; | |
4540 open_work.MusPart[ 6] = &SSGPart[0]; | |
4541 open_work.MusPart[ 7] = &SSGPart[1]; | |
4542 open_work.MusPart[ 8] = &SSGPart[2]; | |
4543 open_work.MusPart[ 9] = &RhythmPart; | |
4544 | |
4545 mdataarea[0] = 0; | |
4546 for(i = 0; i < 12; i++) { | |
4547 mdataarea[i*2+1] = 0x18; | |
4548 mdataarea[i*2+2] = 0; | |
4549 } | |
4550 mdataarea[25] = 0x80; | |
4551 | |
4552 open_work.fm_voldown = fmvd_init; // FM_VOLDOWN | |
4553 open_work._fm_voldown = fmvd_init; // FM_VOLDOWN | |
4554 open_work.ssg_voldown = 0; // SSG_VOLDOWN | |
4555 open_work._ssg_voldown = 0; // SSG_VOLDOWN | |
4556 open_work.rhythm_voldown = 0; // RHYTHM_VOLDOWN | |
4557 open_work._rhythm_voldown = 0; // RHYTHM_VOLDOWN | |
4558 | |
4559 memset(FMPart, 0, sizeof(FMPart)); | |
4560 memset(SSGPart, 0, sizeof(SSGPart)); | |
4561 memset(&RhythmPart, 0, sizeof(RhythmPart)); | |
4562 | |
4563 pmdwork.music_flag = 0; | |
4564 pmdwork.ppsdrv_flag = false; // PPSDRV FLAG | |
4565 | |
4566 //---------------------------------------------------------------- | |
4567 // 曲データ,音色データ格納番地を設定 | |
4568 //---------------------------------------------------------------- | |
4569 open_work.mmlbuf = &mdataarea[1]; | |
4570 | |
4571 //---------------------------------------------------------------- | |
4572 // 効果音/FMINT/EFCINTを初期化 | |
4573 //---------------------------------------------------------------- | |
4574 effwork.effon = 0; | |
4575 effwork.psgefcnum = 0xff; | |
4576 | |
4577 //---------------------------------------------------------------- | |
4578 // 088/188/288/388 (同INT番号のみ) を初期設定 | |
4579 //---------------------------------------------------------------- | |
4580 OPNASetReg(&opna, 0x29, 0x00); | |
4581 OPNASetReg(&opna, 0x24, 0x00); | |
4582 OPNASetReg(&opna, 0x25, 0x00); | |
4583 OPNASetReg(&opna, 0x26, 0x00); | |
4584 OPNASetReg(&opna, 0x27, 0x3f); | |
4585 | |
4586 //---------------------------------------------------------------- | |
4587 // OPN割り込み開始 | |
4588 //---------------------------------------------------------------- | |
4589 opnint_start(); | |
4590 | |
4591 return true; | |
4592 } | |
4593 | |
4594 | |
4595 //============================================================================= | |
4596 // 合成周波数の設定 | |
4597 //============================================================================= | |
4598 void PMDWIN::setpcmrate(unsigned int rate) | |
4599 { | |
4600 if(rate == SOUND_55K || rate == SOUND_55K_2) { | |
4601 open_work.rate = SOUND_44K; | |
4602 open_work.fmcalc55k = true; | |
4603 } else { | |
4604 open_work.rate = rate; | |
4605 open_work.fmcalc55k = false; | |
4606 } | |
4607 OPNASetRate(&opna, open_work.rate, open_work.fmcalc55k); | |
4608 } | |
4609 | |
4610 | |
4611 //============================================================================= | |
4612 // Mask to enable/disable usage of FM (bit 0), SSG (bit 1) and Rhythm (bit 2) | |
4613 // on the OPNA. Mostly for testing purposes. | |
4614 //============================================================================= | |
4615 void PMDWIN::setdevmask(uint8_t mask) | |
4616 { | |
4617 opna.devmask = mask; | |
4618 } | |
4619 | |
4620 | |
4621 void PMDWIN::setchanmask(uint32_t mask) | |
4622 { | |
4623 OPNASetChannelMask(&opna, mask); | |
4624 } | |
4625 | |
4626 | |
4627 //============================================================================= | |
4628 // 演奏開始 | |
4629 //============================================================================= | |
4630 void PMDWIN::music_start(void) | |
4631 { | |
4632 mstart_f(); | |
4633 } | |
4634 | |
4635 | |
4636 //============================================================================= | |
4637 // 演奏停止 | |
4638 //============================================================================= | |
4639 void PMDWIN::music_stop(void) | |
4640 { | |
4641 mstop_f(); | |
4642 } | |
4643 | |
4644 | |
4645 //============================================================================= | |
4646 // PCM データ(wave データ)の取得 | |
4647 //============================================================================= | |
4648 void PMDWIN::getpcmdata(short *buf, int nsamples) | |
4649 { | |
4650 int copysamples = 0; // コピー済みのサンプル数 | |
4651 int i, us; | |
4652 | |
4653 do { | |
4654 if(nsamples - copysamples <= us2) { | |
4655 memcpy(buf, pos2, (nsamples - copysamples)*2); | |
4656 us2 -= (nsamples - copysamples); | |
4657 pos2 += (nsamples - copysamples)*2; | |
4658 copysamples = nsamples; | |
4659 } else { | |
4660 memcpy(buf, pos2, us2 * 2); | |
4661 buf += us2; | |
4662 copysamples += us2; | |
4663 pos2 = (char *)wavbuf2; | |
4664 | |
4665 if(ReadStatus(&opna) & 0x01) { | |
4666 TimerA_main(); | |
4667 } | |
4668 | |
4669 if(ReadStatus(&opna) & 0x02) { | |
4670 TimerB_main(); | |
4671 } | |
4672 | |
4673 OPNASetReg(&opna, 0x27, open_work.ch3mode | 0x30); // TIMER RESET(timerA,Bとも) | |
4674 | |
4675 | |
4676 us = OPNAGetNextEvent(&opna); | |
4677 us2 = (int)((float)us * open_work.rate / 1000000.0f); | |
4678 OPNATimerCount(&opna, us); | |
4679 | |
4680 int32_t tmpbuf[8192]; | |
4681 for(i=0; i<us2; i++) tmpbuf[i] = 0; | |
4682 OPNAMix(&opna, (int32_t*)tmpbuf, us2); | |
4683 upos += us; | |
4684 | |
4685 for(i = 0; i < us2; i++) { | |
4686 wavbuf2[i].left = Limit(tmpbuf[i], 32767, -32768); | |
4687 } | |
4688 } | |
4689 } while(copysamples < nsamples); | |
4690 } | |
4691 | |
4692 | |
4693 //============================================================================= | |
4694 // FM で 55kHz合成、一次補完するかどうかの設定 | |
4695 //============================================================================= | |
4696 void PMDWIN::setfmcalc55k(bool flag) | |
4697 { | |
4698 open_work.fmcalc55k = flag; | |
4699 OPNASetRate(&opna, open_work.rate, open_work.fmcalc55k); | |
4700 } | |
4701 | |
4702 | |
4703 unsigned int PMDWIN::getstatus(char *buf, size_t bufsize) | |
4704 { | |
4705 char *p = buf; | |
4706 unsigned int i = 0, len; | |
4707 while(i < 6) { | |
4708 *p++ = 'F'; | |
4709 *p++ = 'M'; | |
4710 *p++ = (i + 0x30); | |
4711 *p++ = ':'; | |
4712 *p++ = ' '; | |
4713 *p++ = notes[pmdstatus[i]][0]; | |
4714 *p++ = notes[pmdstatus[i]][1]; | |
4715 *p++ = ' '; | |
4716 i++; | |
4717 } | |
4718 while(i < 9) { | |
4719 *p++ = 'P'; | |
4720 *p++ = 'S'; | |
4721 *p++ = 'G'; | |
4722 *p++ = (i + 0x30 - 6); | |
4723 *p++ = ':'; | |
4724 *p++ = ' '; | |
4725 *p++ = notes[pmdstatus[i]][0]; | |
4726 *p++ = notes[pmdstatus[i]][1]; | |
4727 *p++ = ' '; | |
4728 i++; | |
4729 } | |
4730 p -= 3; | |
4731 *p++ = (pmdstatus[8] + 0x30); | |
4732 *p++ = '\0'; | |
4733 len = (p - buf); | |
4734 return len; | |
4735 } | |
4736 | |
4737 | |
4738 //============================================================================= | |
4739 // メモの取得(内部動作) | |
4740 //============================================================================= | |
4741 char* PMDWIN::_getmemo(char *dest, uchar *musdata, int size, int al) | |
4742 { | |
4743 uchar *si, *mmlbuf; | |
4744 int i, dx; | |
4745 int maxsize; | |
4746 | |
4747 if(musdata == NULL || size == 0) { | |
4748 mmlbuf = open_work.mmlbuf; | |
4749 maxsize = sizeof(mdataarea) - 1; | |
4750 } else { | |
4751 mmlbuf = &musdata[1]; | |
4752 maxsize = size - 1; | |
4753 } | |
4754 if(maxsize < 2) { | |
4755 *dest = '\0'; // 曲データが不正 | |
4756 return NULL; | |
4757 } | |
4758 | |
4759 if(mmlbuf[0] != 0x1a || mmlbuf[1] != 0x00) { | |
4760 *dest = '\0'; // 音色がないfile=メモのアドレス取得不能 | |
4761 return dest; | |
4762 } | |
4763 | |
4764 if(maxsize < 0x18+1) { | |
4765 *dest = '\0'; // 曲データが不正 | |
4766 return NULL; | |
4767 } | |
4768 | |
4769 if(maxsize < *(ushort *)&mmlbuf[0x18] - 4 + 3) { | |
4770 *dest = '\0'; // 曲データが不正 | |
4771 return NULL; | |
4772 } | |
4773 | |
4774 si = &mmlbuf[*(ushort *)&mmlbuf[0x18] - 4]; | |
4775 if(*(si + 2) != 0x40) { | |
4776 if(*(si + 3) != 0xfe || *(si + 2) < 0x41) { | |
4777 *dest = '\0'; // 音色がないfile=メモのアドレス取得不能 | |
4778 return dest; | |
4779 } | |
4780 } | |
4781 | |
4782 if(*(si + 2) >= 0x42) { | |
4783 al++; | |
4784 } | |
4785 | |
4786 if(*(si + 2) >= 0x48) { | |
4787 al++; | |
4788 } | |
4789 | |
4790 if(al < 0) { | |
4791 *dest = '\0'; // 登録なし | |
4792 return dest; | |
4793 } | |
4794 | |
4795 si = &mmlbuf[*(ushort *)si]; | |
4796 | |
4797 for(i = 0; i <= al; i++) { | |
4798 if(maxsize < si - mmlbuf + 1) { | |
4799 *dest = '\0'; // 曲データが不正 | |
4800 return NULL; | |
4801 } | |
4802 | |
4803 dx = *(ushort *)si; | |
4804 if(dx == 0) { | |
4805 *dest = '\0'; | |
4806 return dest; | |
4807 } | |
4808 | |
4809 if(maxsize < dx) { | |
4810 *dest = '\0'; // 曲データが不正 | |
4811 return NULL; | |
4812 } | |
4813 | |
4814 if(mmlbuf[dx] == '/') { | |
4815 *dest = '\0'; | |
4816 return dest; | |
4817 } | |
4818 | |
4819 si += 2; | |
4820 } | |
4821 | |
4822 for(i = dx; i < maxsize; i++) { | |
4823 if(mmlbuf[i] == '\0') break; | |
4824 } | |
4825 | |
4826 // 終端の \0 がない場合 | |
4827 if(i >= maxsize) { | |
4828 memcpy(dest, &mmlbuf[dx], maxsize - dx); | |
4829 dest[maxsize - dx - 1] = '\0'; | |
4830 } else { | |
4831 memcpy(dest, &mmlbuf[dx], i); | |
4832 dest[i] = '\0'; | |
4833 } | |
4834 return dest; | |
4835 } | |
4836 | |
4837 /* | |
4838 Conversion between SJIS codes (s1,s2) and JISX0208 codes (c1,c2): | |
4839 Example. (s1,s2) = 0x8140, (c1,c2) = 0x2121. | |
4840 0x81 <= s1 <= 0x9F || 0xE0 <= s1 <= 0xEA, | |
4841 0x40 <= s2 <= 0x7E || 0x80 <= s2 <= 0xFC, | |
4842 0x21 <= c1 <= 0x74, 0x21 <= c2 <= 0x7E. | |
4843 Invariant: | |
4844 94*2*(s1 < 0xE0 ? s1-0x81 : s1-0xC1) + (s2 < 0x80 ? s2-0x40 : s2-0x41) | |
4845 = 94*(c1-0x21)+(c2-0x21) | |
4846 Conversion (s1,s2) -> (c1,c2): | |
4847 t1 := (s1 < 0xE0 ? s1-0x81 : s1-0xC1) | |
4848 t2 := (s2 < 0x80 ? s2-0x40 : s2-0x41) | |
4849 c1 := 2*t1 + (t2 < 0x5E ? 0 : 1) + 0x21 | |
4850 c2 := (t2 < 0x5E ? t2 : t2-0x5E) + 0x21 | |
4851 Conversion (c1,c2) -> (s1,s2): | |
4852 t1 := (c1 - 0x21) >> 1 | |
4853 t2 := ((c1 - 0x21) & 1) * 0x5E + (c2 - 0x21) | |
4854 s1 := (t1 < 0x1F ? t1+0x81 : t1+0xC1) | |
4855 s2 := (t2 < 0x3F ? t2+0x40 : t2+0x41) | |
4856 */ | |
4857 | |
4858 static int sjis_to_ucs4(uint32_t *pwc, const uint8_t *s, int n) | |
4859 { | |
4860 uint8_t c = *s; | |
4861 if (c <= 0x80) { | |
4862 if (c == 0x5c) | |
4863 *pwc = (uint32_t) 0x00a5; | |
4864 else if (c == 0x7e) | |
4865 *pwc = (uint32_t) 0x203e; | |
4866 else | |
4867 *pwc = (uint32_t) c; | |
4868 return 1; | |
4869 } else if (c >= 0xa1 && c <= 0xdf) { | |
4870 *pwc = (uint32_t) c + 0xfec0; | |
4871 return 1; | |
4872 } else { | |
4873 uint8_t s1, s2; | |
4874 s1 = c; | |
4875 if ((s1 >= 0x81 && s1 <= 0x9f) || (s1 >= 0xe0 && s1 <= 0xea)) { | |
4876 if (n < 2) | |
4877 return -2; | |
4878 s2 = s[1]; | |
4879 if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) { | |
4880 uint8_t t1 = (s1 < 0xe0 ? s1-0x81 : s1-0xc1); | |
4881 uint8_t t2 = (s2 < 0x80 ? s2-0x40 : s2-0x41); | |
4882 uint8_t buf[2]; | |
4883 buf[0] = 2*t1 + (t2 < 0x5e ? 0 : 1) + 0x21; | |
4884 buf[1] = (t2 < 0x5e ? t2 : t2-0x5e) + 0x21; | |
4885 return jisx0208_mbtowc(pwc,buf,2); | |
4886 } | |
4887 } else if (s1 >= 0xf0 && s1 <= 0xf9) { | |
4888 /* User-defined range. See | |
4889 * Ken Lunde's "CJKV Information Processing", table 4-66, p. 206. */ | |
4890 if (n < 2) | |
4891 return -2; | |
4892 s2 = s[1]; | |
4893 if ((s2 >= 0x40 && s2 <= 0x7e) || (s2 >= 0x80 && s2 <= 0xfc)) { | |
4894 *pwc = 0xe000 + 188*(s1 - 0xf0) + (s2 < 0x80 ? s2-0x40 : s2-0x41); | |
4895 return 2; | |
4896 } | |
4897 } | |
4898 return -1; | |
4899 } | |
4900 } | |
4901 | |
4902 static int ucs4_to_utf8(uint8_t *utf8, uint32_t ucs4) | |
4903 { | |
4904 if (ucs4 <= 0x0000007fL) { | |
4905 utf8[0] = ucs4; | |
4906 return 1; | |
4907 } else if (ucs4 <= 0x000007ffL) { | |
4908 utf8[0] = 0xc0 | ((ucs4 >> 6) & 0x1f); | |
4909 utf8[1] = 0x80 | ((ucs4 >> 0) & 0x3f); | |
4910 return 2; | |
4911 } else if (ucs4 <= 0x0000ffffL) { | |
4912 utf8[0] = 0xe0 | ((ucs4 >> 12) & 0x0f); | |
4913 utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f); | |
4914 utf8[2] = 0x80 | ((ucs4 >> 0) & 0x3f); | |
4915 return 3; | |
4916 } | |
4917 | |
4918 /* default */ | |
4919 utf8[0] = '?'; | |
4920 return 1; | |
4921 } | |
4922 | |
4923 static size_t sjis_to_utf8(uint8_t *outbuf, uint8_t *inbuf, size_t insize) { | |
4924 uint32_t wc = 0; | |
4925 uint8_t *utf8str = outbuf; | |
4926 uint8_t *utf8str_start = utf8str; | |
4927 int ret; | |
4928 while(insize > 0) { | |
4929 ret = sjis_to_ucs4(&wc, inbuf, insize); | |
4930 if(ret < 0) { | |
4931 inbuf++; insize--; | |
4932 continue; | |
4933 } | |
4934 utf8str += ucs4_to_utf8(utf8str, wc); | |
4935 inbuf += ret; | |
4936 insize -= ret; | |
4937 } | |
4938 return (utf8str - utf8str_start); | |
4939 } | |
4940 | |
4941 char* PMDWIN::_getmemo3(char *dest, uchar *musdata, int size, int al) | |
4942 { | |
4943 char buf[mdata_def*1024]; | |
4944 _getmemo((char *)buf, musdata, size, al); | |
4945 sjis_to_utf8((uint8_t*)dest, (uint8_t*)buf, strlen(buf)+1); | |
4946 return dest; | |
4947 } | |
4948 | |
4949 | |
4950 //============================================================================= | |
4951 // パートのマスク | |
4952 //============================================================================= | |
4953 int PMDWIN::maskon(unsigned int ch) | |
4954 { | |
4955 int ah, fmseltmp; | |
4956 | |
4957 | |
4958 if(ch >= sizeof(open_work.MusPart) / sizeof(QQ *)) { | |
4959 return ERR_WRONG_PARTNO; // part number error | |
4960 } | |
4961 | |
4962 if(part_table[ch][0] < 0) { | |
4963 open_work.rhythmmask = 0; // Rhythm音源をMask | |
4964 OPNASetReg(&opna, 0x10, 0xff); // Rhythm音源を全部Dump | |
4965 } else { | |
4966 fmseltmp = pmdwork.fmsel; | |
4967 if(open_work.MusPart[ch]->partmask == 0 && open_work.play_flag) { | |
4968 if(part_table[ch][2] == 0) { | |
4969 pmdwork.partb = part_table[ch][1]; | |
4970 pmdwork.fmsel = 0; | |
4971 silence_fmpart(open_work.MusPart[ch]); // 音を完璧に消す | |
4972 } else if(part_table[ch][2] == 1) { | |
4973 pmdwork.partb = part_table[ch][1]; | |
4974 pmdwork.fmsel = 0x100; | |
4975 silence_fmpart(open_work.MusPart[ch]); // 音を完璧に消す | |
4976 } else if(part_table[ch][2] == 2) { | |
4977 pmdwork.partb = part_table[ch][1]; | |
4978 ah = 1 << (pmdwork.partb - 1); | |
4979 ah |= (ah << 3); | |
4980 // PSG keyoff | |
4981 PSGSetReg(&(opna.psg), 0x07, ah | PSGGetReg(&(opna.psg), 0x07)); | |
4982 } else if(part_table[ch][2] == 4) { | |
4983 if(effwork.psgefcnum < 11) { | |
4984 effend(); | |
4985 } | |
4986 } | |
4987 } | |
4988 open_work.MusPart[ch]->partmask |= 1; | |
4989 pmdwork.fmsel = fmseltmp; | |
4990 } | |
4991 return PMDWIN_OK; | |
4992 } | |
4993 | |
4994 | |
4995 //============================================================================= | |
4996 // パートのマスク解除 | |
4997 //============================================================================= | |
4998 int PMDWIN::maskoff(unsigned int ch) | |
4999 { | |
5000 int fmseltmp; | |
5001 | |
5002 if(ch >= sizeof(open_work.MusPart) / sizeof(QQ *)) { | |
5003 return ERR_WRONG_PARTNO; // part number error | |
5004 } | |
5005 | |
5006 if(part_table[ch][0] < 0) { | |
5007 open_work.rhythmmask = 0xff; | |
5008 } else { | |
5009 if(open_work.MusPart[ch]->partmask == 0) return ERR_NOT_MASKED; // マスクされていない | |
5010 // 効果音でまだマスクされている | |
5011 if((open_work.MusPart[ch]->partmask &= 0xfe) != 0) return ERR_EFFECT_USED; | |
5012 // 曲が止まっている | |
5013 if(open_work.play_flag == 0) return ERR_MUSIC_STOPPED; | |
5014 | |
5015 fmseltmp = pmdwork.fmsel; | |
5016 if(open_work.MusPart[ch]->address != NULL) { | |
5017 if(part_table[ch][2] == 0) { // FM音源(表) | |
5018 pmdwork.fmsel = 0; | |
5019 pmdwork.partb = part_table[ch][1]; | |
5020 neiro_reset(open_work.MusPart[ch]); | |
5021 } else if(part_table[ch][2] == 1) { // FM音源(裏) | |
5022 pmdwork.fmsel = 0x100; | |
5023 pmdwork.partb = part_table[ch][1]; | |
5024 neiro_reset(open_work.MusPart[ch]); | |
5025 } | |
5026 } | |
5027 pmdwork.fmsel = fmseltmp; | |
5028 | |
5029 } | |
5030 return PMDWIN_OK; | |
5031 } | |
5032 | |
5033 | |
5034 //============================================================================= | |
5035 // FM Volume Down の設定 | |
5036 //============================================================================= | |
5037 void PMDWIN::setfmvoldown(int voldown) | |
5038 { | |
5039 open_work.fm_voldown = open_work._fm_voldown = voldown; | |
5040 } | |
5041 | |
5042 | |
5043 //============================================================================= | |
5044 // SSG Volume Down の設定 | |
5045 //============================================================================= | |
5046 void PMDWIN::setssgvoldown(int voldown) | |
5047 { | |
5048 open_work.ssg_voldown = open_work._ssg_voldown = voldown; | |
5049 } | |
5050 | |
5051 | |
5052 //============================================================================= | |
5053 // Rhythm Volume Down の設定 | |
5054 //============================================================================= | |
5055 void PMDWIN::setrhythmvoldown(int voldown) | |
5056 { | |
5057 open_work.rhythm_voldown = open_work._rhythm_voldown = voldown; | |
5058 open_work.rhyvol = 48*4*(256-open_work.rhythm_voldown)/1024; | |
5059 OPNASetReg(&opna, 0x11, open_work.rhyvol); | |
5060 | |
5061 } | |
5062 | |
5063 | |
5064 //============================================================================= | |
5065 // FM Volume Down の取得 | |
5066 //============================================================================= | |
5067 int PMDWIN::getfmvoldown(void) | |
5068 { | |
5069 return open_work.fm_voldown; | |
5070 } | |
5071 | |
5072 | |
5073 //============================================================================= | |
5074 // FM Volume Down の取得(その2) | |
5075 //============================================================================= | |
5076 int PMDWIN::getfmvoldown2(void) | |
5077 { | |
5078 return open_work._fm_voldown; | |
5079 } | |
5080 | |
5081 | |
5082 //============================================================================= | |
5083 // SSG Volume Down の取得 | |
5084 //============================================================================= | |
5085 int PMDWIN::getssgvoldown(void) | |
5086 { | |
5087 return open_work.ssg_voldown; | |
5088 } | |
5089 | |
5090 | |
5091 //============================================================================= | |
5092 // SSG Volume Down の取得(その2) | |
5093 //============================================================================= | |
5094 int PMDWIN::getssgvoldown2(void) | |
5095 { | |
5096 return open_work._ssg_voldown; | |
5097 } | |
5098 | |
5099 | |
5100 //============================================================================= | |
5101 // Rhythm Volume Down の取得 | |
5102 //============================================================================= | |
5103 int PMDWIN::getrhythmvoldown(void) | |
5104 { | |
5105 return open_work.rhythm_voldown; | |
5106 } | |
5107 | |
5108 | |
5109 //============================================================================= | |
5110 // Rhythm Volume Down の取得(その2) | |
5111 //============================================================================= | |
5112 int PMDWIN::getrhythmvoldown2(void) | |
5113 { | |
5114 return open_work._rhythm_voldown; | |
5115 } | |
5116 | |
5117 | |
5118 //============================================================================= | |
5119 // 再生位置の移動(pos : ms) | |
5120 //============================================================================= | |
5121 void PMDWIN::setpos(int pos) | |
5122 { | |
5123 uint64_t _pos; | |
5124 int us; | |
5125 | |
5126 _pos = (uint64_t)pos * 1000; // (ms -> usec への変換) | |
5127 | |
5128 if(upos > _pos) { | |
5129 mstart(); | |
5130 pos2 = (char *)wavbuf2; // buf に余っているサンプルの先頭位置 | |
5131 us2 = 0; // buf に余っているサンプル数 | |
5132 upos = 0; // 演奏開始からの時間(μsec) | |
5133 } | |
5134 | |
5135 while(upos < _pos) { | |
5136 if(ReadStatus(&opna) & 0x01) { | |
5137 TimerA_main(); | |
5138 } | |
5139 | |
5140 if(ReadStatus(&opna) & 0x02) { | |
5141 TimerB_main(); | |
5142 } | |
5143 | |
5144 OPNASetReg(&opna, 0x27, open_work.ch3mode | 0x30); // TIMER RESET(timerA,Bとも) | |
5145 | |
5146 us = OPNAGetNextEvent(&opna); | |
5147 OPNATimerCount(&opna, us); | |
5148 upos += us; | |
5149 } | |
5150 | |
5151 if(open_work.status2 == -1) { | |
5152 silence(); | |
5153 } | |
5154 } | |
5155 | |
5156 | |
5157 //============================================================================= | |
5158 // 再生位置の移動(pos : count 単位) | |
5159 //============================================================================= | |
5160 void PMDWIN::setpos2(int pos) | |
5161 { | |
5162 int us; | |
5163 | |
5164 if(open_work.syousetu_lng * open_work.syousetu + open_work.opncount > pos) { | |
5165 mstart(); | |
5166 pos2 = (char *)wavbuf2; // buf に余っているサンプルの先頭位置 | |
5167 us2 = 0; // buf に余っているサンプル数 | |
5168 } | |
5169 | |
5170 while(open_work.syousetu_lng * open_work.syousetu + open_work.opncount < pos) { | |
5171 if(ReadStatus(&opna) & 0x01) { | |
5172 TimerA_main(); | |
5173 } | |
5174 | |
5175 if(ReadStatus(&opna) & 0x02) { | |
5176 TimerB_main(); | |
5177 } | |
5178 | |
5179 OPNASetReg(&opna, 0x27, open_work.ch3mode | 0x30); // TIMER RESET(timerA,Bとも) | |
5180 | |
5181 us = OPNAGetNextEvent(&opna); | |
5182 OPNATimerCount(&opna, us); | |
5183 } | |
5184 | |
5185 if(open_work.status2 == -1) { | |
5186 silence(); | |
5187 } | |
5188 } | |
5189 | |
5190 | |
5191 //============================================================================= | |
5192 // 再生位置の取得(pos : ms) | |
5193 //============================================================================= | |
5194 int PMDWIN::getpos(void) | |
5195 { | |
5196 return (int)(upos / 1000); | |
5197 } | |
5198 | |
5199 | |
5200 //============================================================================= | |
5201 // 再生位置の取得(pos : count 単位) | |
5202 //============================================================================= | |
5203 int PMDWIN::getpos2(void) | |
5204 { | |
5205 return open_work.syousetu_lng * open_work.syousetu + open_work.opncount; | |
5206 } | |
5207 | |
5208 | |
5209 //============================================================================= | |
5210 // 曲の長さの取得(pos : ms) | |
5211 //============================================================================= | |
5212 bool PMDWIN::getlength(uint *length, uint *loop) | |
5213 { | |
5214 int us; | |
5215 mstart(); | |
5216 upos = 0; // 演奏開始からの時間(μsec) | |
5217 *length = 0; | |
5218 | |
5219 do { | |
5220 if(ReadStatus(&opna) & 0x01) { | |
5221 TimerA_main(); | |
5222 } | |
5223 | |
5224 if(ReadStatus(&opna) & 0x02) { | |
5225 TimerB_main(); | |
5226 } | |
5227 | |
5228 OPNASetReg(&opna, 0x27, open_work.ch3mode | 0x30); // TIMER RESET(timerA,Bとも) | |
5229 | |
5230 us = OPNAGetNextEvent(&opna); | |
5231 OPNATimerCount(&opna, us); | |
5232 upos += us; | |
5233 if(open_work.status2 == 1 && *length == 0) { // ループ時 | |
5234 *length = (int)(upos / 1000); | |
5235 } else if(open_work.status2 == -1) { // ループなし終了時 | |
5236 *length = (int)(upos / 1000); | |
5237 *loop = 0; | |
5238 mstop(); | |
5239 return true; | |
5240 } else if(getpos2() >= 65536) { // 65536クロック以上なら強制終了 | |
5241 *length = (int)(upos / 1000); | |
5242 *loop = *length; | |
5243 return true; | |
5244 } | |
5245 } while(open_work.status2 < 2); | |
5246 | |
5247 *loop = (int)(upos / 1000) - *length; | |
5248 mstop(); | |
5249 return true; | |
5250 } | |
5251 | |
5252 | |
5253 //============================================================================= | |
5254 // ループ回数の取得 | |
5255 //============================================================================= | |
5256 int PMDWIN::getloopcount(void) | |
5257 { | |
5258 return open_work.status2; | |
5259 } | |
5260 | |
5261 | |
5262 //============================================================================= | |
5263 // OPEN_WORKのポインタの取得 | |
5264 //============================================================================= | |
5265 OPEN_WORK* PMDWIN::getopenwork(void) | |
5266 { | |
5267 return &open_work; | |
5268 } | |
5269 | |
5270 | |
5271 //============================================================================= | |
5272 // パートワークのポインタの取得 | |
5273 //============================================================================= | |
5274 QQ* PMDWIN::getpartwork(unsigned int ch) | |
5275 { | |
5276 if(ch >= sizeof(open_work.MusPart) / sizeof(QQ *)) { | |
5277 return NULL; | |
5278 } | |
5279 return open_work.MusPart[ch]; | |
5280 } | |
5281 | |
5282 PMDWIN* pmdwin; | |
5283 #ifdef WIN32 | |
5284 //============================================================================= | |
5285 // DLL Export Functions | |
5286 //============================================================================= | |
5287 BOOL DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) | |
5288 { | |
5289 switch (ul_reason_for_call) | |
5290 { | |
5291 case DLL_PROCESS_ATTACH: | |
5292 //DisableThreadLibraryCalls(hModule); | |
5293 pmdwin = NULL; | |
5294 break; | |
5295 | |
5296 case DLL_THREAD_ATTACH: | |
5297 break; | |
5298 | |
5299 case DLL_THREAD_DETACH: | |
5300 break; | |
5301 | |
5302 case DLL_PROCESS_DETACH: | |
5303 break; | |
5304 } | |
5305 return TRUE; | |
5306 } | |
5307 #endif | |
5308 | |
5309 #ifdef __cplusplus | |
5310 extern "C" { | |
5311 #endif | |
5312 | |
5313 | |
5314 //============================================================================= | |
5315 // バーション取得 | |
5316 //============================================================================= | |
5317 DLLEXPORT int getversion(void) | |
5318 { | |
5319 return DLLVersion; | |
5320 } | |
5321 | |
5322 | |
5323 //============================================================================= | |
5324 // 初期化 | |
5325 //============================================================================= | |
5326 DLLEXPORT bool pmdwininit(void) | |
5327 { | |
5328 bool result; | |
5329 | |
5330 if(pmdwin == NULL) { | |
5331 //pmdwin = new PMDWIN; | |
5332 #if defined(WIN32) || defined(WIN64) | |
5333 pmdwin = (PMDWIN*)VirtualAlloc(NULL, sizeof(PMDWIN), MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE); | |
5334 #else | |
5335 pmdwin = (PMDWIN*)mmap(NULL, sizeof(PMDWIN), PROT_READ|PROT_WRITE, | |
5336 MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); | |
5337 #endif | |
5338 } | |
5339 result = pmdwin->init(); | |
5340 return result; | |
5341 } | |
5342 | |
5343 | |
5344 DLLEXPORT void pmdwinfree(void) | |
5345 { | |
5346 #if defined(WIN32) || defined(WIN64) | |
5347 VirtualFree(pmdwin, 0, MEM_RELEASE); | |
5348 #else | |
5349 munmap(pmdwin, sizeof(PMDWIN)); | |
5350 #endif | |
5351 } | |
5352 | |
5353 | |
5354 //============================================================================= | |
5355 // 合成周波数の設定 | |
5356 //============================================================================= | |
5357 DLLEXPORT void setpcmrate(unsigned int rate) | |
5358 { | |
5359 pmdwin->setpcmrate(rate); | |
5360 } | |
5361 | |
5362 | |
5363 DLLEXPORT void setdevmask(uint8_t mask) | |
5364 { | |
5365 pmdwin->setdevmask(mask); | |
5366 } | |
5367 | |
5368 DLLEXPORT void setchanmask(uint32_t mask) | |
5369 { | |
5370 pmdwin->setchanmask(mask); | |
5371 } | |
5372 | |
5373 | |
5374 //============================================================================= | |
5375 // 曲の読み込みその2(メモリから) | |
5376 //============================================================================= | |
5377 DLLEXPORT int music_load3(uchar *musdata, int size) | |
5378 { | |
5379 return pmdwin->music_load3(musdata, size); | |
5380 } | |
5381 | |
5382 | |
5383 //============================================================================= | |
5384 // 演奏開始 | |
5385 //============================================================================= | |
5386 DLLEXPORT void music_start(void) | |
5387 { | |
5388 pmdwin->music_start(); | |
5389 } | |
5390 | |
5391 | |
5392 //============================================================================= | |
5393 // 演奏停止 | |
5394 //============================================================================= | |
5395 DLLEXPORT void music_stop(void) | |
5396 { | |
5397 pmdwin->music_stop(); | |
5398 } | |
5399 | |
5400 | |
5401 //============================================================================= | |
5402 // PCM データ(wave データ)の取得 | |
5403 //============================================================================= | |
5404 DLLEXPORT void getpcmdata(short *buf, int nsamples) | |
5405 { | |
5406 pmdwin->getpcmdata(buf, nsamples); | |
5407 } | |
5408 | |
5409 | |
5410 //============================================================================= | |
5411 // FM で 55kHz合成、一次補完するかどうかの設定 | |
5412 //============================================================================= | |
5413 DLLEXPORT void setfmcalc55k(bool flag) | |
5414 { | |
5415 pmdwin->setfmcalc55k(flag); | |
5416 } | |
5417 | |
5418 | |
5419 DLLEXPORT unsigned int getstatus(char *buf, size_t bufsize) | |
5420 { | |
5421 return pmdwin->getstatus(buf, bufsize); | |
5422 } | |
5423 | |
5424 | |
5425 //============================================================================= | |
5426 // メモの取得 | |
5427 //============================================================================= | |
5428 DLLEXPORT char * getmemo(char *dest, uchar *musdata, int size, int al) | |
5429 { | |
5430 return pmdwin->_getmemo(dest, musdata, size, al); | |
5431 } | |
5432 | |
5433 | |
5434 //============================================================================= | |
5435 // メモの取得(2バイト半角→半角文字に変換+ESCシーケンスの除去) | |
5436 //============================================================================= | |
5437 DLLEXPORT char * getmemo3(char *dest, uchar *musdata, int size, int al) | |
5438 { | |
5439 return pmdwin->_getmemo3(dest, musdata, size, al); | |
5440 } | |
5441 | |
5442 | |
5443 //============================================================================= | |
5444 // パートのマスク | |
5445 //============================================================================= | |
5446 DLLEXPORT int maskon(unsigned int ch) | |
5447 { | |
5448 return pmdwin->maskon(ch); | |
5449 } | |
5450 | |
5451 | |
5452 //============================================================================= | |
5453 // パートのマスク解除 | |
5454 //============================================================================= | |
5455 DLLEXPORT int maskoff(unsigned int ch) | |
5456 { | |
5457 return pmdwin->maskoff(ch); | |
5458 } | |
5459 | |
5460 | |
5461 //============================================================================= | |
5462 // FM Volume Down の設定 | |
5463 //============================================================================= | |
5464 DLLEXPORT void setfmvoldown(int voldown) | |
5465 { | |
5466 pmdwin->setfmvoldown(voldown); | |
5467 } | |
5468 | |
5469 | |
5470 //============================================================================= | |
5471 // SSG Volume Down の設定 | |
5472 //============================================================================= | |
5473 DLLEXPORT void setssgvoldown(int voldown) | |
5474 { | |
5475 pmdwin->setssgvoldown(voldown); | |
5476 } | |
5477 | |
5478 | |
5479 //============================================================================= | |
5480 // Rhythm Volume Down の設定 | |
5481 //============================================================================= | |
5482 DLLEXPORT void setrhythmvoldown(int voldown) | |
5483 { | |
5484 pmdwin->setrhythmvoldown(voldown); | |
5485 } | |
5486 | |
5487 | |
5488 //============================================================================= | |
5489 // FM Volume Down の取得 | |
5490 //============================================================================= | |
5491 DLLEXPORT int getfmvoldown(void) | |
5492 { | |
5493 return pmdwin->getfmvoldown(); | |
5494 } | |
5495 | |
5496 | |
5497 //============================================================================= | |
5498 // FM Volume Down の取得(その2) | |
5499 //============================================================================= | |
5500 DLLEXPORT int getfmvoldown2(void) | |
5501 { | |
5502 return pmdwin->getfmvoldown2(); | |
5503 } | |
5504 | |
5505 | |
5506 //============================================================================= | |
5507 // SSG Volume Down の取得 | |
5508 //============================================================================= | |
5509 DLLEXPORT int getssgvoldown(void) | |
5510 { | |
5511 return pmdwin->getssgvoldown(); | |
5512 } | |
5513 | |
5514 | |
5515 //============================================================================= | |
5516 // SSG Volume Down の取得(その2) | |
5517 //============================================================================= | |
5518 DLLEXPORT int getssgvoldown2(void) | |
5519 { | |
5520 return pmdwin->getssgvoldown2(); | |
5521 } | |
5522 | |
5523 | |
5524 //============================================================================= | |
5525 // Rhythm Volume Down の取得 | |
5526 //============================================================================= | |
5527 DLLEXPORT int getrhythmvoldown(void) | |
5528 { | |
5529 return pmdwin->getrhythmvoldown(); | |
5530 } | |
5531 | |
5532 | |
5533 //============================================================================= | |
5534 // Rhythm Volume Down の取得(その2) | |
5535 //============================================================================= | |
5536 DLLEXPORT int getrhythmvoldown2(void) | |
5537 { | |
5538 return pmdwin->getrhythmvoldown2(); | |
5539 } | |
5540 | |
5541 | |
5542 //============================================================================= | |
5543 // 再生位置の移動(pos : ms) | |
5544 //============================================================================= | |
5545 DLLEXPORT void setpos(int pos) | |
5546 { | |
5547 pmdwin->setpos(pos); | |
5548 } | |
5549 | |
5550 | |
5551 //============================================================================= | |
5552 // 再生位置の移動(pos : count 単位) | |
5553 //============================================================================= | |
5554 DLLEXPORT void setpos2(int pos) | |
5555 { | |
5556 pmdwin->setpos2(pos); | |
5557 } | |
5558 | |
5559 | |
5560 //============================================================================= | |
5561 // 再生位置の取得(pos : ms) | |
5562 //============================================================================= | |
5563 DLLEXPORT int getpos(void) | |
5564 { | |
5565 return pmdwin->getpos(); | |
5566 } | |
5567 | |
5568 | |
5569 //============================================================================= | |
5570 // 再生位置の取得(pos : count 単位) | |
5571 //============================================================================= | |
5572 DLLEXPORT int getpos2(void) | |
5573 { | |
5574 return pmdwin->getpos2(); | |
5575 } | |
5576 | |
5577 | |
5578 //============================================================================= | |
5579 // 曲の長さの取得(pos : ms) | |
5580 //============================================================================= | |
5581 DLLEXPORT bool getlength(uint *length, uint *loop) | |
5582 { | |
5583 return pmdwin->getlength(length, loop); | |
5584 } | |
5585 | |
5586 | |
5587 //============================================================================= | |
5588 // ループ回数の取得 | |
5589 //============================================================================= | |
5590 DLLEXPORT int getloopcount(void) | |
5591 { | |
5592 return pmdwin->getloopcount(); | |
5593 } | |
5594 | |
5595 | |
5596 //============================================================================= | |
5597 // OPEN_WORKのポインタの取得 | |
5598 //============================================================================= | |
5599 DLLEXPORT OPEN_WORK * getopenwork(void) | |
5600 { | |
5601 return pmdwin->getopenwork(); | |
5602 } | |
5603 | |
5604 | |
5605 //============================================================================= | |
5606 // パートワークのポインタの取得 | |
5607 //============================================================================= | |
5608 DLLEXPORT QQ * getpartwork(unsigned int ch) | |
5609 { | |
5610 return pmdwin->getpartwork(ch); | |
5611 } | |
5612 | |
5613 | |
5614 #ifdef __cplusplus | |
5615 } | |
5616 #endif |