Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,475,194
  • Replies Replies 6,048
  • Likes Likes 54
You can easily reference C libraries in C++. It is a bit more difficult to reference a C++ library from C. So the current solution is easy to use with both.

Awesome, thank you for the explanation. That makes perfect sense. I am just looking through libctru to understand the underlying code before even starting anything, as my C++ is very rusty, and the last I used plain C was back when I was in college... haha

Looking through the code, it is nice to see it is well-documented as well as well-written (as far as I can tell from a cursory glance). Let's see how long it takes me to actually get anything to even run on a test unit. :P
 
Awesome, thank you for the explanation. That makes perfect sense. I am just looking through libctru to understand the underlying code before even starting anything, as my C++ is very rusty, and the last I used plain C was back when I was in college... haha

Looking through the code, it is nice to see it is well-documented as well as well-written (as far as I can tell from a cursory glance). Let's see how long it takes me to actually get anything to even run on a test unit. :P
The examples were moved over to the devkitpro git repository. Not sure if they get added with the devkitpro installer. But they are a good place to start.
 
  • Like
Reactions: Deleted User
The examples were moved over to the devkitpro git repository. Not sure if they get added with the devkitpro installer. But they are a good place to start.

GBATemp can be annoying at times, but this is not one of those times. I am very glad the community of developers for the 3DS are patient with the uninitiated, and that I can find such a wide array of information by searching this forum. So, thank you again. :)
 
Another question: is it okay to have multiple loops w/ aptMainLoop() as the condition? It's more a question of proper programming etiquette, but I couldn't find what it means, and what does it really do.
 
Another question: is it okay to have multiple loops w/ aptMainLoop() as the condition? It's more a question of proper programming etiquette, but I couldn't find what it means, and what does it really do.
HI, i may be misunderstood but, the aptMainLoop() return true as long as no exit command has been send, so it should be only on your main loop. If you want some hint about how to manage your main loop maybe this article can help (it's c++ but the idea is the same in c, and if you go for c++ the whole book is great):
http://gameprogrammingpatterns.com/game-loop.html .
Documentation about aptMainLoop():
https://smealum.github.io/ctrulib/apt_8h.html#a84808c36d9a8c389896ecf241c7f89cb
An example:
https://smealum.github.io/ctrulib/app_launch_2source_2main_8c-example.html#a1
http://gameprogrammingpatterns.com/game-loop.html
 
So I´m a really big noob in programming, and have just learnt a bit c++ / java, but in generell when looking at same examples I kinda uneerstand them. But there are (of cource) many many new commands, and i would like to know if there is a list with them. Also how do I choose where for example a text is displayed? And can I just use allthe normal commands that i know from c++ (cin;cout;if,else;do,while;int,double,etc)?
 
So I´m a really big noob in programming, and have just learnt a bit c++ / java, but in generell when looking at same examples I kinda uneerstand them. But there are (of cource) many many new commands, and i would like to know if there is a list with them. Also how do I choose where for example a text is displayed? And can I just use allthe normal commands that i know from c++ (cin;cout;if,else;do,while;int,double,etc)?
http://smealum.github.io/ctrulib/
The entire documentation. You'll want to have a look.
From all the examples I see that using int is discouraged (why? is it because it's 16-bit?), use s32/u32 instead.
Not sure if cin/couts are supported, besides printf is more versatile :^)
I'm afraid you'll have to learn more. Don't worry, documentation is your friend. As is Stack Overflow, but only if you browse it. And if you have a more concrete question and post here, I'm pretty sure someone will respond.

For the "how to set where is displayed" you'll want to go to Files and find "console.h" for console related functions.

HI, i may be misunderstood but, the aptMainLoop() return true as long as no exit command has been send, so it should be only on your main loop.
I wanted to give the user a chance to see if an error occured (during texture loading or something else - the checks happen before the main loop) and wait for him to press START to exit (and that requires a loop of course). I guess I could put that into the main loop with a flag or something, but I'd prefer to keep it as efficient and clean as possible.
 
Last edited by Spaqin,
  • Like
Reactions: Xen0
I know almost nothing about coding. Have only tried php, xml and mysql a little.

I want to try to port open source games. Like the ones in the link MasterFeizz posted.

http://osgameclones.com

Would Python and Lua be the best choices to work with?
 
Last edited by SLiV3R,
I know almost nothing about coding. Have only tried php, xml and mysql a little.

I want to try to port open source games. Like the ones in the link MasterFeizz posted.

http://osgameclones.com

Would Python and Lua be the best choices to work with?
Forget python, lua could work. Most games there either use C or C++, those are the best choices.
 
  • Like
Reactions: SLiV3R
i've been thinking of making a homebrew application that downloads badges from badges.3dsthem.es, but my 3ds' sd card slot has duct tape stuck on it,
is it possible to debug homebrew on a pc?

does it have networking?
 
i've been thinking of making a homebrew application that downloads badges from badges.3dsthem.es, but my 3ds' sd card slot has duct tape stuck on it,
is it possible to debug homebrew on a pc?

does it have networking?
Use 3dslink to push the 3dsx to your 3ds and ftp to push necessary files.
 
I wanted to give the user a chance to see if an error occured (during texture loading or something else - the checks happen before the main loop) and wait for him to press START to exit (and that requires a loop of course). I guess I could put that into the main loop with a flag or something, but I'd prefer to keep it as efficient and clean as possible.

In smealum portal3ds, he use multiple successive loops. You could do the same but with gameInit return a boolean at true if everything is ok false otherwise. I don't know the best way, but this is how i'll would do on a single or two screen game in c.

Smealum portal3ds main.c:
https://github.com/smealum/portal3DS/blob/master/source/main.c
 
Last edited by delsky,
  • Like
Reactions: Spaqin
Hey all,

As an introduction to 3DS homebrew development, I've taken it upon myself to help port oot3dhax_installer from ctrulib-0.6.0 to ctrulib-1.0.0. At this point, I've got most of the transition done, but there's something that I'm not understanding... I've forked the code to my repository here.

The issue is specifically with this file, filesystem.c . So currently, in my last commit, trying to open the archive for the save data is failing with error code 0xC920454. Now, after playing around a lot, I figured out the following work-around:

Code:
#include <string.h>
#include <stdio.h>
#include <inttypes.h>

#include <3ds.h>

#include "filesystem.h"

FS_Archive saveGameArchive, sdmcArchive;
Handle fsHandle;

Result filesystemInit()
{
  Result ret;

  //Workaround begin
  srvGetServiceHandleDirect(&fsHandle, "fs:USER");
  FSUSER_Initialize(fsHandle);
  fsUseSession(fsHandle, false);
  //Workaround end

  sdmcArchive = (FS_Archive){ARCHIVE_SDMC, (FS_Path){PATH_EMPTY, 1, (u8*)""}, 0};
  ret = FSUSER_OpenArchive(&sdmcArchive);

  saveGameArchive = (FS_Archive){ARCHIVE_SAVEDATA, (FS_Path){PATH_EMPTY, 1, (u8*)""}, 0}; 
  ret = FSUSER_OpenArchive(&saveGameArchive);

  return ret;
}

Result filesystemExit()
{
  Result ret;
 
  ret = FSUSER_CloseArchive(&saveGameArchive);
  ret = FSUSER_CloseArchive(&sdmcArchive);

  fsEndUseSession();

  return ret;
}
Why exactly do I need to request another handle, and substitute the main one with it in order to get the "FSUSER_OpenArchive(&saveGameArchive);" to work? I have a hunch it's something having to do with permissions with the original handle, but I don't know how to go about testing that. Any suggestions?

Another observation is that changing srvGetServiceHandleDirect to srvGetServiceHandle leads to another error message and actually leads to a program hang as it's trying to exit. I'm guessing (from having looked at the ctrulib source code) that this has to do with the fact the latter function probably just copies the original handle, versus the former which returns a new one unconditionally. Thoughts?
 
  • Like
Reactions: SLiV3R
You should use

fsUseSession
fsEndUseSession

whenever you want to use a different archive.

This is because all the FS_* functions were changed during great-refactor to use only the current session handle.
Now you should be able to simply use fsUseSession(savedataHandle, false) to have access to the savedata, and still be able to use the standard fopen fclose for the sdmc access
 
Last edited by Lectem,
  • Like
Reactions: Gelex
Aaah, that makes sense, especially with fsUseSession() being initialized to false (so that the SD access still goes to the original handle). I wish somewhere anything would have mentioned that every archive needs its own handle. The great refactor made me think that wasn't needed anymore.

The current approach of overriding the current session feels cludgy. I would have much rather preferred manually providing handles, and allowing that parameter be NULL so that a default is used. That's just my personal taste, though. Thanks for the insight.
 

Site & Scene News

Popular threads in this forum