ow its that simple ,thnx
Printable View
ow its that simple ,thnx
What if i want to print on a background? I tried (i did declare color black):Zitat:
Zitat von yaustar
printTextScreen(200, 200, CurrentTime, Black);
The text was scrambled when i tried that. Basically, i did this
That caused the text to be scrambled. Could anyone help?Code:void CurrentTime( char * timeText) {
pspTime rtime;
sceRtcGetCurrentClockLocalTime(&rtime);
snprintf(timeText, 8, "%i : %i" , rtime.hour , rtime.minutes);
}
int main()
{
char aTime[16] = "";
CurrentTime( aTime );
Color Black = RGB(0, 0, 0);
printTextScreen(200, 200, CurrentTime, Black);
flipScreen();
return 0;
}
Also, I tried using the 4th brightness, and i don't get any compiler errors. Does 4th brightness work on 3.03OE-C? Same question for the time function (maybe my firmware is causing the time and 4th brightness problem.
printTextScreen(200, 200, CurrentTime, Black);Zitat:
Zitat von Xylem
you're passing the address of CurrentTime (the function) instead of aTime. ;)
Thanks, it works! Now to test the 4th brightness....Zitat:
Zitat von Waterbottle
Edit: Nope, it doesn't work. Can it work on 3.03 OE-C? Btw, here is my code
Am i doing something wrong? Btw, i did remember to put "-lpspdisplay_driver" in my makefile.Code:#define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6
void sceDisplay_driver_9E3C6DC6(int a0,int a1); /*a0 0-100,a1 = 0/1 (set to 0)*/
//Later in the main loop controls (the while part)
if (pad.Buttons & PSP_CTRL_LTRIGGER){
sceDisplay_driver_9E3C6DC6(100,0);
}
Hey,
I am having a problem with my code. It's not that it doesn't work because it does work. However, the memory stick light is constantly flashing (while i am in this loop), and i don't know why. I think it may be because of the battery percentage i tried to display in my loop. Here is the code causing problems:
Code:void batterypercent( char * batterytext) {
scePowerGetBatteryLifePercent()
snprintf(batterytext, 8, "%i" , scePowerGetBatteryLifePercent());
}
//later in loop that is using battery percentage
int appmain() {
Color Black = RGB(0, 0, 0);
char x[2];
char variable[2] = "0";
char variable1[2] = "1";
char variable2[2] = "2";
char variable3[2] = "3";
char variable4[2] = "4";
char variable5[2] = "5";
char variable6[2] = "6";
FILE *cpu;
if ((cpu = fopen("./files/cpu.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, cpu)] = 0;
fclose(cpu);
if(strcmp (variable1,x) == 0)
{
scePowerSetClockFrequency(111, 111, 111);
}
if(strcmp (variable2,x) == 0)
{
scePowerSetClockFrequency(222, 222, 111);
}
if(strcmp (variable3,x) == 0)
{
scePowerSetClockFrequency(333, 333, 166);
}
Font* myfont1 = Font_Load("./files/Fonts/VERA.TTF");
Font_SetSize(myfont1, 14);
Font* myfont2 = Font_Load("./files/Fonts/VERA.TTF");
Font_SetSize(myfont2, 18);
Font* myfont3 = Font_Load("./files/Fonts/VERA.TTF");
Font_SetSize(myfont3, 20);
Font* myfont4 = Font_Load("./files/Fonts/REN_STIM.TTF");
Font_SetSize(myfont4, 22);
Image* cursor;
cursor = loadImage("./files/images/cursor.png");
char aTime[16] = "";
CurrentTime( aTime );
char abattery[16] = "";
batterypercent( abattery );
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
int CursorXPosition = 0;
int CursorYPosition = 0;
Image* tback;
FILE *menu;
if ((menu = fopen("./files/menu.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, cpu)] = 0;
fclose(menu);
if(strcmp (variable,x) == 0)
{
configuration();
}
if(strcmp (variable1,x) == 0)
{
//nothing
}
FILE *theme;
if ((theme = fopen("./files/theme.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, theme)] = 0;
fclose(theme);
if(strcmp (variable1,x) == 0)
{
tback = loadImage("./files/images/superbat.png");
}
if(strcmp (variable2,x) == 0)
{
tback = loadImage("./files/images/superbatxs.png");
}
if(strcmp (variable3,x) == 0)
{
tback = loadImage("./files/images/superbatxs2.png");
}
if(strcmp (variable4,x) == 0)
{
tback = loadImage("./files/images/kill.png");
}
if(strcmp (variable5,x) == 0)
{
tback = loadImage("./files/images/bubbles.png");
}
if(strcmp (variable6,x) == 0)
{
tback = loadImage("./files/images/sbg.png");
}
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
blitAlphaImageToScreen(0, 0 , 480, 272, tback, 0, 0);
blitAlphaImageToScreen(0, 0, 35, 40, cursor, CursorXPosition, CursorYPosition);
FILE *time;
if ((time = fopen("./files/time.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, time)] = 0;
fclose(time);
if(strcmp (variable,x) == 0)
{
//nothing
}
if(strcmp (variable1,x) == 0)
{
printTextScreen(445, 15, aTime, Black);
}
FILE *battery;
if ((battery = fopen("./files/battery.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, battery)] = 0;
fclose(battery);
if(strcmp (variable,x) == 0)
{
//nothing
}
if(strcmp (variable1,x) == 0)
{
printTextScreen(445, 25, abattery, Black);
}
flipScreen();
if (pad.Buttons & PSP_CTRL_RTRIGGER){
configuration();
}
if (CursorXPosition < 0){
CursorXPosition = 0;
}
if (CursorXPosition > 452){
CursorXPosition = 452;
}
if(CursorYPosition < 0){
CursorYPosition = 0;
}
if(CursorYPosition > 243){
CursorYPosition = 243;
}
FILE *pointer;
if ((pointer = fopen("./files/pointer.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, pointer)] = 0;
fclose(pointer);
if(strcmp (variable2,x) == 0)
{
if (pad.Lx < 80) //left
CursorXPosition -= 2;
if (pad.Lx > 175) //right
CursorXPosition += 2;
if (pad.Ly > 175) //down
CursorYPosition += 2;
if (pad.Ly < 80) //up
CursorYPosition -= 2;
}
if(strcmp (variable3,x) == 0)
{
if (pad.Lx < 80) //left
CursorXPosition -= 4;
if (pad.Lx > 175) //right
CursorXPosition += 4;
if (pad.Ly > 175) //down
CursorYPosition += 4;
if (pad.Ly < 80) //up
CursorYPosition -= 4;
}
if(strcmp (variable4,x) == 0)
{
if (pad.Lx < 80) //left
CursorXPosition -= 5;
if (pad.Lx > 175) //right
CursorXPosition += 5;
if (pad.Ly > 175) //down
CursorYPosition += 5;
if (pad.Ly < 80) //up
CursorYPosition -= 5;
}
if(strcmp (variable5,x) == 0)
{
if (pad.Lx < 80) //left
CursorXPosition -= 6;
if (pad.Lx > 175) //right
CursorXPosition += 6;
if (pad.Ly > 175) //down
CursorYPosition += 6;
if (pad.Ly < 80) //up
CursorYPosition -= 6;
}
}
sceKernelSleepThread();
return 0;
}
I think me putting the file I/O function for the battery file in the while loop is constantly being repeated and updated?
From the look of that, you're constantly loading and re-loading the files in a loop.
Don't.
Load them once before the loop.
Are you talking about the while loop, or the whole int appmain() itself?Zitat:
Zitat von Insert_Witty_Name
The while loop.
Now, the pointer doesn't move, and nothing happens. The only thing that works is the home button, and the R trigger (the image and cursor do blit).Code:int appmain() {
Color Black = RGB(0, 0, 0);
char x[2];
char variable[2] = "0";
char variable1[2] = "1";
char variable2[2] = "2";
char variable3[2] = "3";
char variable4[2] = "4";
char variable5[2] = "5";
char variable6[2] = "6";
FILE *cpu;
if ((cpu = fopen("./files/cpu.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, cpu)] = 0;
fclose(cpu);
if(strcmp (variable1,x) == 0)
{
scePowerSetClockFrequency(111, 111, 111);
}
if(strcmp (variable2,x) == 0)
{
scePowerSetClockFrequency(222, 222, 111);
}
if(strcmp (variable3,x) == 0)
{
scePowerSetClockFrequency(333, 333, 166);
}
Font* myfont1 = Font_Load("./files/Fonts/VERA.TTF");
Font_SetSize(myfont1, 14);
Font* myfont2 = Font_Load("./files/Fonts/VERA.TTF");
Font_SetSize(myfont2, 18);
Font* myfont3 = Font_Load("./files/Fonts/VERA.TTF");
Font_SetSize(myfont3, 20);
Font* myfont4 = Font_Load("./files/Fonts/REN_STIM.TTF");
Font_SetSize(myfont4, 22);
Image* cursor;
cursor = loadImage("./files/images/cursor.png");
char aTime[16] = "";
CurrentTime( aTime );
char abattery[16] = "";
batterypercent( abattery );
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
int CursorXPosition = 0;
int CursorYPosition = 0;
Image* tback;
//FILE *credit;
//if ((credit = fopen("./files/credit.txt","rb")) == NULL)
//{
// printf("There is nothing in this file");
//}
////x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, credit)] = 0;
//fclose(credit);
//if(strcmp (variable,x) == 0)
// {
//nothing
// }
//if(strcmp (variable1,x) == 0)
// {
//Image* credits;
//credits = loadImage("./files/images/superbatxs.png");
//Image* credits2;
//credits2 = loadImage("./files/images/bubbles.png");
//Image* credits3;
//credits3 = loadImage("./files/images/superbat.png");
//blitAlphaImageToScreen(0, 0 , 480, 272, credits, 0, 0);
//Font_PrintScreen(myfont3, 160, 125, "SuperbatXS presents...", GU_RGBA(0, 100, 0, 255), getVramDrawBuffer());
//sceDisplayWaitVblankStart(480);
//flipscreen();
//clearscreen(0);
// }
FILE *menu;
if ((menu = fopen("./files/menu.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, cpu)] = 0;
fclose(menu);
if(strcmp (variable,x) == 0)
{
configuration();
}
if(strcmp (variable1,x) == 0)
{
//nothing
}
FILE *theme;
if ((theme = fopen("./files/theme.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, theme)] = 0;
fclose(theme);
if(strcmp (variable1,x) == 0)
{
tback = loadImage("./files/images/superbat.png");
}
if(strcmp (variable2,x) == 0)
{
tback = loadImage("./files/images/superbatxs.png");
}
if(strcmp (variable3,x) == 0)
{
tback = loadImage("./files/images/superbatxs2.png");
}
if(strcmp (variable4,x) == 0)
{
tback = loadImage("./files/images/kill.png");
}
if(strcmp (variable5,x) == 0)
{
tback = loadImage("./files/images/bubbles.png");
}
if(strcmp (variable6,x) == 0)
{
tback = loadImage("./files/images/sbg.png");
}
FILE *pointer;
if ((pointer = fopen("./files/pointer.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
FILE *battery;
if ((battery = fopen("./files/battery.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
FILE *time;
if ((time = fopen("./files/time.txt","rb")) == NULL)
{
printf("There is nothing in this file");
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, time)] = 0;
fclose(time);
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
blitAlphaImageToScreen(0, 0 , 480, 272, tback, 0, 0);
blitAlphaImageToScreen(0, 0, 35, 40, cursor, CursorXPosition, CursorYPosition);
if(strcmp (variable,x) == 0)
{
//nothing
}
if(strcmp (variable1,x) == 0)
{
printTextScreen(445, 15, aTime, Black);
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, battery)] = 0;
fclose(battery);
if(strcmp (variable,x) == 0)
{
//nothing
}
if(strcmp (variable1,x) == 0)
{
printTextScreen(445, 25, abattery, Black);
}
flipScreen();
if (pad.Buttons & PSP_CTRL_RTRIGGER){
configuration();
}
if (CursorXPosition < 0){
CursorXPosition = 0;
}
if (CursorXPosition > 452){
CursorXPosition = 452;
}
if(CursorYPosition < 0){
CursorYPosition = 0;
}
if(CursorYPosition > 243){
CursorYPosition = 243;
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, pointer)] = 0;
fclose(pointer);
if(strcmp (variable2,x) == 0)
{
if (pad.Lx < 80) //left
CursorXPosition -= 2;
if (pad.Lx > 175) //right
CursorXPosition += 2;
if (pad.Ly > 175) //down
CursorYPosition += 2;
if (pad.Ly < 80) //up
CursorYPosition -= 2;
}
if(strcmp (variable3,x) == 0)
{
if (pad.Lx < 80) //left
CursorXPosition -= 4;
if (pad.Lx > 175) //right
CursorXPosition += 4;
if (pad.Ly > 175) //down
CursorYPosition += 4;
if (pad.Ly < 80) //up
CursorYPosition -= 4;
}
if(strcmp (variable4,x) == 0)
{
if (pad.Lx < 80) //left
CursorXPosition -= 5;
if (pad.Lx > 175) //right
CursorXPosition += 5;
if (pad.Ly > 175) //down
CursorYPosition += 5;
if (pad.Ly < 80) //up
CursorYPosition -= 5;
}
if(strcmp (variable5,x) == 0)
{
if (pad.Lx < 80) //left
CursorXPosition -= 6;
if (pad.Lx > 175) //right
CursorXPosition += 6;
if (pad.Ly > 175) //down
CursorYPosition += 6;
if (pad.Ly < 80) //up
CursorYPosition -= 6;
}
}
sceKernelSleepThread();
return 0;
}
superbatx,
You can simplify the code by using pointers.
can be simplified to:Code:
char variable[2] = "0";
char variable1[2] = "1";
char variable2[2] = "2";
char variable3[2] = "3";
char variable4[2] = "4";
char variable5[2] = "5";
char variable6[2] = "6";
If you know about pointers, you can use them to point the the actual address in memory of a string.Code:char *pointer;
pointer = &variable[0];
char variable[8] = "0123456";
"pointer = &variable[0];" tells the pointer to point to the first character in the string it points to. This works for all strings.
Now, if you want to access the other characters in the string, its easy. Just increase the address that the pointer points to by one. Example for PSP:
That can be used for a primitive OSK to point to individual letters in a string ;pCode:int a = 0;
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons != paddata_old)
{
if(pad.Buttons & PSP_CTRL_UP)
{
a++;
}
if(pad.Buttons & PSP_CTRL_DOWN)
{
a--;
}
pspDebugScreenSetXY(1,1);
printf("%c", *(pointer + a));
if(a > 10)
{
i = 10;
}
if(a < 0)
{
a = 0;
}
paddata_old = pad.Buttons;
}
}
Just telling you how to make your code much more readable and efficient.
--
Now, about those variables. Its looks much better if you actually declare all of your variables in one place. Its really irritating trying to read your source if the variables are being declared randomly.
--
Also, it looks like you are closing files that were not opened in the first place.
I keep getting this warning
here is line 1764Code:main.c:1764: warning: passing argument 3 of 'printTextScreen' makes pointer from
integer without a cast
argument 3Code:printg(150,245, cpuClockFrequencyText() ,setRedTextColor());
Code:char *cpuClockFrequencyText()
{
sprintf(cpuText , "Cpu Speed : %i mhz", scePowerGetCpuClockFrequency());
return(cpuText);
}
Wow... nvm.
pointer,a character only returns one byte
Actually, I think it is referring to setRedTextColor(). Can you post the code for that function? And also the code for printg (if this is a #define, stop using them to shorten function names! At the very worst, write an inline function that wraps around it).
Code:extern void printTextScreen(int x, int y, const char* text, u32 color);
Code:int setRedTextColor()
{
return(0x0000FF);
}
Why don't you just use u32 Red = 0x0000FF;? Much less of a hassle -_-Zitat:
Zitat von hallo007
Try:Code:int setRedTextColor()
{
return(0x0000FF);
}
Code:u32 setRedTextColor()
{
return (u32)(0x0000FF);
}
Could anyone help me? Also, is there a function that allows you to blit an image for only a few seconds? I know you can use a timer, but i don't know how...and i was also sure there was an easier way too.Zitat:
Zitat von Xylem
Blit. Flip. WaitVblankStart X number of times. 60 times for a second.
hello, I would like to use Jono's web browser example for my project...
http://www.psp-programming.com/forum...ic,1333.0.html
I was just wondering, can any body make a working makefile for that? Thanks for your time...
It's a file browser ;)
It doesn't look like it uses any libraries that are not included as standard so that should be fine, just add the file_browser.o to the OBJS line.
Lol, it's a file browser. Not much of a makefile for it.Zitat:
Zitat von BlackShark
Edit: Lol, you beat me by like only a couple of seconds Insert_Witty_Name
lol ok, thanks
"WaitVblankStart(60); ", how come this doesn't work? Am i not using the right code? It doesn't compile. I blit the image, flipped it, put this line, and clearscreen(0); What is the exact code you are telling me?Zitat:
Zitat von yaustar
use a counter, its not that different from a timer (in your case, atleast):Zitat:
Zitat von Xylem
Code:int main()
int showTime = 0;
// LOAD IMAGES AND CALLBACKS AND THE OTHER STUFF //
for (;;) {
if (showTime < 60) { // EVERY 60 IS A SECOND //
// DISPLAY PICTURE //
showTime++;
}
flipSceen();
sceDisplayWaitVblankStart();
}
return 0;
}
So how do you do like a if showTime > 240 and if showTime < 480?Zitat:
Zitat von Grimfate126
Read about if statements: http://www.cprogramming.com/tutorial/lesson2.html
you'd do just that...Zitat:
Zitat von Xylem
Code:if ((showTime > 240) && (showTime < 480)) {
you cant do that, you're thinking about lua. that will generate errors. here, this works:Zitat:
Zitat von BlackShark
Code:if ((showTime > 240 && showTime < 480)) {
It wont generate errors -_-Zitat:
Zitat von Grimfate126
if ((showTime > 240) && (showTime < 480)) is absolutely fine.
I didn't know you can do that in lua :P
cool, well grim answered your question.
Lol, i found that out quite a while ago. This works fine for me:
if (showTime > 240 && showTime < 480)
with lua, you can use ( and ) just about anywhere ;)Zitat:
Zitat von BlackShark
1. That wont generate errorsZitat:
Zitat von Grimfate126
2. This is the C/C++ Help Thread, he isnt thinking in lua.
fixed , was a prob with my pc
do you use a (se)plugin? it could be problem
i've got a problem 2
this is my main:
and this is my: menu:Code:int main()
{ // dit is gewoon standaard ;) direct menu callen
pspDebugScreenInit();
SetupCallbacks();
sceIoUnassign("flash0:");
sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
menu();
return 0;
}
error is in dutch, I will translate itCode:void menu()
{
SceCtrlData pad;
if(tempMenuSelection == 1)
{
pspDebugScreenPrintf(" -> Menu optie 1\n");
pspDebugScreenPrintf(" Menu optie 2\n");
pspDebugScreenPrintf(" Menu optie 3\n");
pspDebugScreenPrintf(" Menu optie 4\n");
}
else if(tempMenuSelection == 2)
{
pspDebugScreenPrintf(" Menu optie 1\n");
pspDebugScreenPrintf(" -> Menu optie 2\n");
pspDebugScreenPrintf(" Menu optie 3\n");
pspDebugScreenPrintf(" Menu optie 4\n");
}
else if(tempMenuSelection == 3)
{
pspDebugScreenPrintf(" Menu optie 1\n");
pspDebugScreenPrintf(" Menu optie 2\n");
pspDebugScreenPrintf(" -> Menu optie 3\n");
pspDebugScreenPrintf(" Menu optie 4\n");
}
else if(tempMenuSelection == 4)
{
pspDebugScreenPrintf(" Menu optie 1\n");
pspDebugScreenPrintf(" Menu optie 2\n");
pspDebugScreenPrintf(" Menu optie 3\n");
pspDebugScreenPrintf(" -> Menu optie 4\n");
}
else if(tempMenuSelection == 5)
{
}
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_UP)
{
tempMenuSelection--;
wait(5);
menu();
}
else if (pad.Buttons & PSP_CTRL_DOWN)
{
tempMenuSelection++;
wait(5);
menu();
}
if (tempMenuSelection > 11) // if the menu selector is past the end of the menu,
tempMenuSelection = 6; // move it to the beginning,
else if (tempMenuSelection < 6) // otherwise if it is before the beginning,
tempMenuSelection = 11; // move it to the end.
}
if (pad.Buttons & PSP_CTRL_CROSS){
if(tempMenuSelection==1)
{
printf("menu optie 1\n");
}
else if (pad.Buttons & PSP_CTRL_CROSS){
if(tempMenuSelection==2)
{
printf("menu optie 2\n");
}
else if (pad.Buttons & PSP_CTRL_CROSS){
if(tempMenuSelection==3)
{
printf("menu optie 3\n");
}
else if (pad.Buttons & PSP_CTRL_CROSS){
if(tempMenuSelection==4)
{
printf("menu optie 4\n");
}
}
My Compiler says:
main.c: In functie ‘menu’:
main.c:607: let op: ‘main’ is gewoonlijk een niet-static funtie
main.c:614: fout: syntax error at end of input
make: *** [main.o] Fout 1
which means:
main.c: In function ‘menu’:
main.c:607:let op: ‘main’ is normaly a not-static function
main.c:614: error: syntax error at end of input
make: *** [main.o] error 1
you forgot a }
How about a "Get Started on 3d/PSP GU for Dummies" kind of thread?
That has all the tutorials[freshly cooked, not copy pasted] and Defines all 3d terms like culling fulling :p ,etc? Just so that it acts like a very useful central repository...
3d HB is also becoming near-rare.
I read up on psp-programming but they seem too intricate to understand. and also complex.
NOTE: Only respond to this if u have anything + to say, Cease posting if it's something that burns :P
That menu won't work. I suggest you look a few pages back for the menu code I posted. It uses the graphics library though.Zitat:
Zitat von Kwastie
Go to Nehe ( http://nehe.gamedev.net/ ). Learn C, learn OpenGL, come back and start reading the documentation for the GU and the SDK samples.Zitat:
Zitat von Mr305