Homebrew Homebrew Development

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
I was looking for an example for threads in C.
I found this one. https://github.com/smealum/ctrulib/blob/master/examples/threads/event/source/main.c

Does someone have a better example?
Maybe something with comments.

Also i don't get one thing.

When you press A, shouldn't the counter keep going up?
It only goes up by 1 every time i click it.

svcCreateThread returns 0
In the thread svcWaitSynchronization is waiting for threadRequest to be signaled (this what pressing the A button is does). When threadRequest is signaled the svcWaitSynchronization call returns and then the next call is to clear the event. It then updates the counter and svcWaitSynchronization waits for the event to be singled again.
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
In the thread svcWaitSynchronization is waiting for threadRequest to be signaled (this what pressing the A button is does). When threadRequest is signaled the svcWaitSynchronization call returns and then the next call is to clear the event. It then updates the counter and svcWaitSynchronization waits for the event to be singled again.
Don't know how i could mis that, thanks! gonna try it again

--------------------- MERGED ---------------------------

Code:
u32 *threadStack = memalign(32, STACKSIZE);
    Result ret = svcCreateThread(&threadHandle, threadMain, 0, &threadStack[STACKSIZE/4], 0x3f, 0);

Why does it use index STACKSIZE/4
 
  • Like
Reactions: elhobbs

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
Don't know how i could mis that, thanks! gonna try it again

--------------------- MERGED ---------------------------

Code:
u32 *threadStack = memalign(32, STACKSIZE);
    Result ret = svcCreateThread(&threadHandle, threadMain, 0, &threadStack[STACKSIZE/4], 0x3f, 0);

Why does it use index STACKSIZE/4
STACKSIZE is the size in bytes. ThreadStack is a u32 pointer - rather than a byte pointer, so the size is divided by the size of a u32 (which is 4) to translate. This puts the pointer just after the end of threadStack array. This is ok in this situation as a stack uses memory backwards. Oddly enough the function does not care how big the stack is - it is up to you to make sure you provided enough space for your code to run.
 
  • Like
Reactions: Tjessx

Selim873

Nunnayobeesnes
Member
Joined
Jul 31, 2010
Messages
1,275
Trophies
0
Age
30
Location
Chillin' with Bob Ross
XP
1,112
Country
United States
I wish I were cool like you guys so I could make/port things. :(

I do have a question out of curiosity, though. If the 3DS uses the ARM architecture (Does homebrew use ARM9 or 11?) and OpenGL ES, would an open source emulator written for Android be easy(easier) to port to 3DS? I just want to be intrigued. lol If I could ever want anything on the 3DS, is for Reicast to even boot, even at 1fps. That would make me happy just because of how cool that system was. I'm almost certain the 3DS is way too weak to emulate the Dreamcast though, but I would have tried it if I were able to, because why not? :yaysp:
 

Philip3ds

Well-Known Member
Member
Joined
May 13, 2015
Messages
187
Trophies
0
Age
27
XP
149
Country
I need some help, so I installed devkit pro on my windows pc, and I also downloaded ctrulib, but now how do I open the program?
 
D

Deleted User

Guest
devkitpro is not a program by itself.. you need other tools to use those libraries..
like notepad++ / programmers notepad or some sort of ide... you can even use your windows texteditor to write code
 

Philip3ds

Well-Known Member
Member
Joined
May 13, 2015
Messages
187
Trophies
0
Age
27
XP
149
Country
devkitpro is not a program by itself.. you need other tools to use those libraries..
like notepad++ / programmers notepad or some sort of ide... you can even use your windows texteditor to write code
Thanks for your reply. Now how do I know what code to type?
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
Thanks for your reply. Now how do I know what code to type?
I am going to assume at this point that you have put in no effort. Look at the examples. Build the examples. Modify the examples. Then come back when you have a specific question. Good question would be - I am trying to do "something specific". Here is what I tried "code example". The result was "picture/description". I was expecting "picture/description". Then ask for someone to review and suggest alternatives/corrections.
 

Philip3ds

Well-Known Member
Member
Joined
May 13, 2015
Messages
187
Trophies
0
Age
27
XP
149
Country
I am going to assume at this point that you have put in no effort. Look at the examples. Build the examples. Modify the examples. Then come back when you have a specific question. Good question would be - I am trying to do "something specific". Here is what I tried "code example". The result was "picture/description". I was expecting "picture/description". Then ask for someone to review and suggest alternatives/corrections.
Well I'm trying to make an n64 emulator for the 3ds.
 

MeisterFenster

Well-Known Member
Member
Joined
Nov 18, 2014
Messages
168
Trophies
0
Age
28
XP
165
Country
Gambia, The
You should learn how to code first. After that figure out how emulators work (most of them are open source and you can look at the code). Finally, you will find that it is not possible to make a decent n64 emulator for the 3DS. If it is even possible to get games running.
 

Philip3ds

Well-Known Member
Member
Joined
May 13, 2015
Messages
187
Trophies
0
Age
27
XP
149
Country
You should learn how to code first. After that figure out how emulators work (most of them are open source and you can look at the code). Finally, you will find that it is not possible to make a decent n64 emulator for the 3DS. If it is even possible to get games running.
The PSP had a n64 emulator, even though the 3ds is more powerful.
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
Country
Italy
You should learn how to code first. After that figure out how emulators work (most of them are open source and you can look at the code). Finally, you will find that it is not possible to make a decent n64 emulator for the 3DS. If it is even possible to get games running.

Daedalus X64 for PSP is a pretty decent N64 emulator who support lot of retail games in fullspeed.
3DS is better then PSP (a lot better if compared to N3DS), so why not?
 

MeisterFenster

Well-Known Member
Member
Joined
Nov 18, 2014
Messages
168
Trophies
0
Age
28
XP
165
Country
Gambia, The
Architecture. The n64 and psp are both mips based, while the 3DS is ARM based. It would require a lot more effort to emulate the n64 on arm (a completly different architecutre) then on mips.
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
indeed, most n64 games where programmed with MIPS caveats in mind (big endian, branch delay slot [detects whether there is an upcoming re-usage of the current volatile register to be accesed and interlocks accordingly, which is the ability to stall the pipeline... ARM cant do that because at least in ARM9 is always 32bytes-constant of prefetch (pipeline refill)], five stage execution pipeline usage of full 64 registers[32 for GPSR, or "scratch pad registers" and 32 for FGRS ], co processors comms between units such RDP, etc). ARM Core is 16 volatile registers + PSR (both Saved and Current) with different cache management (round robin or random), three stage execution pipeline.

but i will say the TLB is somewhat similar to MMU
 
Last edited by Coto,
  • Like
Reactions: MeisterFenster

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
9,858
Trophies
2
XP
28,912
Country
United Kingdom
Well I'm trying to make an n64 emulator for the 3ds.
Type "I'm trying to make an n64 emulator for the 3ds" into a new text file about a hundred times. Save it and run it through devkit pro. Copy the error text that it outputs into a new text file, then run that file through devkit pro, and so on. You'll get there eventually.
 

ifrit05

Well-Known Member
Newcomer
Joined
Aug 11, 2014
Messages
85
Trophies
0
Age
33
XP
340
Country
United States
Just a quick question. What are the audio capabilities of the 3DS? I was thinking about porting GME (Game Music Emulator) or VGMStream. I'm working on VGMStream for the Wii and maybe porting GME also to the Wii (maybe a GME/VGMStream hybrid).

Do you think the 3DS is capable of playing back streamed music from video games? Or should I wait until a more robust SDK is out? DevKitARM for 3DS seems a little "half-baked" at the moment compared to the other SDK's.
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
Just a quick question. What are the audio capabilities of the 3DS? I was thinking about porting GME (Game Music Emulator) or VGMStream. I'm working on VGMStream for the Wii and maybe porting GME also to the Wii (maybe a GME/VGMStream hybrid).

Do you think the 3DS is capable of playing back streamed music from video games? Or should I wait until a more robust SDK is out? DevKitARM for 3DS seems a little "half-baked" at the moment compared to the other SDK's.
It is more than capable. There are already homebrew with wav, ogg and mp3 streaming capabilities.
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
I got a cool idea to for some vasic functions whoch could be very very handyfor homebrew devellopers. But for security reasons i don't really want to share the source code. Is it possible to create something similar to a .dll for homebrew devellopment (never did something like this in c)
 

KingOfHell

Well-Known Member
Newcomer
Joined
Mar 15, 2015
Messages
74
Trophies
0
Age
36
XP
83
Country
United States
Don't think you can use dynamically linked libraries with the 3ds(.CRO maybe, but I don't think there's really any support for them), you might just have to create a statically linked library and just publish the resulting binary (.a i think) and headers. I don't think many people are going to go for a closed source library around here though.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: https://gbatemp.net/profile-posts/163064/