try posting at that site first.Zitat:
Zitat von liornetwork
also that is the second tutorial of many more.
you have to use what you learned to move forward.
Printable View
try posting at that site first.Zitat:
Zitat von liornetwork
also that is the second tutorial of many more.
you have to use what you learned to move forward.
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
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);
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
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?
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.
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:
Zitat von Insomniac197
Look at the fillScreenRect function mate, it'll answer your question.
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... :(
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.
I believe this should work:Zitat:
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);
}
help i get an error with cygwin three days ago it just works fine
http://img291.imageshack.us/img291/2307/naamlooswk4.gif
Copy cygwin1.dll from C:\cygwin\bin to C:\Windows\system32. That should fix the problem.
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:
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.
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]?????
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:
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;
}
}
}
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.
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 ,...)
Zitat:
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!!
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:
Zitat von Grimfate126
Why bother? Just define variables that hold the information and update them as and when you need to.Zitat:
Zitat von Grimfate126
but, when i restart the game.. wont they be inttialized back to 0?? i want them, to be kept same...Zitat:
Zitat von Insomniac197
How do I put text in the middle of the screen?
Can't figure it out...
Then you won't be able compile the text file with the eboot then, as this would do the same thing.Zitat:
Zitat von Grimfate126
You'll need to encrypt/decrypt the high scores file somehow.
Hey, does anyone know where I can find a tutorial for PSPGU well documented and explained for first time users?:Argh:
That depends on what you're using to print text. But if you're using the graphics lib you can do this:Zitat:
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:tutorialsZitat:
Zitat von Devun_06
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.
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;
}
Now, inPath, and outPath, are the file paths, right? And what about inFile and inBuf and inSize? Do I have to replace those?
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:
Zitat von ARza
http://www.sendspace.com/file/ufgrtm
Is that Slasher's? Because I already have that. I got it now though. Thanks for your help.Zitat:
Zitat von Alexisonfire
Have a look at my sig, it's me :)Zitat:
Zitat von Alexisonfire
Durr. God I'm stupid. I know that you're slasher. I just got you confused with homer because he posted too.
when i was testing with loading backgrounds and cpu speed i get this error
http://img154.imageshack.us/img154/5415/naamlooslq0.png
Code://cpu speed changer
/* cpu speed changer created by hallo007 (8 september 2006)and produced by rp productions
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
#include <pspdisplay.h>
#include <pspctrl.h>
#include <stdio.h>
#include <psppower.h>
PSP_MODULE_INFO("cpu speed changer", 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("rp productions"); //print text on screen
Image* menu;
menu = loadImage("menu.png")//laad afbeelding
SceCtrlData pad;//zo kan je de controls gebruiken
if(pad.Buttons & PSP_CTRL_UP) {//zeg wat de psp moet doen met het indrukken van up
int main(void) {
scePowerSetClockFrequency(333, 333, 166);//zet de cpu speed
}
printf("cpu speed = 333, 333, 166"); //print text on screen
}
if(pad.Buttons & PSP_CTRL_DOWN) {//zeg wat de psp moet doen met het indrukken van down
int main(void) {
scePowerSetClockFrequency(222, 222, 111);//zet de cpu speed
}
printf("cpu speed = 222, 222, 111"); //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
You just had the same error three days ago. I'm guessing the same fix will work a second time.
I told you before. Copy c:\cygwin\bin\cygwin1.dll to C:\windows\system32
ow srry gays
i uploaded the wrong imgae xD
really srry
i m uploading the real image now
-= Double Post =-
oke now is it the good picture i did check it ;)
Who're you calling gay?Zitat:
ow srry gays
i uploaded the wrong imgae xD
lol, j/k.
Anyway, you haven't included the graphics lib nor psppad.h.
oke thnx
the problem is
if i take an snapshot i open it with paint and save it
but it saves always as naamloos (i dont changes the name
but i got many with that name:d
so i v got
naamloos.gif
naamloos.png
....
lol
You do know you can copy text from the cygwin window right?
Zitat:
Zitat von jsharrad