C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Zitat von liornetwork no way it takes a cuple of howers ant when i try to compile a diffrent program ...
-
09-03-2006, 05:23 PM #841QJ Gamer Silver
- Registriert seit
- Jul 2005
- Ort
- Brampton
- Beiträge
- 631
- Points
- 6.764
- Level
- 54
- Downloads
- 0
- Uploads
- 0
try posting at that site first.
Zitat von liornetwork
also that is the second tutorial of many more.
you have to use what you learned to move forward.
You can hyperlink quotes and the whole box will be a link:
A Ultimate QJ FAQ-Topics I'm in-My qj game topic-My psp-prog topic-Old QJ Download site-Only ISO topic
Zitat von ANTONIO_424
"You stayed up all night trying to make your psp crash? LOLOL!!" - my brother
My PSN name is "icantthinkofone".
-
09-04-2006, 12:03 PM #842
Hey guys,
I was wondering if someone could help me out.
I'd like to clip off a part of a text blitted with the freetype2 lib.
IE.
I'd like it to display only the first part of the text, so:Code:mytext = "This is a long line of text which needs to be clipped"; text_to_screen(mytext, x, y);
"This is a long li"
Any ideas or suggestions are highly appreciated.
Thanks in advance,
Gh0sT
-
09-04-2006, 12:21 PM #843words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Uhh... what? You can always seperate the string into an array of strings, allowing you to loop through and print them... Like a paragraph.
That will print out the array of character arrays in a paragraph form. I dont know if the freetype library uses the top-left pixel as 0,0, so if it isnt, then youll have to modify the Y co-ordinate in the for loop differently.Code:char paragraph[4][18] = { "Sentence #1", "Sentence #2", "Sentence #3", "Sentence #4" } ... for ( int i=0; i<4; i++ ) text_to_screen(paragraph[i], 0, i*character_height);
There also is another way to do what you want as well...
That will print Hello, or more to the point, the charracters from 'start_clipping' and 'end_clipping'.Code:char string[] = "World Hello"; int start_clipping=6, end_clipping=11; ... for ( int i = start_clipping; i <= end_clipping; i++ ) text_to_screen ( string[i], i*char_width, 0);

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
09-04-2006, 12:57 PM #844
Hey SG57, thanks for replying.
I just got a different solution from someone which does the trick for me:
Thanks anyway,Code:char mytext[10]; strncpy(mytext,"This is a long line of text which need to be clipped",10);
Gh0sT
-
09-09-2006, 08:07 AM #845Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Color* vram = getVramDrawBuffer();
for(curentco = 0; curentco < PSP_LINE_SIZE*272+480; curentco++) {
vram[curentco] = RGB(255,255,255);
}
why dosn't that make the screen white?
-
09-09-2006, 08:25 AM #846Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
What exactly are you trying to achieve waterbottle? If you're just trying to create a white 'background' then either use the clearScreen function, or draw a white quad using GU_SPRITES.
That function looks like it would be slow.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-09-2006, 08:35 AM #847Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I were bored and got the idea to write that, arn't going to use it, just wondering why it dosn't work.. maybe I should swap the buffers?!
Zitat von Insomniac197
-
09-09-2006, 08:58 AM #848Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Look at the fillScreenRect function mate, it'll answer your question.

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-09-2006, 02:14 PM #849words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
What engine he's using should have been asked first... PSPGL, SDL, OSlib, GU? All have there own framebuffers so maybe your using one that isn't compatible with Insomniac's advice? Since fillScreenRect is GU within the graphics library, if your using SDL, OSlib or PSPGL it wont do much good...

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
09-09-2006, 03:53 PM #850Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
It was obvious what he was using as a front end with the first line:
Since getVramDrawBuffer() is a graphics lib function, I know he's asking about graphics lib usage.Code:Color* vram = getVramDrawBuffer();
Do your research, then when you think about coming back with an answer that is neither informative or accurate...
.. Don't.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-09-2006, 04:05 PM #851AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
I believe this should work:
Zitat von waterbottle
Code:Color* vram = getVramDrawBuffer(); int x, y; for(x = 0; x < 480; x ++) { for(y = 0; y < 272; y++) vram[PSP_LINE_SIZE*y+x] = RGB(255,255,255); }
-
09-10-2006, 02:22 AM #852Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
help i get an error with cygwin three days ago it just works fine
-
09-10-2006, 02:29 AM #853AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Copy cygwin1.dll from C:\cygwin\bin to C:\Windows\system32. That should fix the problem.
-
09-10-2006, 05:01 AM #854QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
It doesn't matter anything which frontend you use. As long as you directly access the framebuffer it's just going to fill it up (the only question would be how to make that framebuffer visible on screen then, but that can be done with a flipscreen in graphics.c, or a sceGuSetFrameBuffer). You can do the same under windows with either OpenGL or DirectX or SDL or whatever you use. Only problem there is that DirectX for example locks framebuffers for access, but that doesn't matter in this case.
Zitat von SG57
Also as Insomniac stated, he used the "Color* vram = getVramDrawBuffer();" function to get the framebuffer pointer, so it's obvious he uses graphics.c.
-
09-10-2006, 06:56 AM #855Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
rare when i compill it no errors
but when i tried to launch it with psp it gives an error
-= Double Post =-Code://hello world v0.01b /* thnx to psp-programming for their tutorials */ #include <pspkernel.h> //alle codes voor de psp zodat schrijven gemmakelijker word #include <pspdebug.h> //nodig voor text op het scherm te printen PSP_MODULE_INFO("Hello World", 0, 1, 1); /* niets belangerijk we vertellen de psp de naam van het programma maar je kan het weglaten het is niet echt de naam dat op het scherm zal verschijnen */ #define printf pspDebugScreenPrintf /* we vertellen de compiller dat we screen gaan printen en om het gemmakelijk te maken zorgen we ervoor dat de compiller vanaf nu prontf kan lezen */ /* Exit callback */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; } /* Callback thread */ int CallbackThread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } /* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } //belangerijk altijd in code aanwezig zijn voor het sluiten enzovoort int main() { //start een functie pspDebugScreenInit(); SetupCallbacks(); //zorg ervoor dat de functie start printf("hello world"); //print text on screen sceKernelSleepThread(); // dit zorgt ervoor dat de psp een pause neemt waardoor je je functie kan zien return 0; // het blift de functie herhalen herhalen /* nu zeggen we dat de functie gedaan is en kan de psp eventueel de volgende functies uitvoeren of beter gezegd de ram blift de functie niet herladen */ //momenteel einde }
very rare
i installed my 1.5 again and now it works
-= Double Post =-
so with the tutorials of psp-programming i made a timer
but when stoped , you cant restart it , how do you let it restart by pressing [X]?????Geändert von hallo007 (09-10-2006 um 06:56 AM Uhr) Grund: Automerged Doublepost
-
09-10-2006, 07:18 AM #856Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
you could either put the entire code inside a different function or put all of it inside a loop and let that restart after the timer is finished. I would recomend you to complete and undersstand all of the tutorials before writing this though..
Zitat von hallo007
but here is an example code of how you can do it..
Code:#include <pspkernel.h> #include <pspdebug.h> #include <pspdisplay.h> #include <pspctrl.h> PSP_MODULE_INFO("Timer", 0,1,1); #define printf pspDebugScreenPrintf void timerfunction();//define the function so you can use it anywhere in the code. SceCtrlData pad;//make pad global so you can use it in all functions /* Exit callback */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; } /* Callback thread */ int CallbackThread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } /* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } int main() { pspDebugScreenInit(); SetupCallbacks(); while(1) { timerfunction(); }//when ever the program gets here start the timer function return 0; } /////////////////////////////////////////////////////////77 void timerfunction() {//start of the timer function int counter = 0; int i = 0; printf("Press [X] To Start the Timer"); while(1) { sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons & PSP_CTRL_CROSS) { break; } } while(1) { sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons & PSP_CTRL_CIRCLE) { break; } pspDebugScreenClear(); printf("Press [O] To Stop the Timer\n"); printf("Counter: %i", counter); counter++; for(i=0; i<5; i++) { sceDisplayWaitVblankStart(); } } pspDebugScreenClear(); printf("Counter Finished."); printf(" Final Count: %i\n", counter); printf("Press X to restart"); while(1) { sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons & PSP_CTRL_CROSS) {//when the timer is finished wait for player to press X before returing to main() and restarting timer function break; } } }
-
09-10-2006, 07:39 AM #857I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Now, if I try to flash a file, from within DevHook, it will reroute all files flashed to the "dh" folder, right? Even though, I'm only flashing name_plate.png, I'm still a little hesitant.

-
09-10-2006, 07:42 AM #858Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
can somone find a tutorial for loading just a background in c/c++ , or give me a code
because i cant find it on psp-programming (it's with variables ,...)
-
09-10-2006, 12:14 PM #859Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von hallo007
-= Double Post =-Code:Image* theImage; theImage = loadImage("theImage.png")
help:
ok, so i have a txt file with all my highscores. BUT, i want it so that when i compile, it will compile the text file INTO the eboot, so the player cant cheat and change the highscores. thx to anbody who helps!!Geändert von Grimfate126 (09-10-2006 um 12:14 PM Uhr) Grund: Automerged Doublepost
--------------------------------------------------------------------------------------
-
09-10-2006, 12:18 PM #860AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
That's a bit more complicated than just adding the txt to the eboot and then it's done. I have a function so you can read and create bin files which contains certain files. But I'm using that in my project, so I'm not willing to spread it around.
Zitat von Grimfate126
-
09-10-2006, 12:19 PM #861Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Why bother? Just define variables that hold the information and update them as and when you need to.
Zitat von Grimfate126

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-10-2006, 01:05 PM #862Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
but, when i restart the game.. wont they be inttialized back to 0?? i want them, to be kept same...
Zitat von Insomniac197
--------------------------------------------------------------------------------------
-
09-10-2006, 01:05 PM #863QJ Gamer Platinum
Awards:
- Registriert seit
- Jul 2006
- Ort
- NorCal
- Beiträge
- 24.899
- Points
- 88.881
- Level
- 100
- Downloads
- 0
- Uploads
- 0
How do I put text in the middle of the screen?
Can't figure it out...If you ever need me, you can contact me at [URL="**********.net"]**********.net.[/URL]
-
09-10-2006, 01:10 PM #864Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Then you won't be able compile the text file with the eboot then, as this would do the same thing.
Zitat von Grimfate126
You'll need to encrypt/decrypt the high scores file somehow.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-11-2006, 03:54 PM #865
Hey, does anyone know where I can find a tutorial for PSPGU well documented and explained for first time users?:Argh:
-
09-11-2006, 04:03 PM #866AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
That depends on what you're using to print text. But if you're using the graphics lib you can do this:
Zitat von TrumpeyGeek
Code:printTextScreen((480/2)-((strlen("The text")*8)/2, (272/2)-(8/2), "The text", color);Here: http://www.psp-programming.com/code/...id=c:tutorials
Zitat von Devun_06
-
09-12-2006, 02:35 PM #867I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
What's the basic function for flashing a file to the flash? Something simple, like flashing name_plate.png. I just want the basic function, I don't want any error checks or printing to the screen, or anything else.

-
09-12-2006, 02:43 PM #868AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Well.. I'm pretty sure this should work:
Code:int FlashFile(char *inPath, char *outPath) { char *inBuf; long inSize = 0; FILE * inFile = fopen(inPath, "rb"); fseek(inFile, 0, SEEK_END); inSize = ftell(inFile); fseek(inFile, 0, SEEK_SET); inBuf = malloc(inSize+1); fread(inBuf, 1, inSize, inFile); fclose(inFile); //Flash the file sceIoUnassign("flash0:"); sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", 0, NULL, 0); FILE * outFile = fopen(outPath, "wb"); fwrite(inBuf, 1, inSize, outFile); fclose(outFile); return 1; }
-
09-12-2006, 02:47 PM #869I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Now, inPath, and outPath, are the file paths, right? And what about inFile and inBuf and inSize? Do I have to replace those?

-
09-12-2006, 02:48 PM #870OMFG

- Registriert seit
- Jul 2005
- Ort
- Toronto
- Beiträge
- 2.814
- Points
- 19.453
- Level
- 88
- Downloads
- 0
- Uploads
- 0
This is basically exactly what you're looking for. I have it in my own thread somewhere, but I think the link is dead until I get a reliable server.
Zitat von ARza
http://www.sendspace.com/file/ufgrtm


LinkBack URL
About LinkBacks
Mit Zitat antworten


Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum