summaryrefslogtreecommitdiff
path: root/src/dolphin/gd/GDBase.c
blob: 8b64442e5babad70af32067cb4722339db2d6cfe (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
#include "dolphin/gd/GDBase.h"
#include "dolphin/os/OS.h"

GDLObj* __GDCurrentDL = NULL;
static GDOverflowCallback overflowcb = NULL;

void GDInitGDLObj(GDLObj* dl, void* start, u32 length) {
    ASSERTMSGLINE(40, !((u32)start & 0x1F), "start must be aligned to 32 bytes");
    ASSERTMSGLINE(41, !((u32)length & 0x1F), "length must be aligned to 32 bytes");
    dl->start = start;
    dl->ptr = start;
    dl->top = (u8*)start + length;
    dl->length = length;
}

void GDFlushCurrToMem(void) {
    DCFlushRange(__GDCurrentDL->start, __GDCurrentDL->length);
}

void GDPadCurr32(void) {
    u32 n;

    n = (u32)__GDCurrentDL->ptr & 0x1F;
    if (n != 0) {
        for (; n < 32; n = n + 1) {
            __GDWrite(0);
        }
    }
}

void GDOverflowed(void) {
    if (overflowcb) {
        (*overflowcb)();
    } else {
        ASSERTMSGLINE(77, 0, "GDWrite: display list overflowed");
    }
}