gsp: Added gspAllocLinear() to allocate from LINEAR heap
Required by CSND, for example
This commit is contained in:
parent
fa18d4750b
commit
dc052c19ee
@ -3,6 +3,19 @@
|
||||
|
||||
#define CSND_SHAREDMEM_DEFAULT 0x10004000
|
||||
|
||||
typedef enum{
|
||||
CSND_LOOP_DISABLE,
|
||||
CSND_LOOP_ENABLE
|
||||
} CSND_LOOPING;
|
||||
|
||||
typedef enum{
|
||||
CSND_ENCODING_PCM8,
|
||||
CSND_ENCODING_PCM16,
|
||||
CSND_ENCODING_IMA_ADPCM,
|
||||
CSND_ENCODING_PSG//"3 = PSG, similar to DS?"
|
||||
} CSND_ENCODING;
|
||||
|
||||
|
||||
//See here regarding CSND shared-mem commands, etc: http://3dbrew.org/wiki/CSND_Shared_Memory
|
||||
|
||||
Result CSND_initialize(u32* sharedMem);
|
||||
|
@ -27,6 +27,7 @@ void gfxSwapBuffers();
|
||||
|
||||
//helper stuff
|
||||
u8* gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16* width, u16* height);
|
||||
void* gfxAllocLinear(size_t size);
|
||||
|
||||
//global variables
|
||||
extern u8* gfxTopLeftFramebuffers[2];
|
||||
|
@ -21,6 +21,25 @@ Handle gspEvent, gspSharedMemHandle;
|
||||
|
||||
u8* gspHeap;
|
||||
u32* gxCmdBuf;
|
||||
extern u32 __gsp_heap_size;
|
||||
|
||||
|
||||
|
||||
// TODO: this function is not thread-safe and you cannot 'free' this memory.
|
||||
void* gfxAllocLinear(size_t size)
|
||||
{
|
||||
static size_t currentOffset = 0;
|
||||
size_t free = __gsp_heap_size - currentOffset;
|
||||
|
||||
if(free >= size)
|
||||
{
|
||||
currentOffset += size;
|
||||
return (void*) &gspHeap[currentOffset - size];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void gfxSet3D(bool enable)
|
||||
{
|
||||
@ -51,8 +70,6 @@ void gfxSetFramebufferInfo(gfxScreen_t screen, u8 id)
|
||||
}
|
||||
}
|
||||
|
||||
extern u32 __gsp_heap_size;
|
||||
|
||||
void gfxInit()
|
||||
{
|
||||
gspInit();
|
||||
@ -78,12 +95,12 @@ void gfxInit()
|
||||
// topright1 0x000FD200-0x00143700
|
||||
// topright2 0x00143700-0x00189C00
|
||||
|
||||
gfxTopLeftFramebuffers[0]=(u8*)gspHeap;
|
||||
gfxTopLeftFramebuffers[1]=gfxTopLeftFramebuffers[0]+0x46500;
|
||||
gfxBottomFramebuffers[0]=gfxTopLeftFramebuffers[1]+0x46500;
|
||||
gfxBottomFramebuffers[1]=gfxBottomFramebuffers[0]+0x38400;
|
||||
gfxTopRightFramebuffers[0]=gfxBottomFramebuffers[1]+0x38400;
|
||||
gfxTopRightFramebuffers[1]=gfxTopRightFramebuffers[0]+0x46500;
|
||||
gfxTopLeftFramebuffers[0]=gfxAllocLinear(0x46500);
|
||||
gfxTopLeftFramebuffers[1]=gfxAllocLinear(0x46500);
|
||||
gfxBottomFramebuffers[0]=gfxAllocLinear(0x38400);
|
||||
gfxBottomFramebuffers[1]=gfxAllocLinear(0x38400);
|
||||
gfxTopRightFramebuffers[0]=gfxAllocLinear(0x46500);
|
||||
gfxTopRightFramebuffers[1]=gfxAllocLinear(0x46500);
|
||||
enable3d=false;
|
||||
|
||||
//initialize framebuffer info structures
|
||||
|
Loading…
Reference in New Issue
Block a user