Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,475,037
  • Replies Replies 6,048
  • Likes Likes 54
[Q] Is sleep mode something that has to be coded, or is it something automatically taken care of by ctrulib?
ctrulib will automatically pause/resume DSP audio on sleep, but that's about it I think.

To support sleeping, just have to reset game clock essentially, like this:

https://github.com/cpp3ds/cpp3ds/blob/master/src/cpp3ds/Window/Game.cpp#L14

And to support game suspension for non-3dsx homebrew, you will have to reset some GPU stuff, like this:

https://github.com/xerpi/sf2dlib/blob/master/libsf2d/source/sf2d.c#L299

These are both callback functions registered using ctrulib's aptHook function.
 
Last edited by TheCruel,
ctrulib will automatically pause/resume DSP audio on sleep, but that's about it I think.

To support sleeping, just have to reset game clock essentially, like this:

https://github.com/cpp3ds/cpp3ds/blob/master/src/cpp3ds/Window/Game.cpp#L14

And to support game suspension for non-3dsx homebrew, you will have to reset some GPU stuff, like this:

https://github.com/xerpi/sf2dlib/blob/master/libsf2d/source/sf2d.c#L299

These are both callback functions registered using ctrulib's aptHook function.

I'm having a little trouble finding what APT_HookType is...

Code:
 error: 'APT_HookType' was not declared in this scope
 
Is there something with the 3DS that tells it to cull out polygons based on position within the visual area? I'm trying to draw horizontal lines (technically 2 polygons to form a rectangle that goes from position {y} to position {y + 1}, since from {y} to {y} doesn't draw anything), but when in a particular position, they get completely thrown out. For instance, I'm working with a texture destination that's 256x256 texels, so my 4x4 projection matrix along the diagonal is {2.0f/256.0f, 2.0f/256.0f, 1, 1}. If I draw from 0 to 256 (remember, just horizontal lines), it draws the line. If I draw from 100 to 156, it draws the line. But, when I draw from something like 60 to 80, or 140 to 200, the line isn't drawn. When going by vertical steps, adjusting by 1 each time, it looks like it discards any line I make that doesn't have one point on the left side of the buffer and the other point on the other side (like p1 must not be on the same half as p2).

To possibly help determine the cause, if I were to only draw one of the 2 polygons and draw a line that spanned the full width of the buffer, only half of the line would get drawn. I would assume this is due to the triangle polygon having just one point at {y + 1} with the other two at {y}, so the side with the {y + 1} fully envelops the texel areas the polygon occupies. Still, it doesn't make sense with the current problem I'm having.

Hope this is understandable.
 
Is there something with the 3DS that tells it to cull out polygons based on position within the visual area? I'm trying to draw horizontal lines (technically 2 polygons to form a rectangle that goes from position {y} to position {y + 1}, since from {y} to {y} doesn't draw anything), but when in a particular position, they get completely thrown out. For instance, I'm working with a texture destination that's 256x256 texels, so my 4x4 projection matrix along the diagonal is {2.0f/256.0f, 2.0f/256.0f, 1, 1}. If I draw from 0 to 256 (remember, just horizontal lines), it draws the line. If I draw from 100 to 156, it draws the line. But, when I draw from something like 60 to 80, or 140 to 200, the line isn't drawn. When going by vertical steps, adjusting by 1 each time, it looks like it discards any line I make that doesn't have one point on the left side of the buffer and the other point on the other side (like p1 must not be on the same half as p2).

To possibly help determine the cause, if I were to only draw one of the 2 polygons and draw a line that spanned the full width of the buffer, only half of the line would get drawn. I would assume this is due to the triangle polygon having just one point at {y + 1} with the other two at {y}, so the side with the {y + 1} fully envelops the texel areas the polygon occupies. Still, it doesn't make sense with the current problem I'm having.

Hope this is understandable.
Did you try setting back face culling to none?
 
Did you try setting back face culling to none?

Yes, but about 15 minutes ago, I found out what the problem was. It was a mistake on my part of handling a sort of clipping in my geo-shader, which was taking into account not just the length of the line from left-to-right, but also the heights from top-to-bottom, the latter which it wasn't supposed to. It ended up clipping the height, making it less than 1 pixel, and therefore, discarded the polygons. Adjusted it, and now it works as it's meant to.
 
I'm trying to add a pause/resume feature to ndsp wrapper but it seems to not work (pause work fine but when i try to resume i get no audio output.). Does someone knows where i'm wrong?

Code:
static int lua_pause(lua_State *L)
{
  int argc = lua_gettop(L);
   #ifndef SKIP_ERROR_HANDLING
     if (argc != 1) return luaL_error(L, "wrong number of arguments");
   #endif
   Music* src = (Music*)luaL_checkinteger(L, 1);
   #ifndef SKIP_ERROR_HANDLING
     if (src->magic != 0x4C534E44) return luaL_error(L, "attempt to access wrong memory block type");
   #endif
   if (src->isPlaying){
     ndspChnSt* chn = &ndspChn[src->ch];
     LightLock_Lock(&chn->lock);
     src->savestate = (ndspChnSt*)malloc(sizeof(ndspChnSt));
     memcpy(src->savestate,chn,sizeof(ndspChnSt));
     LightLock_Unlock(&chn->lock);
     ndspChnWaveBufClear(src->ch);
     src->isPlaying = false;
     src->tick = (osGetTime()-src->tick);
   }
   return 0;
}

static int lua_resume(lua_State *L)
{
  int argc = lua_gettop(L);
   #ifndef SKIP_ERROR_HANDLING
     if (argc != 1) return luaL_error(L, "wrong number of arguments");
   #endif
   Music* src = (Music*)luaL_checkinteger(L, 1);
   #ifndef SKIP_ERROR_HANDLING
     if (src->magic != 0x4C534E44) return luaL_error(L, "attempt to access wrong memory block type");
   #endif
   if (!src->isPlaying){
     ndspChnSt* chn = &ndspChn[src->ch];
     LightLock_Lock(&chn->lock);
     memcpy(chn,src->savestate,sizeof(ndspChnSt));
     LightLock_Unlock(&chn->lock);
     free(src->savestate);
     src->isPlaying = true;
     src->tick = (osGetTime()-src->tick);
   }
   return 0;
}

EDIT: SOLVED!
 
Last edited by Rinnegatamante,
Can someone point me towards a way to realize some sort of sd file browsing with ctrulib?

For example: i want to specify a path and i want to retrieve all the files/folders in that path
i browsed through the fs.h file of ctrulib but i didn't find anything useful.
 
this might sound stupid but honestly as far as i've seen no one has really named the homebrew except just homebrew why not name it homebrew 3d or 3d homebrew i dont know just something
 
Sorry for being a noob, but how do I get .png images from .c images? And vice versa?

You can use GIMP. Just open your .png and then File->Export, name it yourname.c and it will automatically prompt a new menu. In the title section you should put the name you want to use in your source code. Save it with the alpha channel enabled (RGBA) and nothing more (don't use GUNIT type)

then open the generated .c file with a text editor and replace "static const struct" with just "const struct" (as it won't compile otherwise)
 
You can use GIMP. Just open your .png and then File->Export, name it yourname.c and it will automatically prompt a new menu. In the title section you should put the name you want to use in your source code. Save it with the alpha channel enabled (RGBA) and nothing more (don't use GUNIT type)

then open the generated .c file with a text editor and replace "static const struct" with just "const struct" (as it won't compile otherwise)
Thanks! Can I open .c files with gimp?

EDIT: And what about .h images?
 

Site & Scene News

Popular threads in this forum