Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
286e79774c
26
examples/Makefile
Normal file
26
examples/Makefile
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
SUBDIRS:= $(shell ls | egrep -v '^(CVS)$$')
|
||||||
|
|
||||||
|
DATESTRING := $(shell date +%Y)$(shell date +%m)$(shell date +%d)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
all: examples
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
@rm -fr bin
|
||||||
|
@mkdir -p bin
|
||||||
|
@find . -name "*.3dsx" -exec cp -fv {} bin \;
|
||||||
|
|
||||||
|
examples:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
@rm -fr bin
|
||||||
|
@rm -f *.bz2
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
dist: clean
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
@rm -fr bin
|
||||||
|
@tar --exclude=.svn --exclude=*CVS* -cvjf 3ds-examples-$(DATESTRING).tar.bz2 *
|
@ -6,10 +6,7 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
srvInit(); // Needed
|
gfxInitDefault(); // Init graphic stuff
|
||||||
aptInit(); // Needed
|
|
||||||
gfxInit(); // Init graphic stuff
|
|
||||||
hidInit(NULL); // For input (buttons, touchscreen...)
|
|
||||||
|
|
||||||
|
|
||||||
// We need these 2 buffers for APT_DoAppJump() later. They can be smaller too
|
// We need these 2 buffers for APT_DoAppJump() later. They can be smaller too
|
||||||
@ -46,11 +43,7 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Deinit everything before the app process get's terminated
|
|
||||||
hidExit();
|
|
||||||
gfxExit();
|
gfxExit();
|
||||||
aptExit();
|
|
||||||
srvExit();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,7 @@ int main()
|
|||||||
u8 control=0x40;
|
u8 control=0x40;
|
||||||
u32 audio_initialized = 0;
|
u32 audio_initialized = 0;
|
||||||
|
|
||||||
srvInit();
|
gfxInitDefault();
|
||||||
aptInit();
|
|
||||||
gfxInit();
|
|
||||||
hidInit(NULL);
|
|
||||||
|
|
||||||
if(CSND_initialize(NULL)==0)audio_initialized = 1;
|
if(CSND_initialize(NULL)==0)audio_initialized = 1;
|
||||||
|
|
||||||
@ -85,10 +82,7 @@ int main()
|
|||||||
free(sharedmem);
|
free(sharedmem);
|
||||||
linearFree(audiobuf);
|
linearFree(audiobuf);
|
||||||
|
|
||||||
hidExit();
|
|
||||||
gfxExit();
|
gfxExit();
|
||||||
aptExit();
|
|
||||||
srvExit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,7 @@
|
|||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// Initialize services
|
// Initialize services
|
||||||
gfxInit();
|
gfxInitDefault();
|
||||||
initCfgu();
|
initCfgu();
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,11 +189,8 @@ void renderFrame()
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
//setup services
|
|
||||||
srvInit();
|
gfxInitDefault();
|
||||||
aptInit();
|
|
||||||
gfxInit();
|
|
||||||
hidInit(NULL);
|
|
||||||
|
|
||||||
//initialize GPU
|
//initialize GPU
|
||||||
GPU_Init(NULL);
|
GPU_Init(NULL);
|
||||||
@ -321,9 +318,6 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gsExit();
|
gsExit();
|
||||||
hidExit();
|
|
||||||
gfxExit();
|
gfxExit();
|
||||||
aptExit();
|
|
||||||
srvExit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
7
examples/graphics/Makefile
Normal file
7
examples/graphics/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
|
||||||
|
all:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||||
|
clean:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
||||||
|
install:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done;
|
7
examples/graphics/printing/Makefile
Normal file
7
examples/graphics/printing/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
|
||||||
|
all:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||||
|
clean:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
||||||
|
install:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done;
|
@ -17,11 +17,7 @@
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// Initialize services
|
gfxInitDefault();
|
||||||
srvInit();
|
|
||||||
aptInit();
|
|
||||||
gfxInit();
|
|
||||||
hidInit(NULL);
|
|
||||||
|
|
||||||
//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one
|
//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one
|
||||||
consoleInit(GFX_TOP, NULL);
|
consoleInit(GFX_TOP, NULL);
|
||||||
@ -54,10 +50,6 @@ int main(int argc, char **argv)
|
|||||||
gspWaitForVBlank();
|
gspWaitForVBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit services
|
|
||||||
gfxExit();
|
gfxExit();
|
||||||
hidExit();
|
|
||||||
aptExit();
|
|
||||||
srvExit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,18 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
Result http_download(httpcContext *context)//This error handling needs updated with proper text printing once ctrulib itself supports that.
|
Result http_download(httpcContext *context)//This error handling needs updated with proper text printing once ctrulib itself supports that.
|
||||||
{
|
{
|
||||||
Result ret=0;
|
Result ret=0;
|
||||||
u8* framebuf_top, *framebuf_bottom;
|
u8* framebuf_top;
|
||||||
u32 statuscode=0;
|
u32 statuscode=0;
|
||||||
u32 size=0, contentsize=0;
|
u32 size=0, contentsize=0;
|
||||||
u8 *buf;
|
u8 *buf;
|
||||||
|
|
||||||
framebuf_bottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
|
||||||
memset(framebuf_bottom, 0x40, 240*320*3);
|
|
||||||
gfxFlushBuffers();
|
|
||||||
gfxSwapBuffers();
|
|
||||||
|
|
||||||
framebuf_bottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
|
||||||
memset(framebuf_bottom, 0x40, 240*320*3);
|
|
||||||
gfxFlushBuffers();
|
|
||||||
gfxSwapBuffers();
|
|
||||||
gspWaitForVBlank();
|
|
||||||
|
|
||||||
ret = httpcBeginRequest(context);
|
ret = httpcBeginRequest(context);
|
||||||
if(ret!=0)return ret;
|
if(ret!=0)return ret;
|
||||||
|
|
||||||
@ -33,23 +24,13 @@ Result http_download(httpcContext *context)//This error handling needs updated w
|
|||||||
ret=httpcGetDownloadSizeState(context, NULL, &contentsize);
|
ret=httpcGetDownloadSizeState(context, NULL, &contentsize);
|
||||||
if(ret!=0)return ret;
|
if(ret!=0)return ret;
|
||||||
|
|
||||||
|
printf("size: %"PRId32"\n",contentsize);
|
||||||
|
gfxFlushBuffers();
|
||||||
|
|
||||||
buf = (u8*)malloc(contentsize);
|
buf = (u8*)malloc(contentsize);
|
||||||
if(buf==NULL)return -1;
|
if(buf==NULL)return -1;
|
||||||
memset(buf, 0, contentsize);
|
memset(buf, 0, contentsize);
|
||||||
|
|
||||||
framebuf_bottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
|
||||||
memset(framebuf_bottom, 0xc0, 240*320*3);
|
|
||||||
gfxFlushBuffers();
|
|
||||||
gfxSwapBuffers();
|
|
||||||
|
|
||||||
framebuf_bottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
|
||||||
memset(framebuf_bottom, 0xc0, 240*320*3);
|
|
||||||
gfxFlushBuffers();
|
|
||||||
gfxSwapBuffers();
|
|
||||||
gspWaitForVBlank();
|
|
||||||
|
|
||||||
framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
|
||||||
framebuf_bottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
|
||||||
|
|
||||||
ret = httpcDownloadData(context, buf, contentsize, NULL);
|
ret = httpcDownloadData(context, buf, contentsize, NULL);
|
||||||
if(ret!=0)
|
if(ret!=0)
|
||||||
@ -59,18 +40,15 @@ Result http_download(httpcContext *context)//This error handling needs updated w
|
|||||||
}
|
}
|
||||||
|
|
||||||
size = contentsize;
|
size = contentsize;
|
||||||
if(size>(240*400*3))size = 240*400*3;
|
if(size>(240*400*3*2))size = 240*400*3*2;
|
||||||
|
|
||||||
memset(framebuf_bottom, 0xff, 240*320*3);
|
framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||||
memcpy(framebuf_top, buf, size);
|
memcpy(framebuf_top, buf, size);
|
||||||
|
|
||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
gfxSwapBuffers();
|
gfxSwapBuffers();
|
||||||
|
|
||||||
framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||||
framebuf_bottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
|
||||||
|
|
||||||
memset(framebuf_bottom, 0xff, 240*320*3);
|
|
||||||
memcpy(framebuf_top, buf, size);
|
memcpy(framebuf_top, buf, size);
|
||||||
|
|
||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
@ -87,19 +65,26 @@ int main()
|
|||||||
Result ret=0;
|
Result ret=0;
|
||||||
httpcContext context;
|
httpcContext context;
|
||||||
|
|
||||||
// Initialize services
|
gfxInitDefault();
|
||||||
srvInit();
|
|
||||||
aptInit();
|
|
||||||
hidInit(NULL);
|
|
||||||
gfxInit();
|
|
||||||
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
|
||||||
httpcInit();
|
httpcInit();
|
||||||
|
|
||||||
ret = httpcOpenContext(&context, "http://10.0.0.3/httpexample_rawimg.bin", 0);//Change this to your own URL.
|
consoleInit(GFX_BOTTOM,NULL);
|
||||||
|
|
||||||
|
//Change this to your own URL.
|
||||||
|
char *url = "http://devkitpro.org/misc/httpexample_rawimg.rgb";
|
||||||
|
|
||||||
|
printf("Downloading %s\n",url);
|
||||||
|
gfxFlushBuffers();
|
||||||
|
|
||||||
|
ret = httpcOpenContext(&context, url , 0);
|
||||||
|
printf("return from httpcOpenContext: %"PRId32"\n",ret);
|
||||||
|
gfxFlushBuffers();
|
||||||
|
|
||||||
if(ret==0)
|
if(ret==0)
|
||||||
{
|
{
|
||||||
ret=http_download(&context);
|
ret=http_download(&context);
|
||||||
|
printf("return from http_download: %"PRId32"\n",ret);
|
||||||
|
gfxFlushBuffers();
|
||||||
httpcCloseContext(&context);
|
httpcCloseContext(&context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,9 +108,6 @@ int main()
|
|||||||
// Exit services
|
// Exit services
|
||||||
httpcExit();
|
httpcExit();
|
||||||
gfxExit();
|
gfxExit();
|
||||||
hidExit();
|
|
||||||
aptExit();
|
|
||||||
srvExit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,11 +4,7 @@ int main()
|
|||||||
{
|
{
|
||||||
u32 val, i;
|
u32 val, i;
|
||||||
|
|
||||||
// Initialize services
|
gfxInitDefault();
|
||||||
srvInit();
|
|
||||||
aptInit();
|
|
||||||
hidInit(NULL);
|
|
||||||
gfxInit();
|
|
||||||
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
||||||
|
|
||||||
val = 0x22447899;
|
val = 0x22447899;
|
||||||
@ -42,9 +38,6 @@ int main()
|
|||||||
|
|
||||||
// Exit services
|
// Exit services
|
||||||
gfxExit();
|
gfxExit();
|
||||||
hidExit();
|
|
||||||
aptExit();
|
|
||||||
srvExit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,13 +106,7 @@ void draw_startup()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Initialize services
|
gfxInitDefault();
|
||||||
srvInit();
|
|
||||||
aptInit();
|
|
||||||
hidInit(NULL);
|
|
||||||
gfxInit();
|
|
||||||
fsInit();
|
|
||||||
sdmcInit();
|
|
||||||
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
||||||
|
|
||||||
memset(logstring, 0, 256);
|
memset(logstring, 0, 256);
|
||||||
@ -143,13 +137,7 @@ int main()
|
|||||||
if(inaddr)linearFree(inaddr);
|
if(inaddr)linearFree(inaddr);
|
||||||
if(outaddr)linearFree(outaddr);
|
if(outaddr)linearFree(outaddr);
|
||||||
|
|
||||||
// Exit services
|
|
||||||
sdmcExit();
|
|
||||||
fsExit();
|
|
||||||
gfxExit();
|
gfxExit();
|
||||||
hidExit();
|
|
||||||
aptExit();
|
|
||||||
srvExit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,11 +11,7 @@ int main()
|
|||||||
qtmHeadtrackingInfo qtminfo;
|
qtmHeadtrackingInfo qtminfo;
|
||||||
u32 colors[4] = {0x0000FF, 0x00FF00, 0xFF0000, 0xFFFFFF};
|
u32 colors[4] = {0x0000FF, 0x00FF00, 0xFF0000, 0xFFFFFF};
|
||||||
|
|
||||||
// Initialize services
|
gfxInitDefault();
|
||||||
srvInit();
|
|
||||||
aptInit();
|
|
||||||
hidInit(NULL);
|
|
||||||
gfxInit();
|
|
||||||
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
||||||
|
|
||||||
qtmInit();
|
qtmInit();
|
||||||
@ -84,9 +80,6 @@ int main()
|
|||||||
// Exit services
|
// Exit services
|
||||||
qtmExit();
|
qtmExit();
|
||||||
gfxExit();
|
gfxExit();
|
||||||
hidExit();
|
|
||||||
aptExit();
|
|
||||||
srvExit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ void renderEffect()
|
|||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
gfxInit(); //makes displaying to screen easier
|
gfxInitDefault(); //makes displaying to screen easier
|
||||||
|
|
||||||
FILE *file = fopen("test.bin","rb");
|
FILE *file = fopen("test.bin","rb");
|
||||||
if (file == NULL) goto exit;
|
if (file == NULL) goto exit;
|
||||||
|
7
examples/templates/Makefile
Normal file
7
examples/templates/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
|
||||||
|
all:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||||
|
clean:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
||||||
|
install:
|
||||||
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done;
|
@ -4,11 +4,7 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Initialize services
|
gfxInitDefault();
|
||||||
srvInit();
|
|
||||||
aptInit();
|
|
||||||
hidInit(NULL);
|
|
||||||
gfxInit();
|
|
||||||
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
@ -36,10 +32,6 @@ int main()
|
|||||||
gfxSwapBuffers();
|
gfxSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit services
|
|
||||||
gfxExit();
|
gfxExit();
|
||||||
hidExit();
|
|
||||||
aptExit();
|
|
||||||
srvExit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ endif
|
|||||||
include $(DEVKITARM)/base_rules
|
include $(DEVKITARM)/base_rules
|
||||||
|
|
||||||
export LIBCTRU_MAJOR := 0
|
export LIBCTRU_MAJOR := 0
|
||||||
export LIBCTRU_MINOR := 2
|
export LIBCTRU_MINOR := 3
|
||||||
export LIBCTRU_PATCH := 0
|
export LIBCTRU_PATCH := 0
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
@ -23,7 +23,7 @@ consoleInit()
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef bool(* ConsolePrint)(void* con, char c);
|
typedef bool(* ConsolePrint)(void* con, int c);
|
||||||
|
|
||||||
//! a font struct for the console.
|
//! a font struct for the console.
|
||||||
typedef struct ConsoleFont
|
typedef struct ConsoleFont
|
||||||
|
@ -19,7 +19,8 @@ typedef enum
|
|||||||
}gfx3dSide_t;
|
}gfx3dSide_t;
|
||||||
|
|
||||||
//system stuff
|
//system stuff
|
||||||
void gfxInit();
|
void gfxInitDefault();
|
||||||
|
void gfxInit(GSP_FramebufferFormats topFormat, GSP_FramebufferFormats bottomFormat, bool vrambuffers);
|
||||||
void gfxExit();
|
void gfxExit();
|
||||||
|
|
||||||
//control stuff
|
//control stuff
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <3ds/types.h>
|
||||||
|
|
||||||
#define CSND_SHAREDMEM_DEFAULT 0x10004000
|
#define CSND_SHAREDMEM_DEFAULT 0x10004000
|
||||||
|
|
||||||
typedef enum{
|
typedef enum{
|
||||||
@ -14,17 +16,25 @@ typedef enum{
|
|||||||
CSND_ENCODING_PSG//"3 = PSG, similar to DS?"
|
CSND_ENCODING_PSG//"3 = PSG, similar to DS?"
|
||||||
} CSND_ENCODING;
|
} CSND_ENCODING;
|
||||||
|
|
||||||
|
struct CSND_CHANNEL_STATUS {
|
||||||
|
u8 state;
|
||||||
|
u8 pad[3];
|
||||||
|
u32 unknown;
|
||||||
|
u32 position;
|
||||||
|
} ALIGN(4);
|
||||||
|
|
||||||
|
|
||||||
//See here regarding CSND shared-mem commands, etc: http://3dbrew.org/wiki/CSND_Shared_Memory
|
//See here regarding CSND shared-mem commands, etc: http://3dbrew.org/wiki/CSND_Shared_Memory
|
||||||
|
|
||||||
Result CSND_initialize(u32* sharedMem);
|
Result CSND_initialize(u32* sharedMem);
|
||||||
Result CSND_shutdown();
|
Result CSND_shutdown();
|
||||||
|
|
||||||
|
u32 CSND_convertsamplerate(u32 samplerate);
|
||||||
Result CSND_playsound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u32 *vaddr0, u32 *vaddr1, u32 totalbytesize, u32 unk0, u32 unk1);
|
Result CSND_playsound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u32 *vaddr0, u32 *vaddr1, u32 totalbytesize, u32 unk0, u32 unk1);
|
||||||
void CSND_setchannel_playbackstate(u32 channel, u32 value);
|
void CSND_setchannel_playbackstate(u32 channel, u32 value);
|
||||||
void CSND_sharedmemtype0_cmd0(u32 channel, u32 value);
|
void CSND_sharedmemtype0_cmd0(u32 channel, u32 value);
|
||||||
void CSND_writesharedmem_cmdtype0(u16 cmdid, u8 *cmdparams);
|
void CSND_writesharedmem_cmdtype0(u16 cmdid, u8 *cmdparams);
|
||||||
Result CSND_sharedmemtype0_cmdupdatestate(int waitdone);
|
Result CSND_sharedmemtype0_cmdupdatestate(int waitdone);
|
||||||
|
|
||||||
Result CSND_getchannelstate(u32 entryindex, u32 *out);
|
Result CSND_getchannelstate(u32 entryindex, struct CSND_CHANNEL_STATUS *out);
|
||||||
Result CSND_getchannelstate_isplaying(u32 entryindex, u8 *status);
|
Result CSND_getchannelstate_isplaying(u32 entryindex, u8 *status);
|
||||||
|
@ -42,3 +42,9 @@ typedef s32 Result;
|
|||||||
typedef void (*ThreadFunc)(u32);
|
typedef void (*ThreadFunc)(u32);
|
||||||
|
|
||||||
#define BIT(n) (1U<<(n))
|
#define BIT(n) (1U<<(n))
|
||||||
|
|
||||||
|
//! aligns a struct (and other types?) to m, making sure that the size of the struct is a multiple of m.
|
||||||
|
#define ALIGN(m) __attribute__((aligned (m)))
|
||||||
|
|
||||||
|
//! packs a struct (and other types?) so it won't include padding bytes.
|
||||||
|
#define PACKED __attribute__ ((packed))
|
||||||
|
@ -39,6 +39,7 @@ bool MemPool::Allocate(MemChunk& chunk, u32 size, int align)
|
|||||||
{
|
{
|
||||||
auto addr = b->base;
|
auto addr = b->base;
|
||||||
u32 begWaste = (u32)addr & alignM;
|
u32 begWaste = (u32)addr & alignM;
|
||||||
|
if (begWaste > 0) begWaste = alignM + 1 - begWaste;
|
||||||
addr += begWaste;
|
addr += begWaste;
|
||||||
u32 bSize = b->size - begWaste;
|
u32 bSize = b->size - begWaste;
|
||||||
if (bSize < size) continue;
|
if (bSize < size) continue;
|
||||||
|
@ -43,7 +43,7 @@ PrintConsole defaultConsole =
|
|||||||
{
|
{
|
||||||
(u8*)default_font_bin, //font gfx
|
(u8*)default_font_bin, //font gfx
|
||||||
0, //first ascii character in the set
|
0, //first ascii character in the set
|
||||||
128 //number of characters in the font set
|
256 //number of characters in the font set
|
||||||
},
|
},
|
||||||
(u16*)NULL,
|
(u16*)NULL,
|
||||||
0,0, //cursorX cursorY
|
0,0, //cursorX cursorY
|
||||||
@ -68,7 +68,7 @@ PrintConsole* currentConsole = ¤tCopy;
|
|||||||
|
|
||||||
PrintConsole* consoleGetDefault(void){return &defaultConsole;}
|
PrintConsole* consoleGetDefault(void){return &defaultConsole;}
|
||||||
|
|
||||||
void consolePrintChar(char c);
|
void consolePrintChar(int c);
|
||||||
void consoleDrawChar(int c);
|
void consoleDrawChar(int c);
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
@ -672,7 +672,7 @@ void consoleDrawChar(int c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
void consolePrintChar(char c) {
|
void consolePrintChar(int c) {
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
if (c==0) return;
|
if (c==0) return;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <3ds/gfx.h>
|
#include <3ds/gfx.h>
|
||||||
#include <3ds/svc.h>
|
#include <3ds/svc.h>
|
||||||
#include <3ds/linear.h>
|
#include <3ds/linear.h>
|
||||||
|
#include <3ds/vram.h>
|
||||||
|
|
||||||
GSP_FramebufferInfo topFramebufferInfo, bottomFramebufferInfo;
|
GSP_FramebufferInfo topFramebufferInfo, bottomFramebufferInfo;
|
||||||
|
|
||||||
@ -96,8 +97,23 @@ void gfxWriteFramebufferInfo(gfxScreen_t screen)
|
|||||||
framebufferInfoHeader[0x1]=1;
|
framebufferInfoHeader[0x1]=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxInit()
|
void (*screenFree)(void *) = NULL;
|
||||||
|
|
||||||
|
void gfxInit(GSP_FramebufferFormats topFormat, GSP_FramebufferFormats bottomFormat, bool vrambuffers)
|
||||||
{
|
{
|
||||||
|
void *(*screenAlloc)(size_t);
|
||||||
|
|
||||||
|
if (vrambuffers)
|
||||||
|
{
|
||||||
|
screenAlloc=vramAlloc;
|
||||||
|
screenFree=vramFree;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
screenAlloc=linearAlloc;
|
||||||
|
screenFree=linearFree;
|
||||||
|
}
|
||||||
|
|
||||||
gspInit();
|
gspInit();
|
||||||
|
|
||||||
gfxSharedMemory=(u8*)0x10002000;
|
gfxSharedMemory=(u8*)0x10002000;
|
||||||
@ -117,15 +133,22 @@ void gfxInit()
|
|||||||
// if 3d enabled :
|
// if 3d enabled :
|
||||||
// topright1 0x000FD200-0x00143700
|
// topright1 0x000FD200-0x00143700
|
||||||
// topright2 0x00143700-0x00189C00
|
// topright2 0x00143700-0x00189C00
|
||||||
|
u32 topSize = 400 * 240 * __get_bytes_per_pixel(topFormat);
|
||||||
|
u32 bottomSize = 320 * 240 * __get_bytes_per_pixel(bottomFormat);
|
||||||
|
|
||||||
|
gfxTopLeftFramebuffers[0]=screenAlloc(topSize);
|
||||||
|
gfxTopLeftFramebuffers[1]=screenAlloc(topSize);
|
||||||
|
gfxBottomFramebuffers[0]=screenAlloc(bottomSize);
|
||||||
|
gfxBottomFramebuffers[1]=screenAlloc(bottomSize);
|
||||||
|
gfxTopRightFramebuffers[0]=screenAlloc(topSize);
|
||||||
|
gfxTopRightFramebuffers[1]=screenAlloc(topSize);
|
||||||
|
|
||||||
gfxTopLeftFramebuffers[0]=linearAlloc(0x46500);
|
|
||||||
gfxTopLeftFramebuffers[1]=linearAlloc(0x46500);
|
|
||||||
gfxBottomFramebuffers[0]=linearAlloc(0x38400);
|
|
||||||
gfxBottomFramebuffers[1]=linearAlloc(0x38400);
|
|
||||||
gfxTopRightFramebuffers[0]=linearAlloc(0x46500);
|
|
||||||
gfxTopRightFramebuffers[1]=linearAlloc(0x46500);
|
|
||||||
enable3d=false;
|
enable3d=false;
|
||||||
|
|
||||||
|
//set requested modes
|
||||||
|
gfxSetScreenFormat(GFX_TOP,topFormat);
|
||||||
|
gfxSetScreenFormat(GFX_BOTTOM,bottomFormat);
|
||||||
|
|
||||||
//initialize framebuffer info structures
|
//initialize framebuffer info structures
|
||||||
gfxSetFramebufferInfo(GFX_TOP, 0);
|
gfxSetFramebufferInfo(GFX_TOP, 0);
|
||||||
gfxSetFramebufferInfo(GFX_BOTTOM, 0);
|
gfxSetFramebufferInfo(GFX_BOTTOM, 0);
|
||||||
@ -143,18 +166,24 @@ void gfxInit()
|
|||||||
GSPGPU_SetLcdForceBlack(NULL, 0x0);
|
GSPGPU_SetLcdForceBlack(NULL, 0x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gfxInitDefault() {
|
||||||
|
gfxInit(GSP_BGR8_OES,GSP_BGR8_OES,false);
|
||||||
|
}
|
||||||
|
|
||||||
void gfxExit()
|
void gfxExit()
|
||||||
{
|
{
|
||||||
|
if (screenFree == NULL ) return;
|
||||||
|
|
||||||
// Exit event handler
|
// Exit event handler
|
||||||
gspExitEventHandler();
|
gspExitEventHandler();
|
||||||
|
|
||||||
// Free framebuffers
|
// Free framebuffers
|
||||||
linearFree(gfxTopRightFramebuffers[1]);
|
screenFree(gfxTopRightFramebuffers[1]);
|
||||||
linearFree(gfxTopRightFramebuffers[0]);
|
screenFree(gfxTopRightFramebuffers[0]);
|
||||||
linearFree(gfxBottomFramebuffers[1]);
|
screenFree(gfxBottomFramebuffers[1]);
|
||||||
linearFree(gfxBottomFramebuffers[0]);
|
screenFree(gfxBottomFramebuffers[0]);
|
||||||
linearFree(gfxTopLeftFramebuffers[1]);
|
screenFree(gfxTopLeftFramebuffers[1]);
|
||||||
linearFree(gfxTopLeftFramebuffers[0]);
|
screenFree(gfxTopLeftFramebuffers[0]);
|
||||||
|
|
||||||
//unmap GSP shared mem
|
//unmap GSP shared mem
|
||||||
svcUnmapMemoryBlock(gspSharedMemHandle, 0x10002000);
|
svcUnmapMemoryBlock(gspSharedMemHandle, 0x10002000);
|
||||||
@ -167,6 +196,8 @@ void gfxExit()
|
|||||||
GSPGPU_ReleaseRight(NULL);
|
GSPGPU_ReleaseRight(NULL);
|
||||||
|
|
||||||
gspExit();
|
gspExit();
|
||||||
|
|
||||||
|
screenFree = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16* width, u16* height)
|
u8* gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16* width, u16* height)
|
||||||
@ -185,9 +216,12 @@ u8* gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16* width, u16* hei
|
|||||||
|
|
||||||
void gfxFlushBuffers()
|
void gfxFlushBuffers()
|
||||||
{
|
{
|
||||||
GSPGPU_FlushDataCache(NULL, gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x46500);
|
u32 topSize = 400 * 240 * __get_bytes_per_pixel(gfxGetScreenFormat(GFX_TOP));
|
||||||
if(enable3d)GSPGPU_FlushDataCache(NULL, gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), 0x46500);
|
u32 bottomSize = 320 * 240 * __get_bytes_per_pixel(gfxGetScreenFormat(GFX_BOTTOM));
|
||||||
GSPGPU_FlushDataCache(NULL, gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL), 0x38400);
|
|
||||||
|
GSPGPU_FlushDataCache(NULL, gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), topSize);
|
||||||
|
if(enable3d)GSPGPU_FlushDataCache(NULL, gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), topSize);
|
||||||
|
GSPGPU_FlushDataCache(NULL, gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL), bottomSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSwapBuffers()
|
void gfxSwapBuffers()
|
||||||
|
@ -301,14 +301,14 @@ Result CSND_playsound(u32 channel, u32 looping, u32 encoding, u32 samplerate, u3
|
|||||||
return CSND_sharedmemtype0_cmdupdatestate(0);
|
return CSND_sharedmemtype0_cmdupdatestate(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result CSND_getchannelstate(u32 entryindex, u32 *out)
|
Result CSND_getchannelstate(u32 entryindex, struct CSND_CHANNEL_STATUS *out)
|
||||||
{
|
{
|
||||||
Result ret=0;
|
Result ret=0;
|
||||||
|
|
||||||
if((ret = CSND_sharedmemtype0_cmdupdatestate(1))!=0)return ret;
|
if((ret = CSND_sharedmemtype0_cmdupdatestate(1))!=0)return ret;
|
||||||
|
|
||||||
memcpy(out, &CSND_sharedmem[(CSND_sharedmem_cmdblocksize+8 + entryindex*0xc) >> 2], 0xc);
|
memcpy(out, &CSND_sharedmem[(CSND_sharedmem_cmdblocksize+8 + entryindex*0xc) >> 2], 0xc);
|
||||||
out[2] -= 0x0c000000;
|
out->position -= 0x0c000000;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -316,12 +316,12 @@ Result CSND_getchannelstate(u32 entryindex, u32 *out)
|
|||||||
Result CSND_getchannelstate_isplaying(u32 entryindex, u8 *status)
|
Result CSND_getchannelstate_isplaying(u32 entryindex, u8 *status)
|
||||||
{
|
{
|
||||||
Result ret;
|
Result ret;
|
||||||
u32 entry[0xc>>2];
|
struct CSND_CHANNEL_STATUS entry;
|
||||||
|
|
||||||
ret = CSND_getchannelstate(entryindex, entry);
|
ret = CSND_getchannelstate(entryindex, &entry);
|
||||||
if(ret!=0)return ret;
|
if(ret!=0)return ret;
|
||||||
|
|
||||||
*status = entry[0] & 0xff;
|
*status = entry.state;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,6 @@ void __attribute__((weak)) __attribute__((noreturn)) __libctru_exit(int rc)
|
|||||||
{
|
{
|
||||||
u32 tmp=0;
|
u32 tmp=0;
|
||||||
|
|
||||||
// Run the global destructors
|
|
||||||
__libc_fini_array();
|
|
||||||
|
|
||||||
__appExit();
|
__appExit();
|
||||||
|
|
||||||
// Unmap the linear heap
|
// Unmap the linear heap
|
||||||
|
@ -12,9 +12,6 @@ void __system_allocateHeaps();
|
|||||||
void __system_initArgv();
|
void __system_initArgv();
|
||||||
void __appInit();
|
void __appInit();
|
||||||
|
|
||||||
// newlib definitions we need
|
|
||||||
void __libc_init_array(void);
|
|
||||||
|
|
||||||
|
|
||||||
void __ctru_exit(int rc);
|
void __ctru_exit(int rc);
|
||||||
|
|
||||||
@ -32,6 +29,4 @@ void __attribute__((weak)) __libctru_init(void (*retAddr)(void))
|
|||||||
|
|
||||||
__appInit();
|
__appInit();
|
||||||
|
|
||||||
// Run the global constructors
|
|
||||||
__libc_init_array();
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ initSystem:
|
|||||||
bics sp, sp, #7
|
bics sp, sp, #7
|
||||||
str sp, [r2]
|
str sp, [r2]
|
||||||
|
|
||||||
|
bl __libc_init_array
|
||||||
|
|
||||||
ldr r2, =saved_stack
|
ldr r2, =saved_stack
|
||||||
ldr lr, [r2,#4]
|
ldr lr, [r2,#4]
|
||||||
bx lr
|
bx lr
|
||||||
@ -31,6 +33,8 @@ initSystem:
|
|||||||
.type __ctru_exit, %function
|
.type __ctru_exit, %function
|
||||||
|
|
||||||
__ctru_exit:
|
__ctru_exit:
|
||||||
|
bl __libc_fini_array
|
||||||
|
|
||||||
ldr r2, =saved_stack
|
ldr r2, =saved_stack
|
||||||
ldr sp, [r2]
|
ldr sp, [r2]
|
||||||
b __libctru_exit
|
b __libctru_exit
|
||||||
|
Loading…
Reference in New Issue
Block a user