Those files are generated by the build.mak file that you are including in your makefile.Zitat:
Zitat von SodR
Simply don't include it, although rm should delete them if you are wanting to delete them.
'make clean' should sort it too.
Printable View
Those files are generated by the build.mak file that you are including in your makefile.Zitat:
Zitat von SodR
Simply don't include it, although rm should delete them if you are wanting to delete them.
'make clean' should sort it too.
Zitat:
Zitat von psphacker12.
You know we can't help you unless you post the main.c file containing the errors...
Insomniac197: If I add for example rm -f file.elf to the end of my makefile I get a missing sparator error when I try to complie. Any ideas?
.....Zitat:
Zitat von SodR
I removed it and it gave me an error.
Well Im not sure how to put of the error since its extremely long in the batch file, but i put the return 0; like this:
It gave me an error now...Code:blitAlphaImageToScreen(0, 0, 480, 272, Background, 0, 0);
blitAlphaImageToScreen(0, 0, 33, 26, MegaImage, MegaX, MegaY);
blitAlphaImageToScreen(0, 0, 24, 25, ProtoImage, ProtoX, ProtoY);
sceDisplayWaitVblankStart();
flipScreen();
}
}
return 0; /* Whether I put return 0 or 1 it still freezes */
@SG57:
snakman? Did I miss something? ... uhhhh... well could be, I hadn't much time lately to keep up with newest releases and stuff. I dunno what method was used and it's pretty much impossible to say unless you ask the one that converted it :P Actually it doesn't matter, just use the appropriate tool for your image format (bmp2c for .bmp files, bin2c for .raw files, etc.) and you're good. I suppose you tried to use bin2c with a non-raw file, therefore screwing the image up. bin2c only converts every byte from the file into an output array so if the file contains any header information that has nothing to do with the image data, or even the image is compressed, then bin2c will not work correctly. Thatswhy you need raw images, which only contain the pixels of the image in linear form.
EDIT: Damn that thread moves too fast for me already... heh... I'm gettin' old.
Regarding char array problematic - well, it doesn't matter whether your C-array is an unsigned char array or unsingned int array or whatever your tool outputs, because data is just data. char and int are just interpretations of this (same) data. So say you want to get your 16bit RGB image into a C array, but your bin2c outputs an unsigned char array. Well, just typecast that array into an unsigned short array and you have your 16bit image. The same works into any direction.
You need to add something like this mate, at the end of the makefile:Zitat:
Zitat von SodR
Then when you come to compile just put 'make noelf'.Code:noelf: kxploit
rm -f myfile.elf
Note that the rm line is indented with a tab, this is required. You can add more lines after that if you wish to delete other files etc, these need a tab indent also.
The 'kxploit' at the end I put in assuming you required it, you can change it to whatever you normally do or remove it altogether.
-= Double Post =-
Zitat:
Zitat von Gonrai
Your return was in the wrong place, again.Code:blitAlphaImageToScreen(0, 0, 480, 272, Background, 0, 0);
blitAlphaImageToScreen(0, 0, 33, 26, MegaImage, MegaX, MegaY);
blitAlphaImageToScreen(0, 0, 24, 25, ProtoImage, ProtoX, ProtoY);
sceDisplayWaitVblankStart();
flipScreen();
}
return 0; /* Whether I put return 0 or 1 it still freezes */
}
This is insane!!! I put it in the right place but now it still gives me an error, a HUGE error:
-_-Code:graphics.h:165: warning: 'fillScreenRect' initialized and declared 'extern'
graphics.h:165: error: variable or field 'fillScreenRect' declared void
graphics.h:165: error: 'Color' was not declared in this scope
graphics.h:165: error: expected primary-expression before 'int'
graphics.h:165: error: expected primary-expression before 'int'
graphics.h:165: error: expected primary-expression before 'int'
graphics.h:165: error: expected primary-expression before 'int'
graphics.h:165: error: initializer expression list treated as compound expressi
n
graphics.h:175: warning: 'putPixelScreen' initialized and declared 'extern'
graphics.h:175: error: variable or field 'putPixelScreen' declared void
graphics.h:175: error: 'Color' was not declared in this scope
graphics.h:175: error: expected primary-expression before 'int'
graphics.h:175: error: expected primary-expression before 'int'
graphics.h:175: error: initializer expression list treated as compound expressi
n
graphics.h:185: warning: 'putPixelImage' initialized and declared 'extern'
graphics.h:185: error: variable or field 'putPixelImage' declared void
graphics.h:185: error: 'Color' was not declared in this scope
graphics.h:185: error: expected primary-expression before 'int'
graphics.h:185: error: expected primary-expression before 'int'
graphics.h:185: error: expected primary-expression before '*' token
graphics.h:185: error: 'image' was not declared in this scope
graphics.h:185: error: initializer expression list treated as compound expressi
n
graphics.h:195: error: 'Color' does not name a type
graphics.h:205: error: 'Color' does not name a type
graphics.h:215: error: 'u32' has not been declared
graphics.h:226: error: 'u32' has not been declared
graphics.h:239: error: 'Color' has not been declared
graphics.h:266: error: 'Color' has not been declared
graphics.h:278: error: 'Color' has not been declared
graphics.h:285: error: expected initializer before '*' token
graphics.h:292: error: expected initializer before '*' token
main.cpp: In function 'int exit_callback(int, int, void*)':
main.cpp:24: error: 'sceKernelExitGame' was not declared in this scope
main.cpp: In function 'int CallbackThread(SceSize, void*)':
main.cpp:32: error: 'sceKernelCreateCallback' was not declared in this scope
main.cpp:33: error: 'sceKernelRegisterExitCallback' was not declared in this sc
pe
main.cpp:35: error: 'sceKernelSleepThreadCB' was not declared in this scope
main.cpp: In function 'int SetupCallbacks()':
main.cpp:44: error: 'sceKernelCreateThread' was not declared in this scope
main.cpp:46: error: 'sceKernelStartThread' was not declared in this scope
/usr/local/pspdev/psp/sdk/include/psptypes.h: At global scope:
/usr/local/pspdev/psp/sdk/include/psptypes.h:73: warning: '_sb' defined but not
used
/usr/local/pspdev/psp/sdk/include/psptypes.h:74: warning: '_sh' defined but not
used
/usr/local/pspdev/psp/sdk/include/psptypes.h:75: warning: '_sw' defined but not
used
/usr/local/pspdev/psp/sdk/include/psptypes.h:76: warning: '_sd' defined but not
used
make: *** [main.o] Error 1
Well one of your problems is WeatherBug, which is adware and (last I heard) difficult to remove. Second, what's up with using that SBC Yahoo browser? I suppose it's better than IE.Zitat:
Zitat von psphacker12.
Did you see Insomniac's post?Zitat:
Zitat von Gonrai
is anyone going to help?Zitat:
Zitat von psphacker12.
Errors only help when we have somewhat good view on your project... Either you have made the functions after when your trying to use them, not linking the library ,etc...
Well heres my project, but it links to the graphics.h lib....
http://savefile.com/files/160310
Code:
Errors:Code:#include "main.h"
LOCAL char *readInput(FILE *fp) {
char *retp = NULL;
int curp = 0, ch;
int cursz = EXP_INP_SZ_;
retp = my_malloc(sizeof *retp * cursz);
while ( (ch = fgetc(fp)) != EOF ) {
if ( curp >= cursz ) {
retp = my_realloc(retp, sizeof *retp * (cursz + EXP_INP_SZ_));
cursz += EXP_INP_SZ_;
}
retp[curp++] = ch;
}
if ( !curp ) {
MY_FREE(retp);
return NULL;
}
if ( retp[curp-1] == '\n' ) {
retp = my_realloc(retp, sizeof *retp * curp);
retp[curp-1] = 0;
}
else {
retp = my_realloc(retp, sizeof *retp * (curp + 1));
retp[curp] = 0;
}
return retp;
}
LOCAL void printCipherMap(CipherText *ctptr) {
int i, j;
CipherChar *ccptr = ctptr->ciphermap;
int *ciphermap = ctptr->plainmap;
char *plainchars = ctptr->plainchars;
for ( i = 0; i < ALPHA_SZ_; ++i ) {
int current = ciphermap[i];
if ( !ccptr[i].isPresent )
continue;
printf("%c => ", 'a' + i);
if ( plainchars[i] == '?' ) {
current = ciphermap[i];
for ( j = 0; j < ALPHA_SZ_; ++j ) {
if ( current & aleph_codes[j] ) {
printf("%c", 'a' + j);
current &= ~aleph_codes[j];
if ( current )
printf(", ");
}
}
}
else
printf("%c", plainchars[i]);
printf("\n");
}
}
int main(int argc, char *argv[]) {
char *txt;
CipherText gctxt;
clock_t start, end;
double duration;
int unsolved;
if ( argc <= 1 )
txt = readInput(stdin);
else {
FILE *fp = fopen(argv[1], "r");
if ( !fp ) {
perror("fopen failed");
fprintf(stderr, "Input file couldn't be opened\n");
exit(EXIT_FAILURE);
}
txt = readInput(fp);
}
if ( !txt ) {
fprintf(stderr, "No input given!!\n");
exit(EXIT_FAILURE);
}
start = clock();
unsolved = solveQuip(txt, &gctxt);
end = clock();
if ( !unsolved ) {
printf("Original Text:\n");
printf("%s\n\n", gctxt.ociphertxt);
printf("Deciphered Text:\n");
printf("%s\n\n", gctxt.plaintxt);
printf("Cipher to Plain text mapping:\n");
printf("-----------------------------\n");
printCipherMap(&gctxt);
duration = (double) (end - start) / CLOCKS_PER_SEC;
printf("Solving time: %2.1f seconds\n", duration);
}
else
exit(EXIT_FAILURE);
return 0;
}
http://i52.photobucket.com/albums/g9...r12/omghax.jpg
First of all, thanks for your answers!
As for the list of artist, I think the best delimiter would be a newline-character (\n) since it will never appear in an artistname; It would look like this:
I thought by sending along the lenght of the artist- album-names I could allocate exactly allocate the amount of memeory I needed, not more not less. No artists- or album-name would have been cut. But as I heard allocating memory using malloc slows down the PSP, so I'll go with your suggestions.Code:536 // First line, number of artists
A perfect circle // Name of the artist (#1)
3 // Albumcount
Emotive // Name of the album (#1)
Mer de noms // Name of the album (#2)
The thiteenth step // Name of the album (#3)
Aphex Twin // Name of the artist (#2)
2 // albumcount
Come to daddy // Name of the album (#1)
Selected ambient works // Name of the album (#2)
[...] // Name of the artist (#3)
There is only one question left: How do I read a varialble until the next newline as quickly as possible??
psphacker12: Learn how to code before trying to copy/paste someone elses code into your own.
Problem fixed.
??Zitat:
Zitat von Insomniac197
im trying to port cryptoquip
-= Double Post =-
okay heres my problem..
I have solveQuip declared as a function like this
but when i try to use it like this..Code:int solveQuip(char *txt, CipherText *ctptr) {
CipherWord **cipherwordptrs;
int i;
int newmap[ALPHA_SZ_];
int ncipherwords;
Bool nosolution = FALSE;
char *ciphertxt = ctptr->ociphertxt;
char plainmap[ALPHA_SZ_];
processInput(txt, ctptr);
if ( ctptr->ncipherwords <= 0 )
return 1;
cipherwordptrs = my_malloc(sizeof *cipherwordptrs * ctptr->ncipherwords);
for ( i = 0; i < ctptr->ncipherwords; ++i ) {
cipherwordptrs[i] = ctptr->cipherwords[i];
}
for ( i = 0; i < ctptr->ncipherwords-1; ++i ) {
int j;
int ikey = cipherwordptrs[i]->len;
for ( j = i+1; j < ctptr->ncipherwords; ++j ) {
int jkey = cipherwordptrs[j]->len;
if ( ikey < jkey ) {
CipherWord *temp = cipherwordptrs[i];
cipherwordptrs[i] = cipherwordptrs[j];
cipherwordptrs[j] = temp;
ikey = jkey;
}
}
}
for ( i = 0; i < ctptr->ncipherwords; ++i ) {
CipherWord *wptr = cipherwordptrs[i];
getMatchingWordsFromDict(wptr, dicts + wptr->len - 1, ctptr->ciphermap);
}
ncipherwords = ctptr->ncipherwords;
while ( 1 ) {
int j;
nosolution = solveWords(cipherwordptrs, ncipherwords, newmap);
if ( !nosolution )
break;
for ( i = 0; i < ncipherwords; ++i ) {
if ( cipherwordptrs[i]->isIgnored )
continue;
cipherwordptrs[i]->isIgnored = TRUE;
fprintf(stderr, "Couldn't find a solution, Ignoring %s and trying others\n", cipherwordptrs[i]->word);
break;
}
if ( i == ncipherwords )
break;
for ( j = 0; j < ALPHA_SZ_; ++j ) {
CipherChar *ccptr = ctptr->ciphermap + j;
if ( ! ccptr->isPresent )
continue;
ccptr->plainmap = ALEPH_ALL;
}
for ( ++i; i < ncipherwords; ++i ) {
if ( cipherwordptrs[i]->isIgnored )
continue;
cipherwordptrs[i]->curmatch = 0;
if ( cipherwordptrs[i]->possiblewords )
MY_FREE(cipherwordptrs[i]->possiblewords);
getMatchingWordsFromDict(cipherwordptrs[i], dicts + cipherwordptrs[i]->len - 1, ctptr->ciphermap);
}
}
if ( nosolution ) {
fprintf(stderr, "Couldn't find a solution!\n");
return 1;
}
else {
convertMapToChars(ctptr->ciphermap, newmap, plainmap);
memcpy(ctptr->plainmap, newmap, sizeof *newmap * ALPHA_SZ_);
memcpy(ctptr->plainchars, plainmap, sizeof *plainmap * ALPHA_SZ_);
ctptr->plaintxt = my_malloc(sizeof *ctptr->plaintxt * strlen(ctptr->ociphertxt));
strcpy(ctptr->plaintxt, ctptr->ociphertxt);
ciphertxt = ctptr->plaintxt;
for ( ; *ciphertxt; ciphertxt++ ) {
char cipherchar = *ciphertxt;
int isupper;
if ( !isalpha((int) cipherchar) )
continue;
isupper = isupper((int) cipherchar);
cipherchar = tolower((int) cipherchar);
*ciphertxt = isupper ? toupper((int)plainmap[CHAR_TO_INDEX(cipherchar)]) : plainmap[CHAR_TO_INDEX(cipherchar)];
}
}
return 0;
}
it gives me these errorsCode:unsolved = solveQuip(txt, &gctxt);
Code:[email protected] /$
$ make
psp-gcc -I. -I/usr/psp/sdk/include -O2 -G0 -Wall -c -o main.o main.c
main.c : In function 'main':
main.c(186) : error: called object 'solveQuip' is not a function
make: *** [main.o] Error 1
Again, heres my project:
http://savefile.com/files/160310
Please someone help, whats wrong with it? The graphics.h connects to it fine..I dont know whats wrong.
That's plain utter bull. malloc shouldn't be used inside inner loops of realtime-apps, yes, but even there it is possible to some extent. Whoever told you that, don't listen to him.Zitat:
Zitat von Lukeson
Uh... read char by char into a buffer until one char turns up as newline. Stop. Repeat. Pretty simple :PZitat:
There is only one question left: How do I read a varialble until the next newline as quickly as possible??
ugh...
1. Remove the ] bracket at the start of your main.c...
2. You dont need that extern C stuff since you're already saying it's in C by having main file main.c...
That should fix it.
All right its actually working now :P
But is there a way to make it so when I press Up or Down he doesnt move like 1 inch?? Like when i press it he doesnt keep moving he just stops.
How do i make it so when i hold it down he keeps moving, and when i release he stops?
Gonrai - You specifically said to make him only move once (in the code). Remove the UP and DOWN if statements (the button input) OUT of the if statement that says if oldpad ~=pad or w/e.
Thanks for the code, I appreciate it. The code you gave me worked like a charm. But if only want a "regular" eboot I'll first have to type "make" then "make noex" (I have deleted the kxploit line). Is there a way to short it down so I'll only have to type one line in cygwin?Zitat:
Zitat von Insomniac197
Psphacker12.: Try changing 'int' to 'void', that works sometimes with errors like these. At least I had an error that said that it was not a function and it took me a day to figure out what was worng. But I still don't know why it didn't work when I was using int :)
SodR - Im not sure what your question really is, but to spit out a NON kxploit eboot, just type 'make' rather than 'make kxploit'. Once again, Im not 100% what you and Insomniac had discussed and am a little too lazy to read back :o
Lol, no that is not what I'm asking :) I just wondered if you could type make clean without first having to type make to generate the eboot. That is so I wont have to type two lines into cygwin ;)Zitat:
Zitat von SG57
Sounds pretty slow...Zitat:
Uh... read char by char into a buffer until one char turns up as newline. Stop. Repeat. Pretty simple :P
Wouldn't it even be faster to write the string to a file and use fgets? That's pretty 'dirty' and I guess fgets does nothing else than doing the char-by-char-thing, but maybe not?
That would probably be the slowest way to do it. Just do something likeZitat:
Zitat von Lukeson
It should be pretty fast.Code:for(int i=0;i<strlen(str);i++)
{
if(str[i]=='\n') //newline
}
Writing to a file just to read again byte for byte? How should that ever be faster? And yes, fgets also only reads byte for byte, but from a file instead of from memory which is hundreds times slower, plus the additional writing which is even more slower.Zitat:
Zitat von Lukeson
That's somewhat how I imagined and it's the fastest way possible by any means. Do it like that.Zitat:
for(int i=0;i<strlen(str);i++)
{
if(str[i]=='\n') //newline
}
how do you do this:
let the program while in a loop return to the beginning of that loop
for exemple
you see , so it stay asking it ,untiln the variabel "leerlingen = 21" ofcoures;)Code:
for(leerlingen=1; leerlingen<=21;) {
cout<<"geef de score van leerling "<<leerlingen;
cin>>punten[leerlingen];
cout<<"\n";
leerlingen +1;
/************************************************
*********************return now to the beginning*******/
if (leerlingen=21) {
break;
}
}
}
I don't really understand what you mean but here is an example of a while loop;Zitat:
Zitat von hallo007
I hope it'll helpCode:int x = 0;
// Endless loop if we don't break it using 'break;'
while(1) {
x++;
// If the integer x = 21 we'll break the loop
if(x==21) {
break;
}
}
// This code will only run when we have broke out of the loop
no i dont help , lol
i understand what a loop is
but i wanne repeat the loop
so if the user put a value for number 1 , it ask a value for number 2 , i have that , the only thing i need to do is that it's start again from the beginning
for exempla
understand?? srry , i know my english is bad:(Code:what's the value of number 1? 4
/*now it repeats and x is one more so it prints number 2 and save the value to arrey 2*/
what's the value of number 2? 7
Why don't you do it like this
Or in your caseCode:int a = 0;
while(1)
{
cin>>var;
a++;
if(a==21)
break;
/*else
{
//Not needed at all, just showing you the continue statement
continue;
}*/
}
Code://Reset to avoid any memory problems
leerlingen = 0;
while(1)
{
cout<<"geef de score van leerling "<<leerlingen;
cin>>punten[leerlingen];
cout<<"\n";
leerlingen++;
if (leerlingen==21)
break;
}
You could also put the loop inside another loop. Then, in the inside loop, make it check which run through the outside loop it is. Example:
Or...Code:for(x=0;x<5;x++)
{
for(y=0;y<5;y++)
{
switch(x)
{
case 0:
// something to do the first time through
break;
case 1:
// something to do the second time through
break;
case 2:
// something to do the third time through
break;
case 3:
// something to do the fourth time through
break;
case 4:
// something to do the fifth time through
break;
}
}
}
Code:for(x=0;x<5;x++)
{
printf("What's the value of number %i?\n", x);
//get input here... however you want to do it
}
Should be:Code:for(leerlingen=1; leerlingen<=21;) {
cout<<"geef de score van leerling "<<leerlingen;
cin>>punten[leerlingen];
cout<<"\n";
leerlingen +1; // This line doesn't do anything to 'leerlingen'
/************************************************
*********************return now to the beginning*******/
if (leerlingen=21) {
break;
}
}
}
Code:for( leerlingen = 0; leerlingen < 21; ++leerlingen ) {
cout << "geef de score van leerling " << leerlingen;
cin >> punten[leerlingen];
cout << endl;
}
Heh. Looks like we all missed that he wasn't incrementing the value, except for you. Also:will start storing values in the second array element.Code:for( leerlingen = 0; leerlingen < 21; ++leerlingen ) {
cout << "geef de score van leerling " << leerlingen;
cin >> punten[leerlingen];
cout << endl;
}
will start from the first :)Code:for( leerlingen = 0; leerlingen < 21; ++leerlingen ) {
cout << "geef de score van leerling " << leerlingen;
cin >> punten[leerlingen-1];
cout << endl;
}
so when i put in the first value , the program do first the second loop (and repeats it 100times ) and then it crashes:(
Now I got a question for you guys:
I use this posted by Insomniac :) at psp-programming to generate a random number:
Then I got an array that looks like this:Code:int getRandomNum(int lo, int hi)
{
SceKernelUtilsMt19937Context ctx;
u32 rand_val = sceKernelUtilsMt19937UInt(&ctx);
rand_val = lo + rand_val % hi;
return (int)rand_val;
}
The numbers are offsets if anyone wonders.Code:char color[5];
// Yellow
color[1] = 0;
// Green
color[2] = 29;
// Black
color[3] = 58;
// Red
color[4] = 87;
// Blue
color[5] = 116;
Then I generate a random number between 1 and 5 like this:
Then I finaly want to use the random number and blit the image:Code:int RandomNum;
RandomNum = getRandomNum(1,5);
This compiles fine but when I try it on the psp it'll always generate the number 1 = the color/offset is always 0/yellow. I know I can do this fix it "the lazy way" using alot of if statements but I got [f]Alot[/f] of different images I'm bliting and it would take forever to write if statements to them all.Code:blitAlphaImageToScreen(color[RandomNum],0,29,25, hex_image, 132, 222);
blitAlphaImageToScreen(color[RandomNum],0,29,25, hex_image, 132, 247);
Any thoughts?
Woah. That would start from -1 not 0. On the first loop, leerlingen = 0, it doesnt increment until the end of the first loop.Zitat:
Zitat von FreePlay
You need to seed the randomizer.
Not sure how you do it with that way.
but you could do:
srand(time(NULL));
RandomNum = rand() % (5+1);
Thanks It worked fine. I guess there is no "magic" way of making the integer change every time you use it? I.e.Zitat:
Zitat von waterbottle
That would save me alot of time/space in the source.Code:// First a number is generated here:
blitAlphaImageToScreen(color[RandomNum],0,29,25, hex_image, 132, 222);
// A new number is automaticly generated using the same integer
blitAlphaImageToScreen(color[RandomNum],0,29,25, hex_image, 132, 247);
thnx , i m nearly there now i want to parts the punten[leerlingen]
but how do you adds them up if you dont know how many there gonna be????????
If you read the full post mate it shows how to seed the Mersenne Twister etc.Zitat:
Zitat von SodR
http://www.psp-programming.com/dev-f...pic.php?t=1076
I found it a lot more random than using the rand() stuff.
-= Double Post =-
I think you could do something like this...:Code:// First a number is generated here:
blitAlphaImageToScreen(color[RandomNum],0,29,25, hex_image, 132, 222);
// A new number is automaticly generated using the same integer
blitAlphaImageToScreen(color[RandomNum],0,29,25, hex_image, 132, 247);
Code:blitAlphaImageToScreen(color[GetRandomNum(0, 10)],0,29,25, hex_image, 132, 222);