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

#include "egg/core/eggSystem.h"
#include "egg/core/eggVideo.h"

namespace EGG {

void Xfb::init(u16 width, u16 height, Heap *heap) {
    mWidth = width;
    mHeight = height;
    u32 size = calcBufferSize(width, height);
    if (heap == nullptr) {
        heap = Heap::sCurrentHeap;
    }

    u8 *buf = new (heap, 32) u8[size];
    mBuffer = buf;
    mPrev = nullptr;
    mNext = nullptr;
    mState = XFB_UNPROCESSED;
}

Xfb::Xfb(Heap *heap) {
    Video *video = BaseSystem::mConfigData->getVideo();
    init(video->pRenderMode->fbWidth, video->pRenderMode->xfbHeight, heap);
}

u32 Xfb::calcBufferSize(u16 width, u16 height) {
    return ((width + 0xf) & 0xfff0) * height * 2;
}

} // namespace EGG