//
// Generated by dtk
// Translation Unit: JAIConst.cpp
//

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

#include "JSystem/JAudio/JAIConst.h"
#include "JSystem/JAudio/JAIBasic.h"
#include "JSystem/JAudio/JASDvdThread.h"
#include "JSystem/JAudio/JASSystemHeap.h"
#include "JSystem/JKernel/JKRDvdRipper.h"
#include "JSystem/JKernel/JKRSolidHeap.h"
#include "JSystem/JUtility/JUTAssert.h"

JAInter::Camera JAInter::Const::nullCamera(&camTrans, &camPreTrans, camMtx);
JAInter::Actor JAInter::Const::nullActor(NULL, NULL, 0, NULL);
Mtx JAInter::Const::camMtx;
Vec JAInter::Const::camTrans;
Vec JAInter::Const::camPreTrans;
Vec JAInter::Const::dummyZeroVec = {0.0f, 0.0f, 0.0f};
u8 JAInter::Const::sCInfos_0[] = {
    4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2,
    4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2,
};
JMath::TRandom_fast_ JAInter::Const::random(0);

/* 80291704-802917D8       .text transInitDataFile__7JAInterFPUcUl */
u8* JAInter::transInitDataFile(u8* param_1, u32 param_2) {
    u8* var1 = new (JAIBasic::getCurrentJAIHeap(), 0x20) u8[param_2];
    if (var1) {
        for (int i = 0; i < param_2; i++) {
            var1[i] = param_1[i];
        }
    }
    return var1;
}

/* 802917D8-802918CC       .text loadTmpDVDFile__7JAInterFPcPPUc */
void JAInter::loadTmpDVDFile(char* param_1, u8** tmpPointer) {
    u32 size = JASystem::Dvd::checkFile(param_1);
    if (size == 0) {
        *tmpPointer = NULL;
        return;
    }
    *tmpPointer = (u8*)JASDram->alloc(size, -0x20);
    JUT_ASSERT_MSG(113, (*tmpPointer), "JAIBasic::loadTmpDVDFile Cannot Alloc Heap!!\n");
    if (!JKRDvdRipper::loadToMainRAM(param_1, *tmpPointer, EXPAND_SWITCH_UNKNOWN0, 0, NULL, JKRDvdRipper::ALLOC_DIRECTION_FORWARD, 0, NULL)) {
        *tmpPointer = NULL;
    }
}

/* 802918CC-802918FC       .text deleteTmpDVDFile__7JAInterFPPUc */
void JAInter::deleteTmpDVDFile(u8** tmpPointer) {
    if (*tmpPointer) {
        JASDram->freeTail();
    }
}

/* 802918FC-8029193C       .text routeToTrack__7JAInterFUl */
u32 JAInter::routeToTrack(u32 param_1) {
    u32 r4;
    u32 r5 = 0;
    r4 = param_1 & 0xF0000000;
    if (r4 == 0) {
        return 0;
    }
    if (r4 == 0x10000000) {
        r5 = 0x0F;
    } else if (r4 == 0x20000000) {
        r5 = 0xFF;
    }
    return param_1 & r5;
}
