Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,474,966
  • Replies Replies 6,048
  • Likes Likes 54
So I am quite confused. I'm trying to show text when I touch a certain area of the touch screen. Well, two problems:
1. The text is already showing when I start the program
2. When I touch the area I have specified, it doesn't do anything (Probably because the text is already showing) and when I touch the area that shouldn't display the text, it removes the text.

So really, now thinking about it, I just need to find a way to not show the text when the program loads?

Here's the code (the part you need at least):
Code:
void BottomScreen(){
    screenBottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);
    clearScreen(screenBottom, GFX_BOTTOM);
    
    drawFillRect(0, 0, 30, 240, 255, 255, 255, screenBottom);
    
    BottomText("Love me?  I do.", 120, 100, 0, 0, 255);
    BottomText("Woosh!", 20, 10, 255, 255, 255);
    Notes();
};

void Notes(){
    touchPosition myTouchPosition;
    hidTouchRead(&myTouchPosition);
    u16 posX = myTouchPosition.px;
    u16 posY = myTouchPosition.py;
    if((posX >= 0 && posX <= 30) && (posY >= 0 && posY <= 240)){
        BottomText("Hehe, that tickles!", 100, 100, 255, 255, 255);
    };
};
Why is there a semicolon(;) after the touch area "if"? I mean:

If(something)
{

};

This is wrong, the semicolon ";" isn't needed.
 
  • Like
Reactions: filfat
I'm used to putting semi colons at the end of if statements, functions and such in general. And it may not be needed, but it isn't wrong to have it.

I did remove it just to see if it did anything and I still have the same problem.
 
I'm used to putting semi colons at the end of if statements, functions and such in general. And it may not be needed, but it isn't wrong to have it.

I did remove it just to see if it did anything and I still have the same problem.
You can remove the line "clearScreen(screenBottom, GFX_BOTTOM);" it just paints the screen with black, is rather useless(unless you ofc want to make the screen black at some occasion).

You also have a ';' after every function
Remove them ;)
 
I'm used to putting semi colons at the end of if statements, functions and such in general. And it may not be needed, but it isn't wrong to have it.

I did remove it just to see if it did anything and I still have the same problem.
Cleaned up code:
Code:
void BottomScreen(){
    screenBottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);
   
    drawFillRect(0, 0, 30, 240, 255, 255, 255, screenBottom);
   
    BottomText("Love me?  I do.", 120, 100, 0, 0, 255);
    BottomText("Woosh!", 20, 10, 255, 255, 255);
    Notes();
}
 
void Notes(){
    touchPosition myTouchPosition;
    hidTouchRead(&myTouchPosition);
    u16 posX = myTouchPosition.px;
    u16 posY = myTouchPosition.py;
    if((posX >= 0 && posX <= 30) && (posY >= 0 && posY <= 240)){
        BottomText("Hehe, that tickles!", 100, 100, 0, 0, 0);
    }
}

Try that code (have'nt tested it myself)
 
I'm used to putting semi colons at the end of if statements, functions and such in general. And it may not be needed, but it isn't wrong to have it.

I did remove it just to see if it did anything and I still have the same problem.
posX and posY are 0 by default. When you boot the homebrew, you are probably not tapping on the touchscreen, so it gets posX = 0 and posY =0. Your code shows the code when posX is >= 0 && posY>=0, so it shows the text at boot. I suggest you to use posX>0 and posY>0, so the default x and y cords will stay outside the touch area...
 
posX and posY are 0 by default. When you boot the homebrew, you are probably not tapping on the touchscreen, so it gets posX = 0 and posY =0. Your code shows the code when posX is >= 0 && posY>=0, so it shows the text at boot. I suggest you to use posX>0 and posY>0, so the default x and y cords will stay outside the touch area...
And that just makes sense. Thank you, kind sir. I honestly can't believe I didn't realize that one.

Now, I do have another question: How is music loaded and played on the 3DS?

I've been looking at others codes trying to figure out how it works, but I just can't seem to put two and two together. I do know it deals with the CSND functions, but I'm not seeing much documented on it. That's really the last step to what I need.
 
And that just makes sense. Thank you, kind sir. I honestly can't believe I didn't realize that one.

Now, I do have another question: How is music loaded and played on the 3DS?

I've been looking at others codes trying to figure out how it works, but I just can't seem to put two and two together. I do know it deals with the CSND functions, but I'm not seeing much documented on it. That's really the last step to what I need.
Music playing would be interesting, but it seems that none still implemented it, as far as i know. Maybe the mic recording homebrew example (located in examples folder inside ctrulib repo) could be a good entrypoint, since it has recorded audio playback.
 
I did think of that. I am afraid to use it though because when I compiled just the example it crashed once I tried to record something. I'll take another look at it though.

I was also thinking I could try to use other libraries such as SFML. I would still need to figure out how the 3DS plays it though.
 
  • Like
Reactions: AlbertoSONIC
I did think of that. I am afraid to use it though because when I compiled just the example it crashed once I tried to record something. I'll take another look at it though.

I was also thinking I could try to use other libraries such as SFML. I would still need to figure out how the 3DS plays it though.
Could someone confirm me that at the moment there isn't any homebrew that supports audio playback? smea
 
Alright so we have audio access. Do you know an homebrew that uses audio playback? (Excluding emulators)
I'm afraid I don't know offhand unless one of smea's bundled ninjhax demos has it implemented. I know that the updated CTRulib that added sound support was supposed to drop alongside ninjhax.

But I'd say Cyan might know being the keeper of the wiki.
 
Could someone confirm me that at the moment there isn't any homebrew that supports audio playback? smea
Of the things I've tried, which isn't much so far, blargSNES has sound, and my own HCGE does also, both running under Ninjhax. Accounting for posts that came up while I was writing this, Ninjhax only lacks sound on New 3DS; it's fine on the regular 3DS

As you mentioned in an earlier post, I based my code on the mic example

From what I can tell, blargSNES only has mono sound, no stereo, and since I couldn't find any information on panning or multiple output channels on a single mixing channel, nor could I accomplish anything with the two "unknown" parameters to CSND_playsound, HCGE also uses mono sound. If there is a method for outputting separate left/right on a single mix channel, or panning a mix channel entirely left or right, I'd certainly like to know about it :P

I've also come across an issue that I think relates to a question someone else asked earlier in this thread too - it seems that using CSND_LOOP_ENABLE doesn't actually work. At least, when I tried using it at startup and later manipulating the buffer it used, I was getting no sound output

Because I couldn't find any information on a callback function that triggers when the buffer is empty, or a way to determine the playback position of the buffer, and because CSND_LOOP_ENABLE didn't seem to work for me, what I ended up having to do was, given that I use VSYNC to lock HCGE to a 60fps rate, on every frame - Try to fill the audio buffer with enough data to account for 1/60th of a second, and make a new call to CSND_playsound with CSND_LOOP_DISABLE. The result isn't fantastic (it's slightly jittery and there's noticeable crackling), but it does provide continuous sound output

If you don't need to do your own sound mixing via software like I do, though, you'd probably get better results just feeding individual sounds to individual hardware channels by calling CSND_playsound with a different channel any time you needed to play a sound effect or start your music. However, your sound data would have to be loaded uncompressed in its entirety into a buffer, and the format would have to correspond with whichever setting you used for CSND_playsound. Also, for looping music, you'd probably have to use the playback length in time to set up a timer and make another CSND_playsound call to start it over, unless you happen to get CSND_LOOP_ENABLE to work. This, of course, probably wouldn't have a seamless repeat

As for actually loading the sound, you'd just create a regular array in RAM and fill it with the sound data you want to play

While I'm posting, though, I'd like to pose some questions directly -

Does CSND_LOOP_ENABLE actually ever work, and are there some known specific scenarios in which it wouldn't that someone can explain?

Is there a known way to pan a hardware channel to the left or right, or to cause a single hardware channel to send different output to the left and right? If so, how is that done?

Is there a way to receive a signal when CSND_playsound is finished and respond to it immediately, or, is there a way to determine the playback position within the data after a CSND_playsound call is made? If so, how?

Is it possible at this point to use svcCreateThread to offload software sound mixing to the other processor core, and could someone explain its usage?
 
I didn't test them all yet. I mainly tried to list existing projects as a start, I'll create their page and test them little by little.
The only homebrew I tested with sound is currently BlargSnes.

CTR Streaming Server has sound, But I don't know how to compile it (it require lot of libraries).
you might check yellows8's project. https://github.com/yellows8/ctr-streaming-server
I think it might be the only "non emulator" homebrew with sound.
edit: HCGE has sound too, check my previous post, and LUA interpreter too.


I have a game project too, I hope I will be able to add sound.
I haven't started it yet, I'm trying to learn about GPU and GFX functions.
 
  • Like
Reactions: AlbertoSONIC
CTR Streaming Server has sound, But I don't know how to compile it (it require lot of libraries).
you might check yellows8's project. https://github.com/yellows8/ctr-streaming-server
I think it might be the only "non emulator" homebrew with sound.
You probably haven't gotten around to it yet, but I wouldn't call HCGE an emulator. Just wanted to make mention in the hope that my last post doesn't get overlooked as the very last post on page 144, since I also talked about using CSND and asked some questions I'd like answered :P
 
  • Like
Reactions: AlbertoSONIC

Site & Scene News

Popular threads in this forum