#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);
//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];
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)
{
}
}
-extern u32 __gsp_heap_size;
-
void gfxInit()
{
gspInit();
// 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