summaryrefslogtreecommitdiff
path: root/include/vram.h
blob: 26fa441244c26b8bce1999088d7d0a5408b7a3b1 (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
#ifndef VRAM_H
#define VRAM_H

#include "global.h"
#include "entity.h"

#define MAX_GFX_SLOTS 44

typedef enum {
    GFX_SLOT_FREE,
    GFX_SLOT_UNLOADED, // some sort of free? no longer in use?
    GFX_SLOT_STATUS2,  // some sort of free?
    GFX_SLOT_FOLLOWER, // Set by SetGFXSlotStatus for the following slots
    GFX_SLOT_RESERVED, // maybe ready to be loaded?
    GFX_SLOT_GFX,
    GFX_SLOT_PALETTE
} GfxSlotStatus;

typedef enum {
    GFX_VRAM_0,
    GFX_VRAM_1, // uploaded to vram?
    GFX_VRAM_2,
    GFX_VRAM_3, // not yet uploaded to vram?
} GfxSlotVramStatus;

typedef struct {
    /*0x00*/ u8 status : 4;
    /*0x00*/ u8 vramStatus : 4; // Whether the gfx was uploaded to the vram?
    /*0x01*/ u8 slotCount;
    /*0x02*/ u8 referenceCount; /**< How many entities use this gfx slot */
    /*0x03*/ u8 unk_3;
    /*0x04*/ u16 gfxIndex;
    /*0x06*/ u16 paletteIndex;
    /*0x08*/ const void* palettePointer;
} GfxSlot;

typedef struct {
    /*0x00*/ u8 unk0;
    /*0x01*/ u8 unk_1;
    /*0x02*/ u8 unk_2;
    /*0x03*/ u8 unk_3;
    /*0x04*/ GfxSlot slots[MAX_GFX_SLOTS];
} GfxSlotList;
extern GfxSlotList gGFXSlots;

static_assert(sizeof(GfxSlotList) == 0x214);

extern bool32 LoadFixedGFX(Entity*, u32);
extern bool32 LoadSwapGFX(Entity*, u32, u32);
extern void UnloadGFXSlots(Entity*);
extern void sub_080ADD70(void);

extern u16 gBG0Buffer[0x400];
extern u16 gBG1Buffer[0x400];
extern u16 gBG2Buffer[0x400];
extern u16 gBG3Buffer[0x800];

typedef struct {
    u8 unk0;
    u8 unk1;
    u16 unk2;
    u8 unk4;
    u8 unk5;
    u8 unk6;
    u8 unk7;
} OAMObj;

typedef struct {
    u8 field_0x0;
    u8 field_0x1;
    u8 spritesOffset;
    u8 updated;
    u16 _4;
    u16 _6;
    u8 _0[0x18];
    struct OamData oam[0x80];
    OAMObj unk[0xA0]; /* todo: affine */
} OAMControls;
extern OAMControls gOAMControls;

#endif // VRAM_H