DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
sound.cpp
1#include "sound.hpp"
2
3#include <eekernel.h>
4#include <libsdr.h>
5#include <modmsin.h>
6#include <sifrpc.h>
7
8#include <cstdio>
9#include <cstdlib>
10#include <cstring>
11
12#include "dataread.hpp"
13#include "gameutil.hpp"
14
16static sceCslCtx msinCtx;
17
19static sceCslBuffGrp msinBfGrp[2];
20
22static sceCslBuffCtx msinBfCtx[6];
23
25static MSIN_BUFFER msinBf[6] __attribute__((aligned(64)));
26
28static MIDI_BANK gBank;
29
31static MIDI_STATE midi_state;
32
34static SQ_INF_TABLE sq_inf_tbl;
35
37static SE_INF_TABLE se_inf_tbl;
38
40static int iopMSINBuffAddr;
41
43static int bd_size_total;
44
46 return &midi_state;
47}
48
50 return (short *) &se_inf_tbl;
51}
52
53int CSound::GetSeNo(int bank, int program) {
54 int i;
55
56 for (i = 0; i < se_inf_tbl.count; i++) {
57 if (bank == se_inf_tbl.entry[i].bank && program == se_inf_tbl.entry[i].program) {
58 break;
59 }
60 }
61
62 if (i < se_inf_tbl.count) {
63 return i;
64 }
65
66 return -1;
67}
68
69void CSound::StopVoice(int core) {
70 sceSdRemote(1, rSdSetSwitch, core | SD_S_KOFF, 0xFFFFFF);
71 printf("voice completed Core=%d\n", core);
72}
73
74void CSound::SetReverb(int core, int mode, int depth) {
75 sceSdEffectAttr attr;
76
77 sceSdRemote(1, rSdSetCoreAttr, SD_C_SPDIF_MODE, SD_SPDIF_COPY_PROHIBIT);
78 sceSdRemote(1, rSdSetAddr, core | SD_A_EEA, 0x1FFFFF - (core << 17));
79 attr.depth_L = 0;
80 attr.depth_R = 0;
81 attr.mode = mode | SD_REV_MODE_CLEAR_WA;
82 sceSdRemote(1, rSdSetEffectAttr, core, &attr);
83 sceSdRemote(1, rSdSetCoreAttr, core | SD_C_EFFECT_ENABLE, 1);
84 sceSdRemote(1, rSdSetParam, core | SD_P_EVOLL, (depth << 8) & 0xFFFF);
85 sceSdRemote(1, rSdSetParam, core | SD_P_EVOLR, (depth << 8) & 0xFFFF);
86 sceSdRemote(1, rSdSetParam, core | SD_P_MVOLL, 0x3FFF);
87 sceSdRemote(1, rSdSetParam, core | SD_P_MVOLR, 0x3FFF);
88}
89
97void set_spu(int mode0, int mode1, int depth0, int depth1) {
98 int mode[2];
99 int depth[2];
100 sceSdEffectAttr attr;
101 int core;
102
103 mode[0] = mode0;
104 mode[1] = mode1;
105 depth[0] = depth0;
106 depth[1] = depth1;
107 sceSdRemoteInit();
108 sceSdRemote(1, rSdInit, 0);
109 sceSdRemote(1, rSdSetCoreAttr, SD_C_SPDIF_MODE, SD_SPDIF_COPY_PROHIBIT);
110
111 for (core = 0; core < 2; core++) {
112 sceSdRemote(1, rSdSetAddr, core | SD_A_EEA, 0x1FFFFF - (core << 17));
113 attr.depth_L = 0;
114 attr.depth_R = 0;
115 attr.mode = mode[core] | SD_REV_MODE_CLEAR_WA;
116 sceSdRemote(1, rSdSetEffectAttr, core, &attr);
117 sceSdRemote(1, rSdSetCoreAttr, core | SD_C_EFFECT_ENABLE, 1);
118 sceSdRemote(1, rSdSetParam, core | SD_P_EVOLL, (depth[core] << 8) & 0xFFFF);
119 sceSdRemote(1, rSdSetParam, core | SD_P_EVOLR, (depth[core] << 8) & 0xFFFF);
120 sceSdRemote(1, rSdSetParam, core | SD_P_MVOLL, 0x3FFF);
121 sceSdRemote(1, rSdSetParam, core | SD_P_MVOLR, 0x3FFF);
122 }
123}
124
132int TransHdBd(int hd, int hd_size, int bd, int bd_size) {
133 void *bd_address;
134 void *hd_address;
135
136 if (bd_size == 0) {
137 printf("BD LOAD Err!!!!!!!!!!!!!!!!!!!!!\n");
138 gBank.bd_size = 0;
139 gBank.hd_address = 0;
140 return -1;
141 }
142
143 if (hd_size == 0) {
144 printf("HD LOAD Err!!!!!!!!!!!!!!!!!!!!!\n");
145 gBank.bd_size = 0;
146 gBank.hd_address = 0;
147 return -1;
148 }
149
150 sceSifInitIopHeap();
151 bd_address = sceSifAllocIopHeap(bd_size + 0x10);
152
153 if (bd_address == 0) {
154 printf("AllocIopHeap Err\n");
155 return -1;
156 }
157
158 if (ezTransToIOP(bd_address, (void *) bd, bd_size) != 0) {
159 printf("ezTransToIOP Err\n");
160 }
161
162 gBank.bd_address = bd_address;
163 gBank.bd_size = bd_size;
164 FlushCache(0);
165 ezMidi(0x9070, (int) &gBank);
166 sceSifInitIopHeap();
167 sceSifFreeIopHeap(bd_address);
168 sceSifInitIopHeap();
169 hd_address = sceSifAllocIopHeap(hd_size + 0x10);
170
171 if (hd_address == 0) {
172 printf("AllocIopHeap Err\n");
173 return -1;
174 }
175
176 printf("AllocIopHeap %d \n", hd_address);
177
178 if (ezTransToIOP(hd_address, (void *) hd, hd_size) != 0) {
179 printf("ezTransToIOP Err\n");
180 }
181
182 gBank.hd_address = hd_address;
183 return 0;
184}
185
186int CSound::LoadSoundFileFromPack(char *name, unsigned int *pack) {
187 static char wk_name[20];
188 static char wk_name2[20];
189 int size;
190 int bd_size;
191 char delimiter[] = "\n";
192 char *token;
193 int hd;
194 int i;
195
196 printf("SND_INF= %s \n", name);
197 token = strtok((char *) GetPackFile(pack, name, &size), delimiter);
198
199 while (token != NULL) {
200 strncpy(wk_name, " ", 9);
201 strncpy(wk_name2, " ", 9);
202 strncpy(wk_name, token, 9);
203
204 if (strncmp(&wk_name[6], ".sq", 3) == 0) {
205 if (strncmp(&wk_name[5], "a", 1) == 0) {
206 LoadSeq_A((int) GetPackFile(pack, wk_name, &size), size);
207
208 for (i = 0; i < sq_inf_tbl.count; i++) {
209 if (strncmp(wk_name, sq_inf_tbl.sequence[i].name, 9) == 0) {
210 break;
211 }
212 }
213
214 if (i < sq_inf_tbl.count) {
215 midi_state.port[0].sequence[midi_state.port[0].sequence_count] = &sq_inf_tbl.sequence[i];
216 midi_state.port[0].sequence_count++;
217 } else {
218 printf("################SQ_TBL NOT FOUND NEME=%s ##################\n", wk_name);
219 }
220 }
221
222 if (strncmp(&wk_name[5], "e", 1) == 0) {
223 LoadSeq_E((int) GetPackFile(pack, wk_name, &size), size);
224
225 for (i = 0; i < sq_inf_tbl.count; i++) {
226 if (strncmp(wk_name, sq_inf_tbl.sequence[i].name, 9) == 0) {
227 break;
228 }
229 }
230
231 if (i < sq_inf_tbl.count) {
232 midi_state.port[2].sequence[midi_state.port[2].sequence_count] = &sq_inf_tbl.sequence[i];
233 midi_state.port[2].sequence_count++;
234 } else {
235 printf("################SQ_TBL NOT FOUND NEME=%s ##################\n", wk_name);
236 }
237 }
238
239 if (strncmp(&wk_name[5], "i", 1) == 0) {
240 LoadSeq_I((int) GetPackFile(pack, wk_name, &size), size);
241
242 for (i = 0; i < sq_inf_tbl.count; i++) {
243 if (strncmp(wk_name, sq_inf_tbl.sequence[i].name, 9) == 0) {
244 break;
245 }
246 }
247
248 if (i < sq_inf_tbl.count) {
249 midi_state.port[4].sequence[midi_state.port[4].sequence_count] = &sq_inf_tbl.sequence[i];
250 midi_state.port[4].sequence_count++;
251 } else {
252 printf("################SQ_TBL NOT FOUND NEME=%s ##################\n", wk_name);
253 }
254 }
255 }
256
257 if (strncmp(&wk_name[6], ".hd", 3) == 0) {
258 if (strncmp(&wk_name[5], "a", 1) == 0) {
259 strncpy(wk_name2, wk_name, 9);
260 strcpy(&wk_name2[7], "bd");
261 hd = (int) GetPackFile(pack, wk_name, &size);
262 LoadHdBd_A(hd, size, (int) GetPackFile(pack, wk_name2, &bd_size), bd_size);
263 }
264
265 if (strncmp(&wk_name[5], "c", 1) == 0) {
266 strcpy(wk_name2, wk_name);
267 strcpy(&wk_name2[7], "bd");
268 hd = (int) GetPackFile(pack, wk_name, &size);
269 LoadHdBd_C(hd, size, (int) GetPackFile(pack, wk_name2, &bd_size), bd_size);
270 }
271
272 if (strncmp(&wk_name[5], "e", 1) == 0) {
273 strncpy(wk_name2, wk_name, 9);
274 strcpy(&wk_name2[7], "bd");
275 hd = (int) GetPackFile(pack, wk_name, &size);
276 LoadHdBd_E(hd, size, (int) GetPackFile(pack, wk_name2, &bd_size), bd_size);
277 }
278
279 if (strncmp(&wk_name[5], "i", 1) == 0) {
280 strncpy(wk_name2, wk_name, 9);
281 strcpy(&wk_name2[7], "bd");
282 hd = (int) GetPackFile(pack, wk_name, &size);
283 LoadHdBd_I(hd, size, (int) GetPackFile(pack, wk_name2, &bd_size), bd_size);
284 }
285
286 if (strncmp(&wk_name[5], "g", 1) == 0) {
287 strncpy(wk_name2, wk_name, 9);
288 strcpy(&wk_name2[7], "bd");
289 hd = (int) GetPackFile(pack, wk_name, &size);
290 LoadHdBd_G(hd, size, (int) GetPackFile(pack, wk_name2, &bd_size), bd_size);
291 }
292
293 if (strncmp(&wk_name[5], "m", 1) == 0) {
294 strncpy(wk_name2, wk_name, 9);
295 strcpy(&wk_name2[7], "bd");
296 hd = (int) GetPackFile(pack, wk_name, &size);
297 LoadHdBd_M(hd, size, (int) GetPackFile(pack, wk_name2, &bd_size), bd_size);
298 }
299
300 if (strncmp(&wk_name[5], "q", 1) == 0) {
301 strncpy(wk_name2, wk_name, 9);
302 strcpy(&wk_name2[7], "bd");
303 hd = (int) GetPackFile(pack, wk_name, &size);
304 LoadHdBd_Q(hd, size, (int) GetPackFile(pack, wk_name2, &bd_size), bd_size);
305 }
306
307 if (strncmp(&wk_name[5], "s", 1) == 0) {
308 strncpy(wk_name2, wk_name, 9);
309 strcpy(&wk_name2[7], "bd");
310 hd = (int) GetPackFile(pack, wk_name, &size);
311 LoadHdBd_S(hd, size, (int) GetPackFile(pack, wk_name2, &bd_size), bd_size);
312 }
313 }
314
315 token = strtok(NULL, delimiter);
316 }
317
318 return 0;
319}
320
321int CSound::LoadSqInf(char *name, unsigned int *buffer) {
322 int size;
323 char number[4];
324 char *token;
325
326 LoadFile(name, buffer, &size);
327 *(char *) ((int) buffer + size) = 0;
328 char delimiter[] = " ;,\t\n\r";
329 strtok((char *) buffer, "\n\r");
330 token = strtok(NULL, delimiter);
331
332 while (token != NULL) {
333 strncpy(sq_inf_tbl.sequence[sq_inf_tbl.count].name, token, 9);
334 token = strtok(NULL, delimiter);
335 strcpy(number, token);
336 sq_inf_tbl.sequence[sq_inf_tbl.count].volume = atoi(number);
337 sq_inf_tbl.count++;
338 token = strtok(NULL, delimiter);
339 }
340
341 return size;
342}
343
344int CSound::LoadSeInf(char *name, unsigned int *buffer) {
345 int size;
346 char number[4];
347 char *token;
348
349 LoadFile(name, buffer, &size);
350 *(char *) ((int) buffer + size) = 0;
351 char delimiter[] = " ;,\t\n\r";
352 se_inf_tbl.count = 0;
353 strtok((char *) buffer, "\n\r");
354 token = strtok(NULL, delimiter);
355
356 while (token != NULL) {
357 strncpy(number, token, 4);
358 se_inf_tbl.entry[se_inf_tbl.count].bank = atoi(number);
359 token = strtok(NULL, delimiter);
360 strncpy(number, token, 4);
361 se_inf_tbl.entry[se_inf_tbl.count].program = atoi(number);
362 token = strtok(NULL, delimiter);
363 strncpy(number, token, 4);
364 se_inf_tbl.entry[se_inf_tbl.count].volume = atoi(number);
365 token = strtok(NULL, delimiter);
366 se_inf_tbl.count++;
367 }
368
369 return size;
370}
371
372int CSound::Init(int mode0, int mode1, int depth0, int depth1) {
373 static int load_m_flg = (int) 0.0f;
374 int i;
375
376 printf("EzMIDI initialize...\n");
377 ezMidiInit();
378 set_spu(mode0, mode1, depth0, depth1);
379
380 if (iopMSINBuffAddr == 0) {
381 iopMSINBuffAddr = ezMidi(0x8010, 0x4000);
382 sceSifInitIopHeap();
383 printf("iopMSINBuffAddr %d\n", iopMSINBuffAddr);
384 }
385
386 msinCtx.extmod = 0;
387 msinCtx.callBack = 0;
388 msinCtx.conf = 0;
389 msinCtx.buffGrpNum = 2;
390 msinCtx.buffGrp = msinBfGrp;
391 msinBfGrp[0].buffNum = 0;
392 msinBfGrp[0].buffCtx = 0;
393 msinBfGrp[1].buffNum = 6;
394 msinBfGrp[1].buffCtx = msinBfCtx;
395
396 for (i = 0; i < 6; i++) {
397 MSIN_BUFFER *buffer;
398
399 msinBfCtx[i].sema = 0;
400 buffer = &msinBf[i];
401 msinBfCtx[i].buff = buffer;
402 buffer->size = sizeof(MSIN_BUFFER);
403 buffer->length = 0;
404 }
405
406 if (sceMSIn_Init(&msinCtx) != 0) {
407 printf("sceMSIn_Init Error\n");
408 return 1;
409 }
410
411 bd_size_total = 0;
412 midi_state.port[0].bank = 0;
413 midi_state.port[0].spu_address = 0x5010;
414
415 for (i = 0; i < 10; i++) {
416 midi_state.port[0].sequence_address[i] = 0;
417 }
418
419 midi_state.port[0].sequence_count = 0;
420 midi_state.port[0].fade[0].active = false;
421 midi_state.port[0].fade[1].active = false;
422 midi_state.port[1].bank = 0;
423 midi_state.port[1].spu_address = 0x7D010;
424
425 for (i = 0; i < 10; i++) {
426 midi_state.port[1].sequence_address[i] = 0;
427 }
428
429 midi_state.port[1].sequence_count = 0;
430 midi_state.port[1].fade[0].active = false;
431 midi_state.port[1].fade[1].active = false;
432 midi_state.port[2].bank = 0;
433 midi_state.port[2].spu_address = 0x7D010;
434
435 for (i = 0; i < 10; i++) {
436 midi_state.port[2].sequence_address[i] = 0;
437 }
438
439 midi_state.port[2].sequence_count = 0;
440 midi_state.port[2].fade[0].active = false;
441 midi_state.port[2].fade[1].active = false;
442 midi_state.port[4].bank = 0;
443 midi_state.port[4].spu_address = 0x16E900;
444
445 for (i = 0; i < 10; i++) {
446 midi_state.port[4].sequence_address[i] = 0;
447 }
448
449 midi_state.port[4].sequence_count = 0;
450 midi_state.port[4].fade[0].active = false;
451 midi_state.port[4].fade[1].active = false;
452 midi_state.port[3].bank = 0;
453 midi_state.port[3].spu_address = 0x16E900;
454
455 for (i = 0; i < 10; i++) {
456 midi_state.port[3].sequence_address[i] = 0;
457 }
458
459 midi_state.port[3].sequence_count = 0;
460 midi_state.port[3].fade[0].active = false;
461 midi_state.port[3].fade[1].active = false;
462 midi_state.port[5].bank = 0;
463 midi_state.port[5].spu_address = 0x16E900;
464
465 for (i = 0; i < 10; i++) {
466 midi_state.port[5].sequence_address[i] = 0;
467 }
468
469 midi_state.port[5].sequence_count = 0;
470 midi_state.port[5].fade[0].active = false;
471 midi_state.port[5].fade[1].active = false;
472 midi_state.port[6].bank = 0;
473 midi_state.port[6].spu_address = 0x18AE20;
474
475 for (i = 0; i < 10; i++) {
476 midi_state.port[6].sequence_address[i] = 0;
477 }
478
479 midi_state.port[6].sequence_count = 0;
480 midi_state.port[6].fade[0].active = false;
481 midi_state.port[6].fade[1].active = false;
482 midi_state.port[7].bank = 0;
483 midi_state.port[7].spu_address = 0x1B6D40;
484
485 for (i = 0; i < 10; i++) {
486 midi_state.port[7].sequence_address[i] = 0;
487 }
488
489 midi_state.port[7].sequence_count = 0;
490 midi_state.port[7].fade[0].active = false;
491 midi_state.port[7].fade[1].active = false;
492 return 0;
493}
494
495void CSound::SQ_Play(int port, int seq_no) {
496 int address;
497 int volume;
498
499 switch (port) {
500 case MIDI_PORT_BGM:
501 if (seq_no < midi_state.port[0].sequence_count) {
502 address = (int) midi_state.port[0].sequence_address[seq_no];
503 volume = midi_state.port[0].sequence[seq_no]->volume;
504 break;
505 }
506
507 printf("###############NOT FOUND SEQ_NO=%d #####################\n", seq_no);
508 return;
509 case MIDI_PORT_AMBIENT:
510 if (seq_no < midi_state.port[2].sequence_count) {
511 address = (int) midi_state.port[2].sequence_address[seq_no];
512 volume = midi_state.port[2].sequence[seq_no]->volume;
513 break;
514 }
515
516 printf("###############NOT FOUND SEQ_NO=%d #####################\n", seq_no);
517 return;
518 case MIDI_PORT_UNK_2:
519 if (seq_no < midi_state.port[4].sequence_count) {
520 address = (int) midi_state.port[4].sequence_address[seq_no];
521 volume = midi_state.port[4].sequence[seq_no]->volume;
522 break;
523 }
524
525 printf("###############NOT FOUND SEQ_NO=%d #####################\n", seq_no);
526 return;
527 }
528
529 printf("MIDI start! port=%d \n", port);
530 ezMidi(port + 0x40, address);
531 ezMidi(port + 0xB0, volume);
532 ezMidi(port + 0x30, 0);
533 ezMidi(port, 0);
534}
535
536void CSound::SQ_Play(int port, int seq_no, int volume) {
537 int address;
538
539 switch (port) {
540 case MIDI_PORT_BGM:
541 if (seq_no < midi_state.port[0].sequence_count) {
542 address = (int) midi_state.port[0].sequence_address[seq_no];
543 break;
544 }
545
546 printf("###############NOT FOUND SEQ_NO=%d #####################\n", seq_no);
547 return;
548 case MIDI_PORT_AMBIENT:
549 if (seq_no < midi_state.port[2].sequence_count) {
550 address = (int) midi_state.port[2].sequence_address[seq_no];
551 break;
552 }
553
554 printf("###############NOT FOUND SEQ_NO=%d #####################\n", seq_no);
555 return;
556 case MIDI_PORT_UNK_2:
557 if (seq_no < midi_state.port[4].sequence_count) {
558 address = (int) midi_state.port[4].sequence_address[seq_no];
559 break;
560 }
561
562 printf("###############NOT FOUND SEQ_NO=%d #####################\n", seq_no);
563 return;
564 }
565
566 ezMidi(port + 0x20, 0);
567 printf("MIDI start! port=%d \n", port);
568 ezMidi(port + 0x40, address);
569 ezMidi(port + 0xB0, volume);
570 ezMidi(port + 0x30, 0);
571 ezMidi(port, 0);
572}
573
574void CSound::SQ_RePlay(int port) {
575 printf("MIDI restart! port=%d \n", port);
576 ezMidi(port, 0);
577}
578
579void CSound::SE_Play(int port, int bank, int program, int pan, int velocity, int volume, int voice) {
580 unsigned char message[8];
581 int channel;
582
583 switch (port) {
584 case MIDI_PORT_SE_TITLE:
585 channel = 5;
586 break;
587 case MIDI_PORT_SE_DEFAULT:
588 channel = 4;
589 break;
590 case MIDI_PORT_UNK_D:
591 channel = 3;
592 break;
593 case MIDI_PORT_SE_SPECIAL:
594 channel = 2;
595 break;
596 case MIDI_PORT_UNK_B:
597 channel = 1;
598 break;
599 case MIDI_PORT_UNK_A:
600 channel = 0;
601 break;
602 }
603
604 sceMSIn_PutMsg(&msinCtx, channel, ((bank & 0x7F) << 8) | 0xC0);
605 message[0] = 0xF9;
606 message[1] = 0;
607 message[2] = 0;
608 message[3] = volume;
609 message[4] = 0;
610 sceMSIn_PutHsMsg(&msinCtx, channel, message);
611 message[1] = 2;
612 message[2] = 0;
613 message[3] = 0;
614 message[4] = 0x40;
615 message[0] = 0xF9;
616 message[1] = 1;
617 message[2] = 0;
618 message[3] = pan;
619 message[4] = 0;
620 sceMSIn_PutHsMsg(&msinCtx, channel, message);
621 message[0] = 0xFD;
622 message[1] = 0x10;
623 message[2] = 0;
624 message[3] = program;
625 message[4] = voice;
626 message[5] = velocity;
627 message[6] = 0;
628 sceMSIn_PutHsMsg(&msinCtx, channel, message);
629}
630
631void CSound::SE_Play(int port, int se_no, int voice) {
632 SE_Play(port, se_inf_tbl.entry[se_no].bank, se_inf_tbl.entry[se_no].program, 0x40, 0x7F, se_inf_tbl.entry[se_no].volume, voice);
633}
634
635void CSound::SE_Play(int port, int bank, int program, int volume, int voice) {
636 SE_Play(port, bank, program, 0x40, 0x7F, volume, voice);
637}
638
639void CSound::SE_Play(int port, int bank, int program, int voice) {
640 SE_Play(port, bank, program, 0x40, 0x7F, 0x7F, voice);
641}
642
643void CSound::SE_SetVol(int port, int bank, int program, int volume, int voice) {
644 unsigned char message[8];
645 int channel;
646
647 switch (port) {
648 case MIDI_PORT_SE_TITLE:
649 channel = 5;
650 break;
651 case MIDI_PORT_SE_DEFAULT:
652 channel = 4;
653 break;
654 case MIDI_PORT_UNK_D:
655 channel = 3;
656 break;
657 case MIDI_PORT_SE_SPECIAL:
658 channel = 2;
659 break;
660 case MIDI_PORT_UNK_B:
661 channel = 1;
662 break;
663 case MIDI_PORT_UNK_A:
664 channel = 0;
665 break;
666 }
667
668 sceMSIn_PutMsg(&msinCtx, channel, ((bank & 0x7F) << 8) | 0xC0);
669 message[0] = 0xFD;
670 message[1] = 0;
671 message[2] = 0;
672 message[3] = program;
673 message[4] = voice;
674 message[5] = volume;
675 message[6] = 0;
676 sceMSIn_PutHsMsg(&msinCtx, channel, message);
677}
678
679void CSound::SE_SetPan(int port, int bank, int program, int pan, int voice) {
680 unsigned char message[8];
681 int channel;
682
683 switch (port) {
684 case MIDI_PORT_SE_TITLE:
685 channel = 5;
686 break;
687 case MIDI_PORT_SE_DEFAULT:
688 channel = 4;
689 break;
690 case MIDI_PORT_UNK_D:
691 channel = 3;
692 break;
693 case MIDI_PORT_SE_SPECIAL:
694 channel = 2;
695 break;
696 case MIDI_PORT_UNK_B:
697 channel = 1;
698 break;
699 case MIDI_PORT_UNK_A:
700 channel = 0;
701 break;
702 }
703
704 sceMSIn_PutMsg(&msinCtx, channel, ((bank & 0x7F) << 8) | 0xC0);
705 message[0] = 0xFD;
706 message[1] = 1;
707 message[2] = 0;
708 message[3] = program;
709 message[4] = voice;
710 message[5] = pan;
711 message[6] = 0;
712 sceMSIn_PutHsMsg(&msinCtx, channel, message);
713}
714
715void CSound::SE_SetPan(int port, int se_no, int pan, int voice) {
716 SE_SetPan(port, se_inf_tbl.entry[se_no].bank, se_inf_tbl.entry[se_no].program, pan, voice);
717}
718
719void CSound::SE_Stop(int port, int bank, int program, int voice) {
720 unsigned char message[8];
721 int channel;
722
723 switch (port) {
724 case MIDI_PORT_SE_TITLE:
725 channel = 5;
726 break;
727 case MIDI_PORT_SE_DEFAULT:
728 channel = 4;
729 break;
730 case MIDI_PORT_UNK_D:
731 channel = 3;
732 break;
733 case MIDI_PORT_SE_SPECIAL:
734 channel = 2;
735 break;
736 case MIDI_PORT_UNK_B:
737 channel = 1;
738 break;
739 case MIDI_PORT_UNK_A:
740 channel = 0;
741 break;
742 }
743
744 sceMSIn_PutMsg(&msinCtx, channel, ((bank & 0x7F) << 8) | 0xC0);
745 message[0] = 0xFD;
746 message[1] = 0x10;
747 message[2] = 0;
748 message[3] = program;
749 message[4] = voice;
750 message[5] = 0;
751 message[6] = 0;
752 sceMSIn_PutHsMsg(&msinCtx, channel, message);
753}
754
755void CSound::Fade(int port, float step, int volume) {
756 switch (port) {
757 case MIDI_PORT_BGM:
758 midi_state.port[0].fade[0].active = true;
759 midi_state.port[0].fade[0].target_volume = volume;
760 midi_state.port[0].fade[0].step = step;
761 midi_state.port[0].fade[0].volume = ezMidi(port + 0x80E0, 0);
762 break;
763 case MIDI_PORT_AMBIENT:
764 midi_state.port[2].fade[0].active = true;
765 midi_state.port[2].fade[0].target_volume = volume;
766 midi_state.port[2].fade[0].step = step;
767 midi_state.port[2].fade[0].volume = ezMidi(port + 0x80E0, 0);
768 break;
769 case MIDI_PORT_UNK_2:
770 midi_state.port[4].fade[0].active = true;
771 midi_state.port[4].fade[0].target_volume = volume;
772 midi_state.port[4].fade[0].step = step;
773 midi_state.port[4].fade[0].volume = ezMidi(port + 0x80E0, 0);
774 break;
775 case MIDI_PORT_SE_TITLE:
776 midi_state.port[1].fade[1].active = true;
777 midi_state.port[1].fade[1].target_volume = volume;
778 midi_state.port[1].fade[1].step = step;
779 midi_state.port[1].fade[1].volume = ezMidi(port + 0x80E0, 0);
780 break;
781 case MIDI_PORT_SE_DEFAULT:
782 midi_state.port[4].fade[1].active = true;
783 midi_state.port[4].fade[1].target_volume = volume;
784 midi_state.port[4].fade[1].step = step;
785 midi_state.port[4].fade[1].volume = ezMidi(port + 0x80E0, 0);
786 break;
787 case MIDI_PORT_UNK_A:
788 midi_state.port[3].fade[1].active = true;
789 midi_state.port[3].fade[1].target_volume = volume;
790 midi_state.port[3].fade[1].step = step;
791 midi_state.port[3].fade[1].volume = ezMidi(port + 0x80E0, 0);
792 break;
793 case MIDI_PORT_UNK_D:
794 midi_state.port[5].fade[1].active = true;
795 midi_state.port[5].fade[1].target_volume = volume;
796 midi_state.port[5].fade[1].step = step;
797 midi_state.port[5].fade[1].volume = ezMidi(port + 0x80E0, 0);
798 break;
799 case MIDI_PORT_SE_SPECIAL:
800 midi_state.port[6].fade[1].active = true;
801 midi_state.port[6].fade[1].target_volume = volume;
802 midi_state.port[6].fade[1].step = step;
803 midi_state.port[6].fade[1].volume = ezMidi(port + 0x80E0, 0);
804 break;
805 case MIDI_PORT_UNK_B:
806 midi_state.port[7].fade[1].active = true;
807 midi_state.port[7].fade[1].target_volume = volume;
808 midi_state.port[7].fade[1].step = step;
809 midi_state.port[7].fade[1].volume = ezMidi(port + 0x80E0, 0);
810 break;
811 }
812}
813
815 int i;
816
817 if (midi_state.port[0].fade[0].active) {
818 midi_state.port[0].fade[0].volume += midi_state.port[0].fade[0].step;
819
820 if (midi_state.port[0].fade[0].step > 0.0f && midi_state.port[0].fade[0].volume > midi_state.port[0].fade[0].target_volume) {
821 midi_state.port[0].fade[0].volume = midi_state.port[0].fade[0].target_volume;
822 midi_state.port[0].fade[0].active = false;
823 }
824
825 if (midi_state.port[0].fade[0].step < 0.0f && midi_state.port[0].fade[0].volume < midi_state.port[0].fade[0].target_volume) {
826 midi_state.port[0].fade[0].volume = midi_state.port[0].fade[0].target_volume;
827 midi_state.port[0].fade[0].active = false;
828 }
829
830 SetVol(0, (int) midi_state.port[0].fade[0].volume);
831 }
832
833 if (midi_state.port[2].fade[0].active) {
834 midi_state.port[2].fade[0].volume += midi_state.port[2].fade[0].step;
835
836 if (midi_state.port[2].fade[0].step > 0.0f && midi_state.port[2].fade[0].volume > midi_state.port[2].fade[0].target_volume) {
837 midi_state.port[2].fade[0].volume = midi_state.port[2].fade[0].target_volume;
838 midi_state.port[2].fade[0].active = false;
839 }
840
841 if (midi_state.port[2].fade[0].step < 0.0f && midi_state.port[2].fade[0].volume < midi_state.port[2].fade[0].target_volume) {
842 midi_state.port[2].fade[0].volume = midi_state.port[2].fade[0].target_volume;
843 midi_state.port[2].fade[0].active = false;
844 }
845
846 SetVol(1, (int) midi_state.port[2].fade[0].volume);
847 }
848
849 if (midi_state.port[4].fade[0].active) {
850 midi_state.port[4].fade[0].volume += midi_state.port[4].fade[0].step;
851
852 if (midi_state.port[4].fade[0].step > 0.0f && midi_state.port[4].fade[0].volume > midi_state.port[4].fade[0].target_volume) {
853 midi_state.port[4].fade[0].volume = midi_state.port[4].fade[0].target_volume;
854 midi_state.port[4].fade[0].active = false;
855 }
856
857 if (midi_state.port[4].fade[0].step < 0.0f && midi_state.port[4].fade[0].volume < midi_state.port[4].fade[0].target_volume) {
858 midi_state.port[4].fade[0].volume = midi_state.port[4].fade[0].target_volume;
859 midi_state.port[4].fade[0].active = false;
860 }
861
862 SetVol(2, (int) midi_state.port[4].fade[0].volume);
863 }
864
865 if (midi_state.port[1].fade[1].active) {
866 midi_state.port[1].fade[1].volume += midi_state.port[1].fade[1].step;
867
868 if (midi_state.port[1].fade[1].step > 0.0f && midi_state.port[1].fade[1].volume > midi_state.port[1].fade[1].target_volume) {
869 midi_state.port[1].fade[1].volume = midi_state.port[1].fade[1].target_volume;
870 midi_state.port[1].fade[1].active = false;
871 }
872
873 if (midi_state.port[1].fade[1].step < 0.0f && midi_state.port[1].fade[1].volume < midi_state.port[1].fade[1].target_volume) {
874 midi_state.port[1].fade[1].volume = midi_state.port[1].fade[1].target_volume;
875 midi_state.port[1].fade[1].active = false;
876 }
877
878 SetVol(15, (int) midi_state.port[1].fade[1].volume);
879 }
880
881 if (midi_state.port[4].fade[1].active) {
882 midi_state.port[4].fade[1].volume += midi_state.port[4].fade[1].step;
883
884 if (midi_state.port[4].fade[1].step > 0.0f && midi_state.port[4].fade[1].volume > midi_state.port[4].fade[1].target_volume) {
885 midi_state.port[4].fade[1].volume = midi_state.port[4].fade[1].target_volume;
886 midi_state.port[4].fade[1].active = false;
887 }
888
889 if (midi_state.port[4].fade[1].step < 0.0f && midi_state.port[4].fade[1].volume < midi_state.port[4].fade[1].target_volume) {
890 midi_state.port[4].fade[1].volume = midi_state.port[4].fade[1].target_volume;
891 midi_state.port[4].fade[1].active = false;
892 }
893
894 SetVol(14, (int) midi_state.port[4].fade[1].volume);
895 }
896
897 if (midi_state.port[3].fade[1].active) {
898 midi_state.port[3].fade[1].volume += midi_state.port[3].fade[1].step;
899
900 if (midi_state.port[3].fade[1].step > 0.0f && midi_state.port[3].fade[1].volume > midi_state.port[3].fade[1].target_volume) {
901 midi_state.port[3].fade[1].volume = midi_state.port[3].fade[1].target_volume;
902 midi_state.port[3].fade[1].active = false;
903 }
904
905 if (midi_state.port[3].fade[1].step < 0.0f && midi_state.port[3].fade[1].volume < midi_state.port[3].fade[1].target_volume) {
906 midi_state.port[3].fade[1].volume = midi_state.port[3].fade[1].target_volume;
907 midi_state.port[3].fade[1].active = false;
908 }
909
910 SetVol(10, (int) midi_state.port[3].fade[1].volume);
911 }
912
913 if (midi_state.port[5].fade[1].active) {
914 midi_state.port[5].fade[1].volume += midi_state.port[5].fade[1].step;
915
916 if (midi_state.port[5].fade[1].step > 0.0f && midi_state.port[5].fade[1].volume > midi_state.port[5].fade[1].target_volume) {
917 midi_state.port[5].fade[1].volume = midi_state.port[5].fade[1].target_volume;
918 midi_state.port[5].fade[1].active = false;
919 }
920
921 if (midi_state.port[5].fade[1].step < 0.0f && midi_state.port[5].fade[1].volume < midi_state.port[5].fade[1].target_volume) {
922 midi_state.port[5].fade[1].volume = midi_state.port[5].fade[1].target_volume;
923 midi_state.port[5].fade[1].active = false;
924 }
925
926 SetVol(13, (int) midi_state.port[5].fade[1].volume);
927 }
928
929 if (midi_state.port[6].fade[1].active) {
930 midi_state.port[6].fade[1].volume += midi_state.port[6].fade[1].step;
931
932 if (midi_state.port[6].fade[1].step > 0.0f && midi_state.port[6].fade[1].volume > midi_state.port[6].fade[1].target_volume) {
933 midi_state.port[6].fade[1].volume = midi_state.port[6].fade[1].target_volume;
934 midi_state.port[6].fade[1].active = false;
935 }
936
937 if (midi_state.port[6].fade[1].step < 0.0f && midi_state.port[6].fade[1].volume < midi_state.port[6].fade[1].target_volume) {
938 midi_state.port[6].fade[1].volume = midi_state.port[6].fade[1].target_volume;
939 midi_state.port[6].fade[1].active = false;
940 }
941
942 SetVol(12, (int) midi_state.port[6].fade[1].volume);
943 }
944
945 if (midi_state.port[7].fade[1].active) {
946 midi_state.port[7].fade[1].volume += midi_state.port[7].fade[1].step;
947
948 if (midi_state.port[7].fade[1].step > 0.0f && midi_state.port[7].fade[1].volume > midi_state.port[7].fade[1].target_volume) {
949 midi_state.port[7].fade[1].volume = midi_state.port[7].fade[1].target_volume;
950 midi_state.port[7].fade[1].active = false;
951 }
952
953 if (midi_state.port[7].fade[1].step < 0.0f && midi_state.port[7].fade[1].volume < midi_state.port[7].fade[1].target_volume) {
954 midi_state.port[7].fade[1].volume = midi_state.port[7].fade[1].target_volume;
955 midi_state.port[7].fade[1].active = false;
956 }
957
958 SetVol(11, (int) midi_state.port[7].fade[1].volume);
959 }
960
961 // Send each effect port's queued messages across to the stream input module.
962 for (i = 0; i < 6; i++) {
963 MSIN_BUFFER *buffer = &msinBf[i];
964 s32 *length = &buffer->length;
965
966 if (buffer->length != 0) {
967 if (ezTransToIOP((void *) (iopMSINBuffAddr + i * sizeof(MSIN_BUFFER)), buffer, sizeof(MSIN_BUFFER)) != 0) {
968 printf("EX MIDI SEND ERR!! SIZE= %d\n", *length);
969 }
970
971 *length = 0;
972 } else {
973 *length = 0;
974 }
975 }
976}
977
978void CSound::Stop(int port) {
979 ezMidi(port + 0x20, 0);
980 printf("MIDI stop! %d\n", port);
981}
982
983void CSound::SetVol(int port, int volume) {
984 ezMidi(port + 0xB0, volume);
985}
986
987void CSound::SetStereoMode(int mode) {
988 ezMidi(0xC0, mode);
989}
990
991int CSound::LoadHdBd_A(int hd, int hd_size, int bd, int bd_size) {
992 int i;
993
994 if (midi_state.port[0].bank != 0) {
995 if (ezMidi(0x8090 + 0, 0) != 0) {
996 ezMidi(0x20 + 0, 0);
997 }
998
999 sceSifInitIopHeap();
1000 sceSifFreeIopHeap(midi_state.port[0].bank);
1001 midi_state.port[0].bank = 0;
1002
1003 for (i = 0; i < midi_state.port[0].sequence_count; i++) {
1004 if (midi_state.port[0].sequence_address[i] != 0) {
1005 sceSifInitIopHeap();
1006 sceSifFreeIopHeap(midi_state.port[0].sequence_address[i]);
1007 }
1008 }
1009
1010 midi_state.port[0].sequence_count = 0;
1011 }
1012
1013 gBank.spu_address = midi_state.port[0].spu_address;
1014 TransHdBd(hd, hd_size, bd, bd_size);
1015 midi_state.port[0].bank = gBank.hd_address;
1016 ezMidi(0x9050 + 0, (int) &gBank);
1017 ezMidi(0xA0 + 0, 0x3020);
1018 ezMidi(0xB0 + 0, 0);
1019 return 0;
1020}
1021
1022int CSound::LoadHdBd_C(int hd, int hd_size, int bd, int bd_size) {
1023 int i;
1024
1025 if (midi_state.port[1].bank != 0) {
1026 ezMidi(0x20 + 15, 0);
1027 ezMidi(0x20 + 1, 0);
1028 sceSifInitIopHeap();
1029 sceSifFreeIopHeap(midi_state.port[1].bank);
1030 midi_state.port[1].bank = 0;
1031 sceSifInitIopHeap();
1032 sceSifFreeIopHeap(midi_state.port[2].bank);
1033 midi_state.port[2].bank = 0;
1034 midi_state.port[2].spu_address = midi_state.port[1].spu_address = 0x7D010;
1035
1036 for (i = 0; i < midi_state.port[1].sequence_count; i++) {
1037 if (midi_state.port[1].sequence_address[i] != 0) {
1038 sceSifInitIopHeap();
1039 sceSifFreeIopHeap(midi_state.port[1].sequence_address[i]);
1040 }
1041 }
1042
1043 midi_state.port[1].sequence_count = 0;
1044
1045 for (i = 0; i < midi_state.port[2].sequence_count; i++) {
1046 if (midi_state.port[2].sequence_address[i] != 0) {
1047 sceSifInitIopHeap();
1048 sceSifFreeIopHeap(midi_state.port[2].sequence_address[i]);
1049 }
1050 }
1051
1052 midi_state.port[2].sequence_count = 0;
1053 }
1054
1055 gBank.spu_address = midi_state.port[1].spu_address;
1056 TransHdBd(hd, hd_size, bd, bd_size);
1057 midi_state.port[1].bank = gBank.hd_address;
1058 midi_state.port[2].spu_address = midi_state.port[1].spu_address + gBank.bd_size + 0x10;
1059 ezMidi(0x9050 + 15, (int) &gBank);
1060 ezMidi(0xA0 + 15, 0x3070);
1061 ezMidi(0xB0 + 15, 0);
1062 return 0;
1063}
1064
1065int CSound::LoadHdBd_E(int hd, int hd_size, int bd, int bd_size) {
1066 int i;
1067
1068 if (midi_state.port[2].bank != 0) {
1069 if (ezMidi(0x8090 + 1, 0) != 0) {
1070 ezMidi(0x20 + 1, 0);
1071 }
1072
1073 sceSifInitIopHeap();
1074 sceSifFreeIopHeap(midi_state.port[2].bank);
1075 midi_state.port[2].bank = 0;
1076
1077 for (i = 0; i < midi_state.port[2].sequence_count; i++) {
1078 if (midi_state.port[2].sequence_address[i] != 0) {
1079 sceSifInitIopHeap();
1080 sceSifFreeIopHeap(midi_state.port[2].sequence_address[i]);
1081 }
1082 }
1083
1084 midi_state.port[2].sequence_count = 0;
1085 }
1086
1087 gBank.spu_address = midi_state.port[2].spu_address;
1088 TransHdBd(hd, hd_size, bd, bd_size);
1089 midi_state.port[2].bank = gBank.hd_address;
1090 ezMidi(0x9050 + 1, (int) &gBank);
1091 ezMidi(0xA0 + 1, 0x3060);
1092 ezMidi(0xB0 + 1, 0);
1093 return 0;
1094}
1095
1096int CSound::LoadHdBd_G(int hd, int hd_size, int bd, int bd_size) {
1097 int i;
1098
1099 if (midi_state.port[3].bank != 0) {
1100 ezMidi(0x20 + 10, 0);
1101 sceSifInitIopHeap();
1102 sceSifFreeIopHeap(midi_state.port[3].bank);
1103 midi_state.port[3].bank = 0;
1104
1105 for (i = 0; i < midi_state.port[3].sequence_count; i++) {
1106 if (midi_state.port[3].sequence_address[i] != 0) {
1107 sceSifInitIopHeap();
1108 sceSifFreeIopHeap(midi_state.port[3].sequence_address[i]);
1109 }
1110 }
1111
1112 midi_state.port[3].sequence_count = 0;
1113 }
1114
1115 gBank.spu_address = midi_state.port[4].spu_address - (bd_size + 0x10);
1116 midi_state.port[3].spu_address = gBank.spu_address;
1117 TransHdBd(hd, hd_size, bd, bd_size);
1118 midi_state.port[3].bank = gBank.hd_address;
1119 ezMidi(0x9050 + 10, (int) &gBank);
1120 ezMidi(0xA0 + 10, 0x3040);
1121 ezMidi(0xB0 + 10, 0);
1122 return 0;
1123}
1124
1125int CSound::LoadHdBd_I(int hd, int hd_size, int bd, int bd_size) {
1126 int i;
1127
1128 if (midi_state.port[4].bank != 0) {
1129 if (ezMidi(0x8090 + 2, 0) != 0) {
1130 ezMidi(0x20 + 2, 0);
1131 }
1132
1133 ezMidi(0x20 + 14, 0);
1134 sceSifInitIopHeap();
1135 sceSifFreeIopHeap(midi_state.port[4].bank);
1136 midi_state.port[4].bank = 0;
1137 sceSifInitIopHeap();
1138 sceSifFreeIopHeap(midi_state.port[3].bank);
1139 midi_state.port[3].bank = 0;
1140 midi_state.port[3].spu_address = midi_state.port[4].spu_address = 0x16E900;
1141
1142 for (i = 0; i < midi_state.port[4].sequence_count; i++) {
1143 if (midi_state.port[4].sequence_address[i] != 0) {
1144 sceSifInitIopHeap();
1145 sceSifFreeIopHeap(midi_state.port[4].sequence_address[i]);
1146 }
1147 }
1148
1149 midi_state.port[4].sequence_count = 0;
1150
1151 for (i = 0; i < midi_state.port[3].sequence_count; i++) {
1152 if (midi_state.port[3].sequence_address[i] != 0) {
1153 sceSifInitIopHeap();
1154 sceSifFreeIopHeap(midi_state.port[3].sequence_address[i]);
1155 }
1156 }
1157
1158 midi_state.port[3].sequence_count = 0;
1159 }
1160
1161 gBank.spu_address = midi_state.port[4].spu_address - (bd_size + 0x10);
1162 TransHdBd(hd, hd_size, bd, bd_size);
1163 midi_state.port[4].spu_address = gBank.spu_address;
1164 midi_state.port[4].bank = gBank.hd_address;
1165 ezMidi(0x9050 + 2, (int) &gBank);
1166 ezMidi(0xA0 + 2, 0x3050);
1167 ezMidi(0xB0 + 2, 0);
1168 ezMidi(0x9050 + 14, (int) &gBank);
1169 ezMidi(0xA0 + 14, 0x3040);
1170 ezMidi(0xB0 + 14, 0);
1171 return 0;
1172}
1173
1174int CSound::LoadHdBd_M(int hd, int hd_size, int bd, int bd_size) {
1175 int i;
1176
1177 if (midi_state.port[5].bank != 0) {
1178 ezMidi(0x20 + 13, 0);
1179 sceSifInitIopHeap();
1180 sceSifFreeIopHeap(midi_state.port[5].bank);
1181 midi_state.port[5].bank = 0;
1182
1183 for (i = 0; i < midi_state.port[5].sequence_count; i++) {
1184 if (midi_state.port[5].sequence_address[i] != 0) {
1185 sceSifInitIopHeap();
1186 sceSifFreeIopHeap(midi_state.port[5].sequence_address[i]);
1187 }
1188 }
1189
1190 midi_state.port[5].sequence_count = 0;
1191 }
1192
1193 gBank.spu_address = midi_state.port[5].spu_address;
1194 TransHdBd(hd, hd_size, bd, bd_size);
1195 midi_state.port[5].bank = gBank.hd_address;
1196 ezMidi(0x9050 + 13, (int) &gBank);
1197 ezMidi(0xA0 + 13, 0x3080);
1198 ezMidi(0xB0 + 13, 0);
1199 return 0;
1200}
1201
1202int CSound::LoadHdBd_Q(int hd, int hd_size, int bd, int bd_size) {
1203 int i;
1204
1205 if (midi_state.port[6].bank != 0) {
1206 ezMidi(0x20 + 12, 0);
1207 sceSifInitIopHeap();
1208 sceSifFreeIopHeap(midi_state.port[6].bank);
1209 midi_state.port[6].bank = 0;
1210
1211 for (i = 0; i < midi_state.port[6].sequence_count; i++) {
1212 if (midi_state.port[6].sequence_address[i] != 0) {
1213 sceSifInitIopHeap();
1214 sceSifFreeIopHeap(midi_state.port[6].sequence_address[i]);
1215 }
1216 }
1217
1218 midi_state.port[6].sequence_count = 0;
1219 }
1220
1221 gBank.spu_address = midi_state.port[6].spu_address;
1222 TransHdBd(hd, hd_size, bd, bd_size);
1223 midi_state.port[6].bank = gBank.hd_address;
1224 ezMidi(0x9050 + 12, (int) &gBank);
1225 ezMidi(0xA0 + 12, 0x3090);
1226 ezMidi(0xB0 + 12, 0);
1227 return 0;
1228}
1229
1230int CSound::LoadHdBd_S(int hd, int hd_size, int bd, int bd_size) {
1231 int i;
1232
1233 if (midi_state.port[7].bank != 0) {
1234 ezMidi(0x20 + 11, 0);
1235 sceSifInitIopHeap();
1236 sceSifFreeIopHeap(midi_state.port[7].bank);
1237 midi_state.port[7].bank = 0;
1238
1239 for (i = 0; i < midi_state.port[7].sequence_count; i++) {
1240 if (midi_state.port[7].sequence_address[i] != 0) {
1241 sceSifInitIopHeap();
1242 sceSifFreeIopHeap(midi_state.port[7].sequence_address[i]);
1243 }
1244 }
1245
1246 midi_state.port[7].sequence_count = 0;
1247 }
1248
1249 gBank.spu_address = midi_state.port[7].spu_address;
1250 TransHdBd(hd, hd_size, bd, bd_size);
1251 midi_state.port[7].bank = gBank.hd_address;
1252 ezMidi(0x9050 + 11, (int) &gBank);
1253 ezMidi(0xA0 + 11, 0x3090);
1254 ezMidi(0xB0 + 11, 0);
1255 return 0;
1256}
1257
1258int CSound::LoadSeq_A(int address, int size) {
1259 void *sequence;
1260
1261 sceSifInitIopHeap();
1262 sequence = sceSifAllocIopHeap(0xFA00);
1263
1264 if (sequence == 0) {
1265 printf("AllocIopHeap Err\n");
1266 return -1;
1267 }
1268
1269 printf("AllocIopHeap %d \n", sequence);
1270 ezTransToIOP(sequence, (void *) address, size);
1271 midi_state.port[0].sequence_address[midi_state.port[0].sequence_count] = sequence;
1272 return 0;
1273}
1274
1275int CSound::LoadSeq_E(int address, int size) {
1276 void *sequence;
1277
1278 sceSifInitIopHeap();
1279 sequence = sceSifAllocIopHeap(0xFA00);
1280
1281 if (sequence == 0) {
1282 printf("AllocIopHeap Err\n");
1283 return -1;
1284 }
1285
1286 printf("AllocIopHeap %d \n", sequence);
1287 ezTransToIOP(sequence, (void *) address, size);
1288 midi_state.port[2].sequence_address[midi_state.port[2].sequence_count] = sequence;
1289 return 0;
1290}
1291
1292int CSound::LoadSeq_I(int address, int size) {
1293 void *sequence;
1294
1295 sceSifInitIopHeap();
1296 sequence = sceSifAllocIopHeap(0xFA00);
1297
1298 if (sequence == 0) {
1299 printf("AllocIopHeap Err\n");
1300 return -1;
1301 }
1302
1303 printf("AllocIopHeap %d \n", sequence);
1304 ezTransToIOP(sequence, (void *) address, size);
1305 midi_state.port[4].sequence_address[midi_state.port[4].sequence_count] = sequence;
1306 return 0;
1307}
void StopVoice(int core)
Definition sound.cpp:69
int Init(int mode0, int mode1, int depth0, int depth1)
Definition sound.cpp:372
int LoadHdBd_E(int hd, int hd_size, int bd, int bd_size)
Definition sound.cpp:1065
int LoadSeq_I(int address, int size)
Definition sound.cpp:1292
void SE_Play(int port, int bank, int program, int pan, int velocity, int volume, int voice)
Definition sound.cpp:579
int LoadSoundFileFromPack(char *name, unsigned int *pack)
Definition sound.cpp:186
int LoadSeq_E(int address, int size)
Definition sound.cpp:1275
int LoadHdBd_S(int hd, int hd_size, int bd, int bd_size)
Definition sound.cpp:1230
int LoadHdBd_C(int hd, int hd_size, int bd, int bd_size)
Definition sound.cpp:1022
void SetStereoMode(int mode)
Definition sound.cpp:987
void SE_SetPan(int port, int bank, int program, int pan, int voice)
Definition sound.cpp:679
void Step()
Definition sound.cpp:814
void SetVol(int port, int volume)
Definition sound.cpp:983
int LoadHdBd_M(int hd, int hd_size, int bd, int bd_size)
Definition sound.cpp:1174
int LoadHdBd_G(int hd, int hd_size, int bd, int bd_size)
Definition sound.cpp:1096
void SE_SetVol(int port, int bank, int program, int volume, int voice)
Definition sound.cpp:643
int LoadHdBd_A(int hd, int hd_size, int bd, int bd_size)
Definition sound.cpp:991
int LoadHdBd_Q(int hd, int hd_size, int bd, int bd_size)
Definition sound.cpp:1202
void Fade(int port, float step, int volume)
Definition sound.cpp:755
int LoadHdBd_I(int hd, int hd_size, int bd, int bd_size)
Definition sound.cpp:1125
void SQ_RePlay(int port)
Definition sound.cpp:574
void Stop(int port)
Definition sound.cpp:978
short * GetSeInfTbl()
Definition sound.cpp:49
void SE_Stop(int port, int bank, int program, int voice)
Definition sound.cpp:719
int LoadSeq_A(int address, int size)
Definition sound.cpp:1258
int LoadSqInf(char *name, unsigned int *buffer)
Definition sound.cpp:321
void SQ_Play(int port, int seq_no)
Definition sound.cpp:495
int LoadSeInf(char *name, unsigned int *buffer)
Definition sound.cpp:344
void SetReverb(int core, int mode, int depth)
Definition sound.cpp:74
int GetSeNo(int bank, int program)
Definition sound.cpp:53
MIDI_STATE * GetMidiState()
Definition sound.cpp:45
void * hd_address
Definition sound.hpp:85
s32 spu_address
Definition sound.hpp:88
s32 bd_size
Definition sound.hpp:87
void * bd_address
Definition sound.hpp:86
s32 active
Definition sound.hpp:46
float volume
Definition sound.hpp:48
s32 target_volume
Definition sound.hpp:47
float step
Definition sound.hpp:49
MIDI_FADE fade[2]
Definition sound.hpp:64
void * sequence_address[10]
Definition sound.hpp:61
s32 spu_address
Definition sound.hpp:60
MIDI_SEQUENCE * sequence[10]
Definition sound.hpp:62
void * bank
Definition sound.hpp:59
s32 sequence_count
Definition sound.hpp:63
char name[12]
Definition sound.hpp:28
MIDI_PORT port[8]
Definition sound.hpp:74
SE_INF entry[3000]
Definition sound.hpp:108
s8 bank
Definition sound.hpp:99
s16 volume
Definition sound.hpp:101
s8 program
Definition sound.hpp:100
MIDI_SEQUENCE sequence[400]
Definition sound.hpp:36
void * buff
Definition csl.h:8
int sema
Definition csl.h:7
sceCslBuffCtx * buffCtx
Definition csl.h:16
int buffNum
Definition csl.h:15
sceCslBuffGrp * buffGrp
Definition csl.h:24
void * conf
Definition csl.h:25
void * callBack
Definition csl.h:26
int buffGrpNum
Definition csl.h:23
char ** extmod
Definition csl.h:27
short depth_R
Definition libsdr.h:34
short depth_L
Definition libsdr.h:33