Homebrew Homebrew Development

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
Thanks for your tips, i ported the entire socket module, now i need only to test it.
Anyway, about send bug, sendto last arguments need to be leaved NULL and 0 or they may refer to an existent server?
They mat refer to an existent server, but it isn't necesairy.
I also only tested it with null, 0
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,858
Country
Italy
With this piece of code i get always a "Failed connecting server" error. (I call it after initialization of SOC:u service and i give it my website IP as IP and 80 as port (i'm trying to simply download a file through sockets);

Code:
static int lua_connect(lua_State *L)
{
   int argc = lua_gettop(L);
   if (argc != 2) return luaL_error(L, "wrong number of arguments");

   Socket* my_socket = (Socket*) malloc(sizeof(Socket));
   my_socket->serverSocket = 0;

   const char *host = luaL_checkstring(L, 1);
   int port = luaL_checkinteger(L, 2);
   my_socket->addrTo.sin_family = AF_INET;
   my_socket->addrTo.sin_port = htons(port);
   my_socket->addrTo.sin_addr.s_addr = inet_addr(host);

   my_socket->sock = socket(AF_INET, SOCK_STREAM, 0);
   if (my_socket->sock < 0) return luaL_error(L, "Failed creating socket.");
   setSockNoBlock(my_socket->sock, 1);

   int err = connect(my_socket->sock, (struct sockaddr*)&my_socket->addrTo, sizeof(my_socket->addrTo));
   if (err < 0 ) return luaL_error(L, "Failed connecting server.");
   lua_pushinteger(L, (u32)my_socket);
   return 1;
}
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
Lua is an interpretation language, right?
Would it be possible to compile php for 3ds?
I saw a thing named ph7, which basicly compiles php as c into an executable.
Someone thinks it could be compiled into a bin? Or is there a specific reason why it can be dlne with lua and not with php

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

With this piece of code i get always a "Failed connecting server" error. (I call it after initialization of SOC:u service and i give it my website IP as IP and 80 as port (i'm trying to simply download a file through sockets);

Code:
static int lua_connect(lua_State *L)
{
   int argc = lua_gettop(L);
   if (argc != 2) return luaL_error(L, "wrong number of arguments");

   Socket* my_socket = (Socket*) malloc(sizeof(Socket));
   my_socket->serverSocket = 0;

   const char *host = luaL_checkstring(L, 1);
   int port = luaL_checkinteger(L, 2);
   my_socket->addrTo.sin_family = AF_INET;
   my_socket->addrTo.sin_port = htons(port);
   my_socket->addrTo.sin_addr.s_addr = inet_addr(host);

   my_socket->sock = socket(AF_INET, SOCK_STREAM, 0);
   if (my_socket->sock < 0) return luaL_error(L, "Failed creating socket.");
   setSockNoBlock(my_socket->sock, 1);

   int err = connect(my_socket->sock, (struct sockaddr*)&my_socket->addrTo, sizeof(my_socket->addrTo));
   if (err < 0 ) return luaL_error(L, "Failed connecting server.");
   lua_pushinteger(L, (u32)my_socket);
   return 1;
}
What is the error number?
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,858
Country
Italy
Lua is an interpretation language, right?
Would it be possible to compile php for 3ds?
I saw a thing named ph7, which basicly compiles php as c into an executable.
Someone thinks it could be compiled into a bin? Or is there a specific reason why it can be dlne with lua and not with php

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


What is the error number?

Any interpreted language could be ported to 3DS by writing an interpreter (Python, LUA, Ruby, PHP, Java (in reality, Java is both compiled and interpreted) and so on)

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

Solved for the socket ;)
 
  • Like
Reactions: Seriel

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
I would love to see php homebrew applications. I might work on this wen i got some time (probably not).
Si jf there is another php fan arround here. I would highly appreciate it :-D
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium

Stracker

Well-Known Member
Newcomer
Joined
Sep 7, 2015
Messages
86
Trophies
0
Age
28
XP
167
Country
France
Alright, I'm having a lot of trouble tracking a bug in my app, is there any way to know what caused a crash or a debugger, anything ?
I can pinpoint the lines where it happens but I can't see to find a goddamn reason why my app just freezes...
 

Garcia98

Hey! Listen!
Member
Joined
Sep 8, 2015
Messages
361
Trophies
0
Location
Salamanca
Website
github.com
XP
267
Country
Alright, I'm having a lot of trouble tracking a bug in my app, is there any way to know what caused a crash or a debugger, anything ?
I can pinpoint the lines where it happens but I can't see to find a goddamn reason why my app just freezes...

You can use Citra to debug your app, you can also post here your code, maybe we can help you.
 

Stracker

Well-Known Member
Newcomer
Joined
Sep 7, 2015
Messages
86
Trophies
0
Age
28
XP
167
Country
France
You can use Citra to debug your app, you can also post here your code, maybe we can help you.
well unless you know of a way to emulate the 'select app' of homebrew launcher with citra, it won't work, my app is handling save data...

My code is getting too massive to post, but what I've seen so far is :
- It crashes on any printf with an escape sequence on the bottom screen
- It only does this when handling a save from pokemon X/Y, and after I try to export a pokemon from one of the specific screens

I've pinpointed the crash here
Only after this part is ran
I'm printing pointer adresses right, thinking about some kind of memory corruption, but i'm not sure...
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
well unless you know of a way to emulate the 'select app' of homebrew launcher with citra, it won't work, my app is handling save data...

My code is getting too massive to post, but what I've seen so far is :
- It crashes on any printf with an escape sequence on the bottom screen
- It only does this when handling a save from pokemon X/Y, and after I try to export a pokemon from one of the specific screens

I've pinpointed the crash here
Only after this part is ran
I'm printing pointer adresses right, thinking about some kind of memory corruption, but i'm not sure...
I dint think you can write to possition 0, 0 since the pixels start at 1.
Try remove the positioning at printf(without it it will just continue on that line untill it is full, so end uour messages woth a \n)
 

Stracker

Well-Known Member
Newcomer
Joined
Sep 7, 2015
Messages
86
Trophies
0
Age
28
XP
167
Country
France
I dint think you can write to possition 0, 0 since the pixels start at 1.
Try remove the positioning at printf(without it it will just continue on that line untill it is full, so end uour messages woth a \n)
Not it, this isn't a pixel position, it's a character position in a terminal, [0;0] works perfectly in several other parts of the code, including this one is most cases
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
Not it, this isn't a pixel position, it's a character position in a terminal, [0;0] works perfectly in several other parts of the code, including this one is most cases
Yeah i realised just after i posted it. Forgive me i'm really tired

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

Are you sure it happens a that line? not before or not after?
 

Stracker

Well-Known Member
Newcomer
Joined
Sep 7, 2015
Messages
86
Trophies
0
Age
28
XP
167
Country
France
Yeah i realised just after i posted it. Forgive me i'm really tired

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

Are you sure it happens a that line? not before or not after?

Absolutely certain that the crash is there, I don't think the problem comes from that line though

EDIT :
I got my thing running in citra, how do I debug now ? breakpoints don't work...
 
Last edited by Stracker,

UltiNaruto

Well-Known Member
Member
Joined
Sep 4, 2015
Messages
182
Trophies
0
Age
30
XP
203
Country
France
Any ways to place the image in the framebuffer using x and y?

Code:
void drawImage(gfxScreen_t screen, const void * image, int len, int x, int y)
{
    u8* fb = gfxGetFramebuffer(screen, GFX_LEFT, NULL, NULL);
    u8* toFB = (u8*)image;
    int console_height = 240;
    for(int i=0;i<len;i++)
    {
        fb[i] = toFB[i];
    }
}

I wanted to place some images at specific locations but since fb size is different than toFB size.
fb = 400*240 (top screen)
and toFB = 20*20 (a small square texture)
I need to place toFB in (x,y) of fb.
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
Any ways to place the image in the framebuffer using x and y?

Code:
void drawImage(gfxScreen_t screen, const void * image, int len, int x, int y)
{
    u8* fb = gfxGetFramebuffer(screen, GFX_LEFT, NULL, NULL);
    u8* toFB = (u8*)image;
    int console_height = 240;
    for(int i=0;i<len;i++)
    {
        fb[i] = toFB[i];
    }
}

I wanted to place some images at specific locations but since fb size is different than toFB size.
fb = 400*240 (top screen)
and toFB = 20*20 (a small square texture)
I need to place toFB in (x,y) of fb.

Here is the function i use to color one pixel:
Code:
void color_pixel(int x, int y, u8 r, u8 g, u8 b, u8* screen) {
    y = HEIGHT - y;
    int hulp = x;
    x = y;
    y = hulp;
   
    u32 v=(x + y * HEIGHT) * 3;
   
    if((screen == top && v < 288000 && v > 0) || (v < 230400 && v > 0)) {
        screen[v] = color.b;
        screen[v + 1] = color.g;
        screen[v + 2] = color.r;
    }
}

Then you can do something like:
Code:
void drawImage(u8* screen, const void * image, int width, int height, int x, int y)
{
    int len = width * height;
   
    u8* fb = gfxGetFramebuffer(screen, GFX_LEFT, NULL, NULL);
    u8* toFB = (u8*)image;
   
    int i, j, v;
    for(i = 0; i < height; i++) {
        for(j = 0; j < width; j++) {
            v = (height * i + width) * 3;
            color_pixel(x + j, y + i, toFB[v], toFB[v++], toFB[v++], screen);
        }
    }
}

I haven't tested this code, but it should be something like that.
This is just to give you an idea about how it could be done
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: @PandaPandel, irl or in the game?