I've tried print but it doesn't display anything.
*this is a spambot with links in the sig*
This is going to sound very stupid and noobish. that probably wasn't a good way to open my question but whatever![]()
Is there a way when the psp is set in graphics mode to print a variable. I've tried printf but it doesn't display anything. I know about outtextxy but it doesn't print variables. atleast it didn't do it for me...
I've tried print but it doesn't display anything.
*this is a spambot with links in the sig*
Last edited by yaustar; September 1st, 2008 at 17:36.
printf (the actual C library function) will print to the TTY. Whichever graphics library you are using, there is normally a function to print text to the screen. Have a little hunt in the library headers/documentation and you should find one easily enough.
The only graphics library that I am using is graphics.h, but the problem isn't with printing text to the screen. I understand how to do that. its with printing variables. printf is what I want to use, but when I init the graphics printf ceases to function and outtextxy will not print variables. I'll look again though...
You'd be better off using printf and PSPlink, to keep things neat.
PSPLink will save you bucket loads of time anndd its a TTY interface so woo!
Wally
Where do you want to print out your variables? On screen? In the TTY?
If on screen and you are using the header graphics.h, if you look in the header, you see a function:
Which only takes a char string. You will have to use char string functions (snprintf(C), sprintf(C) and stringstreams(C++)) to create your string to print on screen. E.gCode:void printTextScreen(int x, int y, const char* text, u32 color)
Code:int foo = 20; float bar = 2.2f; char buffer[128] = "\0"; snprintf( buffer, 127, "blah blah %d, %.2f", foo, bar ); buffer[127] = '\0'; printTextScreen( 0, 0, buffer, 0 );
Last edited by yaustar; September 4th, 2008 at 20:46.
The way I do it can be found in the latest version of Basilisk II for the PSP. Here's the relevant code as a quote because the code tags don't work on this forum.It's the show_msg() function in video_psp.cpp.
That uses pspDebugScreenSetOffset() to make the subsequent pspDebugScreenPrintf() draw to a place designated as the debug text texture buffer. It's just one line worth of space - 512x8x4.void show_msg(char *message, uint32 fc, uint32 bc)
{
struct texVertex *vertices;
pspDebugScreenSetOffset(DEBUG_BUF);
pspDebugScreenSetBackColor(bc);
pspDebugScreenSetTextColor(fc);
pspDebugScreenSetXY(0, 0);
pspDebugScreenPrintf("%s", message);
sceGuEnable(GU_TEXTURE_2D);
sceGuTexMode(GU_PSM_8888,0,0,0);
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
sceGuTexFilter(GU_LINEAR, GU_LINEAR);
sceGuTexImage(0, 512, 8, 512, (void *)(0x40000000 | (uint32)sceGeEdramGetAddr() + DEBUG_BUF));
sceGuTexSync();
vertices = (struct texVertex*)sceGuGetMemory(2 * sizeof(struct texVertex));
vertices[0].u = 0;
vertices[1].u = strlen(message)*7;
vertices[0].v = 0;
vertices[1].v = 8;
vertices[0].x = (SCR_WIDTH-strlen(message)*7)/2;
vertices[1].x = vertices[0].x + strlen(message)*7;
vertices[0].y = SCR_HEIGHT-48;
vertices[1].y = vertices[0].y + 8;
vertices[0].z = 0;
vertices[1].z = 0;
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_VERT EX_16BIT|GU_TRANSFORM_2D, 2,0,vertices);
}
Then that texture buffer is blitted to the screen. Just tack a call to show_msg() to the end of your screen drawing before you call sceGuFinish(); sceGuSync(0,0);
Thank you yaustar, your idea worked like a charm!!!
The problem was that I was only using printTextScreen without first dumping the variable with a sprintf. took me a couple of tries to get it placed correctly in the code. but I got it to work!! Thank you again!! :thumbup:
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks