forked from zeldaret/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJASTrack.cpp
More file actions
877 lines (806 loc) · 27.9 KB
/
JASTrack.cpp
File metadata and controls
877 lines (806 loc) · 27.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
//
// Generated By: dol2asm
// Translation Unit: JASTrack
//
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JAudio2/JASTrack.h"
#include "JSystem/JAudio2/JASCriticalSection.h"
#include "JSystem/JAudio2/JASDriverIF.h"
#include "JSystem/JAudio2/JASBank.h"
#include "JSystem/JAudio2/JASAiCtrl.h"
#include "JSystem/JAudio2/JASDSPInterface.h"
/* 80291228-8029131C 28BB68 00F4+00 1/1 3/3 0/0 .text __ct__8JASTrackFv */
JASTrack::JASTrack() : mDefaultChannelMgr(this), mChannelMgrCount(1), mStatus(0) {
mChannelMgrs[0] = &mDefaultChannelMgr;
for (int i = 1; i < 4; i++) {
mChannelMgrs[i] = NULL;
}
init();
}
/* 804316B4-80431AC0 05E3D4 040C+00 1/2 0/0 0/0 .bss sDefaultBankTable__8JASTrack */
JASDefaultBankTable JASTrack::sDefaultBankTable;
/* 80431ACC-80431ADC 05E7EC 0010+00 1/2 0/0 0/0 .bss sTrackList__8JASTrack */
JASTrack::TList JASTrack::sTrackList;
/* 8029131C-80291444 28BC5C 0128+00 4/4 4/4 0/0 .text __dt__8JASTrackFv */
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
JASTrack::~JASTrack() {
for (int i = 1; i < 4; i++) {
delete mChannelMgrs[i];
}
}
/* 80291444-802915D4 28BD84 0190+00 1/1 3/3 0/0 .text setChannelMgrCount__8JASTrackFUl */
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
void JASTrack::setChannelMgrCount(u32 i_count) {
mChannelMgrCount = 1;
for (int i = 1; i < i_count; i++) {
if (mChannelMgrs[i] == NULL) {
mChannelMgrs[i] = new TChannelMgr(this);
if (mChannelMgrs[i] == NULL) {
return;
}
}
mChannelMgrCount++;
}
for (u32 i = mChannelMgrCount; i < 4; i++) {
if (mChannelMgrs[i] != NULL) {
delete mChannelMgrs[i];
mChannelMgrs[i] = NULL;
}
}
}
/* 8039AFD0-8039AFE8 027630 0018+00 1/1 0/0 0/0 .rodata sAdsTable__8JASTrack */
JASOscillator::Point const JASTrack::sAdsTable[4] = {
{0, 0, 0x7fff},
{0, 0, 0x7fff},
{0, 0, 0},
{0xe, 0, 0},
};
/* 8039AFE8-8039B000 027648 0018+00 1/2 0/0 0/0 .rodata sEnvOsc__8JASTrack */
JASOscillator::Data const JASTrack::sEnvOsc = {0, 1.0f, NULL, NULL, 1.0f, 0.0f};
/* 8039B000-8039B018 027660 0018+00 0/1 0/0 0/0 .rodata sPitchEnvOsc__8JASTrack */
JASOscillator::Data const JASTrack::sPitchEnvOsc = {1, 1.0f, NULL, NULL, 1.0f, 0.0f};
/* 802915D4-802918FC 28BF14 0328+00 2/2 1/1 0/0 .text init__8JASTrackFv */
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
void JASTrack::init() {
mSeqCtrl.init();
mTrackPort.init();
initTimed();
mRegisterParam.init();
mOscParam[0] = sEnvOsc;
mOscParam[1] = sPitchEnvOsc;
for (int i = 0; i < 4; i++) {
mOscPoint[i] = sAdsTable[i];
}
mParent = NULL;
for (int i = 0; i < 16; i++) {
mChildren[i] = NULL;
}
mChannelMgrs[0]->init();
mChannelMgrCount = 1;
for (int i = 1; i < 4; i++) {
if (mChannelMgrs[i] != NULL) {
delete mChannelMgrs[i];
mChannelMgrs[i] = NULL;
}
}
mBankTable = &sDefaultBankTable;
field_0x1d8 = 1.0f;
field_0x1dc = 1.0f;
mVibDepth = 0.0f;
mVibPitch = 1.0f;
mTremDepth = 0.0f;
mTremPitch = 1.0f;
mVibDelay = 0;
mTremDelay = 0;
mPanPower = 1.0f;
mDirectRelease = 0;
mSkipSample = 0;
mTempo = 120;
mTimebase = 0x30;
mTempoRate = 1.0f;
updateTempo();
mTranspose = 0;
field_0x22b = 60;
mBankNumber = 0;
mProgNumber = 0xf0;
mBendSense = 0xc;
mNoteOnPrio = 0x40;
mReleasePrio = 0;
mGateRate = 100;
mMixConfig[0] = 0x150;
mMixConfig[1] = 0x210;
mMixConfig[2] = 0x352;
mMixConfig[3] = 0x412;
mMixConfig[4] = 0;
mMixConfig[5] = 0;
for (int i = 0; i < 8; i++) {
mFIR[i] = 0;
}
mFIR[0] = 0x7fff;
for (int i = 0; i < 8; i++) {
mIIR[i] = 0;
}
mIIR[0] = 0x7fff;
mFilterMode = 0;
mFlags.pause = false;
mFlags.mute = false;
mFlags.flag2 = true;
mFlags.flag5 = true;
mFlags.autoDelete = false;
mFlags.flag4 = false;
mFlags.flag6 = false;
mStatus = 0;
}
/* 802918FC-8029194C 28C23C 0050+00 1/1 0/0 0/0 .text initTimed__8JASTrackFv */
void JASTrack::initTimed() {
mMoveParam.params.volume.mValue = 1.0f;
mMoveParam.params.pitch.mValue = 0.0f;
mMoveParam.params.pan.mValue = 0.5f;
mMoveParam.params.fxmix.mValue = 0.0f;
mMoveParam.params.dolby.mValue = 0.0f;
mMoveParam.params.distFilter.mValue = 0.0f;
for (int i = 0; i < 6; i++) {
mMoveParam.array[i].mCount = 0;
mMoveParam.array[i].mTarget = mMoveParam.array[i].mValue;
}
}
/* 8029194C-802919F4 28C28C 00A8+00 1/1 0/0 0/0 .text inherit__8JASTrackFRC8JASTrack */
void JASTrack::inherit(JASTrack const& i_parent) {
mFlags.flag2 = i_parent.mFlags.flag2;
mBankNumber = i_parent.mBankNumber;
mProgNumber = i_parent.mProgNumber;
mNoteOnPrio = i_parent.mNoteOnPrio;
mReleasePrio = i_parent.mReleasePrio;
mSkipSample = i_parent.mSkipSample;
for (int i = 0; i < 8; i++) {
mFIR[i] = i_parent.mFIR[i];
}
for (int i = 0; i < 8; i++) {
mIIR[i] = i_parent.mIIR[i];
}
mFilterMode = i_parent.mFilterMode;
for (int i = 0; i < 6; i++) {
mMixConfig[i] = i_parent.mMixConfig[i];
}
}
/* 802919F4-80291A08 28C334 0014+00 0/0 5/5 0/0 .text
* assignExtBuffer__8JASTrackFUlP14JASSoundParams */
void JASTrack::assignExtBuffer(u32 i_index, JASSoundParams* i_soundParams) {
mChannelMgrs[i_index]->mSoundParams = i_soundParams;
}
/* 80291A08-80291A28 28C348 0020+00 0/0 3/3 0/0 .text setSeqData__8JASTrackFPvUl */
void JASTrack::setSeqData(void* param_0, u32 param_1) {
mSeqCtrl.start(param_0, param_1);
}
/* 80291A28-80291A78 28C368 0050+00 0/0 2/2 0/0 .text startSeq__8JASTrackFv */
void JASTrack::startSeq() {
JASCriticalSection critical_section;
sTrackList.append(this);
mStatus = 1;
}
/* 80291A78-80291ABC 28C3B8 0044+00 0/0 2/2 0/0 .text stopSeq__8JASTrackFv */
void JASTrack::stopSeq() {
JASCriticalSection critical_section;
mFlags.flag6 = 1;
}
/* 80291ABC-80291AC8 28C3FC 000C+00 0/0 1/1 0/0 .text start__8JASTrackFv */
void JASTrack::start() {
mStatus = 1;
}
/* 80291AC8-80291B8C 28C408 00C4+00 4/4 0/0 0/0 .text close__8JASTrackFv */
void JASTrack::close() {
for (int i = 0; i < 16; i++) {
JASTrack* child = mChildren[i];
if (child != NULL) {
child->close();
if (child->mFlags.autoDelete) {
delete child;
mChildren[i] = NULL;
}
}
}
for (u32 i = 0; i < mChannelMgrCount; i++) {
if (mChannelMgrs[i] != NULL) {
mChannelMgrs[i]->releaseAll();
}
}
mParent = NULL;
mStatus = 2;
}
/* 80291B8C-80291BB8 28C4CC 002C+00 1/1 1/1 0/0 .text connectChild__8JASTrackFUlP8JASTrack */
bool JASTrack::connectChild(u32 i_index, JASTrack* i_child) {
if (mChildren[i_index] != NULL) {
return false;
}
i_child->mParent = this;
mChildren[i_index] = i_child;
return true;
}
/* 80291BB8-80291C30 28C4F8 0078+00 0/0 1/1 0/0 .text closeChild__8JASTrackFUl */
void JASTrack::closeChild(u32 i_index) {
JASTrack* child = mChildren[i_index];
if (child != NULL) {
getRootTrack()->updateSeq(false, 1.0f);
child->close();
if (child->mFlags.autoDelete) {
delete child;
mChildren[i_index] = NULL;
}
}
}
/* 80291C30-80291DAC 28C570 017C+00 0/0 2/2 0/0 .text openChild__8JASTrackFUl */
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
JASTrack* JASTrack::openChild(u32 i_index) {
JASTrack* child = mChildren[i_index];
if (child != NULL) {
switch (child->mStatus) {
case 0:
break;
case 1:
getRootTrack()->updateSeq(false, 1.0f);
child->close();
// no break
case 2:
bool auto_delete = child->mFlags.autoDelete;
child->init();
child->mFlags.autoDelete = auto_delete;
mChildren[i_index] = NULL;
connectChild(i_index, child);
break;
}
} else {
child = new JASTrack();
if (child == NULL) {
return NULL;
}
child->mFlags.autoDelete = true;
connectChild(i_index, child);
}
child->setChannelMgrCount(mChannelMgrCount);
child->inherit(*this);
return child;
}
/* 80291DAC-80291DBC 28C6EC 0010+00 0/0 1/1 0/0 .text connectBus__8JASTrackFii */
void JASTrack::connectBus(int param_0, int param_1) {
mMixConfig[param_0] = param_1;
}
/* 80291DBC-80291DF8 28C6FC 003C+00 0/0 1/1 0/0 .text setLatestKey__8JASTrackFUc */
void JASTrack::setLatestKey(u8 param_0) {
field_0x22b = param_0;
field_0x22b += getTransposeTotal();
}
/* 80291DF8-80291F38 28C738 0140+00 2/2 0/0 0/0 .text
* channelStart__8JASTrackFPQ28JASTrack11TChannelMgrUlUlUl */
JASChannel* JASTrack::channelStart(JASTrack::TChannelMgr* i_channelMgr, u32 param_1, u32 param_2,
u32 i_updateTimer) {
JASBank* bank = NULL;
if (mBankTable != NULL) {
bank = mBankTable->getBank(mBankNumber);
}
JASChannel* channel = JASBank::noteOn(bank, mProgNumber, param_1, param_2,
mNoteOnPrio | mReleasePrio << 8,
channelUpdateCallback, i_channelMgr);
if (channel == NULL) {
return NULL;
}
channel->setUpdateTimer(i_updateTimer);
channel->setSkipSamples(mSkipSample);
channel->setVibrateDelay(mVibDelay);
channel->setTremoloDelay(mTremDelay);
channel->setParams(i_channelMgr->mParams);
for (u32 i = 0; i < 6; i++) {
channel->setMixConfig(i, mMixConfig[i]);
}
overwriteOsc(channel);
if (mDirectRelease != 0) {
channel->setDirectRelease(mDirectRelease);
}
return channel;
}
/* 80291F38-80292008 28C878 00D0+00 0/0 1/1 0/0 .text noteOn__8JASTrackFUlUlUl */
int JASTrack::noteOn(u32 i_noteID, u32 param_1, u32 param_2) {
if (isMute()) {
return 0;
}
int ret = 1;
param_1 += getTransposeTotal();
for (u32 i = 0; i < mChannelMgrCount; i++) {
if (mChannelMgrs[i] != NULL) {
mChannelMgrs[i]->noteOff(i_noteID, 0);
JASChannel* channel = channelStart(mChannelMgrs[i], param_1, param_2, 0);
if (channel == NULL) {
ret = 0;
}
mChannelMgrs[i]->mChannels[i_noteID] = channel;
}
}
return ret;
}
/* 80292008-80292198 28C948 0190+00 0/0 1/1 0/0 .text gateOn__8JASTrackFUlUlfUl */
int JASTrack::gateOn(u32 param_0, u32 i_velocity, f32 i_time, u32 i_flags) {
param_0 += getTransposeTotal();
if (mGateRate != 100) {
i_time *= mGateRate / 100.0f;
}
u32 uvar2 = seqTimeToDspTime(i_time);
u32 update_timer = (i_flags & 6) ? 0 : uvar2;
int uvar7;
if (i_flags & 1) {
uvar7 = field_0x22b;
} else {
uvar7 = param_0;
}
for (u32 i = 0; i < mChannelMgrCount; i++) {
TChannelMgr* channel_mgr = mChannelMgrs[i];
if (channel_mgr != NULL) {
if (!mFlags.flag4) {
channel_mgr->noteOff(0, 0);
if (!isMute()) {
channel_mgr->mChannels[0] =
channelStart(channel_mgr, uvar7, i_velocity, update_timer);
}
} else {
JASChannel* channel = channel_mgr->mChannels[0];
if (channel != NULL) {
channel->mKey = uvar7 - channel->field_0xdc.field_0x4.field_0x01;
channel->mVelocity = i_velocity;
channel->mUpdateTimer = update_timer;
}
}
if ((i_flags & 1) && channel_mgr->mChannels[0] != NULL) {
channel_mgr->mChannels[0]->setKeySweepTarget(param_0 - uvar7, uvar2);
}
}
}
mFlags.flag4 = (i_flags >> 1) & 1;
field_0x22b = param_0;
return 1;
}
/* 80292198-80292220 28CAD8 0088+00 1/1 1/1 0/0 .text noteOff__8JASTrackFUlUs */
int JASTrack::noteOff(u32 i_noteID, u16 param_1) {
int ret = 1;
for (u32 i = 0; i < mChannelMgrCount; i++) {
if (mChannelMgrs[i] != NULL) {
if (!mChannelMgrs[i]->noteOff(i_noteID, param_1)) {
ret = 0;
}
}
}
return ret;
}
/* 80292220-8029226C 28CB60 004C+00 0/0 1/1 0/0 .text checkNoteStop__8JASTrackCFUl */
bool JASTrack::checkNoteStop(u32 i_noteID) const {
for (u32 i = 0; i < mChannelMgrCount; i++) {
if (mChannelMgrs[i] != NULL && mChannelMgrs[i]->mChannels[i_noteID] != NULL) {
return false;
}
}
return true;
}
/* 8029226C-802922D8 28CBAC 006C+00 1/1 0/0 0/0 .text overwriteOsc__8JASTrackFP10JASChannel */
void JASTrack::overwriteOsc(JASChannel* i_channel) {
for (u32 i = 0; i < 2; i++) {
if (mOscParam[i].mTable != NULL) {
i_channel->setOscInit(i, &mOscParam[i]);
}
}
}
/* 802922D8-80292348 28CC18 0070+00 1/1 0/0 0/0 .text updateTimedParam__8JASTrackFv */
void JASTrack::updateTimedParam() {
for (u32 i = 0; i < 6; i++) {
MoveParam_* param = &mMoveParam.array[i];
if (param->mCount != 0) {
param->mValue += (param->mTarget - param->mValue) / param->mCount;
param->mCount--;
}
}
}
/* 80292348-802924E4 28CC88 019C+00 1/1 0/0 0/0 .text updateTrack__8JASTrackFf */
void JASTrack::updateTrack(f32 param_0) {
updateTempo();
for (u32 i = 0; i < mChannelMgrCount; i++) {
TChannelMgr* channel_mgr = mChannelMgrs[i];
if (channel_mgr != NULL) {
f32 volume = mMoveParam.params.volume.mValue;
volume = volume * volume;
f32 pitch = 1.0f;
f32 fvar6 = mMoveParam.params.pitch.mValue * mBendSense * (1.0f / 3.0f);
f32 pan = (mMoveParam.params.pan.mValue - 0.5f) * mPanPower;
f32 fxmix = mMoveParam.params.fxmix.mValue;
f32 dolby = mMoveParam.params.dolby.mValue;
JASSoundParams* sound_params = channel_mgr->mSoundParams;
if (sound_params != NULL) {
volume *= sound_params->mVolume;
pitch *= sound_params->mPitch;
pan += sound_params->mPan - 0.5f;
fxmix += sound_params->mFxMix;
dolby += sound_params->mDolby;
}
pan *= param_0;
if (mParent == NULL) {
channel_mgr->mParams.mVolume = volume;
channel_mgr->mParams.mPitch = pitch;
channel_mgr->mParams.mPan = pan;
channel_mgr->mParams.mFxMix = fxmix;
channel_mgr->mParams.mDolby = dolby;
channel_mgr->mParams.field_0x8 = fvar6;
} else {
TChannelMgr* parent_channel_mgr = mParent->mChannelMgrs[i];
if (parent_channel_mgr == NULL) {
parent_channel_mgr = mParent->mChannelMgrs[0];
}
channel_mgr->mParams.mVolume = parent_channel_mgr->mParams.mVolume * volume;
channel_mgr->mParams.mPitch = parent_channel_mgr->mParams.mPitch * pitch;
channel_mgr->mParams.mPan = (parent_channel_mgr->mParams.mPan - 0.5f) + pan;
channel_mgr->mParams.mFxMix = parent_channel_mgr->mParams.mFxMix + fxmix;
channel_mgr->mParams.mDolby = parent_channel_mgr->mParams.mDolby + dolby;
channel_mgr->mParams.field_0x8 = parent_channel_mgr->mParams.field_0x8 + fvar6;
}
channel_mgr->mParams.mPan += 0.5f;
}
}
}
/* 802924E4-80292580 28CE24 009C+00 5/5 0/0 0/0 .text updateTempo__8JASTrackFv */
void JASTrack::updateTempo() {
if (mParent == NULL) {
field_0x1dc = mTempoRate * (mTimebase * mTempo * (4.0f / 3.0f) / JASDriver::getDacRate());
} else {
mTempo = mParent->mTempo;
mTimebase = mParent->mTimebase;
field_0x1dc = mParent->field_0x1dc;
}
}
/* 80292580-80292644 28CEC0 00C4+00 4/4 0/0 0/0 .text updateSeq__8JASTrackFbf */
void JASTrack::updateSeq(bool param_0, f32 param_1) {
if (!param_0) {
param_0 = mFlags.flag5;
}
mFlags.flag5 = false;
if (param_0) {
updateTrack(param_1);
}
f32 fvar1 = param_1 * mPanPower;
for (int i = 0; i < 16; i++) {
if (mChildren[i] != NULL && mChildren[i]->mStatus == 1) {
mChildren[i]->updateSeq(param_0, fvar1);
}
}
}
/* 80292644-802926E0 28CF84 009C+00 1/1 0/0 0/0 .text seqTimeToDspTime__8JASTrackFf */
u32 JASTrack::seqTimeToDspTime(f32 i_seqTime) {
f32 dsp_time;
if (mFlags.flag2) {
dsp_time = i_seqTime / field_0x1dc;
} else {
dsp_time = i_seqTime * (120.0f / mTimebase);
dsp_time *= JASDriver::getSubFrames() / 10.0f;
}
return dsp_time;
}
/* 802926E0-80292708 28D020 0028+00 0/0 4/4 0/0 .text setParam__8JASTrackFUlfUl */
void JASTrack::setParam(u32 i_index, f32 i_target, u32 i_count) {
MoveParam_* param = &mMoveParam.array[i_index];
param->mTarget = i_target;
if (i_count == 0) {
param->mValue = param->mTarget;
}
param->mCount = i_count;
}
/* 80292708-802927A0 28D048 0098+00 1/1 0/0 0/0 .text noteOffAll__8JASTrackFUs */
void JASTrack::noteOffAll(u16 param_0) {
for (u8 i = 0; i < 8; i++) {
noteOff(i, param_0);
}
for (int i = 0; i < 16; i++) {
if (mChildren[i] != NULL && mChildren[i]->mStatus == 1) {
mChildren[i]->noteOffAll(param_0);
}
}
}
/* 802927A0-802927D8 28D0E0 0038+00 0/0 2/2 0/0 .text mute__8JASTrackFb */
void JASTrack::mute(bool i_mute) {
mFlags.mute = i_mute;
if (i_mute) {
noteOffAll(10);
}
}
/* 802927D8-802927E8 28D118 0010+00 0/0 1/1 0/0 .text setOscScale__8JASTrackFUlf */
void JASTrack::setOscScale(u32 i_oscNo, f32 i_scale) {
mOscParam[i_oscNo].mScale = i_scale;
}
/* 802927E8-80292808 28D128 0020+00 0/0 1/1 0/0 .text
* setOscTable__8JASTrackFUlPCQ213JASOscillator5Point */
void JASTrack::setOscTable(u32 i_oscNo, JASOscillator::Point const* i_table) {
mOscParam[i_oscNo].mTable = i_table;
if (i_oscNo != 0) {
mOscParam[i_oscNo]._0C = NULL;
}
}
/* 80292808-8029285C 28D148 0054+00 0/0 1/1 0/0 .text setOscAdsr__8JASTrackFssssUs */
void JASTrack::setOscAdsr(s16 param_0, s16 param_1, s16 param_2, s16 param_3, u16 i_directRelease) {
mOscParam[0] = sEnvOsc;
mOscParam[0].mTable = mOscPoint;
mOscPoint[0]._2 = param_0;
mOscPoint[1]._2 = param_1;
mOscPoint[2]._2 = param_2;
mOscPoint[2]._4 = param_3;
mDirectRelease = i_directRelease;
}
/* 804555D0-804555D4 003BD0 0004+00 2/2 0/0 0/0 .sdata2 FILTER_MODE_IIR__6JASDsp */
const u32 JASDsp::FILTER_MODE_IIR = 0x00000020;
/* 8029285C-8029289C 28D19C 0040+00 0/0 2/2 0/0 .text setFIR__8JASTrackFPCs */
void JASTrack::setFIR(s16 const* i_FIR) {
for (int i = 0; i < 8; i++) {
mFIR[i] = i_FIR[i];
}
mFilterMode &= JASDsp::FILTER_MODE_IIR;
mFilterMode |= 8;
}
/* 8029289C-802928D0 28D1DC 0034+00 0/0 4/4 0/0 .text setIIR__8JASTrackFPCs */
void JASTrack::setIIR(s16 const* i_IIR) {
for (int i = 0; i < 8; i++) {
mIIR[i] = i_IIR[i];
}
mFilterMode |= JASDsp::FILTER_MODE_IIR;
}
/* 802928D0-802928F4 28D210 0024+00 0/0 1/1 0/0 .text readPortSelf__8JASTrackFUl */
u16 JASTrack::readPortSelf(u32 param_0) {
return mTrackPort.readImport(param_0);
}
/* 802928F4-80292918 28D234 0024+00 0/0 1/1 0/0 .text writePortSelf__8JASTrackFUlUs */
void JASTrack::writePortSelf(u32 param_0, u16 param_1) {
mTrackPort.writeExport(param_0, param_1);
}
/* 80292918-8029297C 28D258 0064+00 0/0 4/4 0/0 .text writePort__8JASTrackFUlUs */
void JASTrack::writePort(u32 param_0, u16 param_1) {
mTrackPort.writeImport(param_0, param_1);
if (param_0 == 0 || param_0 == 1) {
JASSeqCtrl::IntrType intr;
if (param_0 == 0) {
intr = JASSeqCtrl::INTRTYPE_VALUE_2;
} else {
intr = JASSeqCtrl::INTRTYPE_VALUE_3;
}
mSeqCtrl.interrupt(intr);
}
}
/* 8029297C-802929A0 28D2BC 0024+00 0/0 3/3 0/0 .text readPort__8JASTrackFUl */
u16 JASTrack::readPort(u32 param_0) {
return mTrackPort.readExport(param_0);
}
/* 802929A0-80292A3C 28D2E0 009C+00 1/1 0/0 0/0 .text setChannelPauseFlag__8JASTrackFb */
void JASTrack::setChannelPauseFlag(bool i_pause) {
for (u32 i = 0; i < mChannelMgrCount; i++) {
if (mChannelMgrs[i] != NULL) {
mChannelMgrs[i]->setPauseFlag(i_pause);
}
}
for (int i = 0; i < 16; i++) {
if (mChildren[i] != NULL) {
mChildren[i]->setChannelPauseFlag(i_pause);
}
}
}
/* 80292A3C-80292AA4 28D37C 0068+00 0/0 2/2 0/0 .text pause__8JASTrackFb */
void JASTrack::pause(bool i_pause) {
if (mFlags.pause != i_pause) {
mFlags.pause = i_pause;
setChannelPauseFlag(i_pause);
mSeqCtrl.interrupt(i_pause ? JASSeqCtrl::INTRTYPE_VALUE_0 : JASSeqCtrl::INTRTYPE_VALUE_1);
}
}
/* 80292AA4-80292AF4 28D3E4 0050+00 3/3 0/0 0/0 .text getTransposeTotal__8JASTrackCFv */
int JASTrack::getTransposeTotal() const {
if (mParent != NULL) {
return mTranspose + mParent->getTransposeTotal();
} else {
return mTranspose;
}
}
/* 80292AF4-80292B58 28D434 0064+00 2/2 0/0 0/0 .text isMute__8JASTrackCFv */
bool JASTrack::isMute() const {
if (mParent != NULL) {
return mFlags.mute || mParent->isMute();
} else {
return mFlags.mute;
}
}
/* 80292B58-80292B8C 28D498 0034+00 0/0 1/1 0/0 .text setTempo__8JASTrackFUs */
void JASTrack::setTempo(u16 i_tempo) {
mTempo = i_tempo;
mFlags.flag5 = true;
updateTempo();
}
/* 80292B8C-80292BC0 28D4CC 0034+00 0/0 2/2 0/0 .text setTempoRate__8JASTrackFf */
void JASTrack::setTempoRate(f32 i_tempoRate) {
mTempoRate = i_tempoRate;
mFlags.flag5 = true;
updateTempo();
}
/* 80292BC0-80292BF4 28D500 0034+00 0/0 1/1 0/0 .text setTimebase__8JASTrackFUs */
void JASTrack::setTimebase(u16 i_timebase) {
mTimebase = i_timebase;
mFlags.flag5 = true;
updateTempo();
}
/* 80292BF4-80292CA4 28D534 00B0+00 1/1 0/0 0/0 .text
* updateChannel__8JASTrackFP10JASChannelPQ26JASDsp8TChannel */
void JASTrack::updateChannel(JASChannel* param_0, JASDsp::TChannel* param_1) {
param_0->setVibrate(mVibDepth, mVibPitch);
param_0->setTremolo(mTremDepth, mTremPitch);
if (mFilterMode & 0x20) {
param_1->setIIRFilterParam(mIIR);
}
if (mFilterMode & 0x1f) {
param_1->setFIR8FilterParam(mFIR);
}
param_1->setFilterMode(mFilterMode);
param_1->setDistFilter(mMoveParam.params.distFilter.mValue * 32767.0f);
}
/* 80292CA4-80292D88 28D5E4 00E4+00 1/1 0/0 0/0 .text
* channelUpdateCallback__8JASTrackFUlP10JASChannelPQ26JASDsp8TChannelPv */
void JASTrack::channelUpdateCallback(u32 param_0, JASChannel* param_1,
JASDsp::TChannel* param_2, void* param_3) {
TChannelMgr* channel_mgr = static_cast<TChannelMgr*>(param_3);
JASTrack* track = channel_mgr->mTrack;
switch (param_0) {
case 0:
case 1:
param_1->mParams = channel_mgr->mParams;
track->updateChannel(param_1, param_2);
break;
case 3:
param_1->release(0);
param_1->free();
channel_mgr->mChannels[0] = NULL;
break;
case 2:
for (int i = 0; i < 8; i++) {
if (param_1 == channel_mgr->mChannels[i]) {
channel_mgr->mChannels[i] = NULL;
break;
}
}
break;
}
}
/* 80292D88-80292DA0 28D6C8 0018+00 3/3 0/0 0/0 .text getRootTrack__8JASTrackFv */
JASTrack* JASTrack::getRootTrack() {
JASTrack* track = this;
while (track->mParent != NULL) {
track = track->mParent;
}
return track;
}
/* 80292DA0-80292E9C 28D6E0 00FC+00 1/1 0/0 0/0 .text tickProc__8JASTrackFv */
int JASTrack::tickProc() {
if (mFlags.pause) {
return 0;
}
int ret = mSeqCtrl.tickProc(this);
updateTimedParam();
mFlags.flag5 = true;
if (ret < 0) {
return -1;
}
for (int i = 0; i < 16; i++) {
JASTrack* child = mChildren[i];
if (child != NULL && child->mStatus == 1) {
ret = child->tickProc();
if (ret < 0) {
getRootTrack()->updateSeq(false, 1.0f);
child->close();
if (child->mFlags.autoDelete) {
delete child;
mChildren[i] = NULL;
}
}
}
}
return 0;
}
/* 80292E9C-80292F6C 28D7DC 00D0+00 1/1 0/0 0/0 .text seqMain__8JASTrackFv */
int JASTrack::seqMain() {
if (mFlags.flag6) {
updateSeq(true, 1.0f);
close();
return -1;
} else {
while (field_0x1d8 >= 1.0f) {
field_0x1d8 -= 1.0f;
if (tickProc() < 0) {
updateSeq(false, 1.0f);
close();
return -1;
}
}
field_0x1d8 += field_0x1dc;
updateSeq(false, 1.0f);
return 0;
}
}
/* 80292F6C-80292F90 28D8AC 0024+00 1/1 0/0 0/0 .text cbSeqMain__Q28JASTrack5TListFPv */
s32 JASTrack::TList::cbSeqMain(void* i_this) {
static_cast<JASTrack::TList*>(i_this)->seqMain();
return 0;
}
/* 80292F90-8029301C 28D8D0 008C+00 1/1 0/0 0/0 .text append__Q28JASTrack5TListFP8JASTrack */
void JASTrack::TList::append(JASTrack* i_track) {
if (!mCallbackRegistered) {
if (!JASDriver::registerSubFrameCallback(cbSeqMain, this)) {
return;
}
mCallbackRegistered = true;
}
Push_back(i_track);
}
/* 8029301C-802930DC 28D95C 00C0+00 1/1 0/0 0/0 .text seqMain__Q28JASTrack5TListFv */
// NONMATCHING missing load instruction
void JASTrack::TList::seqMain() {
iterator it, it2;
for (it = begin(); it != end(); it = it2) {
it2 = it;
++it2;
int seqMainRes = it->seqMain();
if (seqMainRes < 0) {
Remove(&*it);
if (it->mFlags.autoDelete) {
delete &*it;
}
}
}
}
/* 802930DC-80293148 28DA1C 006C+00 2/2 0/0 0/0 .text __ct__Q28JASTrack11TChannelMgrFP8JASTrack */
JASTrack::TChannelMgr::TChannelMgr(JASTrack* i_track) : mSoundParams(NULL), mTrack(i_track) {
for (int i = 0; i < 8; i++) {
mChannels[i] = NULL;
}
for (int i = 0; i < 8; i++) {
field_0x38[i] = 0;
}
}
/* 80293148-802931B0 28DA88 0068+00 1/1 0/0 0/0 .text init__Q28JASTrack11TChannelMgrFv */
void JASTrack::TChannelMgr::init() {
mSoundParams = NULL;
mParams.init();
for (int i = 0; i < 8; i++) {
mChannels[i] = NULL;
}
for (int i = 0; i < 8; i++) {
field_0x38[i] = 0;
}
}
/* 802931B0-80293220 28DAF0 0070+00 1/1 0/0 0/0 .text releaseAll__Q28JASTrack11TChannelMgrFv */
void JASTrack::TChannelMgr::releaseAll() {
for (int i = 0; i < 8; i++) {
JASChannel* channel = mChannels[i];
if (channel != NULL) {
channel->release(0);
channel->free();
mChannels[i] = NULL;
}
}
}
/* 80293220-802932A0 28DB60 0080+00 3/3 0/0 0/0 .text noteOff__Q28JASTrack11TChannelMgrFUlUs */
bool JASTrack::TChannelMgr::noteOff(u32 i_channel, u16 param_1) {
JASChannel* channel = mChannels[i_channel];
if (channel == NULL) {
return false;
}
if (param_1 == 0) {
channel->release(0);
} else {
channel->release(param_1);
}
channel->free();
mChannels[i_channel] = NULL;
return true;
}
/* 802932A0-802932C8 28DBE0 0028+00 1/1 0/0 0/0 .text setPauseFlag__Q28JASTrack11TChannelMgrFb */
void JASTrack::TChannelMgr::setPauseFlag(bool i_pause) {
for (int i = 0; i < 8; i++) {
if (mChannels[i] != NULL) {
mChannels[i]->setPauseFlag(i_pause);
}
}
}