Sponsored Links

Sponsored Links

Results 1 to 6 of 6



  1. #1
    Forum Moderator PS3 News's Avatar
    Join Date
    Apr 2005
    Posts
    27,452
    Sponsored Links

    Sconsole Details a Simple Function for Printing Strings on PS3

    Sponsored Links
    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:
    Code:
    #include "sconsole.h"
    Then we need to initialize it, here it is the syntax:
    Code:
    void sconsoleInit(int bgColor, int fgColor, int screenWidth, int screenHeight);
    - bgcolor is the background color of the printed string,
    - 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.
    Code:
    sconsoleInit(FONT_COLOR_NONE, FONT_COLOR_BLACK, res.width, res.height);
    Printing function needs X and Y coordinates, plus the pointer to the framebuffer where write into.
    Code:
    print(400, 80, "Hello world",  framebuffer);
    Or using sprintf before actually print comples strings:
    Code:
    sprintf(tempString, "Video resolution: %dx%d", res.width, res.height);
    print(540, 160,  tempString, framebuffer);
    Dead simple

    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!

    Sconsole Details a Simple Function for Printing Strings on PS3

    More PlayStation 3 News...
    Attached Files Attached Files

  2. #2
    Registered User luisfg3's Avatar
    Join Date
    Mar 2010
    Posts
    39
    Sponsored Links
    Sponsored Links
    Nice work for devs, thanks

  3. #3
    Senior Member oVERSoLDiER's Avatar
    Join Date
    Jan 2010
    Posts
    1,623
    Sponsored Links

    Question

    Sponsored Links
    For what this should be good ? Printing out is an old technical thing. Don't know which Dev should be interested in this.

  4. #4
    Contributor craidoug's Avatar
    Join Date
    Sep 2010
    Posts
    11
    Sponsored Links
    Sponsored Links
    Oh, it's just the most important debugging tool ever

  5. #5
    Senior Member shummyr's Avatar
    Join Date
    Sep 2008
    Posts
    739
    you're absolutely correct, it is the most important tool to a programmer.

  6. #6
    Forum Moderator PS3 News's Avatar
    Join Date
    Apr 2005
    Posts
    27,452

    Arrow Homebrew - Scogger Running on PS3

    Just a minor (video only) update:
    Scognito tweeted today that his homebrew game, Scogger, which is already available on several gaming platforms, is now running on PS3. There is no download available yet, for the PS3 version of Scogger. However, Scognito did post a video of the game running.

    For those of you unfamiliar with Scogger, Scognito had the following to say about the game:

    Scogger is a simple puzzle game. The goal of the game is to make the frog jump over all the tree trunks. The only avaiable direction the frog can move are forward, left and right (no diagonals), with no jump distance limit! Remember that the frog cannot jump backward!
    First playable scogger running on PS3! It lacks sound and still runs at 640x480 for now:




    Also below, from Franc[e]sco via: rvlution.net/forums/viewtopic.php?f=41&t=836

    CConsole - A wrapper class for sconsole

    Heya, I just started learning PS3 developing and here's my first contribution. I came across sconsole which is a great little snippet to print console-like text. So I decided it to make a wrapper class for it that makes it actually work like a console (you can set the line wrap width and the maximum number of lines).

    Here's an example homebrew with source that uses my class --> Download: [Register or Login to view links]
    *Note: i slightly modified sconsole to make it work with c++ (changed the .c file to .cpp and made the struct extern in the .h)

    Using CConsole is pretty simple:
    - Put sconsole.h, Vector2f.hpp, and CConsole.hpp in your include folder
    - Put sconsole.cpp, Vectro2f.cpp and CConsole.cpp in your source folder

    Now you can just include it and use it right away:
    Code:
        #include "CConsole.hpp"
        ...
        // (after initializing video)
        sconsoleInit(FONT_COLOR_NONE, FONT_COLOR_BLACK, res.width, res.height); // Initialize sConsole
        ...
        // (inside the main loop)
        unsigned long max_lines = 20;
        unsigned long max_width = 30;
        CVector2f position(10.0, 10.0);
        CConsole myconsole(position, max_lines, max_width);
        myconsole.write("Hello World!");
    
        console.draw(buffer[currentBuffer]);
    Check out CConsole.hpp for a list of all the available methods:
    Code:
        #ifndef _CCONSOLE_HPP_
        #define _CCONSOLE_HPP_
    
        #include "CVector2f.hpp"
        #include "sconsole.h"
    
        #include <vector>
        #include <string>
        using namespace std;
    
        class CConsole {
        public:
           CConsole(const CVector2f &pos, unsigned long max_rows, unsigned long width);
           ~CConsole();
           void write(const char *text);
           void clear();
           void draw(s32 *buffer);
           
           void setMaxRows(unsigned long max_rows);
           void setWidth(unsigned long width);
           void setPosition(const CVector2f &pos);
           unsigned long getMaxRows();
           unsigned long getWidth();
           CVector2f &getPosition();
           
        private:
           CVector2f pos;
           unsigned long max_rows, width;
           vector<string> rows;
        };
    
        #endif
    Attached Images<br><br> Attached Images


 

Sponsored Links

Affiliates - Contact Us - PS3 Downloads - Privacy Statement - Site Rules - Top - © 2014 PlayStation 3 News