Homebrew Homebrew Development

D

Deleted User

Guest
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
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
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
D

Deleted User

Guest
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. :)
 

Spaqin

Well-Known Member
Member
Joined
Feb 17, 2015
Messages
123
Trophies
0
Age
29
XP
199
Country
Poland
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.
 

delsky

New Member
Newbie
Joined
Jan 15, 2016
Messages
4
Trophies
0
XP
57
Country
France
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
 

Xen0

Well-Known Member
Member
Joined
Oct 8, 2015
Messages
532
Trophies
0
Age
25
XP
1,946
Country
Germany
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)?
 

Spaqin

Well-Known Member
Member
Joined
Feb 17, 2015
Messages
123
Trophies
0
Age
29
XP
199
Country
Poland
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

MasterFeizz

Well-Known Member
Member
Joined
Oct 15, 2015
Messages
1,098
Trophies
1
Age
29
XP
3,710
Country
United States
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

erman1337

Well-Known Member
Member
Joined
Sep 27, 2015
Messages
1,211
Trophies
0
Location
Brussels
XP
983
Country
Belgium
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?
 

MasterFeizz

Well-Known Member
Member
Joined
Oct 15, 2015
Messages
1,098
Trophies
1
Age
29
XP
3,710
Country
United States
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.
 

delsky

New Member
Newbie
Joined
Jan 15, 2016
Messages
4
Trophies
0
XP
57
Country
France
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

Gelex

Member
Newcomer
Joined
Jan 17, 2016
Messages
14
Trophies
0
XP
78
Country
United States
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

Lectem

Active Member
Newcomer
Joined
Nov 21, 2014
Messages
43
Trophies
0
Age
30
XP
135
Country
France
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

Gelex

Member
Newcomer
Joined
Jan 17, 2016
Messages
14
Trophies
0
XP
78
Country
United States
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

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: https://youtu.be/MddR6PTmGKg?si=mU2EO5hoE7XXSbSr