Homebrew Homebrew Development

Nightbane30

Active Member
Newcomer
Joined
Nov 26, 2014
Messages
37
Trophies
0
Age
36
XP
782
Country
United States

xem

Well-Known Member
Member
Joined
Nov 22, 2014
Messages
142
Trophies
0
Age
36
Location
Valbonne
XP
333
Country
France
Hello, I'm reading 3Dbrew, and ctrulib's source code too but there are still things that I don't get very well, especially about graphics.

According to http://3dbrew.org/wiki/Memory_layout The VRAM's address range is [0x18000000 - 0x18600000].

Question 1: are the 3 screens' 2 framebuffers stored in the VRAM?
According to the same page (at the bottom), it looks like framebuffers are generally stored between addresses 0x1E6000 and 0x4FF800... are those addresses inside the VRAM (i.e. equivalent to global addresses 0x181E6000 - 0x184FF800) ?

Question 2: If that is right, then why is ctrulib using the addresses 0x000000 - 0x189C00? Did they choose to redefine the default framebuffer's addresses to take less space, or something like that?
https://github.com/smealum/ctrulib/...b052d12ecb19dd1/libctru/source/gfx.c#L98-L105

Question 3: in each framebuffer, are the pixels stored sequencially as r,g,b,r,g,b,,... (1 byte for each color) or do they follow another pattern (like b,g,r,b,g,r,...) ? Or maybe it is BGR by default but it can be changed to support other patterns somehow.

Thanks a lot!
 

st4rk

nah
Member
Joined
Feb 11, 2014
Messages
542
Trophies
0
Website
st4rk.net
XP
815
Country
Brazil
Hello, I'm reading 3Dbrew, and ctrulib's source code too but there are still things that I don't get very well, especially about graphics.

According to http://3dbrew.org/wiki/Memory_layout The VRAM's address range is [0x18000000 - 0x18600000].

Question 1: are the 3 screens' 2 framebuffers stored in the VRAM?
According to the same page (at the bottom), it looks like framebuffers are generally stored between addresses 0x1E6000 and 0x4FF800... are those addresses inside the VRAM (i.e. equivalent to global addresses 0x181E6000 - 0x184FF800) ?

Question 2: If that is right, then why is ctrulib using the addresses 0x000000 - 0x189C00? Did they choose to redefine the default framebuffer's addresses to take less space, or something like that?
https://github.com/smealum/ctrulib/...b052d12ecb19dd1/libctru/source/gfx.c#L98-L105

Question 3: in each framebuffer, are the pixels stored sequencially as r,g,b,r,g,b,,... (1 byte for each color) or do they follow another pattern (like b,g,r,b,g,r,...) ? Or maybe it is BGR by default but it can be changed to support other patterns somehow.

Thanks a lot!


Question 3 : 24bpp, BGR Format, but you can change it to 16bpp and other formats too =]
 

jasonmbrown

Well-Known Member
Newcomer
Joined
Sep 11, 2010
Messages
47
Trophies
0
XP
183
Country
Canada
Figured I would do something simple, and recreate space invaders for the 3ds. Since this is the first C++ Il have done (besides Making HelloWorlds for the wii, and tweaking the examples), I dont have much experience. And was wondering If there's anyone who wants to help with logic error?

Currently, Don't have much done up Besides a simple way to create 8x8 sprites and animate them. I had one of them Moving left and right Just to make sure that there wasnt anything weird happening with the variables. However Now that Im drawing multiple "Invaders" It keeps drawing them diagonally which means I have a logic issue somewhere that I cant find...

if anyone wants to take a look feel free, This has the source as well as the buggy diagonal animated "invader" Besides that I havent done much lol. Just this has taken me all night XD.
Crappy Code.

So Ya If anyone wants to take a quick glance and see where I derped?

(code thats probably causing the issue)

EDIT:Got them to line up, however I cant draw the row above for some reason, Causes buncha weird blue invaders to show up...
(modified the below data)
Code:
int alien_layout[121] = {
    1,1,1,1,1,1,1,1,1,1,  1,0,0,0,0,0,0,0,0,0,
    1,1,1,1,1,1,1,1,1,1,  1,0,0,0,0,0,0,0,0,0,
    1,1,1,1,1,1,1,1,1,1,  1,0,0,0,0,0,0,0,0,0,
    1,1,1,1,1,1,1,1,1,1,  1,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0
};
 
int get_xpos(alien_array_position){//Minimum 100px: Maximum 300px
  int xpos = 0;
  xpos = (150 + (alien_array_position * 13) );//150
 
return xpos;
};
 
int get_ypos(alien_array_position){
    int ypos = 0;
    ypos = (50 + ((alien_array_position /20) * 11) );//100
 
return ypos;
};

I feel like the answer to this is gonna be really stupid lol

Edit2: Yay I figured it out... I was multiplying the alien_array_position * 13 but I needed to ((alien_array_position % 20) *13);
 

CalebW

Fellow Temper
Member
Joined
Jun 29, 2012
Messages
638
Trophies
0
Location
Texas
XP
545
Country
United States
I noticed it's popular to use START to exit homebrew, but why don't we just use the home menu button since that's not used and free start for other things?
 

CalebW

Fellow Temper
Member
Joined
Jun 29, 2012
Messages
638
Trophies
0
Location
Texas
XP
545
Country
United States
Yeah, I'd personally say the best idea for having an exit "button" would be to have one on the bottom screen like blargSnes. Guessing buttons is no fun.
Or we(the homebrew community) could just standardize a "soft reset"(like on the DS) key combination, say, like START+SELECT or L+R+START....


Has anybody managed to compile smea's hbmenu? When I try I get
Code:
/home/family/Desktop/Caleb/Github/3ds_hb_menu/source/background.c:74:31: error: 'RAND_MAX' undeclared (first use in this function)
  return (float)rand()/(float)(RAND_MAX);
How come RAND_MAX is undeclared? I greped the entire source tree for RAND_MAX but nothing showed up...
 

shinyquagsire23

SALT/Sm4sh Leak Guy
Member
Joined
Nov 18, 2012
Messages
1,977
Trophies
2
Age
26
Location
Las Vegas
XP
3,765
Country
United States
Or we(the homebrew community) could just standardize a "soft reset"(like on the DS) key combination, say, like START+SELECT or L+R+START....


Has anybody managed to compile smea's hbmenu? When I try I get
Code:
/home/family/Desktop/Caleb/Github/3ds_hb_menu/source/background.c:74:31: error: 'RAND_MAX' undeclared (first use in this function)
  return (float)rand()/(float)(RAND_MAX);
How come RAND_MAX is undeclared? I greped the entire source tree for RAND_MAX but nothing showed up...
It's probably a defined variable in ctrulib. Did you make sure to update ctrulib and create an environment variable CTRULIB to point to the libctru folder?
 

Arisotura

rise of melonism
Member
Joined
Dec 5, 2009
Messages
839
Trophies
1
Age
30
Location
center of the Sun
Website
kuribo64.net
XP
2,498
Country
France
Actually, it is exposed to user mode, more or less.

The APT service lets you sense when it is pressed. The app is then supposed to do some operations that bring it to the background and show the home menu, but I guess one could program it to do something else.

ctrulib hides those details from the user, though.


This shit also doesn't work under Ninjhax.
 

shinyquagsire23

SALT/Sm4sh Leak Guy
Member
Joined
Nov 18, 2012
Messages
1,977
Trophies
2
Age
26
Location
Las Vegas
XP
3,765
Country
United States
Actually, it is exposed to user mode, more or less.

The APT service lets you sense when it is pressed. The app is then supposed to do some operations that bring it to the background and show the home menu, but I guess one could program it to do something else.

ctrulib hides those details from the user, though.


This shit also doesn't work under Ninjhax.
Yeah, I imagined it was there. I might poke around and see what ctrulib's button value fetcher thingy is actually returning when I press the home button, because it might just be a matter of non-implemented details (like the 3D slider thing which is only documented in one of the examples).

EDIT: Definitely not picked up like a normal button.
 

Arisotura

rise of melonism
Member
Joined
Dec 5, 2009
Messages
839
Trophies
1
Age
30
Location
center of the Sun
Website
kuribo64.net
XP
2,498
Country
France
I already tried that before. No bits in the HID button values are set when the Home button is pressed.

The only way to sense presses to that button (and the Power button) is APT. APT_Initialize() gives you event handles, one of them is signaled when those buttons are pressed (among other things).
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    BakerMan @ BakerMan: @salazarcosplay yeah cod's still up