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

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

#include "JSystem/JAudio/JASSeqCtrl.h"
#include "JSystem/JUtility/JUTAssert.h"

/* 8027E3F8-8027E448       .text init__Q28JASystem8TSeqCtrlFv */
void JASystem::TSeqCtrl::init() {
    mRawFilePtr = NULL;
    mCurrentFilePtr = NULL;
    mWaitTimer = 0;
    mLoopIndex = 0;
    for (int i = 0; i < 8; i++) {
        mLoopStartPositions[i] = NULL;
        mLoopTimers[i] = 0;
    }
    field_0x40 = 0;
    mPreviousFilePtr = NULL;
}

/* 8027E448-8027E45C       .text start__Q28JASystem8TSeqCtrlFPvUl */
void JASystem::TSeqCtrl::start(void* param_1, u32 param_2) {
    mRawFilePtr = (u8*)param_1;
    mCurrentFilePtr = mRawFilePtr + param_2;
}

/* 8027E45C-8027E500       .text loopEnd__Q28JASystem8TSeqCtrlFv */
int JASystem::TSeqCtrl::loopEnd() {
    u32 var1 = mLoopIndex;
    if (var1 == 0) {
        JUT_WARN(45, "%s", "cannot loopE for call-stack is NULL");
        return 0;
    }
    u16 var3 = mLoopTimers[var1 - 1];
    if (var3) {
        var3--;
    }
    if (var3 == 0) {
        mLoopIndex--;
        return true;
    }
    mLoopTimers[var1 - 1] = var3;
    mCurrentFilePtr = mLoopStartPositions[mLoopIndex - 1];
    return true;
}

/* 8027E500-8027E530       .text waitCountDown__Q28JASystem8TSeqCtrlFv */
bool JASystem::TSeqCtrl::waitCountDown() {
    if (mWaitTimer > 0) {
        mWaitTimer--;
        if (mWaitTimer) {
            return false;
        }
    }
    return true;
}

/* 8027E530-8027E568       .text callIntr__Q28JASystem8TSeqCtrlFPv */
bool JASystem::TSeqCtrl::callIntr(void* param_1) {
    if (mPreviousFilePtr) {
        return false;
    }
    mPreviousFilePtr = mCurrentFilePtr;
    mCurrentFilePtr = (u8*)param_1;
    field_0x40 = mWaitTimer;
    mWaitTimer = 0;
    return true;
}

/* 8027E568-8027E59C       .text retIntr__Q28JASystem8TSeqCtrlFv */
bool JASystem::TSeqCtrl::retIntr() {
    if (!mPreviousFilePtr) {
        return false;
    }
    mWaitTimer = field_0x40;
    mCurrentFilePtr = mPreviousFilePtr;
    mPreviousFilePtr = NULL;
    return true;
}

/* 8027E59C-8027E5B4       .text get16__Q28JASystem8TSeqCtrlCFUl */
u16 JASystem::TSeqCtrl::get16(u32 param_1) const {
    u16 result = getByte(param_1++) << 8;
    result |= getByte(param_1);
    return result;
}

/* 8027E5B4-8027E5DC       .text get24__Q28JASystem8TSeqCtrlCFUl */
u32 JASystem::TSeqCtrl::get24(u32 param_1) const {
    u32 result = getByte(param_1++) << 8;
    result |= getByte(param_1++);
    result <<= 8;
    result |= getByte(param_1);
    return result;
}

/* 8027E5DC-8027E614       .text get32__Q28JASystem8TSeqCtrlCFUl */
u32 JASystem::TSeqCtrl::get32(u32 param_1) const {
    u32 result = getByte(param_1++) << 8;
    result |= getByte(param_1++);
    result <<= 8;
    result |= getByte(param_1++);
    result <<= 8;
    result |= getByte(param_1);
    return result;
}

/* 8027E614-8027E63C       .text read16__Q28JASystem8TSeqCtrlFv */
u16 JASystem::TSeqCtrl::read16() {
    u16 result = readByte() << 8;
    result |= readByte();
    return result;
}

/* 8027E63C-8027E680       .text read24__Q28JASystem8TSeqCtrlFv */
u32 JASystem::TSeqCtrl::read24() {
    u32 result = readByte() << 8;
    result |= readByte();
    result <<= 8;
    result |= readByte();
    return result;
}