summaryrefslogtreecommitdiff
path: root/src/JSystem/JAudio2/JASBasicBank.cpp
blob: 510d7a718d60c8fc0387f016716d3ebe2484253a (plain)
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
#include "JSystem/JSystem.h" // IWYU pragma: keep

#include "JSystem/JAudio2/JASBasicBank.h"
#include "JSystem/JAudio2/JASCalc.h"

JASBasicBank::JASBasicBank() {
    mInstTable = NULL;
    mInstNumMax = 0;
}

void JASBasicBank::newInstTable(u8 num, JKRHeap* heap) {
    if (num != 0) {
        JUT_ASSERT(31, num <= JASBank::PRG_OSC);
        mInstNumMax = num;
        mInstTable = new (heap, 0) JASInst*[mInstNumMax];
        JASCalc::bzero(mInstTable, mInstNumMax * 4);
    }
}

bool JASBasicBank::getInstParam(int prg_no, int param_1, int param_2,
                                JASInstParam* o_param) const {
    JASInst* inst = getInst(prg_no);
    if (inst == NULL) {
        return NULL;
    }
    return inst->getParam(param_1, param_2, o_param);
}

void JASBasicBank::setInst(int prg_no, JASInst* inst) {
    if (mInstTable != NULL) {
        JUT_ASSERT(50, prg_no < mInstNumMax);
        JUT_ASSERT(54, prg_no >= 0);
        JUT_ASSERT(56, mInstTable[prg_no] == 0);
        mInstTable[prg_no] = inst;
    }
}

JASInst* JASBasicBank::getInst(int prg_no) const {
    if (prg_no < 0) {
        return NULL;
    }
    if (prg_no >= mInstNumMax) {
        return NULL;
    }
    if (mInstTable == NULL) {
        return NULL;
    }
    return mInstTable[prg_no];
}