mirror of
https://github.com/pspdev/pspsdk.git
synced 2026-01-02 05:28:41 +00:00
53 lines
1.2 KiB
C
53 lines
1.2 KiB
C
/*
|
|
* PSP Software Development Kit - https://github.com/pspdev
|
|
* -----------------------------------------------------------------------
|
|
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
|
*
|
|
* Copyright (c) 2010 Dan Peori
|
|
*/
|
|
|
|
#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* guGetStaticVramBuffer(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* guGetStaticVramTexture(unsigned int width, unsigned int height, unsigned int psm)
|
|
{
|
|
void* result = guGetStaticVramBuffer(width,height,psm);
|
|
return (void*)(((unsigned int)result) + ((unsigned int)sceGeEdramGetAddr()));
|
|
}
|