Following up on his previous Guide to Compile PS3 Homebrew via PSL1GHT, today Scognito posted on Sconsole which details a simple function for printing strings on PS3 for developers.
Download: Sconsole PS3 Demo and PKG File v0.1 with Source Code
To quote: PSL1GHT is a fantastic SDK, growing day after day thanks to help of talented developers like phiren, MattP, AerialX and others.
What I need to start porting Scogger is to print some debug information (like screen size, sprites information and such), but unfortunately for me STDOUT and STDERR are redirected to the lv2 TTY interface.
Right now there are two ways I know for printing debug informations:
- using Kammy
- using libcairo font support provided by ps3libraries
Altought these are valid alternatives, they represent a complexity level that is too much for my lazyness: Kammy requires PS3 attached to the router via ethernet cable, plus it prints information to a pc, not to the screen. Most important it needs a peek/poke capable payaload, and my PSJailbreak dongle doesn't have it.
Libcairo is new to me, it has amazing power but for now I don't want to learn another library, also it is a waste to use it just for replacing printf.
That's why I created very simple console, called Sconsole, whose job is to print some text on framebuffer using 8×16 fonts.
Let's see how to use it:
Using Sconsole
Using Sconsole is very simple: just add the three files included in the zip file in your source directory and you are almost done.
Let's see an example.
The first thing to do is actually import the header file:
Then we need to initialize it, here it is the syntax:Code:#include "sconsole.h"
- bgcolor is the background color of the printed string,Code:void sconsoleInit(int bgColor, int fgColor, int screenWidth, int screenHeight);
- fcColor is the actual font color
- screenWidth and screenHeight are your screen resolution
Colors are in the 0xAARRGGBB format (alpha channel not available). Few colors are defined in sconsole.h but you can use yours. Also FONT_COLOR_NONE means no color ("transparent"),
ScreenWidth and ScreenHeight are actually the screen resolution you get with videoGetResolution function.
Printing function needs X and Y coordinates, plus the pointer to the framebuffer where write into.Code:sconsoleInit(FONT_COLOR_NONE, FONT_COLOR_BLACK, res.width, res.height);
Or using sprintf before actually print comples strings:Code:print(400, 80, "Hello world", framebuffer);
Dead simpleCode:sprintf(tempString, "Video resolution: %dx%d", res.width, res.height); print(540, 160, tempString, framebuffer);
Please note: 108 ASCII characters are included (most used ones). They are from 32 (space) to 126 (~) of the ASCII table. They include digits, uppercase & lowecase letters, pluse other ones like parenthesis, plus minus, commas...
Hope it will help someone, waiting for screen output of STDOUT/STDERR.
Happy coding!
More PlayStation 3 News...
13261 HeyManHRU
13219 PS3 News
11307 elser1
11169 oVERSoLDiER
9248 GrandpaHomer
8628 Tidusnake666
7968 saviour07
7340 condorstrike
7258 deank
6858 OGroteKoning
25103 PS3 News
5279 Starlight
2964 HeyManHRU
2178 elser1
2174 CJPC
1815 cfwprophet
1756 her0
1573 oVERSoLDiER
1294 GrandpaHomer
1080 barrybarryk





