Yaustar that code you gave me didnt work. :(
The compiler just threw up a bunch of errors.
Printable View
Yaustar that code you gave me didnt work. :(
The compiler just threw up a bunch of errors.
From the PSPSDK docs:Zitat:
Zitat von Kwastie
I'm not completely sure what it'll return on 3.x, but I think it will return 0x03010010 on 3.10.Zitat:
int sceKernelDevkitVersion(vo id)
Get the firmware version.
Returns:
The firmware version. 0x01000300 on v1.00 unit, 0x01050001 on v1.50 unit, 0x01050100 on v1.51 unit, 0x01050200 on v1.52 unit, 0x02000010 on v2.00/v2.01 unit, 0x02050010 on v2.50 unit, 0x02060010 on v2.60 unit, 0x02070010 on v2.70 unit, 0x02070110 on v2.71 unit.
Here's an example on what you could do in your program (there are other ways too).
Code:int retVal;
int fwMode;
retVal = sceKernelDevkitVersion();
if(retVal == 0x03010010)
{
// do something, like set firmware mode to 310 and check
// if the mode is 310 then don't flash the topmenu_plugin.rco
fwMode = 310;
}
// later on
if(fwMode != 310)
{
// flash topmenu
flashTopmenuPlugin();
}
else
{
// notify the user that topmenus can't be flashed in 3.10OE
errorTopmenu();
}
i'll give it a try :Jump: thanks
What code?Zitat:
Zitat von eldiablov
Edit: Found it:
Try that. (And post the errors up next time).Code:#include <stdio.h>
#include <string.h>
#include <ctype.h>
enum ETeamIds
{
TEAM_ELVES = 0,
TEAM_DWARVES,
TEAM_ALONE,
TOTAL_NUMBER_OF_TEAMS
};
const char * TEAM_NAMES[TOTAL_NUMBER_OF_TEAMS] =
{
"ELVES",
"DWARVES",
"ALONE"
};
const int STRING_BUFFER_LENGTH = 64;
int main( )
{
printf( "What team do you want to be on?\n" );
char inputStringBuffer[STRING_BUFFER_LENGTH] = "";
scanf( "%s", inputStringBuffer );
{
int i = 0;
for( i = 0; i < STRING_BUFFER_LENGTH; ++i )
{
inputStringBuffer[i] = toupper( inputStringBuffer[i] );
}
}
bool validTeamName = false;
{
int i = 0;
for( i = 0; i < TOTAL_NUMBER_OF_TEAMS; ++i )
{
if( 0 == strncmp( TEAM_NAMES[i], inputStringBuffer, STRING_BUFFER_LENGTH ) )
{
printf( "You are in team %s\n", TEAM_NAMES[i] );
validTeamName = true;
break;
}
}
}
if( !validTeamName )
{
printf( "Invalid team choice\n" );
}
return 0;
}
line 26 has 2 errors
37 and 46 have 1 error.
char inputStringBuffer[STRING_BUFFER_LENGTH] = "";
I have that line as causing problems at the moment
Although STRING_BUFFER_LENGTH is a constant, I'm not sure if C lets you pass in a variable for an array length. Try replacing STRING_BUFFER_LENGTH = 64; with #define STRING_BUFFER_LENGTH 64Zitat:
Zitat von eldiablov
but then affects the scanf line :Argh:
solved that now for line 37 and 46
now there's just an error with 46 and 52. I'll post the modified script.Code:#include <stdio.h>
#include <string.h>
#include <ctype.h>
enum ETeamIds
{
TEAM_ELVES = 0,
TEAM_DWARVES,
TEAM_ALONE,
TOTAL_NUMBER_OF_TEAMS
};
const char * TEAM_NAMES[TOTAL_NUMBER_OF_TEAMS] =
{
"ELVES",
"DWARVES",
"ALONE"
};
const int STRING_BUFFER_LENGTH = 64;
int main( )
{
printf( "What team do you want to be on?\n" );
#define char inputStringBuffer[STRING_BUFFER_LENGTH] = "";
#define scanf( "%s", inputStringBuffer );
{
int i = 0;
for( i = 0; i < STRING_BUFFER_LENGTH; ++i )
{
#define inputStringBuffer[i] = toupper( inputStringBuffer[i] );
}
}
#define bool validTeamName = false;
{
int i = 0;
for( i = 0; i < TOTAL_NUMBER_OF_TEAMS; ++i )
{
if( 0 == strncmp( TEAM_NAMES[i], inputStringBuffer, STRING_BUFFER_LENGTH ) )
{
printf( "You are in team %s\n", TEAM_NAMES[i] );
validTeamName = true;
break;
}
}
}
if( !validTeamName )
{
printf( "Invalid team choice\n" );
}
return 0;
}
This should work;Zitat:
Zitat von eldiablov
Code:#include <stdio.h>
#include <string.h>
#include <ctype.h>
enum ETeamIds
{
TEAM_ELVES = 0,
TEAM_DWARVES,
TEAM_ALONE,
TOTAL_NUMBER_OF_TEAMS
};
const char * TEAM_NAMES[TOTAL_NUMBER_OF_TEAMS] =
{
"ELVES",
"DWARVES",
"ALONE"
};
#define STRING_BUFFER_LENGTH 64
#define bool int
#define false 0
#define true 1
int main( )
{
printf( "What team do you want to be on?\n" );
char inputStringBuffer[STRING_BUFFER_LENGTH] = "";
scanf( "%s", inputStringBuffer );
{
int i = 0;
for( i = 0; i < STRING_BUFFER_LENGTH; ++i )
{
inputStringBuffer[i] = toupper( inputStringBuffer[i] );
}
}
bool validTeamName = false;
{
int i = 0;
for( i = 0; i < TOTAL_NUMBER_OF_TEAMS; ++i )
{
if( 0 == strncmp( TEAM_NAMES[i], inputStringBuffer, STRING_BUFFER_LENGTH ) )
{
printf( "You are in team %s\n", TEAM_NAMES[i] );
validTeamName = true;
break;
}
}
}
if( !validTeamName )
{
printf( "Invalid team choice\n" );
}
return 0;
}
Im guessing i have to put a few getchar(); in there to stop the code from stopping everytime i press enter ?
And BTW thanks waterbottle, coolguy and Yaustar
Wow....apparently everyone has a problem with what i have to say. What is wrong with you people? You guys just can't stop flaming me. Seriously, stop trying to make me quit, it's not worth it. I'm not going to quit.Zitat:
Zitat von SG57
hmmm i know its a pretty broad question but does anyone know how you get a prx that you have made to remain over the xmb instead of showing just before the coldboot then closing? even if someone could show me in a simple helloworld would be a great help :) thanks
Run it in a loop :)Zitat:
Zitat von covandy01
I have two questions. Both related to RAM.
1. If I run a program, say it's 1MB, about how much RAM will I have to work with? I know it has 32MB, but how much is actually available.
2. After the program is loaded into the RAM, I can remove the memory stick, right? It won't need to access the EBOOT again, right? (Assuming it needs no external files.
Approximately 24mb to play with.
You can remove the memory stick as the EBOOT is loaded to RAM, as you said.
Just thought I ask before starting to code to show jpeg files, that if any one here has code for dealing with jpeg files it would be a big help with this open source graphics class that I am doing, it would save me time if any one could help.
LuaPlayer has jpeg loading. Check out the LuaPlayer source code. Also, there's a jpeg lib in the PSP svn at ps2dev.org, but I don't know what it does, or if it works.Zitat:
Zitat von xart
Yes, libjpeg is on the svn at ps2dev.org and as Access_Denied already said, check out the graphics.cpp from the Lua Player source (http://www.luaplayer.org) for the code.
Simple question: What is the function to completely restart an app with a touch of a button? I already know that you use sceKernelExitGame(); to exit, but i want to know how to restart.
i dont think such a function exists. However, you may want to check psppower.h in the sdk.Zitat:
Zitat von superbatxs
I'm Making A prx and was wondering how read controler input with the xmb controls still working?
thanks
psp-freak - I had the same problem. turns out you dont need to update the 'pad' enumerator (or is SceCtrlData a structure?). Just:
That will execute blah as well as enter any menu your currently on in the XMB.Code:SceCtrlData pad;
...
for(;;)
if(pad.Buttons & PSP_CTRL_CROSS) { /* blah */ }
Thank you So much!
this will help a lot
Ok, i have a question with File I/O. How do i open a text file, check what is says, and if it says the number i want it to say, i do a certain action. For example, if it reads 0, then i simply pop up a menu or something. After i choose something from that menu, i want to save a different number if i choose a certain option from that menu. For example, if my text says 0, i go to the menu, i click something, i do that action and i want to save a 1 telling my code that in the future, i do not want that menu to pop up.
You could use sceKernelLoadExec to reload the eboot.pbp.Zitat:
Zitat von superbatxs
psp-freak222: Use sceCtrlPeekBufferPositive instead of sceCtrlReadBufferPositive .
Xylem: fopen the file, fread the data in (you may need to convert the data to the correct data type once read in) then assign it to said variable. To save, fopen then fwrite. Google the terms used for how to use them.
The 1.5 custom firmware POC had some code for reading in a config file, it may help you.
Do you know how to open a file?Zitat:
Zitat von Xylem
well, depends on how you are doing it... or where you are looking.
You could use the above to compare strings read in a file... thats what strcmp is.Code:char x[2];
char variable[2] = "0";
char variable2[2] = "1";
FILE *yourFile;
if ((yourFile = fopen("thisfile.txt","rb")) == NULL)
{
return -1;
}
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, yourFile)] = 0;
fclose(yourFile);
if(strcmp (variable,x) == 0)
{
printf("Variable read from thisfile.txt = 0");
}
So that code is saying that if the variable is 0, then you print something! I get it. Nice! Thanks for telling me about strcmp. ;)Zitat:
Zitat von Moca
Xylem, try something like this:
fread(buffer,1,2,blah);
int number = atoi(buffer);
if(number == 24) { blah }
atoi converts a string to a number so you can compare it to other numbers. But make sure you include string.h.
But the code Moca gave me is quite simple and good as well. I do have an important question though. How do you "dofile" (lua) something in C? Also, is it possible to load lua scripts from C? That would be really cool, but it sounds hard.Zitat:
Zitat von Access_Denied
Zitat:
Zitat von Xylem
Im guessing you are misunderstanding the code.
btw, heres how strcmp works..Code:char x[2]; // Creating variable called x. x will contain the string of text that you read from the file
char variable[2] = "0"; // This is just a normal string... In this case, it is 0. So variable = "0"
char variable2[2] = "1"; // I dont know why i put this there ;p
//Standard file IO
FILE *yourFile;
if ((yourFile = fopen("thisfile.txt","rb")) == NULL)
{
return -1;
}
//Below is where a specified number of bytes is read from the file. In this case, 1
x[fread(x, 1, 1/*Number of bytes to read, In this case, 1*/, yourFile)] = 0;
fclose(yourFile);
if(strcmp(x,variable) == 0)
{
printf("Variable read from thisfile.txt = 0");
}
strcmp(string1, string2);
compare the two strings.
if they ARE equal, return 0
if they are NOT equal, dont return 0 ;p
hello,
i am still searching for version check, I found one for "lua" but lua isn't C/C++.
could someone port it to C? because i don't know how:Argh:
Greets Kwastie,
I hope you could help me :Jump: :Jump:
I saw the thread a few posts down and im assuming that is what you are talking about.Zitat:
Zitat von Kwastie
http://forums.qj.net/f-psp-developme...ua-100256.html
If so, it is quite easy. I actually made a function to do this a while ago.
Actually, it uses strcmp ;p ... If you read the past few posts. It is actually related.
Just open the version.txt
Seek to the 77th byte.Code:fopen("flash0:/version.txt","rb");
Read 10 bytes. 77 - 87Code:fseek(file,77,SEEK_SET);
store that in a string.
Then use strcmp to compare the 10 bytes you just read to a predefined string. For example, "0x03010010" = 3.10
:tup:
What's wrong with this part of my code?
All variables is declared, this is just a part of the code. My cursor doesen't move!Code:while (1)
{
clearScreen(ColorBlack);
blitAlphaImageToScreen(0,0,16,20,cursor,x,y);
if ((pad.Buttons & PSP_CTRL_UP) && (y > 3)) {
y = y - 4;
}
if ((pad.Buttons & PSP_CTRL_DOWN) && (y < 237)) {
y = y + 4;
}
if((pad.Buttons & PSP_CTRL_RIGHT) && (x < 445)) {
x = x + 4;
}
if((pad.Buttons & PSP_CTRL_LEFT) && (x > 3)) {
x = x - 4;
}
sceDisplayWaitVblankStart();
flipScreen();
}
sceKernelSleepThread();
return 0;
}
Zitat:
Zitat von gameo
Try using less &&. Did you assign a value to x and y when you declared them... use int x = 0;
btw, that took me a few times to read through that to understand what the boundaries are.
add this and remove those &&'s
if(x < 3){x = 3;}
if(y < 3){y = 3;}
if(x > 445){x = 445;}
if(y > 237){y = 237;}
Dont worry about the ugliness and non indentation ;p
You can fix that.
It will check if x or y has passed its boundaries set and assign it to a value...
With your code, its not enough info just stating you declared it. The value will NEVER increase with the method you used if x/y = 0
something like thatCode:int x = 0;
int y = 0;
while (1)
{
clearScreen(ColorBlack);
blitAlphaImageToScreen(0,0,16,20,cursor,x,y);
if(pad.Buttons & PSP_CTRL_UP)
{
y = y - 4;
}
if(pad.Buttons & PSP_CTRL_DOWN)
{
y = y + 4;
}
if(pad.Buttons & PSP_CTRL_RIGHT)
{
x = x + 4;
}
if(pad.Buttons & PSP_CTRL_LEFT)
{
x = x - 4;
}
if(x < 3){x = 3;}
if(y < 3){y = 3;}
if(x > 445){x = 445;}
if(y > 237){y = 237;}
sceDisplayWaitVblankStart();
flipScreen();
}
sceKernelSleepThread();
return 0;
}
Zitat:
Zitat von Moca
Using less &&? Well i learned it this way from Access_Denied's tut's, so i don't really understand the code you just posted.Zitat:
Zitat von myself
Its not an issue with the && in general. Its the fact that i have to search through the file to find what the boundaries are ;pZitat:
Zitat von gameo
ANd you have no method of checking if the value of x or y is already out of the boundary.
Im assuming the boundaries are
3 - 445 for x
and
3 - 237 for y
Is there an alternative method other than cygwin. I installed it correctly before I formatted my hd. Is there an alternative to cygwin. However, I still want to install toolchain.
you could use psptoolchain @ linux, ubuntu.. I use it to :) it works great
well i understand it but I don't know how to read 10 bytes 77-87 and how to store and read it could you give complete code :oZitat:
Zitat von Moca
@gameo: Don't you have to do a vshCtrlReadBufferPositive call inside your loop (before all the button checks)? Otherwise it'll just keep reading the old buttons.
You should really read up on file IO, nevertheless here is an untested version of the code.Zitat:
Zitat von Kwastie
FILE *file = fopen("flash0:/version.txt","rb");
char buffer[10];
fseek(file,77,SEEK_SET);
fread(buffer, 10, 1, file);
fclose(file);