Hi! :)
Yes, the program doesen't sleep for 10 seconds or 1 second. :)Zitat:
Zitat von hallo007
Nobody knows why sceDisplaySetBrightness() makes my program hang?
Or have someone an example usage of this function?
Many thanks.
Ciaooo
Sakya
Printable View
Hi! :)
Yes, the program doesen't sleep for 10 seconds or 1 second. :)Zitat:
Zitat von hallo007
Nobody knows why sceDisplaySetBrightness() makes my program hang?
Or have someone an example usage of this function?
Many thanks.
Ciaooo
Sakya
check this thread ;)
http://forums.ps2dev.org/viewtopic.p...ysetbrightness
I gotz a question! (obviously :P) Im porting my game to the Old School Library and as such i found it ridiculesly easy to rotate images, so, I would like to rotate smoothly instead of the simple up,down,left,right directions, problem is, how would i make a bullet System to match that??? My result is much like what CS 2d is, but he uses a C++ class for his bullet system, How would i do this in C?
Thank you!
BlackShark - A C++ class can be ported to C via removing the function names class:: pre-fix. As for how he rotated to match the direction vector, one method would be to make a particle engine, and have the bullet be a particle but with a constant, fixed rate of fading and color change for each particle, giving it that solid color look. As for the other method (rotating an actual bullet image to the direction vector) you could grab a point somewhere along your player's direction vector and use atan2f to get what degree it is rotated to your player. Hope that helps (if you need any more help, im free tonight)
Well, I am not that experienced so I would not even know were to begin in making a particle engine :S
Well, then go with the second option. It may be even faster as it doesnt require as many trig calculations per cycle.
For the second option, here's what i would when the bullet is fired (AKA when the X or R trigger button is pressed)
Note: The bullet image would need to have 0 degrees as straight up.
Then you'd say if currentBullet onScreen is true, draw it and move the X values via adding xspeed and Y values via adding yspeed. I might make an example just for fun, but my PSP is currently non useable (it works, its just the LCD is not plugged in)Code:if(osl_key->pressed.cross && numBulletsOnScreen < MAX_BULLETS) {
bullet[currentBullet].image->angle = atan2f((crosshair.y+crosshair.image->height*0.5) - (player.y+player.image->height*0.5), (crosshair.x+crosshair.image->width*0.5) - (player.x+player.image->width*0.5)); // the *0.5 is faster then /2, which is centering where to shoot the bullet from, you could even mod these to shoot from the end of hte barrel for better accuracy
bullet[currentBullet].xspeed = oslCos(bullet[currentBullet].angle,1);
bullet[currentBullet].yspeed = oslSin(bullet[currentBullet].angle,1);
bullet[currentBullet].onScreen = true;
if(currentBullet >= MAX_BULLETS)
currentBullet = 0;
else
currentBullet += 1;
}
It may be either that you are not in kernel mode (but it shouldn't totally freeze if you're in user mode) or the 1.5 kernel doesn't support that function.Zitat:
Zitat von sakya
edit: i found my prob i plan to release the source to this later
Blackshark, think about it like this. Say you have a cursor on the screen and when you shoot you want to the bullet to shoot in the direction of the cursor. The concept for what you want to do is just to make the cursor invisible. So, as your character rotates, the bullet is always shooting in the direction the character is facing (In which the cursor would usually be).
i want to load ELF using this code
psp resets when loading the elfCode:if (pad.Buttons & PSP_CTRL_RTRIGGER){
struct SceKernelLoadExecParam param;
memset(¶m, 0, sizeof(param));
param.size = sizeof(param);
param.args = strlen(DEFINED_ELF)+1;
param.argp = DEFINED_ELF;
param.key = "game";
sceKernelLoadExec(DEFINED_ELF, ¶m);
}
sceKernelLoadExec resets the kernel when loading a module. Use sceKernelLoadModule and sceKernelStartModule instead.
That helps :DZitat:
Zitat von PSPJunkie_
That also very much helps, if you wan't to make a sample, i can test to see if it works, but you don't have to do all that just for this, Thanks again :)Zitat:
Zitat von SG57
the sceKernelLoadExec laods prx's amd eboots fine, but when it comes to load ELF my psp crashesZitat:
Zitat von Archaemic
edit: ok another question. my code compiles but the only error i get is "Syntax error before Struct"
everything compiled fine until i created the menu. now i end with the synatx error before structCode:case 0:
struct SceKernelLoadExecParam param;
memset(¶m, 0, sizeof(param));
param.size = sizeof(param);
param.args = strlen(MY_MODULE)+1;
param.argp = MY_MODULE;
param.key = "game";
sceKernelLoadExec(MY_MODULE, ¶m);
compilled , but doesnt work :/Code:/*
* Origenal Made by vodkkaa
* Last author : hallo007
* Usbon.prx
* You are allowed to upgade the source , but not to delete the credits
*/
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <stdio.h>
#include <stdlib.h>
#include "blit.h"
#define THREAD_PRIORITY 8
#define DELAY_THREAD_AMT 10000
PSP_MODULE_INFO("USBON", 0x0800, 1, 1);
u32 usbStarted;
SceUID display_thid;
int display_timer = 0;
int usb = 0;
int blit = 0;
char usbDriverText[200];
char usbCableText[200];
int LoadStartModule(char *path)
{
u32 loadResult;
u32 startResult;
int status;
loadResult = sceKernelLoadModule(path, 0, NULL);
if (loadResult & 0x80000000) return -1;
else
startResult = sceKernelStartModule(loadResult, 0, NULL, &status, NULL);
if (loadResult != startResult) return -2;
return 0;
}
void initUsb()
{
LoadStartModule("flash0:/kd/semawm.prx");
LoadStartModule("flash0:/kd/usbstor.prx");
LoadStartModule("flash0:/kd/usbstormgr.prx");
LoadStartModule("flash0:/kd/usbstorms.prx");
LoadStartModule("flash0:/kd/usbstorboot.prx");
sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
sceUsbstorBootSetCapacity(0x800000);
usb = 1;
}
int display_thread(SceSize args, void *argp)
{
while (1)
{
//blit text
if(blit)
{
blit_string(42,29,"made by vodkkaa & hallo007",0xffffff,0x0000FF);
blit_string(42,30,usbDriverText,0xffffff,0x0000FF);
blit_string(42,31,usbCableText,0xffffff,0x0000FF);
}
sceKernelDelayThread(DELAY_THREAD_AMT);
}
return 0;
}
int main_thread(SceSize args, void *argp)
{
SceCtrlData pad;
while (1)
{
sceKernelDelayThread(5*DELAY_THREAD_AMT);//needs less running time
if(!usb) initUsb(); // no need to load the prx's again and again
if(display_timer)//fix for suspend bug
{
display_timer--;
if(display_timer == 0)
{
display_thid = sceKernelCreateThread("IRSDisplayThread", display_thread, THREAD_PRIORITY, 0x04000, 0, NULL);//higher priority, less code, reduces flickering
if(display_thid >= 0)
{
sceKernelStartThread(display_thid, args, argp);
}
}
}
//get connection state
usbStarted = sceUsbGetState();
//init usb driver text
if(usbStarted & PSP_USB_ACTIVATED)
{
sprintf(usbDriverText , "USB Driver activated");
}
else
{
sprintf(usbDriverText , "USB Driver deactivated");
}
//init usb cable text
if(usbStarted & PSP_USB_CABLE_CONNECTED)
{
sprintf(usbCableText , "USB cable conencted");
}
else
{
sprintf(usbCableText , "USB cable disconnected");
}
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_RTRIGGER)
{
if(usbStarted & PSP_USB_ACTIVATED)
{
sceUsbDeactivate(0x1c8);
}
else
{
sceUsbActivate(0x1c8);
}
}
else if ( (pad.Buttons & PSP_CTRL_LTRIGGER) && (pad.Buttons & PSP_CTRL_HOME) )
{
//Stops the USB
if(usbStarted & PSP_USB_ACTIVATED)
{
sceUsbDeactivate(0x1c8);
}
sceUsbStop(PSP_USBSTOR_DRIVERNAME, 0, 0);
sceUsbStop(PSP_USBBUS_DRIVERNAME, 0, 0);
break; //Closes the prx
}
else if(pad.Buttons & PSP_CTRL_NOTE)
{
(display_timer == 0) ? display_timer = 1 : display_timer--;
(blit == 0) ? blit = 1 : blit--;
}
sceKernelDelayThread(100000);
}
return 0;
}
void* getModuleInfo(void)
{
return (void *) &module_info;
}
int module_start(SceSize args, void *argp)
{
SceUID thid;
sceKernelDelayThread(10000);//to prevent crashing
thid = sceKernelCreateThread("main_Thread", main_thread,0x18, 0x1000, 0, NULL);
if(thid >= 0)
{
sceKernelStartThread(thid, args,argp);
}
sceKernelExitDeleteThread(0);
return 0;
}
Zitat:
Zitat von vodkkaa
Code:case 0: {
struct SceKernelLoadExecParam param;
memset(¶m, 0, sizeof(param));
param.size = sizeof(param);
param.args = strlen(MY_MODULE)+1;
param.argp = MY_MODULE;
param.key = "game";
sceKernelLoadExec(MY_MODULE, ¶m);
}
Nope.Zitat:
Zitat von Archaemic
Switches work like so,
Code:switch(aVariable)
{
case caseOne:
//do this
break;
case caseTwo:
//do this
break;
case caseThree:
//do this
break;
case default;
//do the
//default
//thing
break;
}
Nope... you can include brackets in a switch, and is required for certain code or it won't compile, forget what, but, the code he posted is valid, it just needs a switch wrapper, like switch(variable) { }.Zitat:
Zitat von PSPJunkie_
I don't get what difference the braces would use, other than giving each case its own scope... If you do add braces, you still need a break statement though.
The problem with is code is the lack of brackets, if you assume it's inside a switch statement. The problem is that the scope there is somewhat ambiguous, so you can't declare more variables. You have to explicitly create a new block inside of which you can declare more variables. Trust me on this one; it's happened to me several times while writing PSPComic. It might work in C++, but it definitely doesn't work in C. Try it yourself if you don't believe me.
If he doesn't have a switch statement at all, then the,
is the syntax error. Putting brackets around it doesn't make sense because it won't recognize the 'case' keyword without being in a switch statement.Code:case 0:
I am pretty sure you can get rid of 'struct' so do this:Zitat:
Zitat von vodkkaa
Code:case 0:
SceKernelLoadExecParam param;
memset(¶m, 0, sizeof(param));
param.size = sizeof(param);
param.args = strlen(MY_MODULE)+1;
param.argp = MY_MODULE;
param.key = "game";
sceKernelLoadExec(MY_MODULE, ¶m);
Zitat:
Zitat von pspballer07
That would only work if 'SceKernelLoadExecParam' was defined as a 'typedef' structure.
Okay, now I have a question:
Has anyone here ever used/gotten SDL_gfx to work on the PSP? I keep getting a SIGBUS when I try to use the rotozoomer.
Here's my post on the PS2Dev forums (that no one responded to :()
I tried reinstalling the toolchain, but I got a SIGHUP in the process :(Zitat:
Zitat von Archaemic
Anyone have any ideas? This is really bugging me.
(The SIGBUS is coming from inside of SDL_gfx, not in my code.)
heres the problem,
Im porting a very very simple menu from Graphics.h to the Old School Library, I plan on upgrading the menu once im done, but for now i just wan't it to show up. when the Eboot starts up, nothing shows up, But i can still press the home button and exit that way, here is the source, im sure the problem is simple, im very new to the OS library.
My menu,
Spoiler for Old Menu codes, yes, it has weird comments, it was my first program in C:
It's because your using the graphics library, not OSlib. printTextScreen is NOT part of oslib. I recommend you follow the tutorials for OSlib. Here they are:
http://www.psp-hacks.com/forums/view...p?id=66708&p=1
Also, post your problems with OSlib there ;)
Apart from the fact you left one call to printTextScreen in, the code looks as though it should work (after a quick glance).
By the way, don't ignore warnings when compiling. Warnings are errors too.
But yeah, remove the graphics.h include, the initGraphics() call and everything else to do with it (including from your makefile).
Also, either remove the SetupCallbacks function or call oslInit(1);
I'm using graphics.h and stuff and I want the screen to fade out after a picture is displayed. I tried writing a fade out func but it didn't work at all. Here is my func:
Help!?Code:void FadeOut(int speed)
{
Color pix;
int i;
int x;
int y;
u8 re;
u8 gr;
u8 bl;
for(i = 0;i<255/speed;i++)
{
for(x = 0;x<SCREEN_WIDTH;x++)
{
for(y = 0;y<SCREEN_HEIGHT;y++)
{
pix = getPixelScreen(x,y);
re = R(pix);
gr = G(pix);
bl = B(pix);
re -= speed;
gr -= speed;
bl -= speed;
pix = GU_RGBA(re,gr,bl,255);
putPixelScreen(pix,x,y);
}
}
flipScreen();
}
}
ok i'm extremly unsure what is wrong with the following code:
Spoiler for code:
Spoiler for test0.x file the one being loaded in:
this code runs fine if compiled on the comp however if u noticed the commented out section if i add them in the psp's version of this won't work
although it should be noted it is not the any of the commented out section's individual fault it's just that lets see if i can explain it so it's understandable:
lets take this section:
}else if(strcmp(string,"i")==0 || strcmp(string,"I")==0){
sprintf(word_string,"%si" ,word_string);
/*
}else if(strcmp(string,"j")==0 || strcmp(string,"J")==0){
sprintf(word_string,"%sj" ,word_string);
}else if(strcmp(string,"k")==0 || strcmp(string,"K")==0){
sprintf(word_string,"%sk" ,word_string);
*/
as you can see the i is not commented out so just as a test i do:
}else if(strcmp(string,"i")==0 || strcmp(string,"I")==0){
sprintf(word_string,"%si" ,word_string);
}else if(strcmp(string,"j")==0 || strcmp(string,"J")==0){
sprintf(word_string,"%sj" ,word_string);
}else if(strcmp(string,"k")==0 || strcmp(string,"K")==0){
sprintf(word_string,"%sk" ,word_string);
now none is commented however now this won't work i can't even do:
}else if(strcmp(string,"i")==0 || strcmp(string,"I")==0){
sprintf(word_string,"%si" ,word_string);
}else if(strcmp(string,"j")==0 || strcmp(string,"J")==0){
sprintf(word_string,"%sj" ,word_string);
/*
}else if(strcmp(string,"k")==0 || strcmp(string,"K")==0){
sprintf(word_string,"%sk" ,word_string);
*/
and just have the k out but i can do:
/*
}else if(strcmp(string,"i")==0 || strcmp(string,"I")==0){
sprintf(word_string,"%si" ,word_string);
*/
}else if(strcmp(string,"j")==0 || strcmp(string,"J")==0){
sprintf(word_string,"%sj" ,word_string);
/*
}else if(strcmp(string,"k")==0 || strcmp(string,"K")==0){
sprintf(word_string,"%sk" ,word_string);
}
*/
i can switch them seperatly but can't have them all nor can i have 2
so i believe for some reason it's on a fixed number
i hope i explained my prob correctly and some1 can help me
Try flipscreen after putPixelScreen....Zitat:
Zitat von pspballer07
+Read the SDK documentation... There a better and faster way to do it[not directly tho by a simple func tho...]...
It didn't work but it did make a cool effect which I am going to use for when you enter a battle on rpg paradiseZitat:
Zitat von Mr305
u do realize that you just have to change the alpha value
also my question:
Spoiler for question:
Nope, that doesn't work.Zitat:
Zitat von slicer4ever
Does anyone know anything about setting light amount? Like so it fades out when I take away light?
really... well i don't use the graphics library anyways
pspballer - That would only work if you were using 3d hardware acceleration (efficiently).
To fade out, you'd simply clear the screen to black with a decreasing alpha value:
Note:I havent used graphics library in ages, so Im not sure if those are the correct function names.Code:for(int i = 255; i > 0; i--) {
clearScreen(RGBA(0,0,0,i));
flipScreen();
}
To have a speed you can set, the decrease value to it:
I do believe that'd work...Code:void fadeOut(const float speed) {
for(float i = 255; i > 0; i-= speed) {
clearScreen(RGBA(0,0,0,int(speed)));
flipScreen();
}
}
It doesn't work and I think its because the Alpha values for graphics can only be yes or no. Like if you have some its yes and if its 0 then no.Zitat:
Zitat von SG57
@sg57 it's possible to create lighting effect in 2d all be it not easyily but it is possible and would most likly consume up many fps to get it to work but it is possible
also clearing the screen does just that clears the screen and if he's trying to fade out a few images that won't work
@pspballer i dl'ed the graphics library and am looking though it now although it doesn't seem like theirs an easy command to change the alpha of an image
-= Double Post =-
ok i'm ganna write a quick function but the way i'm thinking of doing it is ganna be very slow i'll re-post when i'm done
-= Double Post =-
ok i'm done i didn't test it i'll leave that 2 you it should work:
Spoiler for fade out function:
-= Double Post =-
o yea and could some1 plz help me with my question
I had to fix a few syntax errors and no it didn't work :(Zitat:
Zitat von slicer4ever
-= Double Post =-
sorry, I never loaded .x files manually beforeZitat:
Zitat von slicer4ever
Thats very slow using the putPixelScreen function for each pixel on the psp each frame your trying to fade out.
Your best drawing a rectangle to fill the screen with transparency (instead of using the clearScreen method)
what would happen if i unload topmenu plugin from ram while in the xmb?