Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,474,975
  • Replies Replies 6,048
  • Likes Likes 54
yeah you posted it while I was answering.
I didn't add HCGE to wiki yet (I didn't know it and didn't know what it was, I'm reading your thread and looking at the videos).


Edit:
it looks powerful seeing what you can do with it.
You probably spent a lot of time on it and on creating game's levels.
 
I also recently added WAV support to my LUA interpreter (and video support with sound).
If you want to check the code, you can find WAV code here: https://github.com/Rinnegatamante/lpp-3ds/blob/master/source/luaSound.cpp
and video (BMPV format) here: https://github.com/Rinnegatamante/lpp-3ds/blob/master/source/luaVideo.cpp

P.S. More info about BMPV format can be found here: https://github.com/Rinnegatamante/lpp-3ds/tree/master/BMPV
and a little result sample here:

:P

Is there anyway I can do playWav or any of the other functions in a .c file? I'm sorry, even after looking at the whole thing I still am quite confused on how to run audio.

I was trying to copy and paste what I thought I needed. Tried to edit the luaSound code to work and I always got errors. Frustrating. :P
 
Will smealum release the ninjhax source code now that Ninty has blocked it?

nope, not yet. for one thing it's still far from completely blocked, and for another i never said i'd release the code. i mentioned i'd like to (and i still would), but not until it's essentially completely irrelevant, meaning in my mind not for another 6 months or even a year at least.

(for what it's worth you're not missing much, people who've seen it can attest that the code is a complete mess)
 
nope, not yet. for one thing it's still far from completely blocked, and for another i never said i'd release the code. i mentioned i'd like to (and i still would), but not until it's essentially completely irrelevant, meaning in my mind not for another 6 months or even a year at least.

(for what it's worth you're not missing much, people who've seen it can attest that the code is a complete mess)
Clean your room Calvin.

But thanks so much for CTRulib
 
who cares ?

apparently calebw does. it might not be as useful anymore but i do think the way we broke into the system is interesting, and i'm sure a few others would agree.


I know I personally would like to see how it's done, or at least have a blog post or some write up explaining it.

i do have a write up ready, but again waiting to release it.
 
I noticed that the normal heap is set to 24MB in size and the linear heap is set to 32MB, yet according to 3dbrew, there should be 64MB total accessible. Where does the remaining 8MB go? Also, is it at all possible to adjust these limits? (e.g. take 8MB from the normal heap and give it to the linear heap)

http://3dbrew.org/wiki/Ninjhax
 
I know I personally would like to see how it's done, or at least have a blog post or some write up explaining it.
I noticed that the normal heap is set to 24MB in size and the linear heap is set to 32MB, yet according to 3dbrew, there should be 64MB total accessible. Where does the remaining 8MB go? Also, is it at all possible to adjust these limits? (e.g. take 8MB from the normal heap and give it to the linear heap)

http://3dbrew.org/wiki/Ninjhax


everything else is allocated to .text, rodata, data and bss atm. this will be improved in a new version of ninjhax coming soon.
 
Is there anyway I can do playWav or any of the other functions in a .c file? I'm sorry, even after looking at the whole thing I still am quite confused on how to run audio.

I was trying to copy and paste what I thought I needed. Tried to edit the luaSound code to work and I always got errors. Frustrating. :P

What's the error you get?
Without the concept of LUA stack, open a WAV is a lot more simplier. You must do a thing like this in your main:


Code:
int main(){
const char *file_tbo = "/my_wav_file.wav"
Handle fileHandle;

//Open wav file
FS_archive sdmcArchive=(FS_archive){ARCH_SDMC, (FS_path){PATH_EMPTY, 1, (u8*)""}};
FS_path filePath=FS_makePath(PATH_CHAR, file_tbo);
Result ret=FSUSER_OpenFileDirectly(NULL, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_NONE);
u32 magic,samplerate,bytesRead,jump,chunk=0x00000000;
FSFILE_Read(fileHandle, &bytesRead, 0, &magic, 4);
if (magic == 0x46464952){
u64 size;
u32 pos = 16;
while (chunk != 0x61746164){
FSFILE_Read(fileHandle, &bytesRead, pos, &jump, 4);
pos=pos+jump;
FSFILE_Read(fileHandle, &bytesRead, pos, &chunk, 4);
pos=pos+4;
}
FSFILE_GetSize(fileHandle, &size);
u8* audiobuf = (u8*)linearAlloc(size-(pos+4));
FSFILE_Read(fileHandle, &bytesRead, 24, &samplerate, 4);
FSFILE_Read(fileHandle, &bytesRead, pos+4, audiobuf, size-(pos+4));
}
FSFILE_Close(fileHandle);
svcCloseHandle(fileHandle);

//Start wav file
CSND_initialize(NULL);
CSND_playsound(0x08, CSND_LOOP_DISABLE, CSND_ENCODING_PCM16, samplerate, (u32*)audiobuf, NULL, size-(pos+4), 2, 0);
}

And you must free audiobuffer and close CSND at the hb end.
Code:
linearFree(audiobuf);
CSND_shutdown();

Note that my openWav function reads correctly only mono wav files (actually).
 
  • Like
Reactions: Agent Moose
And don't forget to check for success when initializing CSND. If you try to call any CSND-related functions while it didn't init properly (for example when running on Gateway where you don't have permission to use CSND), you will crash and burn.
 
And what about if i wanted to include some sounds inside the homebrew.3dsx?
Convert it into a WAV mono file, open with an hex editor the file and go to data chunk (check the magic "data" in ASCII), take this offset and sum it 0x08 (offset of data + 0x08).
From this offset, take the rest of the file. This will be your audio buffer so convert it into a bin and load it as a buffer. (From WAV header you can also take the samplerate to pass to playsound function. (This is what lua_openwav does).
 
Guys, I'm having a very dumb problem. I'm trying to write a drawPixel function that accepts a framebuffer, x, y coordinates, and r, g, b values.

Code:
/*
* gfxDrawPixel
* Draws a pixel on a screen, using correct coordinates
* @param fb: framebuffer
* @param x: pixel's X coordinate
* @param y: pixel's Y coordinate
* @param r: red (0-255)
* @param g: green (0-255)
* @param b: blue (0-255)
*/
void gfxDrawPixel(u8* fb, s16 x, s16 y, u8 r, u8 g, u8 b){
  u16 index = 3 * (y * 240 + x);        // pixel index in the framebuffer
  fb[index] = b;                        // blue
  fb[index + 1] = g;                    // green
  fb[index + 2] = r;                    // red
}

but strangely when I try to draw a pixel at coordinates 100:100, it gets displayed at 100:10, and I have no idea why.

Code:
u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memset(fb, 0, 240*400*3);
gfxDrawPixel(fb, 100, 100, 255, 255, 255);

If I remove the function call and just let the sample code (of ctrulib), it works

Code:
u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memset(fb, 0, 240*400*3);
fb[3*(100+100*240)] = 0xFF;
fb[3*(100+100*240)+1] = 0xFF;
fb[3*(100+100*240)+2] = 0xFF;

I've been stuck on this for hours, do you have an idea to explain this behavior?

Thanks!


EDIT: I tried this in my main loop, without using a function, and it fails too (it draws 3 coloured pixels but not at the right place):

Code:
u16 pos = 3*(100+100*240);
fb[pos] = 0xFF;
fb[pos+1] = 0xFF;
fb[pos+2] = 0xFF;

Damn, what am I doing wrong?
 
Damn, what am I doing wrong?

Try this way ...

Code:
void paintPixel(u8* dest, u16 x, u16 y, u8 r, u8 g, u8 b) {
    dest[3*(240-y+x*240)+2] = r; //red
    dest[3*(240-y+x*240)+1] = g; //green
    dest[3*(240-y+x*240)] = b; //blue
}
 

Site & Scene News

Popular threads in this forum