summaryrefslogtreecommitdiff
path: root/src/JSystem/JParticle/JPAResourceManager.cpp
blob: 09a80c74fcbdcd8d876de31cb174b7be19ba467a (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
//
// Generated By: dol2asm
// Translation Unit: JPAResourceManager
//

#include "JSystem/JParticle/JPAResourceManager.h"
#include "JSystem/JParticle/JPADynamicsBlock.h"
#include "JSystem/JParticle/JPAResource.h"
#include "string.h"

struct JPAResourceLoader {
    /* 8027D8A0 */ JPAResourceLoader(u8 const*, JPAResourceManager*);
};

/* 80273E10-80273E68 26E750 0058+00 0/0 2/2 0/0 .text __ct__18JPAResourceManagerFPCvP7JKRHeap */
JPAResourceManager::JPAResourceManager(void const* pData, EGG::Heap* pHeap) {
    mpResArr = NULL;
    mpTexArr = NULL;
    mResMax = 0;
    mResNum = 0;
    mTexMax = 0;
    mTexNum = 0;
    mpHeap = pHeap;
    JPAResourceLoader loader((u8 const*)pData, this);
}

/* 80273E68-80273EA8 26E7A8 0040+00 1/1 1/1 0/0 .text getResource__18JPAResourceManagerCFUs */
JPAResource* JPAResourceManager::getResource(u16 usrIdx) const {
    for (u16 i = 0; i < mResNum; i++)
        if (mpResArr[i]->getUsrIdx() == usrIdx)
            return mpResArr[i];
    return NULL;
}

/* 80273EA8-80273EEC 26E7E8 0044+00 0/0 2/2 0/0 .text
 * checkUserIndexDuplication__18JPAResourceManagerCFUs          */
bool JPAResourceManager::checkUserIndexDuplication(u16 usrIdx) const {
    for (s32 i = 0; i < mResNum; i++)
        if (mpResArr[i]->getUsrIdx() == usrIdx)
            return true;
    return false;
}

/* 80273EEC-80273F8C 26E82C 00A0+00 0/0 2/2 0/0 .text
 * swapTexture__18JPAResourceManagerFPC7ResTIMGPCc              */
const EGG::ResTIMG* JPAResourceManager::swapTexture(EGG::ResTIMG const* img, char const* swapName) {
    const EGG::ResTIMG* ret = NULL;

    for (s32 i = 0; i < mTexNum; i++) {
        if (strcmp(swapName, mpTexArr[i]->getName()) == 0) {
            EGG::Texture* tex = mpTexArr[i]->getJUTTexture();
            ret = tex->getTexInfo();
            tex->storeTIMG(img, (u8)0);
            break;
        }
    }

    return ret;
}

/* 80273F8C-80273FAC 26E8CC 0020+00 0/0 1/1 0/0 .text
 * registRes__18JPAResourceManagerFP11JPAResource               */
void JPAResourceManager::registRes(JPAResource* res) {
    mpResArr[mResNum] = res;
    mResNum++;
}

/* 80273FAC-80273FCC 26E8EC 0020+00 0/0 1/1 0/0 .text
 * registTex__18JPAResourceManagerFP10JPATexture                */
void JPAResourceManager::registTex(JPATexture* tex) {
    mpTexArr[mTexNum] = tex;
    mTexNum++;
}

/* 80273FCC-80274010 26E90C 0044+00 0/0 6/6 0/0 .text getResUserWork__18JPAResourceManagerCFUs */
u32 JPAResourceManager::getResUserWork(u16 usrIdx) const {
    u32 ret = 0;

    JPAResource* res = getResource(usrIdx);
    if (res != NULL)
        ret = res->getDyn()->getResUserWork();

    return ret;
}