// File : fwDirect.h // Author : John Wojcik ( QuietBloke ) // Created : August 2000 // Desc : 2D Game Framework Director manager. This manager // is the top level manager. It initialises the display // the begin with. It then co-oridnates the various other // managers in order to refresh the display. // // History : // Date Author Description // -------- --------------- ---------------------------------------- // 01/10/00 J.Wojcik Added call to allow the default background colour to be set ( r,g,b values ) // 12/11/00 J.Wojcik Bug fixed when reducing lifespans where first actor was not updated. #include #include // #include "fwactor.h" // #include "fwdirect.h" #include "fw.h" #define OT_LENGTH 1 GsOT Wot[2]; GsOT_TAG Wtags [2][1< 255 ) { // This mode MUST be in interlaced.mode GsInitGraph ( PIXEL_SCREEN_WIDTH, PIXEL_SCREEN_HEIGHT, GsINTER | GsOFSGPU, 0, 0 ); GsDefDispBuff ( 0,0,0,0 ); } else { GsInitGraph ( PIXEL_SCREEN_WIDTH, PIXEL_SCREEN_HEIGHT, GsNONINTER | GsOFSGPU, 0, 0 ); GsDefDispBuff ( 0,0,0,PIXEL_SCREEN_HEIGHT ); } GsDISPENV.screen.x = 1; GsDISPENV.screen.y = 18; GsDISPENV.screen.w = 255; GsDISPENV.screen.h = 255; Wot[0].length = OT_LENGTH; Wot[1].length = OT_LENGTH; Wot[0].org = Wtags[0]; Wot[1].org = Wtags[1]; GsClearOt ( 0,0, &Wot[0] ); GsClearOt ( 0,0,&Wot[1]); side = GsGetActiveBuff (); GsSetWorkBase ( (PACKET*) PacketArea[side]); // Gotta initialise the pad manager too fwPadInit (); } void fwDirectSetBackGround ( int redValue, int greenValue, int blueValue ) { bgRed = redValue; bgGreen = greenValue; bgBlue = blueValue; } // Given a actual sprite this function simply adds it to the // World Ordering table // void fwDirectWrite ( GsSPRITE *sprite ) { // GsSortFastSprite ( sprite, &Wot[side],0 ); GsSortSprite ( sprite, &Wot[side],0 ); } // This function actual refreshes the display // The first thing to do is update the animations. // Next we cycle through all the actors currently // defined as being On Stage. It then passes the actual // low level sprite on to be added to the World Ordering table // Finally the low level libraries are called to syncronize with // the display, swap display buffers and begin processing // this new World ordering table. // void fwDirectRefresh ( void ) { int CurrentActor; // int ActorID; // Lets update all our animations first fwAnimate ( ); // Cycle through all the Actors On stage // and write them to the Ordering table CurrentActor = fwActorFirstOnStage (); while ( CurrentActor != -1 ) { fwDirectWrite ( fwActorGet(CurrentActor) ); fwActorReduceLifeSpan ( CurrentActor ); CurrentActor = fwActorNextOnStage ( CurrentActor ); } if ( PIXEL_SCREEN_HEIGHT > 255 ) { // Slightly different if runnning in interlaced mode hsync = VSync (0); ResetGraph(1); } else { DrawSync(0); hsync = VSync (0); } GsSwapDispBuff(); GsSortClear ( bgRed, bgGreen , bgBlue, &Wot[side] ); GsDrawOt (&Wot[side] ); side = GsGetActiveBuff (); GsSetWorkBase ( ( PACKET*) PacketArea[side] ); GsClearOt ( 0, 0 , &Wot[side] ); } int fwDirecthSync (void) { return ( hsync ); } int fwDirectScreenWidth(void) { return ( PIXEL_SCREEN_WIDTH ); } int fwDirectScreenHeight(void) { return ( PIXEL_SCREEN_HEIGHT ); }