Пример #1
0
int main()
{
    #ifdef  DEBUG
    cout<<"define DEBUG"<<endl;
    #endif

    printf("words:%s\n", TEST(hello));
    //cout<<TOKEN(a,b)<<endl;
    myprintf("log:%d\n", 1);
    myprintf("log:hi\n");
    //mynoprintf("log:hi\n",);
    argprintf("log:%d\n", 1);
    argprintf("log:hi\n");

    printf("This file:%s\n", THISFILE);
    printf("This fun:%s\n", THISFUNCTION);
    printf("This line:%d\n", THISLINE);
    printf("This time:%s\n", THISTIME);
    printf("This time:%s\n", THISDATE);
}
Пример #2
0
/* video worker thread */
void
videoWorker ( void *arg )
{
  static s32 frames ;
  static time_t starttime ;
  dbgprintf ( "video thread starting" ) ;

  /* cast the void *arg to rsxData */
  videoData* vdata = ( videoData* )arg ;

  /* signal main thread is ready */
  sysCondSignal ( vdata->cond ) ;

  /* lock mutex */
  sysMutexLock ( vdata->mutex, NO_TIMEOUT ) ;

  dbgprintf ( "video thread waiting" ) ;

  /* wait for main to be ready */
  sysCondWait ( vdata->cond, NO_TIMEOUT ) ;

  /* release lock */
  sysMutexUnlock ( vdata->mutex ) ;

  starttime = time( NULL ) ;

  dbgprintf ( "video thread entering loop" ) ;

  /* render frames until exit */
  while ( *vdata->exitapp )
  {
    /* render frame */
    videoDrawFrame ( vdata ) ;
    frames++ ;
  }

  dbgprintf ( "video thread left loop" ) ;

  /* lock mutex */
  sysMutexLock ( vdata->mutex, NO_TIMEOUT ) ;

  /* signal main before exit */
  sysCondSignal ( vdata->cond ) ;

  /* release lock */
  sysMutexUnlock ( vdata->mutex ) ;

  argprintf ( "frame rate: %g frames/sec", ( ( double ) frames ) / difftime ( time ( NULL ) , starttime ) ) ;
  dbgprintf ( "video thread exiting" ) ;

  /* exit thread */
  sysThreadExit ( 0 ) ;
}
Пример #3
0
/* check controller buttons */
inline int
padCheckState ( padBtnData *pdata )
{
  s32 ret = padCheck ( pdata ) ;
  switch ( ret )
  {
    case 0:
      break ;
    case PAD_TRIANGLE:
      dbgprintf ( "PAD_TRIANGLE" ) ;
      *pdata->exitapp = 1 ;
      break ;
    case PAD_CIRCLE:
      dbgprintf ( "PAD_CIRCLE" ) ;
      *pdata->exitapp = 1 ;
      break ;
    case PAD_CROSS:
      dbgprintf ( "PAD_CROSS" ) ;
      *pdata->exitapp = 0 ;
      break ;
    case PAD_SQUARE:
      dbgprintf ( "PAD_SQUARE" ) ;
      *pdata->exitapp = 1 ;
      break ;
    case PAD_SELECT:
      dbgprintf ( "PAD_SELECT" ) ;
      *pdata->exitapp = 1 ;
      break ;
    case PAD_START:
      dbgprintf ( "PAD_START" ) ;
      *pdata->exitapp = 0 ;
      break ;
    default:
      argprintf ( "default: %d", ret ) ;
      break ;
  }
  return 0 ;
}
Пример #4
0
/* initialize resc */
void
rescInitialize ( videoData *vdata )
{
  dbgprintf ( "initializing" ) ;

  static s32 ret ;

  /* Get the state of the display */
  ret = videoGetState (VIDEO_PRIMARY, 0, &vdata->state) ;
  if (ret != 0)
  {
    errprintf ( "ERROR %x", ret ) ;
    goto error;
  }

  /* Make sure display is enabled */
  if (vdata->state.state != 0 )
  {
    errprintf ( "ERROR %x", vdata->state.state ) ;
    goto error;
  }

  /* initialize resc configuration */
  memset (&vdata->rconfig, 0, (size_t)sizeof( rescInitConfig ));

  vdata->rconfig.size = sizeof( rescInitConfig ) ;
  vdata->rconfig.resourcePolicy = RESC_MINIMUM_GPU_LOAD | RESC_CONSTANT_VRAM ;
  vdata->rconfig.supportModes = RESC_1920x1080 | RESC_1280x720 | RESC_720x576 | RESC_720x480 ;
  vdata->rconfig.ratioMode = (vdata->state.displayMode.aspect == ASPECT_4_3) ? RESC_LETTERBOX : RESC_FULLSCREEN ;
  vdata->rconfig.palTemporalMode = RESC_PAL_50 ;
  vdata->rconfig.interlaceMode = RESC_NORMAL_BILINEAR ;
  vdata->rconfig.flipMode = RESC_DISPLAY_VSYNC ;

  ret = rescInit ( &vdata->rconfig ) ;
  if ( ret != 0 )
  {
    errprintf ( "ERROR %x", ret ) ;
    goto error;
  }

  rescVideoResolution2RescBufferMode ( vdata->state.displayMode.resolution, &vdata->bufMode ) ;

  /* 0 */
  {
    vdata->dsts[0].format = RESC_SURFACE_A8R8G8B8 ;
    vdata->dsts[0].pitch = 0xc00 ;
    vdata->dsts[0].heightAlign = 64 ;

    ret = rescSetDsts ( RESC_720x480, &vdata->dsts[0] ) ;
    if ( ret != 0 )
    {
      errprintf ( "ERROR %x", ret ) ;
      goto error;
    }
  }

  /* 1 */
  {
    vdata->dsts[1].format = RESC_SURFACE_A8R8G8B8 ;
    vdata->dsts[1].pitch = 0xc00 ;
    vdata->dsts[1].heightAlign = 64 ;

    ret = rescSetDsts ( RESC_720x576, &vdata->dsts[1] ) ;
    if ( ret != 0 )
    {
      errprintf ( "ERROR %x", ret ) ;
      goto error;
    }
  }

  /* 2 */
  {
    vdata->dsts[2].format = RESC_SURFACE_A8R8G8B8 ;
    vdata->dsts[2].pitch = 0x1400 ;
    vdata->dsts[2].heightAlign = 64 ;

    ret = rescSetDsts ( RESC_1280x720, &vdata->dsts[2] ) ;
    if ( ret != 0 )
    {
      errprintf ( "ERROR %x", ret ) ;
      goto error;
    }
  }

  /* 3 */
  {
    vdata->dsts[3].format = RESC_SURFACE_A8R8G8B8 ;
    vdata->dsts[3].pitch = 0x2000 ;
    vdata->dsts[3].heightAlign = 32 ;

    ret = rescSetDsts ( RESC_1920x1080, &vdata->dsts[3] ) ;
    if ( ret != 0 )
    {
      errprintf ( "ERROR %x", ret ) ;
      goto error;
    }
  }

  ret = rescSetDisplayMode ( vdata->bufMode ) ;
  if ( ret != 0 )
  {
    errprintf ( "ERROR %d", ret ) ;
    goto error;
  }

  ret = rescGetBufferSize ( &vdata->cbuf.size, &vdata->vertbuf.size, &vdata->fragbuf.size ) ;
  if ( ret != 0 )
  {
    errprintf ( "ERROR %d", ret ) ;
    goto error;
  }

  vdata->cbuf.ptr = (void*) rsxMemalign ( 0x10000, vdata->cbuf.size ) ;
  vdata->vertbuf.ptr = (void*) rsxMemalign ( 0x80, vdata->vertbuf.size ) ;
  vdata->fragbuf.ptr = (void*) rsxMemalign ( 0x80, vdata->fragbuf.size ) ;

  ret = rescSetBufferAddress ( vdata->cbuf.ptr, vdata->vertbuf.ptr, vdata->fragbuf.ptr ) ;
  if ( ret != 0 )
  {
    errprintf ( "ERROR %d", ret ) ;
    goto error;
  }

  argprintf("Required size,  color: 0x%x vertex: 0x%x fragment: 0x%x", vdata->cbuf.size, vdata->vertbuf.size, vdata->fragbuf.size);
  argprintf("Buf addr given, color: %p vertex: %p fragment: %p", vdata->cbuf.ptr, vdata->vertbuf.ptr, vdata->fragbuf.ptr);

  /* */
  /* TILING BULLSHIT GOES HERE */
  /* */

  rescSetFlipHandler ( rescFlipCallback ) ;

  rescSetRenderTarget ( vdata ) ;

  return ;
  
  error:
  {
    return ;
  }
}