Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,475,926
  • Replies Replies 6,048
  • Likes Likes 54
I started a C++ framework and library for homebrew 3DS games. It's very barebones now and I'm probably not even going to complete portions of it until smealum makes more stuff public so I can utilize his lib and have better access to the hardware. For instance, I have the layout coded for a flexible input event dispatcher, but for best effect it likely requires threading which I can't achieve at the moment.

A basic example of what code will look like when using the framework can be seen here:
https://github.com/Cruel/cpp3ds/blob/master/examples/gateway/src/gateway.cpp

I'll add some more examples over this next week on my off days. Working on a Scene class at the moment to encapsulate the general game flow so you can easily duplicate it for different parts of games, like a intro screen, pause menu, game levels, etc. With that and a more developed Input class, it should be legitimately useful lol.
 
You should change the SD Card Read Delay Multplier from 13 to 35.
Never Call SDCard Init, only Controller Init.
Force set SDHC in the sdmmc file.

Changed the multiplier and forced SDHC flag to 1. SDCard Init was never called in you code.

But still I can't make it work. Mouting the DS with pf_mount returns always error 7 (No Filesystem).
 
Here is a Breakout game I created, nothing fancy, about as simple as one can get.

Left/Right and Y/A move the Paddle.
X pauses the game.


The sources are here: https://github.com/CalebDW/Breakout3DS, they're not in the best shape though-- it's my first attempt at programming.
 

Attachments

I don't have access to a camera right now, so if someone would like to post a pic please do.

DSC_0815.jpg

enjoy
 
  • Like
Reactions: Huntereb
Hello everyone.
I've been looking through source code of all homebrew posted here (with exception of Yeti3DS) and I can't help but notice that there is one difference that doesn't make sense.
When reading input, all 3 of them use the exact same function, read_word(HID). I checked, the code is the same and the HID address is the same. But what I don't get is, Pong3D reads the input like this:
if (button & BUTTON_DOWN)
While Breakout and Tetris do it like this:
if(!(button_press & BUTTON_X))

In both cases, the button code used is the button that is supposed to be pressed, then how come both of them work, when one is basically 'if pressed' and the other is 'if not pressed'?
 
Hello everyone.
I've been looking through source code of all homebrew posted here (with exception of Yeti3DS) and I can't help but notice that there is one difference that doesn't make sense.
When reading input, all 3 of them use the exact same function, read_word(HID). I checked, the code is the same and the HID address is the same. But what I don't get is, Pong3D reads the input like this:
if (button & BUTTON_DOWN)
While Breakout and Tetris do it like this:
if(!(button_press & BUTTON_X))

In both cases, the button code used is the button that is supposed to be pressed, then how come both of them work, when one is basically 'if pressed' and the other is 'if not pressed'?


Its checking for different flanks
 
Different flanks? I mean, it's not like the games check it both with and without !, it's that one game only uses ! and other doesn't at all, that's why I'm confused.

I didnt read the code so i might be wrong but breakout and tetris probably have a mechanism to check if a button was pressed instead of only checking if a button is down.
Probably comparing the Values of HID with its value from the last loop :)
 
Different flanks? I mean, it's not like the games check it both with and without !, it's that one game only uses ! and other doesn't at all, that's why I'm confused.
The input register (HID) is inverted bitwise.
ex. 11101111 -- the fifth bit from the right '0' is the button being pressed. If you simply go, (button & BUTTON_SOMETHING) you will get an input reported for every button except the one you want. Probably not what you want. :p

you can 'fix it' two ways -- they are opposite, but accomplish the same thing:

button= read_word(HID);
if( !(button & BUTTON_A) )fire();

or my way:

button= ~read_word(HID);
if( button & BUTTON_A )fire();

I think my way is probably a little better since you don't have to have a NOT operator (! or ~) for each input check.
 
The input register (HID) is inverted bitwise.
ex. 11101111 -- the fifth bit from the right '0' is the button being pressed. If you simply go, (button & BUTTON_SOMETHING) you will get an input reported for every button except the one you want. Probably not what you want. :p

you can 'fix it' two ways -- they are opposite, but accomplish the same thing:

button= read_word(HID);
if( !(button & BUTTON_A) )fire();

or my way:

button= ~read_word(HID);
if( button & BUTTON_A )fire();

I think my way is probably a little better since you don't have to have a NOT operator (! or ~) for each input check.


I did think that the register is inverted, which would make sense, but in the Pong3D, there is no ~ before read_word, that's why I was confused.
Anywho, thank you for confirming the invertness.
 
I did think that the register is inverted, which would make sense, but in the Pong3D, there is no ~ before read_word, that's why I was confused.
Anywho, thank you for confirming the invertness.
That's true, I forgot that I did it that way at first. :P Afterwards I used the better method, and I've since updated Pong's source code to use it.
 
Me not yet. I scanned some parts of IO register memory, but at the moment I found only the 3D slider state register at 0x1014470C.

Still trying to figure out what are the other non zero values i found, in the hope to be able to swap framebuffers.

In the range I scanned (0x1012DFA0 - 0x10146BD6) nothing has values changing upon CPAD or touchscreen state.
 

Site & Scene News

Popular threads in this forum