Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,475,188
  • Replies Replies 6,048
  • Likes Likes 54
Can someone clue me into how the hell the pixel buffer works? I can either get the colours correct, OR the x,y location, not both. I'm attempting to use --
Code:
void drawPixel(int x, int y, char r, char g, char b, u8* screen)
{
    int height=240;
  
    u32 v=((239-y)+x*height)*3;
    screen[v]=b;
    screen[v+1]=g;
    screen[v+2]=r;
}

on the upper screen with console output on the lower screen. However, the pixels are spaced out. If I *2 instead of *3, then the pixels are in the correct place, but the rgb values are wrong.

Little help?

Cheers.
 
Can someone clue me into how the hell the pixel buffer works? I can either get the colours correct, OR the x,y location, not both. I'm attempting to use --
Code:
void drawPixel(int x, int y, char r, char g, char b, u8* screen)
{
    int height=240;
 
    u32 v=((239-y)+x*height)*3;
    screen[v]=b;
    screen[v+1]=g;
    screen[v+2]=r;
}

on the upper screen with console output on the lower screen. However, the pixels are spaced out. If I *2 instead of *3, then the pixels are in the correct place, but the rgb values are wrong.

Little help?

Cheers.

Nintendo used vertical screens instead of horizontal ones so upper and lower screen in reality are 90 degrees rotated and have 400x240 and 320x240 resolution.
 
Nintendo used vertical screens instead of horizontal ones so upper and lower screen in reality are 90 degrees rotated and have 400x240 and 320x240 resolution.
I'm ok with the rotation, but I\m drawing a full screen pixel-by-pixel but the display is spread out with gaps, both vertical and horizontal.
 
Try this one (color is a BGRA color)
Code:
void DrawPixel(u8* screen, int x,int y, u32 color){ int idx = (((x)*240) + (239-(y)))*3; *(u32*)&(screen[idx]) = (((color) & 0x00FFFFFF) | ((*(u32*)&(screen[idx])) & 0xFF000000)); }
 
Are you try to draw a pixel to a screen setup by the console? It uses a packed 16 bit per pixel format. Use RBG8_to_565(r,g,b) to pack the colors into a u16 and use 2 instead of 3 for your multiple.
 
So i updated DEVKITARM through the automated installer.
I downloaded the latest ctrulib and did "make install" which was skipped since i got the latest version now.

When i try to build my project i get this error:
/Users/bert/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: cannot find 3dsx_crt0.o: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [/Users/bert/Documents/Devellopment/3ds/pictochat3ds/pictochat3ds.elf] Error 1
make: *** [build] Error 2

Anyone an idea on how to fix this?

EDIT: in the makefile i had to change: "mfloat-abi=softfp" to "mfloat-abi=hard"
 
Last edited by Tjessx,
So i updated DEVKITARM through the automated installer.
I downloaded the latest ctrulib and did "make install" which was skipped since i got the latest version now.

When i try to build my project i get this error:
/Users/bert/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: cannot find 3dsx_crt0.o: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [/Users/bert/Documents/Devellopment/3ds/pictochat3ds/pictochat3ds.elf] Error 1
make: *** [build] Error 2

Anyone an idea on how to fix this?

EDIT: in the makefile i had to change: "mfloat-abi=softfp" to "mfloat-abi=hard"

First of all, do a make clean.
Secondary, if you used some library, you have to rebuild them with mfloat-abi=hard.
 
How do you debug a homebrew app?

I've written a simple one which works at the beginning but after ~6 seconds it freezes and it doesn't seem to read the input (I can't exit from the app or do anything).
 

Site & Scene News

Popular threads in this forum