-
Notifications
You must be signed in to change notification settings - Fork 1
/
vram.c
46 lines (36 loc) · 967 Bytes
/
vram.c
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
#include "vram.h"
#include <pspge.h>
#include <pspgu.h>
static unsigned int staticOffset = 0;
static unsigned int getMemorySize(unsigned int width, unsigned int height, unsigned int psm)
{
switch (psm)
{
case GU_PSM_T4:
return (width * height) >> 1;
case GU_PSM_T8:
return width * height;
case GU_PSM_5650:
case GU_PSM_5551:
case GU_PSM_4444:
case GU_PSM_T16:
return 2 * width * height;
case GU_PSM_8888:
case GU_PSM_T32:
return 4 * width * height;
default:
return 0;
}
}
void* getStaticVramBuffer(unsigned int width, unsigned int height, unsigned int psm)
{
unsigned int memSize = getMemorySize(width,height,psm);
void* result = (void*)staticOffset;
staticOffset += memSize;
return result;
}
void* getStaticVramTexture(unsigned int width, unsigned int height, unsigned int psm)
{
void* result = getStaticVramBuffer(width,height,psm);
return (void*)(((unsigned int)result) + ((unsigned int)sceGeEdramGetAddr()));
}