summaryrefslogtreecommitdiff
path: root/src/egg/core/eggGraphicsFifo.cpp
blob: 7716e3c6abfb8520f4ab6670a58bea494657d517 (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
#include "egg/core/eggGraphicsFifo.h"

#include "egg/core/eggHeap.h"
#include "rvl/GX.h" // IWYU pragma: export

extern "C" void GXGetGPStatus(GXBool *overhi, GXBool *underlow, GXBool *readIdle, GXBool *cmdIdle, GXBool *brkpt);

namespace EGG {

GraphicsFifo *GraphicsFifo::sGraphicsFifo;
u8 GraphicsFifo::sGpStatus[];

void GraphicsFifo::create(u32 size, Heap *heap) {
    if (heap == nullptr) {
        heap = Heap::sCurrentHeap;
    }
    sGraphicsFifo = new (heap, 0x04) GraphicsFifo(size, heap);
}

GraphicsFifo::~GraphicsFifo() {
    do {
        GXGetGPStatus(&sGpStatus[0], &sGpStatus[1], &sGpStatus[2], &sGpStatus[3], &sGpStatus[4]);
    } while (sGpStatus[2] == false);
    Heap::free(mBuffBase, nullptr);
}

GraphicsFifo::GraphicsFifo(u32 size, Heap *heap) {
    mBufSize = ROUND_UP(size, 0x20);
    mBuffBase = Heap::alloc(mBufSize, 0x20, heap);
    mGxInitData = GXInit(mBuffBase, mBufSize);
}

} // namespace EGG