Author Topic: Does the psp have a proper framebuffer mode?  (Read 8395 times)

0 Members and 1 Guest are viewing this topic.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
ive been looking into 2d pixel plotting on the psp and the best i can see is creating a texture and pushing pixels onto that but thats got to be slower than a true frame buffer right? i know that if i use texture cach it speeds the process up monumentally but i still dont think it would be as fast as say the ds`s 2d core frame buffer mode.

im guessing the psp has no 2d core though so everything has to be done 3d. is this correct.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #1 on: July 02, 2007 »
You can poke the screen memory directly.  Just choose some area of vram for the screen, point the GE at that screen and poke away to your heart's content.  You can double buffer simply by allocating 2 areas.
Some info here http://wiki.ps2dev.org/.

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #2 on: July 03, 2007 »
ohh exellent link cheers jim!
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #3 on: July 03, 2007 »
does this look ok jim im getting 73 fps so im guessing its not to bad.

i was getting 713 fps before i started updating the xor image each frame.
Code: [Select]
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

#include <pspctrl.h>
#include <pspgu.h>
#include <psprtc.h>

#include "../common/callbacks.h"
#include "../common/vram.h"

PSP_MODULE_INFO("FrameBuffer", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

static unsigned int __attribute__((aligned(16))) list[262144];

#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)

static unsigned short __attribute__((aligned(16))) pixels[BUF_WIDTH*SCR_HEIGHT];

struct Vertex
{
  unsigned short u, v;
  unsigned short color;
  short x, y, z;
};


void advancedBlit(int sx, int sy, int sw, int sh, int dx, int dy, int slice)
{
  int start, end;

  // blit maximizing the use of the texture-cache

  for (start = sx, end = sx+sw; start < end; start += slice, dx += slice)
  {
    struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
    int width = (start + slice) < end ? slice : end-start;

    vertices[0].u = start; vertices[0].v = sy;
    vertices[0].color = 0;
    vertices[0].x = dx; vertices[0].y = dy; vertices[0].z = 0;

    vertices[1].u = start + width; vertices[1].v = sy + sh;
    vertices[1].color = 0;
    vertices[1].x = dx + width; vertices[1].y = dy + sh; vertices[1].z = 0;

    sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_4444|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,0,vertices);
  }
}


int main(int argc, char* argv[])
{
  unsigned int x,y,xs,ys;

  pspDebugScreenInit();
  setupCallbacks();

  void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
  void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);
  void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444);

  sceGuInit();

  sceGuStart(GU_DIRECT,list);
  sceGuDrawBuffer(GU_PSM_8888,fbp0,BUF_WIDTH);
  sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
  sceGuDepthBuffer(zbp,BUF_WIDTH);
  sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
  sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
  sceGuDepthRange(65535,0);
  sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
  sceGuEnable(GU_SCISSOR_TEST);
  sceGuFrontFace(GU_CW);
  sceGuEnable(GU_TEXTURE_2D);
  sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
  sceGuFinish();
  sceGuSync(0,0);

  sceDisplayWaitVblankStart();
  sceGuDisplay(1);

  void* vram_buffer;
  vram_buffer = getStaticVramTexture(BUF_WIDTH,SCR_HEIGHT,GU_PSM_8888);

  float curr_ms = 1.0f;

  sceCtrlSetSamplingCycle(0);
  sceCtrlSetSamplingMode(0);

  u64 last_tick;
  sceRtcGetCurrentTick(&last_tick);
  u32 tick_frequency = sceRtcGetTickResolution();
  int frame_count = 0;

  while(running())
  {
    for (y = 0; y < SCR_HEIGHT; ++y)
    {
         unsigned short* row = &pixels[y * BUF_WIDTH];
         for (x = 0; x < SCR_WIDTH; ++x)
         {
              row[x] = (x+xs)*(y+ys);
         }
    }
    memcpy( vram_buffer , pixels , ( BUF_WIDTH * 2 ) * SCR_HEIGHT);

    xs+=1;
    ys+=1;

    sceKernelDcacheWritebackAll();

    sceGuStart(GU_DIRECT,list);

    sceGuTexMode(GU_PSM_4444,0,0,0);
    sceGuTexImage(0,512,512,512,vram_buffer);
    sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA);
    sceGuTexFilter(GU_NEAREST,GU_NEAREST);

    advancedBlit(0,0,SCR_WIDTH,SCR_HEIGHT,0,0,64);

    sceGuFinish();
    sceGuSync(0,0);

    float curr_fps = 1.0f / curr_ms;

    pspDebugScreenSetOffset((int)fbp0);
    pspDebugScreenSetXY(0,0);
    pspDebugScreenPrintf("fps: %d.%03d (%dMB/s)",(int)curr_fps,(int)((curr_fps-(int)curr_fps) * 1000.0f),(((int)curr_fps * SCR_WIDTH * SCR_HEIGHT * 2)/(1024*1024)));

    fbp0 = sceGuSwapBuffers();

    ++frame_count;
    u64 curr_tick;
    sceRtcGetCurrentTick(&curr_tick);
    if ((curr_tick-last_tick) >= tick_frequency)
    {
      float time_span = ((int)(curr_tick-last_tick)) / (float)tick_frequency;
      curr_ms = time_span / frame_count;

      frame_count = 0;
      sceRtcGetCurrentTick(&last_tick);
    }
  }

  sceGuTerm();

  sceKernelExitGame();
  return 0;
}
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #4 on: July 03, 2007 »
It looks like you're drawing to system ram, copying it to vram (memcpy) and then using a blit to get it on screen.  You can miss out either of the last two steps.

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #5 on: July 03, 2007 »
Ah yes yes i see that thanks, so if i write straight to vram would that pretty much be as good as pixel plotting gets on the psp?

-edit ive changed it to this

Code: [Select]
for (y = 0; y < SCR_HEIGHT; ++y)
    {
         unsigned short* row = ((unsigned short*)vram_buffer) + y * BUF_WIDTH ;
         for (x = 0; x < SCR_WIDTH; ++x)
         {
              row[x] = (x+xs)*(y+ys);
         }
    }
    //memcpy( vram_buffer , pixels , ( BUF_WIDTH * 2 ) * SCR_HEIGHT);

and its up at 183fps now so big step up there but it still seems like im doing one step more than needed i thought id be able to just poke the pixels to vram and flip the back buffer up to screen address without the need for a blitter function.

im working from the example blitter code btw.
« Last Edit: July 03, 2007 by ninogenio »
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #6 on: July 03, 2007 »
You can either draw straight to vram, keep 2 frames worth of space available and just flip the pointers each frame (no need for any blits at all), or you can draw to system ram and use the blitter to blit the frame from system memory to vram (either to the visible screen or the backbuffer).

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #7 on: July 03, 2007 »
Right so the way i have things just now with me writing to the drawbuffer vram area and fliping that to the disp buffer area each frame i can simply take away the blitter function and it should still go?
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #8 on: July 04, 2007 »
You need 2 vram areas, one for each buffer.
repeat
 draw to buffer 1
 flip to buffer 1
 draw to buffer 2
 flip to buffer 2
until dead

no blitting needed, you're already drawing in the memory which is being displayed.

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #9 on: July 04, 2007 »
cheers jim im trying what your saying and ive got it screwd up cause the psp`s locking up.

Code: [Select]
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

#include <pspctrl.h>
#include <pspgu.h>
#include <psprtc.h>

#include "../common/callbacks.h"
#include "../common/vram.h"

PSP_MODULE_INFO("FrameBuffer", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

static unsigned int __attribute__((aligned(16))) list[262144];

#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)

static unsigned short __attribute__((aligned(16))) pixels[BUF_WIDTH*SCR_HEIGHT];

struct Vertex
{
  unsigned short u, v;
  unsigned short color;
  short x, y, z;
};

#define RGB(r,g,b) (unsigned short)( ( r << 11 ) + ( g << 6 ) + ( b ) )
int main(int argc, char* argv[])
{
  unsigned int x,y,xs,ys;

  pspDebugScreenInit();
  setupCallbacks();

  void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_5650);
  void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_5650);
  void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444);

  sceGuInit();

  sceGuStart(GU_DIRECT,list);
  sceGuDrawBuffer(GU_PSM_5650,fbp0,BUF_WIDTH);
  sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
  sceGuDepthBuffer(zbp,BUF_WIDTH);
  sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
  sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
  sceGuDepthRange(65535,0);
  sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
  sceGuEnable(GU_SCISSOR_TEST);
  sceGuFrontFace(GU_CW);
  sceGuEnable(GU_TEXTURE_2D);
  sceGuDepthMask(0xffff);
  sceGuDisable(GU_DEPTH_TEST);
  sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
  sceGuFinish();
  sceGuSync(0,0);

  sceDisplayWaitVblankStart();
  sceGuDisplay(1);

  float curr_ms = 1.0f;

  sceCtrlSetSamplingCycle(0);
  sceCtrlSetSamplingMode(0);

  u64 last_tick;
  sceRtcGetCurrentTick(&last_tick);
  u32 tick_frequency = sceRtcGetTickResolution();
  int frame_count = 0;

  while(running())
  {

    xs+=1;
    ys+=1;

    for (y = 0; y < SCR_HEIGHT; ++y)
    {
         unsigned short* row = ((unsigned short*)fbp0) + y * BUF_WIDTH;
         for (x = 0; x < SCR_WIDTH; ++x)
         {
              row[x] = (x+xs)*(y+ys);
         }
    }

    sceKernelDcacheWritebackAll();

    float curr_fps = 1.0f / curr_ms;

    pspDebugScreenSetOffset((int)fbp0);
    pspDebugScreenSetXY(0,0);
    pspDebugScreenPrintf("fps: %d.%03d (%dMB/s)",(int)curr_fps,(int)((curr_fps-(int)curr_fps) * 1000.0f),(((int)curr_fps * SCR_WIDTH * SCR_HEIGHT * 2)/(1024*1024)));

    //sceDisplayWaitVblankStart();

    fbp0 = sceGuSwapBuffers();

    ++frame_count;
    u64 curr_tick;
    sceRtcGetCurrentTick(&curr_tick);
    if ((curr_tick-last_tick) >= tick_frequency)
    {
      float time_span = ((int)(curr_tick-last_tick)) / (float)tick_frequency;
      curr_ms = time_span / frame_count;

      frame_count = 0;
      sceRtcGetCurrentTick(&last_tick);
    }
  }

  sceGuTerm();

  sceKernelExitGame();
  return 0;
}
« Last Edit: July 04, 2007 by ninogenio »
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #10 on: July 05, 2007 »
The only problem I can see is you're always only drawing at fbp0.  You need to switch between fbp0 and fbp1.

Slow down and think about what you're trying to do.  Remove the functions that you calling that aren't doing anything (most of them now, you just need to init, set the 2 frame buffer pointers, and flip), and read the docs for those functions that are left to make sure you've not missed something.

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #11 on: July 05, 2007 »
yeah i was just tying to get something on screen by poking to fbp0 and fliping before switching between fbp0 and 1 each frame the locking up is coming from me poking into fbp0 and i cant figure out why.

i think its the initialization thats messing me up

Code: [Select]
sceGuDrawBuffer(GU_PSM_5650,fbp0,BUF_WIDTH);
sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);

doesnt look right for the way im aiming for.

ive been trying to find some frame buffer examples but most of the stuff ive came across has been a 3d stuff. ill keep going though  :).

this looks promising.

display.h
Code: [Select]
/**
 * Display set framebuf
 *
 * @param topaddr - address of start of framebuffer
 * @param bufferwidth - buffer width (must be power of 2)
 * @param pixelformat - One of ::PspDisplayPixelFormats.
 * @param sync - One of ::PspDisplaySetBufSync
 */
void sceDisplaySetFrameBuf(void *topaddr, int bufferwidth, int pixelformat, int sync);

im just not shure on how to impliment it.

-edit actually ive just dug some info up from google that looks promising ill give it a bash.
« Last Edit: July 05, 2007 by ninogenio »
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #12 on: July 05, 2007 »
i think i might have this sused out now.

does this look about right.
Code: [Select]
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

#include <pspctrl.h>
#include <pspgu.h>
#include <psprtc.h>

#include "../common/callbacks.h"
#include "../common/vram.h"

PSP_MODULE_INFO("FrameBuffer", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

char *DispBuf=(char *)0x44000000;
char *BackBuf=(char *)0x44044000;
char *SwapBuf=(char *)0x44000000;

int main(int argc, char* argv[])
{
  unsigned int x,y,xs,ys;
  unsigned char *vptr0;
 // pspDebugScreenInit();
 // setupCallbacks();

 // void* fbp0 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_5650);
 // void* fbp1 = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_5650);
 // void* zbp = getStaticVramBuffer(BUF_WIDTH,SCR_HEIGHT,GU_PSM_4444);

 // sceGuInit();

 // sceGuStart(GU_DIRECT,list);
 // sceGuDrawBuffer(GU_PSM_5650,fbp0,BUF_WIDTH);
 // sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,fbp1,BUF_WIDTH);
 // sceGuDepthBuffer(zbp,BUF_WIDTH);
 // sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
 // sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
 // sceGuDepthRange(65535,0);
 // sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
 // sceGuEnable(GU_SCISSOR_TEST);
 // sceGuFrontFace(GU_CW);
 // sceGuEnable(GU_TEXTURE_2D);
 // sceGuDepthMask(0xffff);
 // sceGuDisable(GU_DEPTH_TEST);
 // sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
 // sceGuFinish();
 // sceGuSync(0,0);

 // sceDisplayWaitVblankStart();
 // sceGuDisplay(1);

 // unsigned int* vram_buffer;
 // vram_buffer = getStaticVramTexture(BUF_WIDTH,SCR_HEIGHT,GU_PSM_5650);

  //float curr_ms = 1.0f;

 // sceCtrlSetSamplingCycle(0);
 // sceCtrlSetSamplingMode(0);

 // u64 last_tick;
  //sceRtcGetCurrentTick(&last_tick);
  //u32 tick_frequency = sceRtcGetTickResolution();
  //int frame_count = 0;
  sceDisplaySetMode(0,480,272);
  sceDisplaySetFrameBuf(DispBuf,512,1,1);

  sceDisplayWaitVblankStart();
  sceDisplaySetFrameBuf(BackBuf,512,1,1);
  unsigned long i;

  vptr0=BackBuf;
  for (i=0; i<0x44000/2; i++)
  {
    *(unsigned short *)vptr0=0;
    vptr0+=2;
  }
  SwapBuf=DispBuf;
  DispBuf=BackBuf;
  BackBuf=SwapBuf;
  while(running())
  {

    xs+=1;
    ys+=1;

    //vram_buffer=fbp0
    sceDisplaySetMode(0,480,272);
    sceDisplaySetFrameBuf(DispBuf,512,1,1);

    sceDisplayWaitVblankStart();
    sceDisplaySetFrameBuf(BackBuf,512,1,1);

    vptr0=BackBuf;

    for (i=0; i<0x44000/2; i++)
    {
         *(unsigned short *)vptr0=0;
         vptr0+=2;
    }

    for (y = 0; y < 272; ++y)
    {
         unsigned short* row = ((unsigned short*)BackBuf) + y * 512;
         for (x = 0; x < 480; ++x)
         {
              row[x] = (x+xs)*(y+ys);
         }
    }

    SwapBuf=DispBuf;
    DispBuf=BackBuf;
    BackBuf=SwapBuf;
    //memcpy( vram_buffer , pixels , ( BUF_WIDTH * 2 ) * SCR_HEIGHT);

   // sceKernelDcacheWritebackAll();

   // sceGuStart(GU_DIRECT,list);

    //sceGuTexMode(GU_PSM_5650,0,0,0);
    //sceGuTexImage(0,512,512,512,vram_buffer);
    //sceGuTexFunc(GU_TFX_REPLACE,GU_TCC_RGBA);
    //sceGuTexFilter(GU_NEAREST,GU_NEAREST);

    //advancedBlit(0,0,SCR_WIDTH,SCR_HEIGHT,0,0,64);

    //sceGuFinish();
    //sceGuSync(0,0);

    /*float curr_fps = 1.0f / curr_ms;

    pspDebugScreenSetOffset((int)fbp0);
    pspDebugScreenSetXY(0,0);
    pspDebugScreenPrintf("fps: %d.%03d (%dMB/s)",(int)curr_fps,(int)((curr_fps-(int)curr_fps) * 1000.0f),(((int)curr_fps * SCR_WIDTH * SCR_HEIGHT * 2)/(1024*1024)));

    //sceDisplayWaitVblankStart();

    fbp0 = sceGuSwapBuffers();

    ++frame_count;
    u64 curr_tick;
    sceRtcGetCurrentTick(&curr_tick);
    if ((curr_tick-last_tick) >= tick_frequency)
    {
      float time_span = ((int)(curr_tick-last_tick)) / (float)tick_frequency;
      curr_ms = time_span / frame_count;

      frame_count = 0;
      sceRtcGetCurrentTick(&last_tick);
    }*/
  }

  //sceGuTerm();

  sceKernelExitGame();
  return 0;
}
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #13 on: July 05, 2007 »
Are you sure it's sceGuSwapBuffers() and not just calls to sceDisplaySetFrameBuf(BackBuf or DispBuff,512,1,1) that you need?  I think that's all you need.

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #14 on: July 05, 2007 »
all the gu stuff is commented out i should have deleted it for clarity.

there is still a bit of clening up to be done but i think it looks a wee bit closer to a frame buffer now.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #15 on: July 05, 2007 »
Code: [Select]
   fbp0 = sceGuSwapBuffers();All except this line!
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #16 on: July 05, 2007 »
i commented that whole chunk out with /* */  :)

Code: [Select]
/*float curr_fps = 1.0f / curr_ms;

    pspDebugScreenSetOffset((int)fbp0);
    pspDebugScreenSetXY(0,0);
    pspDebugScreenPrintf("fps: %d.%03d (%dMB/s)",(int)curr_fps,(int)((curr_fps-(int)curr_fps) * 1000.0f),(((int)curr_fps * SCR_WIDTH * SCR_HEIGHT * 2)/(1024*1024)));

    //sceDisplayWaitVblankStart();

    fbp0 = sceGuSwapBuffers();

    ++frame_count;
    u64 curr_tick;
    sceRtcGetCurrentTick(&curr_tick);
    if ((curr_tick-last_tick) >= tick_frequency)
    {
      float time_span = ((int)(curr_tick-last_tick)) / (float)tick_frequency;
      curr_ms = time_span / frame_count;

      frame_count = 0;
      sceRtcGetCurrentTick(&last_tick);
    }*/
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #17 on: July 05, 2007 »
so you did!  sorry!
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #18 on: July 05, 2007 »
no problem jim  :) me being lazy.

im going to post a proper frame buffer example soon.
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1667
  • Karma: 133
    • View Profile
Re: Does the psp have a proper framebuffer mode?
« Reply #19 on: July 05, 2007 »
jim can you see any reason for the debug screen stuff locking the psp up in framebuffer mode i think it should still work.

Code: [Select]
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

#include <pspctrl.h>
#include <pspgu.h>
#include <psprtc.h>

#include "../common/callbacks.h"
#include "../common/vram.h"

PSP_MODULE_INFO("FrameBuffer", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

char *DispBuf=(char *)0x44000000;
char *BackBuf=(char *)0x44044000;
char *SwapBuf=(char *)0x44000000;

int main(int argc, char* argv[])
{
  unsigned int x,y,xs,ys;
  unsigned char *vptr0;

  pspDebugScreenInit();
  setupCallbacks();

  float curr_ms = 1.0f;

  sceCtrlSetSamplingCycle(0);
  sceCtrlSetSamplingMode(0);

  u64 last_tick;
  sceRtcGetCurrentTick(&last_tick);
  u32 tick_frequency = sceRtcGetTickResolution();
  int frame_count = 0;

  sceDisplaySetMode(0,480,272);

  unsigned long i;

  while(running())
  {

    xs+=1;
    ys+=1;

    sceDisplayWaitVblankStart();
    sceDisplaySetFrameBuf(BackBuf,512,1,1);

    vptr0=BackBuf;

    for (i=0; i<0x44000/2; i++)
    {
         *(unsigned short *)vptr0=0;
         vptr0+=2;
    }

    for (y = 0; y < 272; ++y)
    {
         unsigned short* row = ((unsigned short*)BackBuf) + y * 512;
         for (x = 0; x < 480; ++x)
         {
              row[x] = (x+xs)*(y+ys);
         }
    }

    SwapBuf=DispBuf;
    DispBuf=BackBuf;
    BackBuf=SwapBuf;

    //float curr_fps = 1.0f / curr_ms;

    /*pspDebugScreenSetOffset((int)BackBuf);
    pspDebugScreenSetXY(0,0);
    pspDebugScreenPrintf("fps: %d.%03d (%dMB/s)",(int)curr_fps,(int)((curr_fps-(int)curr_fps) * 1000.0f),(((int)curr_fps * 480 * 272 * 2)/(1024*1024)));

    sceKernelDcacheWritebackAll();

    ++frame_count;
    u64 curr_tick;
    sceRtcGetCurrentTick(&curr_tick);
    if ((curr_tick-last_tick) >= tick_frequency)
    {
      float time_span = ((int)(curr_tick-last_tick)) / (float)tick_frequency;
      curr_ms = time_span / frame_count;

      frame_count = 0;
      sceRtcGetCurrentTick(&last_tick);
    }*/
  }


  sceKernelExitGame();
  return 0;
}
Challenge Trophies Won: