Homebrew Homebrew Development

TheCruel

Developer
Banned
Joined
Dec 6, 2013
Messages
1,350
Trophies
2
XP
3,131
Country
United States
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.
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
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).
 

CalebW

Fellow Temper
Member
Joined
Jun 29, 2012
Messages
638
Trophies
0
Location
Texas
XP
545
Country
United States
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

  • Breakout3DS.zip
    7.3 KB · Views: 566

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
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

PewnyPL

Well-Known Member
Member
Joined
Feb 2, 2014
Messages
771
Trophies
1
XP
2,185
Country
Poland
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'?
 

Kane49

Well-Known Member
Member
Joined
Nov 4, 2013
Messages
446
Trophies
0
Age
36
XP
343
Country
Gambia, The
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
 

Kane49

Well-Known Member
Member
Joined
Nov 4, 2013
Messages
446
Trophies
0
Age
36
XP
343
Country
Gambia, The
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 :)
 

Snailface

My frothing demand for 3ds homebrew is increasing
Member
Joined
Sep 20, 2010
Messages
4,324
Trophies
2
Age
40
Location
Engine Room with Cyan, watching him learn.
XP
2,256
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.
 

PewnyPL

Well-Known Member
Member
Joined
Feb 2, 2014
Messages
771
Trophies
1
XP
2,185
Country
Poland
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.
 

Snailface

My frothing demand for 3ds homebrew is increasing
Member
Joined
Sep 20, 2010
Messages
4,324
Trophies
2
Age
40
Location
Engine Room with Cyan, watching him learn.
XP
2,256
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.
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
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

General chit-chat
Help Users
  • No one is chatting at the moment.
  • K3Nv2 @ K3Nv2:
    Slower speeds for gen4
  • K3Nv2 @ K3Nv2:
    I'll reformat and have a 3tb raid0 m. 2 at least
    +1
  • K3Nv2 @ K3Nv2:
    Lmao that sold out fast
    +1
  • Veho @ Veho:
    Yeet the cat.
    +1
  • K3Nv2 @ K3Nv2:
    Good idea
    +1
  • The Real Jdbye @ The Real Jdbye:
    i thought everybody knew cocktails are like 75% ice
  • Veho @ Veho:
    Yeah but not like this.
  • Veho @ Veho:
    It's not like they're complaining that their Slurpee is 99% ice or something, but if the cocktail calls for "shot of vodka, shot of vermouth, shot of gin, shot of Campari, three shots of juice, squirt of lemon" and ends up being a thimbleful of booze, that's a problem.
  • The Real Jdbye @ The Real Jdbye:
    the funny thing is cocktails in norway are only allowed to have 1 20ml shot of booze
  • The Real Jdbye @ The Real Jdbye:
    so..... yeah
  • The Real Jdbye @ The Real Jdbye:
    we're used to only having a thimbleful of booze
  • Veho @ Veho:
    Booo.
  • The Real Jdbye @ The Real Jdbye:
    same thing if you want whisky on the rocks or something, you can't get a double
  • The Real Jdbye @ The Real Jdbye:
    but you could buy as many shots of whisky (or anything else) as you want and ask for a glass of ice and pour them in
  • The Real Jdbye @ The Real Jdbye:
    it's dumb
  • Veho @ Veho:
    Maybe.
  • Veho @ Veho:
    There was a comparison of the number of Ibuprofen poisonings before and after they limited the maximum dosage per box or per pill (i'll look that up). No limit on the number of boxes you can still buy as many as you want, so people argued it was pointless.
  • Veho @ Veho:
    But the number of (accidental) poisonings dropped because drinking an entire package of ibuprofen pills went from "I need a new liver" to "I need a new box of Ibuprofen".
  • Veho @ Veho:
    Here we have ketoprofen that used to be prescription-only because of the risk of toxic dosages, but then they halved the dose per pill and sell them in bottles of six pills apiece instead of twenty and it doesn't need a prescription any more. Yes you can buy more than one bottle but people simply don't.
  • Psionic Roshambo @ Psionic Roshambo:
    Usually accidentally overdose of ibuprofen here is from people taking like cold medicine then ibuprofen for a headache and the combination is over what they need
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/watch?v=1hp24nDVKvY