- Main Page
- Modules
- Data Structures
- Files

- Search for |

# debug.c

    00001 /*
    00002
    00003   Velocity  v1.5
    00004   Copyright 2006, 2007 Gabriel Anderson
    00005
    00006   This program is free software; you can redistribute it and/or modify
    00007     it under the terms of the GNU General Public License as published by
    00008     the Free Software Foundation; either version 2 of the License, or
    00009     (at your option) any later version.
    00010
    00011     This program is distributed in the hope that it will be useful,
    00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00014     GNU General Public License for more details.
    00015
    00016     You should have received a copy of the GNU General Public License
    00017     along with this program; if not, write to the Free Software
    00018     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    00019
    00020 */
    00021
    00022 //---------------------------------------------------------------------------------//
    00023 // Includes                                                                        //
    00024 //---------------------------------------------------------------------------------//
    00025
    00026 #include "vlib.h"
    00027
    00028 //---------------------------------------------------------------------------------//
    00029 // Debugging                                                                       //
    00030 //---------------------------------------------------------------------------------//
    00031
    00032 void fps() {
    00033   // FPS
    00034   curFps++;
    00035   sceRtcGetCurrentTick ( &fpsTickNow );
    00036
    00037   if ( ( ( fpsTickNow - fpsTickLast ) / ( ( float ) tickResolution ) ) >= 1.0f ) {
    00038     fpsTickLast = fpsTickNow;
    00039     lastFps = curFps;
    00040     curFps = 0;
    00041   }
    00042
    00043   pspDebugScreenSetOffset ( ( int ) fbp0 );
    00044   pspDebugScreenSetXY ( 0, 0 );
    00045   pspDebugScreenPrintf ( "FPS: %d", ( int ) lastFps );
    00046 }
    00047
    00048 void fpsX ( const char *format, ... ) {
    00049   va_list opt = 0;
    00050   char buff[2048];
    00051   va_start ( opt, format );
    00052   vsnprintf ( buff, ( size_t ) sizeof ( buff ), format, opt );
    00053
    00054   // FPS
    00055   curFps++;
    00056   sceRtcGetCurrentTick ( &fpsTickNow );
    00057
    00058   if ( ( ( fpsTickNow - fpsTickLast ) / ( ( float ) tickResolution ) ) >= 1.0f ) {
    00059     fpsTickLast = fpsTickNow;
    00060     lastFps = curFps;
    00061     curFps = 0;
    00062   }
    00063
    00064   pspDebugScreenSetOffset ( ( int ) fbp0 );
    00065   pspDebugScreenSetXY ( 0, 0 );
    00066   pspDebugScreenPrintf ( "FPS: %d\n%s", ( int ) lastFps, buff );
    00067 }
    00068
    00069 void sysmon() {
    00070   // FPS
    00071   curFps++;
    00072   sceRtcGetCurrentTick ( &fpsTickNow );
    00073
    00074   if ( ( ( fpsTickNow - fpsTickLast ) / ( ( float ) tickResolution ) ) >= 1.0f ) {
    00075     fpsTickLast = fpsTickNow;
    00076     lastFps = curFps;
    00077     curFps = 0;
    00078   }
    00079
    00080   pspDebugScreenSetOffset ( ( int ) fbp0 );
    00081   pspDebugScreenSetXY ( 0, 0 );
    00082   pspDebugScreenPrintf ( "FPS: %d Ram: %d Vram: %d  Graphics Mem: %d", ( int ) lastFps, sceKernelMaxFreeMemSize(), vmemavail(), 262144 - sceGuCheckList() );
    00083 }
    00084
    00085 void sysmonX ( const char *format, ... ) {
    00086   va_list opt = 0;
    00087   char buff[2048];
    00088   va_start ( opt, format );
    00089   vsnprintf ( buff, ( size_t ) sizeof ( buff ), format, opt );
    00090
    00091   // FPS
    00092   curFps++;
    00093   sceRtcGetCurrentTick ( &fpsTickNow );
    00094
    00095   if ( ( ( fpsTickNow - fpsTickLast ) / ( ( float ) tickResolution ) ) >= 1.0f ) {
    00096     fpsTickLast = fpsTickNow;
    00097     lastFps = curFps;
    00098     curFps = 0;
    00099   }
    00100
    00101   pspDebugScreenSetOffset ( ( int ) fbp0 );
    00102   pspDebugScreenSetXY ( 0, 0 );
    00103   pspDebugScreenPrintf ( "FPS: %d Mem: %d Vram: %d  Graphics Mem: %d\n%s", ( int ) lastFps, sceKernelMaxFreeMemSize(), vmemavail(), 262144 - sceGuCheckList(), buff );
    00104 }
    00105
    00106 u64 epoch = 0;
    00107 u64 timeTaken = 0;
    00108
    00109 void start_ticker() {
    00110   sceRtcGetCurrentTick ( &epoch );
    00111 }
    00112
    00113 int end_ticker() {
    00114   sceRtcGetCurrentTick ( &timeTaken );
    00115   timeTaken -= epoch;
    00116   return timeTaken;
    00117 }