Subversion Repositories psp

[/] [trunk/] [pl_test/] [pspui.c] - Rev 366

Go to most recent revision | Compare with Previous | Blame | View Log

#include <psptypes.h>
#include <pspkernel.h>
#include <psprtc.h>
#include <pspgu.h>
 
#include "ctrl.h"
 
#include "pl_image.h"
#include "pl_psp.h"
#include "pl_gfx.h"
#include "pl_font.h"
#include "pl_perf.h"
 
PSP_MODULE_INFO(PSP_APP_NAME, 0, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
 
static void psp_exit_callback(void* arg)
{
  ExitPSP = 1;
}
 
/**************************/
/* PSP main()             */
/**************************/
int main(int argc, char *argv[])
{
  SceCtrlData pad;
 
  /* Initialize PSP */
  pl_psp_init(argv[0]);
  if (!pl_gfx_init(pl_gfx_5551))
    return(0);
 
  /* Initialize callbacks */
/* TODO: change callback setup */
  pl_psp_register_callback(PSP_EXIT_CALLBACK,
                           psp_exit_callback,
                           NULL);
  pl_psp_start_callback_thread();
 
  pl_image image, image2;
  pl_font font;
  pl_perf_counter counter;
  if (!pl_image_load(&image, "background.png"))
    return(0);
 
  image.view.x += 10;
  image.view.y += 10;
  image.view.w -= 20;
  image.view.h -= 20;
 
  if (!pl_image_load(&image2, "background.png"))
    return(0);
 
  if (!pl_font_load(&font, "arialnarrow.png"))
    return(0);
 
  pl_perf_init_counter(&counter);
  char pfdata[128];
 
  int ScreenW = image.view.w, ScreenH = image.view.h;
  while (!ExitPSP)
  {
    pspCtrlPollControls(&pad);
    if (pad.Buttons & PSP_CTRL_RIGHT) ScreenW++;
    else if (pad.Buttons & PSP_CTRL_LEFT) ScreenW--;
    if (pad.Buttons & PSP_CTRL_DOWN) ScreenH++;
    else if (pad.Buttons & PSP_CTRL_UP) ScreenH--;
 
    pl_gfx_start_draw();
 
    pl_gfx_clear();
 
    pl_gfx_put_image(&image2, 0, 0, 480, 272);
    pl_gfx_put_image(&image, 100, 100, ScreenW, ScreenH);
    pl_gfx_draw_rect(100, 100, 100+ScreenW, 100+ScreenH, 0xffffffff);
 
 
    sprintf(pfdata, "%.02f", pl_perf_update_counter(&counter));
pl_gfx_print(&font, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 50, 50);
pl_gfx_print(&font, "abcdefghijklmnopqrstuvwxyz 0123456789", 50, 70);
pl_gfx_print(&font, pfdata, 10, 10);
 
    pl_gfx_end_draw();
    pl_gfx_flip();
//    pl_gfx_sync();
  }
 
  pl_image_destroy(&image);
  pl_image_destroy(&image2);
  pl_font_destroy(&font);
 
  /* Release PSP resources */
  pl_gfx_shutdown();
  pl_psp_shutdown();
 
  return(0);
}
 

Go to most recent revision | Compare with Previous | Blame | View Log