Steves Yaroze Page.
"Anything is possible, even Impossible sais "I'm possible".


Up

Scrolly Message Heaven

Download

Scrolly messages everywhere

This is a small (and completely crap) demo used to demonstrate some C++ classes that wrap the Yaroze API.  To run, simply load scrolly.exe using either siocons or pscomutil, then 'go'.  The purpose of this demos is to demonstrate how simply things can be done with classes.

The classes used in this demo include...

CWorld The main 'world'
CPad Class that handles the joy-pad
CDrawTable Class that handle 'CDrawableObject's.  Wraps the order table stuff
CTextMessage Class that handles a scrolly text message
CFrameBuffer Class that handles loading and transferring of frame buffer items
CFastSprite Sprite class
CSprite A 'non-fast' sprite class, ie. handles rotation etc.
CDrawableObject Virtual base class of anything that can be drawn
CContralableObject Virtual base class of anything that can be controlled

If anyone would like to see how 'C++' things are done, I'll update the classes page with information.  To give you some idea, here's the 'main.cpp'


#include "Main.h"
#include "TextMessage.h"

extern unsigned char fontData[] ;

LPWORLD               pWorld ;
CFrameBufferItem     frameBuffer ;

LPORDERTABLE*        ppOrderTables ;
CTextMessage**       ppMessages ;

struct _a
{
    char*    pMessage;
    short speed;
    short y ;
} steve[] =
{
    { "message 1 message 1 message 1 message 1 message 1 message 1 ", 1, -100 },
    { "message 2 message 2 message 2 message 2 message 2 message 2 ", 2, -60 },
    { "message 3 message 3 message 3 message 3 message 3 message 3 ", 3, -20 },
    { "message 4 message 4 message 4 message 4 message 4 message 4 ", 3, 20 },
    { "message 5 message 5 message 5 message 5 message 5 message 5 ", 2, 60 },
    { "message 6 message 6 message 6 message 6 message 6 message 6 ", 1, 100 },
    { NULL,0,0 } ,
};

int getTableSize( ) ;
int InitSprite (void); // init the sprites

void main(void)
{
    u_long PADstatus=0;     // pad status
    CPad thePad ;            // initialise the joypad
    SetVideoMode(MODE_PAL);
    pWorld = new(CWorld);
    pWorld->init( 5 ) ;
    SetVideoMode(MODE_PAL);
    GsDefDispBuff(0, 0, 0, SCREEN_HEIGHT);
    FntLoad(960, 256);
    FntOpen(-140, -120, 252, 222, 0, 512);
    GsInitGraph(SCREEN_WIDTH, SCREEN_HEIGHT, GsINTER|GsOFSGPU, 1, 0);
    GsInit3D( ) ;

    pWorld->setPacketSize( 500 * 24 ) ;
    pWorld->setColor( 128,128,128 ) ;

    if ( InitSprite( ) == 0 ) // init the sprite structure
    {
        printf("initsprite failed");
        return ;
    }

    for (;;) // loop till end
    {
   

        PADstatus= (ulong)thePad ;

        if (PADstatus & PADstart) // check controller for Select
            break; // button.

        int ts = getTableSize( ) ;
        for ( int i = 0 ; i < ts; i++ )
        {
            CTextMessage* p = (*(ppMessages+i) ) ;
            if ( p )
                p->scroll( steve[i].speed ) ;
        }
               
        pWorld->startDrawing( ) ;
        LPORDERTABLE pFirstTable = *ppOrderTables ;
        pFirstTable->draw( ) ;
        for ( int i = 1 ; i < ts; i++ )
        {
            LPORDERTABLE p =         (*(ppOrderTables+i)) ;
            if ( p )
                p->draw( pFirstTable ) ;
        }
        pWorld->finishDrawing( ) ;
       
    }
    ResetGraph(3); // set the video mode back
    return ;
}

int InitSprite (void)
{
//    CFile f ;
//    u_char* p = (u_char*)f.load("font.tim" ) ;

    u_char* p = (u_char*)fontData ;

    frameBuffer.load( (ulong)p ) ;         //put it into the frame buffer

    int ts = getTableSize( ) ;
   
    ppOrderTables = (LPORDERTABLE*)malloc( ts * sizeof( LPORDERTABLE ) );
    ppMessages = (CTextMessage**)malloc( ts * sizeof( CTextMessage* ) );
   
    for ( int i = 0 ; i < ts ; i++ )
    {
        LPORDERTABLE pOrderTable = new(COrderTable) ;
        *(ppOrderTables+i) = pOrderTable ;

        CTextMessage* pMessage = new(CTextMessage ) ;
        *(ppMessages+i) = pMessage ;

        pOrderTable->setSize( 150 );
        pOrderTable->setResolution( 1 ) ;

        char* pText = steve[ i ].pMessage ;
        short speed = steve [ i ].speed ;
        short y = steve[ i ].y ;
        pMessage->setChar( CHAR_WIDTH, CHAR_HIEGHT, &frameBuffer ) ;
        pMessage->setScreen( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
        pMessage->setOrderTable( pOrderTable ) ;
        pMessage->setPosition(      SCREEN_WIDTH/2, y ) ;

        *pMessage = pText ;
        *pWorld+=pOrderTable ;
    }

    pWorld->setColor( 0,0,0 ) ;
    return 1;
}

int
getTableSize( )
{
    int i = -1 ;
    while( steve[++i].pMessage ) ;
    return i ;
}


Visit my other home-page

ICQ:14349918

Sign My Guestbook   View My Guestbook
Guestbook by GuestWorld
Last updated 9th August 1998.   This page has been visited Times