I know C is possible, I'm talking about mp3, mp4, etc., and if we can use those formats in homebrew.Yes, homebrew is possible with C.
I know C is possible, I'm talking about mp3, mp4, etc., and if we can use those formats in homebrew.Yes, homebrew is possible with C.
Yes, you just have to find a library suitable to what you need.I know C is possible, I'm talking about mp3, mp4, etc., and if we can use those formats in homebrew.
There is the mvd service for the n3ds, but if you are asking is there a play mp3 api you can call in libctru or other 3ds provided api, then the answer is no. Libctru does provide apis to access the frame buffer and play audio samples. So you just need to either decode the files yourself or find an existing library that does this. You will then need to provide the "glue" to take the decoded information and put it in the format the 3ds requires and then display/play it.I know C is possible, I'm talking about mp3, mp4, etc., and if we can use those formats in homebrew.
#include <3ds.h>
#include <citro3d.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "ui_main.h"
#include "ctr_vid.h"
#include "ctr_util.h"
#include "font.h"
#define FontWidth 8
#define FontHeight 16
#define CharsPerLine ( 320 / FontWidth )
#define LinesPerScreen ( 240 / FontHeight )
#define MaxCharsToDraw ( CharsPerLine * LinesPerScreen )
struct {
float Left;
float Top;
float Bottom;
float Right;
struct Vertex Verticies[ 6 ];
} GlyphInfo[ 256 ];
static C3D_Tex Font_Tex;
static struct Vertex* VBOData = NULL;
static rgba32_t* Font_Data = NULL;
static int VertexCount = 0;
static int VBOIndex = 0;
void Font_Begin( void ) {
C3D_TexEnv* Env = C3D_GetTexEnv( 0 );
/*
* Courtesy of the system font example.
* I still don't really totally understand this yet.
*/
C3D_TexEnvSrc( Env, C3D_RGB, GPU_PRIMARY_COLOR, 0, 0) ;
C3D_TexEnvSrc( Env, C3D_Alpha, GPU_TEXTURE0, GPU_PRIMARY_COLOR, 0 );
C3D_TexEnvOp( Env, C3D_Both, 0, 0, 0 );
C3D_TexEnvFunc( Env, C3D_RGB, GPU_REPLACE );
C3D_TexEnvFunc( Env, C3D_Alpha, GPU_MODULATE );
VertexCount = 0;
VBOIndex = 0;
}
void Font_AddText( float X, float Y, const char* Text, float R, float G, float B, float A ) {
struct Vertex* Ptr = NULL;
int Len = 0;
int i = 0;
int v = 0;
int c = 0;
Ptr = &VBOData[ VBOIndex ];
Len = strlen( Text );
if ( Len ) {
for ( i = 0; i < Len; i++, X+= 8 ) {
for ( v = 0; v < 6; v++ ) {
c = Text[ i ];
memcpy( Ptr, &GlyphInfo[ c ].Verticies[ v ], sizeof( struct Vertex ) );
Ptr->Position[ 0 ] = GlyphInfo[ c ].Verticies[ v ].Position[ 0 ] + X;
Ptr->Position[ 1 ] = GlyphInfo[ c ].Verticies[ v ].Position[ 1 ] + Y;
Ptr->Color[ 0 ] = R;
Ptr->Color[ 1 ] = G;
Ptr->Color[ 2 ] = B;
Ptr->Color[ 3 ] = A;
Ptr++;
}
}
VertexCount+= ( Len * 6 );
VBOIndex+= ( Len * 6 );
}
}
void Font_End( void ) {
C3D_TexBind( 0, &Font_Tex );
C3D_DrawArrays( GPU_TRIANGLES, 0, VertexCount );
}
int Font_Init( void ) {
C3D_BufInfo* BufInfo = NULL;
float x = 0.0f;
float y = 0.0f;
int i = 0;
printf( "Font_Init\n" );
C3D_TexInit( &Font_Tex, 128, 256, GPU_RGBA8 );
Font_Data = LoadImageToPx2_32( "3ds/vmac/gfx/ui_font4.png", 128, 256 );
if ( Font_Data != NULL ) {
UI_UploadTexture32( Font_Data, &Font_Tex, 128, 256 );
printf( "Texture uploaded\n" );
for ( i = 0; i < 256; i++ ) {
x = ( i % 16 ) / 16.0f;
y = ( i / 16 ) / 16.0f;
GlyphInfo[ i ].Left = x;
GlyphInfo[ i ].Top = y;
GlyphInfo[ i ].Right = x + ( 1.0f / 16.0f );
GlyphInfo[ i ].Bottom = y + ( 1.0f / 16.0f );
// Top left, 1st triangle
GlyphInfo[ i ].Verticies[ 0 ].Position[ 0 ] = 0;
GlyphInfo[ i ].Verticies[ 0 ].Position[ 1 ] = 0;
GlyphInfo[ i ].Verticies[ 0 ].Position[ 2 ] = 0.5f;
GlyphInfo[ i ].Verticies[ 0 ].Texcoord[ 0 ] = x;
GlyphInfo[ i ].Verticies[ 0 ].Texcoord[ 1 ] = y;
// Bottom right, 1st triangle
GlyphInfo[ i ].Verticies[ 1 ].Position[ 0 ] = 8;
GlyphInfo[ i ].Verticies[ 1 ].Position[ 1 ] = 16;
GlyphInfo[ i ].Verticies[ 1 ].Position[ 2 ] = 0.5f;
GlyphInfo[ i ].Verticies[ 1 ].Texcoord[ 0 ] = x + ( 1.0f / 16.0f );
GlyphInfo[ i ].Verticies[ 1 ].Texcoord[ 1 ] = y + ( 1.0f / 16.0f );
// Top right, 1st triangle
GlyphInfo[ i ].Verticies[ 2 ].Position[ 0 ] = 8;
GlyphInfo[ i ].Verticies[ 2 ].Position[ 1 ] = 0;
GlyphInfo[ i ].Verticies[ 2 ].Position[ 2 ] = 0.5f;
GlyphInfo[ i ].Verticies[ 2 ].Texcoord[ 0 ] = x + ( 1.0f / 16.0f );
GlyphInfo[ i ].Verticies[ 2 ].Texcoord[ 1 ] = y;
// Top left, 2nd triangle
GlyphInfo[ i ].Verticies[ 3 ].Position[ 0 ] = 0;
GlyphInfo[ i ].Verticies[ 3 ].Position[ 1 ] = 0;
GlyphInfo[ i ].Verticies[ 3 ].Position[ 2 ] = 0.5f;
GlyphInfo[ i ].Verticies[ 3 ].Texcoord[ 0 ] = x;
GlyphInfo[ i ].Verticies[ 3 ].Texcoord[ 1 ] = y;
// Bottom left, 2nd triangle
GlyphInfo[ i ].Verticies[ 4 ].Position[ 0 ] = 0;
GlyphInfo[ i ].Verticies[ 4 ].Position[ 1 ] = 16;
GlyphInfo[ i ].Verticies[ 4 ].Position[ 2 ] = 0.5f;
GlyphInfo[ i ].Verticies[ 4 ].Texcoord[ 0 ] = x;
GlyphInfo[ i ].Verticies[ 4 ].Texcoord[ 1 ] = y + ( 1.0f / 16.0f );
// Bottom right, 2nd triangle
GlyphInfo[ i ].Verticies[ 5 ].Position[ 0 ] = 8;
GlyphInfo[ i ].Verticies[ 5 ].Position[ 1 ] = 16;
GlyphInfo[ i ].Verticies[ 5 ].Position[ 2 ] = 0.5f;
GlyphInfo[ i ].Verticies[ 5 ].Texcoord[ 0 ] = x + ( 1.0f / 16.0f );
GlyphInfo[ i ].Verticies[ 5 ].Texcoord[ 1 ] = y + ( 1.0f / 16.0f );
}
VBOData = ( struct Vertex* ) linearAlloc( sizeof( struct Vertex ) * 6 * MaxCharsToDraw );
if ( VBOData ) {
BufInfo = C3D_GetBufInfo( );
if ( BufInfo ) {
BufInfo_Init( BufInfo );
BufInfo_Add( BufInfo, VBOData, sizeof( struct Vertex ), 3, 0x210 );
printf( "VBO Created\n" );
return 1;
}
}
}
Font_Close( );
return 0;
}
void Font_Close( void ) {
C3D_TexDelete( &Font_Tex );
if ( Font_Data )
linearFree( Font_Data );
if ( VBOData )
linearFree( VBOData );
Font_Data = NULL;
VBOData = NULL;
}
Will I have to port one?Yes, you just have to find a library suitable to what you need.
No. But like elhobbs said, most libraries only decode the file and the actual playback portion will have to be written by you.Will I have to port one?
Sounds like libjpeg isn't installed or it isn't being detected?
Do you have a portlibs directory in your devkitpro directory?
I thought devkitpro came with libjpeg already installed but you might have to install it yourself:
http://devkitpro.org/wiki/portlibs#libjpeg
Ah, I'll try that.
EDIT: Sorry if I'm asking a noob question here, but how would one go about installing these? The instructions on the website are a little vague.
After you run make, run "make install" and everything should go in the proper folders.
Ah, I'll try that.
EDIT: Sorry if I'm asking a noob question here, but how would one go about installing these? The instructions on the website are a little vague.
Do you mean to use ctrulib's ndsp.h/dsp.h/csnd.h when you want me to make the playback myself, and does the library have to be Linux and Open source? (Yes I know csnd.h is outdated)No. But like elhobbs said, most libraries only decode the file and the actual playback portion will have to be written by you.
Yes, you will need to use ctrulib to get the actual physical output, and the library does need to be open source since I don't really think you will be able to find a closed source library that will be compatible with the architecture and compiler.Do you mean to use ctrulib's ndsp.h/dsp.h/csnd.h when you want me to make the playback myself, and does the library have to be Linux and Open source? (Yes I know csnd.h is outdated)
I assume you are on Windows? You will need MSYS or equivalent in order to run the configure script.
Once you have that use the command given in that wiki to get a Makefile.
then its all of a matter of running the commands TarableCode mentioned.
I don't see why they didn't include precompiled versions of those libraries somewhere (I at least don't seem to have them in my devkitPro installation).
/usr/bin/ld: skipping incompatible ./libbz2.a when searching for -lbz2
/usr/bin/ld: cannot find -lbz2
collect2: error: ld returned 1 exit status
/opt/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/5.3.0/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000008020
Well, I have a Windows desktop and a Ubuntu laptop. I'd like to develop on both, though one would suffice.
Also, an issue installing (on my Ubuntu laptop). zlib builds just fine, I just can't get the other libs to compile.
For example, libjpeg-turbo won't compile. I run "make libjpeg-turbo", then "sudo make install", but the terminal spits out this line:
I also get warnings when compiling, like this:
Not sure if this is related, but I also have two devkitPro folders on my laptop. Probably because I ran the install script twice. Would deleting one alleviate the problem, just out of curiosity.
You will need to point it at the libbz2.a you compiled for the 3ds there should be a flag you can pass to configure to do this.
How would I compile libbz2.a, and would I pass this flag to configure it to do so?
They are two separate memory address spaces. The main difference is that linear can be accessed by hardware and "normal" cannot. Linear can be used for csnd and dsp playback buffers as well as GPU texture, vertex, and index buffers. If the "normal" or main heap is used for these buffers then it will cause garbage to play for sound or cause the gpu to hang the system requiring a full shutdown to resolve the issue.Can someone please say me what the difference between normal and linear heap is?