Homebrew Homebrew Development

spinal_cord

Knows his stuff
Member
Joined
Jul 21, 2007
Messages
3,225
Trophies
1
Age
43
Location
somewhere
Website
spinalcode.co.uk
XP
3,375
Country
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.
 

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
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.
 

spinal_cord

Knows his stuff
Member
Joined
Jul 21, 2007
Messages
3,225
Trophies
1
Age
43
Location
somewhere
Website
spinalcode.co.uk
XP
3,375
Country
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.
 

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
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)); }
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,033
Country
United States
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.
 

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
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,

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
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.
 

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

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

Garcia98

Hey! Listen!
Member
Joined
Sep 8, 2015
Messages
361
Trophies
0
Location
Salamanca
Website
github.com
XP
267
Country
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

General chit-chat
Help Users
  • No one is chatting at the moment.
    NinStar @ NinStar: unless nintendo is going to start selling consoles at a loss that thing won't be cheap based on...