summaryrefslogtreecommitdiff
path: root/src/JSystem/JAudio/JASChAllocQueue.cpp
blob: 46d3e23b2d1891a010cb993c6f790cdbcd7488dc (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
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
//
// Generated by dtk
// Translation Unit: JASChAllocQueue.cpp
//

#include "JSystem/JSystem.h" // IWYU pragma: keep

#include "JSystem/JAudio/JASChAllocQueue.h"
#include "JSystem/JAudio/JASChannel.h"
#include "JSystem/JAudio/JASChannelMgr.h"
#include "JSystem/JAudio/JASDSPChannel.h"
#include "JSystem/JUtility/JUTAssert.h"

JSUList<JASystem::TChannel> JASystem::sDspQueueList;

/* 8028B0C4-8028B224       .text deQueue__Q28JASystem9TDSPQueueFv */
void JASystem::TDSPQueue::deQueue() {
    JSULink<TChannel>* link;
    JSULink<TChannel>* next;
    u32 r31 = TDSPChannel::getNumBreak();
    for (link = sDspQueueList.getFirst(); link; link = next) {
        next = link->getNext();
        TChannel* channel = link->getObject();
        TDSPChannel* dspChannel = TDSPChannel::alloc(0, u32(channel));
        if (!dspChannel) {
            if (r31) {
                r31--;
                continue;
            }
            if (TDSPChannel::breakLower(channel->getNoteOnPriority())) {
                continue;
            }
            channel->field_0x28(channel, 6);
            sDspQueueList.remove(&channel->field_0xd8);
        } else {
            channel->field_0x20 = dspChannel;
            int status = channel->playLogicalChannel();
            JUT_ASSERT(69, status);
            int sst = channel->field_0x4->cutList(channel);
            JUT_ASSERT(72, sst >= 0);
            channel->field_0x4->addListTail(channel, 1);
            sDspQueueList.remove(&channel->field_0xd8);
        }

    }
}

/* 8028B224-8028B288       .text enQueue__Q28JASystem9TDSPQueueFPQ28JASystem8TChannel */
void JASystem::TDSPQueue::enQueue(TChannel* param_1) {
    JSUListIterator<TChannel> it;
    for (it = sDspQueueList.getFirst(); it != sDspQueueList.getEnd(); it++) {
        if (param_1->getNoteOnPriority() > it->getNoteOnPriority()) {
            break;
        }
    }
    sDspQueueList.insert(it.mLink, &param_1->field_0xd8);
}

/* 8028B288-8028B2BC       .text deleteQueue__Q28JASystem9TDSPQueueFPQ28JASystem8TChannel */
int JASystem::TDSPQueue::deleteQueue(TChannel* param_1) {
    return sDspQueueList.remove(&param_1->field_0xd8);
}

/* 8028B2BC-8028B350       .text checkQueue__Q28JASystem9TDSPQueueFv */
void JASystem::TDSPQueue::checkQueue() {
    deQueue();
    JSULink<TChannel>* next;
    for (JSULink<TChannel>* link = sDspQueueList.getFirst(); link; link = next) {
        next = link->getNext();
        TChannel* channel = link->getObject();
        if (channel->field_0x30 > 0) {
            channel->field_0x30--;
        }
        if (channel->field_0x30 == 0) {
            channel->field_0x28(channel, 6);
            sDspQueueList.remove(&channel->field_0xd8);
        }
    }
}