// File : main.c // Coded by : Scotte // History : Created 14/03/00 22:54:09 // // Description : Example of how to use profiler // // Notes : None #define PAL #include #include #include "yaroze.h" #include "main.h" #include "dbuffer.h" #include "profile.h" #include "console.h" // Ordering table static GsOT wot[2]; static GsOT_TAG wtags[2][OTSIZE]; // Packet buffer static PACKET packets[2][PBSIZE]; // Screen dimensions const RECT screen={0,0,SCREEN_W,SCREEN_H}; // Simple example functions to profile void Draw2DBoxTest(GsOT *); void TestMultiplication(void); void TestDivision(void); void TestAddition(void); void TestSubtraction(void); int main(void) { GsOT *ot; u_word end; u_hword frametime,pad,hsync; // Initialise the program Initialise(VIDEO_MODE); // Set up the double buffer DBUFFER_Set(&screen,OFFX,OFFY); // Set up the ordering table wot[0].length=wot[1].length=OT_LENGTH; wot[0].org=wtags[0]; wot[1].org=wtags[1]; DBUFFER_SetOT(&wot[0]); DBUFFER_SetPB(&packets[0][0],PBSIZE); // Initialise the font FntLoad(screen.w,0); FntOpen(8,8,screen.w,screen.h,0,1024); srand(VSync(-1)); end=0; frametime=PROFILE_Frametime(); mMESSAGE("Profile example coded by Scotte\n"); mMESSAGE("sevans@acclaimstudios.co.uk\n"); while(!end) { ot=DBUFFER_CurrentOT(); // Read the controllers pad=PadRead(0); // End the program when select is pressed end=pad&PADselect; // Example of how to use the profiler mPROFILE_READ(0x0,0x0,0x0); Draw2DBoxTest(ot); // Record time taken to execute Draw2DBoxTest() mPROFILE_READ(0x0,0x0,0x80); TestDivision(); // Record time taken to execute TestDivision() mPROFILE_READ(0x80,0x0,0x80); TestMultiplication(); // Record time taken to execute TestMultiplication() mPROFILE_READ(0x0,0x80,0x80); TestAddition(); mPROFILE_READ(0x80,0x80,0x0); TestSubtraction(); mPROFILE_READ(0x80,0x40,0x40); // Update display and start drawing hsync=DBUFFER_Swap(); FntPrint("~c999Profile example coded by Scotte\n"); FntPrint("sevans@acclaimstudios.co.uk\n\n"); FntPrint("~c009Press SELECT to quit\n\n"); FntPrint("~c090Hsync=%d (One frame=%d)\n",hsync,frametime); FntFlush(-1); } // Quit back to Siocons ResetGraph(3); return(0); } // Function : Draw2DBoxTest() // Coded by : Scotte // History : Created 14/03/00 22:47:13 // // Description : None // // Parameters : None // // Returns : None // // Notes : None void Draw2DBoxTest(GsOT *ot) { GsBOXF *box=(GsBOXF *)mSCRATCHADDR(0); u_word i; for(i=0;i<200;i++) { box->r=rand()%0x40; box->g=rand()%0x40; box->b=rand()%0x40; box->x=rand()%screen.w; box->y=rand()%screen.h; box->w=2+(rand()%30); box->h=2+(rand()%30); GsSortBoxFill(box,ot,1); } } // Function : TestDivision() // Coded by : Scotte // History : Created 14/03/00 22:52:07 // // Description : Do some division calculations // // Parameters : None // // Returns : None // // Notes : None void TestDivision(void) { u_word i,n; for(n=0xffffffff,i=0;i<5000;i++) { n=n/5; } } // Function : TestMultiplication() // Coded by : Scotte // History : Created 14/03/00 22:52:07 // // Description : Do some multiplication calculations // // Parameters : None // // Returns : None // // Notes : None void TestMultiplication(void) { u_word i,n; for(n=0xffffffff,i=0;i<5000;i++) { n=n*5; } } // Function : TestAddition() // Coded by : Scotte // History : Created 14/03/00 22:52:07 // // Description : Do some addition calculations // // Parameters : None // // Returns : None // // Notes : None void TestAddition(void) { u_word i,n; for(n=0,i=0;i<5000;i++) { n+=10; } } // Function : TestSubtraction() // Coded by : Scotte // History : Created 14/03/00 22:52:07 // // Description : Do some subtraction calculations // // Parameters : None // // Returns : None // // Notes : None void TestSubtraction(void) { u_word i,n; for(n=0,i=0;i<5000;i++) { n-=10; } }