The above video goes away if you are a member and logged in, so log in now!

 Would you like to get all the newest Gaming News fromQJ.NET in your email each day? Want to learn more about the team who brings you the QJ news?

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; Originally Posted by Slasher Well make your bullets into a struct, then use a for loop to go through them ...

 Tweet
1. Originally Posted by Slasher
Well make your bullets into a struct, then use a for loop to go through them and draw them, update them, etc.
Code:
```#define MAX_BULLETS 128

typedef struct
{
int x, y;
int speed;

int active;

} bullets[MAX_BULLETS];

int curBullet = 0;

int i;
for (i = 1; i <= MAX_BULLETS; i++)
bullets[i].active = 0;

int i;
for (i = 1; i <= MAX_BULLETS; i++)
{
if (bullets[i].active)
{
// Update (Your 'Refresh Shooting' section)
bullets[i].x += bullets[i].speed;

// Draw
blitAlphaImageToScreen
}
}

// Button press (You might want to put a delay on this)
{
if (curBullet < MAX_BULLETS)
curBullet++;
else
curBullet = 1;

bullets[curBullet].active = 1;
bullets[curBullet].x = xvalue;
bullets[curBullet].y = yvalue;
bullets[curBullet].speed = speedvalue;
}```
Hopefully you get the jist of it through that. You'll want to 'deactivate' the bullet after a set time, or perhaps if it goes off the screen. Just keep track of the x value through that for loop.

Ok, i tried something like that, but i couldn't get it working. I am sticking with my old code:

Code:
```//Square
{
//Shoot
FireTimer++;
}

/*******************
Shooting
********************/
if (FireTimer < 1)
{
WeaponPosX = SpaceshipPosX + SpaceshipWidth;
WeaponPosY = SpaceshipPosY + 15;
FireTimer = 0;
}

//Active Shoot
if (FireTimer > 1) {
if (FireTimer < 4) { WAV_Play(fire1); }
blitAlphaImageToScreen(0, 0, WeaponWidth, WeaponHeight, Weapon, WeaponPosX, WeaponPosY);
FireTimer++;
WeaponPosX += WeaponSpeed;
}

//Refresh Shooting
if (FireTimer > WeaponDistance)
{
WeaponPosX = SpaceshipPosX + SpaceshipWidth;
WeaponPosY = SpaceshipPosY + 15;
FireTimer = 0;
}```
How can i modify THIS code to make more than one weapon appear on the screen. Obviously, since i am using on one blitAlphaImageToScreen, the same image refreshes when i hold Square. Therefore, onle one bullet appears one the screen no matter how much i change the speed of the bullet. So my question is, how do i modify my code?

Thanks!

2. argh im new to coding in c but im only trying to add something into lua player could someone please help me figure out how to fix this error please

Code:
```src/luasystem.cpp: In function 'int lua_IRKeybGetKey(lua_State*)':
src/luasystem.cpp:58: error: invalid conversion from 'int' to 'void*'
src/luasystem.cpp:58: error:   initializing argument 1 of 'int pspIrKeybReadinpu
t(void*, int*)'
src/luasystem.cpp:58: error: invalid conversion from 'int' to 'int*'
src/luasystem.cpp:58: error:   initializing argument 2 of 'int pspIrKeybReadinpu
t(void*, int*)'
make: *** [src/luasystem.o] Error 1```
thanks

im sure its something simple like ive put int instead of char or something

** eagerly waits for help

3. Originally Posted by Mr305
Not exactly of what you mean by "'Load' a new one".

----
If you are already able to edit one, replace the old one with the edited one on flash0,0.

or
Is it a problem of 3.xx flashing?
*Sigh*... The whole point of me making a new one and not editing the current one is so I can run them side by side. I want to run the normal pspbtcnf.bin file, and then when I run an app, it will reboot the pspbtcnf_alt.bin file, ultimately going through that bootup, and not the Sony/Dark_AleX one.

-Aura

4. Originally Posted by Auraomega
*Sigh*... The whole point of me making a new one and not editing the current one is so I can run them side by side. I want to run the normal pspbtcnf.bin file, and then when I run an app, it will reboot the pspbtcnf_alt.bin file, ultimately going through that bootup, and not the Sony/Dark_AleX one.

-Aura
I don't have one to look at, so I don't know exactly what type of file it is. I know htat pspbtcnf.txt is a text file with a bunch of .prx paths in it, but I doubt that's what the .bin file is. Have you tried a simple sceKernelLoadExec()?

5. Originally Posted by FaT3oYCG
argh im new to coding in c but im only trying to add something into lua player could someone please help me figure out how to fix this error please

Code:
```src/luasystem.cpp: In function 'int lua_IRKeybGetKey(lua_State*)':
src/luasystem.cpp:58: error: invalid conversion from 'int' to 'void*'
src/luasystem.cpp:58: error:   initializing argument 1 of 'int pspIrKeybReadinpu
t(void*, int*)'
src/luasystem.cpp:58: error: invalid conversion from 'int' to 'int*'
src/luasystem.cpp:58: error:   initializing argument 2 of 'int pspIrKeybReadinpu
t(void*, int*)'
make: *** [src/luasystem.o] Error 1```
thanks

im sure its something simple like ive put int instead of char or something

** eagerly waits for help
Can we see the code that you tried to add?

6. yeah sure here it is

Code:
```static int lua_IRKeybStart(lua_State *L)
{
int argc = lua_gettop(L);
if (argc != 2) return luaL_error(L, "two arguments expected (config file[path], kernel mode[1/0])");
const char* config_file = luaL_checkstring(L, 1);
int kernel_mode = luaL_checkint(L, 2);
pspIrKeybInit(config_file, kernel_mode);
return 0;
}

static int lua_IRKeybSetMode(lua_State *L)
{
int argc = lua_gettop(L);
if (argc != 1) return luaL_error(L, "one argument expected (mode)");
int mode = luaL_checkint(L, 1);
pspIrKeybOutputMode(mode);
return 0;
}

static int lua_IRKeybGetMode(lua_State *L)
{
int argc = lua_gettop(L);
if (argc != 0) return luaL_error(L, "no arguments expected");
pspIrKeybGetOutputMode();
return 0;
}

static int lua_IRKeybGetKey(lua_State *L)
{
}

static int lua_IRKeybEnd(lua_State *L)
{
int argc = lua_gettop(L);
if (argc != 0) return luaL_error(L, "no arguments expected");
pspIrKeybFinish();
return 0;
}```
i took out the bit im having the problem with coz i have tried a few different ways

im integrating the irkeyboard functionality into luaplayer and it all works except for the main part getting key input

lol

so basically i would like some help so that i can get it up and running thanks

here is a cutout from the file im reading it from

Code:
``` * @param buffer - Receive buffer.
* @param length - Length of the received data.
*
* @par Example:
* @code
* unsigned char buffer[255];
* int length;
*
* while( 1 ) {
*      if( pspIrKeybReadinput( buffer, &length ) ==  0 && length > 0)
*          // Do something with the read keyboard data
*          processKeyboardData( buffer, length );
*      tick(); // this is a non blocking read
* }
* @endcode
*
* @returns PspIrKeyResults constant.
*/

7. If I remember correctly SG57 integrated his IR keyboard into Lua Player, I have the source somewhere....

EDIT:

Spoiler for codez:
Code:
``` SceUID irda_fd = -1;
int shift = 0;

static int IRKeyboard_Init(lua_State *L) {
if (lua_gettop(L) != 0) return luaL_error(L, "Argument error: No arguments needed in Controls.IRKeyboardInit()");
if (irda_fd < 0) irda_fd = sceIoOpen("irda0:", PSP_O_RDWR, 0);
if (irda_fd < 0) return luaL_error(L, "ERROR: failed to create IRDA handle.");
return 1;
}

unsigned char getIrPress(int fd, int *shift) {
unsigned char p, key = 0;
int len = 0;
int i = 0;

while (i < 6) {

if (len == 1) i++;

if (i == 3) key = p;

}

if (*shift == 0) {
switch (key) {
case 14: return '`';
case 21: return 'q';
case 22: return '1';
case 26: return 'z';
case 27: return 's';
case 28: return 'a';
case 29: return 'w';
case 30: return '2';
case 33: return 'c';
case 34: return 'x';
case 35: return 'd';
case 36: return 'e';
case 37: return '4';
case 38: return '3';
case 41: return ' ';
case 42: return 'v';
case 43: return 'f';
case 44: return 't';
case 45: return 'r';
case 46: return '5';
case 49: return 'n';
case 50: return 'b';
case 51: return 'h';
case 52: return 'g';
case 53: return 'y';
case 54: return '6';
case 58: return 'm';
case 59: return 'j';
case 60: return 'u';
case 61: return '7';
case 62: return '8';
case 66: return 'k';
case 67: return 'i';
case 68: return 'o';
case 69: return '0';
case 70: return '9';
case 72: return ',';
case 73: return '.';
case 74: return '/';
case 75: return 'l';
case 76: return ';';
case 77: return 'p';
case 78: return '-';
case 82: return '\'';
case 84: return '[';
case 85: return '=';
case 90: return '\n';
case 91: return ']';
case 93: return '\\';
case 102: return '\b';
case 18: *shift = 1;
case 89: *shift = 1;
default: return 0;
}
}

if (*shift == 1) {
switch (key) {
case 14: return '~';
case 21: return 'Q';
case 22: return '!';
case 26: return 'Z';
case 27: return 'S';
case 28: return 'A';
case 29: return 'W';
case 30: return '@';
case 33: return 'C';
case 34: return 'X';
case 35: return 'D';
case 36: return 'E';
case 37: return '\$';
case 38: return '#';
case 41: return ' ';
case 42: return 'V';
case 43: return 'F';
case 44: return 'T';
case 45: return 'R';
case 46: return '%';
case 49: return 'N';
case 50: return 'B';
case 51: return 'H';
case 52: return 'G';
case 53: return 'Y';
case 54: return '^';
case 58: return 'M';
case 59: return 'J';
case 60: return 'U';
case 61: return '&';
case 62: return '*';
case 66: return 'K';
case 67: return 'I';
case 68: return 'O';
case 69: return ')';
case 70: return '(';
case 72: return '<';
case 73: return '>';
case 74: return '?';
case 75: return 'L';
case 76: return ':';
case 77: return 'P';
case 78: return '_';
case 82: return '"';
case 84: return '{';
case 85: return '+';
case 90: return '\n';
case 91: return '}';
case 93: return '|';
case 102: return '\b';
case 146: *shift = 0;
case 217: *shift = 0;
default: return 0;
}
}

return 0;
}

static int IRKeyboard_GetKey(lua_State *L) {
if (lua_gettop(L) != 1) return luaL_error(L, "Argument error: 1 argument expected in System.KeyboardGetKey(shift)");
if(irda_fd < 0) return luaL_error(L, "You must initialize the IR Keyboard before requesting a key from it.");

const char key_pressed[] = {getIrPress(irda_fd, &shift),'\0'};
lua_pushstring(L, key_pressed);

return 1;
}

...

static const luaL_reg System_functions[] = {
{"KeyboardGetKey",                IRKeyboard_GetKey},
{"KeyboardInit",                  IRKeyboard_Init},
};```

8. Hey guys, Does anyone know another lib other than OSLib and WAVplayer that loads .WAV's? Thanks

9. triEngine :P

10. Originally Posted by Judas
I don't have one to look at, so I don't know exactly what type of file it is. I know htat pspbtcnf.txt is a text file with a bunch of .prx paths in it, but I doubt that's what the .bin file is. Have you tried a simple sceKernelLoadExec()?
The .bin file is the new versions for the 3.50+ firmwares, its basically all the pspbtcnf files combined, so you have the VSH, GAME, UPDATER, POPS, and all the other types in it.

I doubt sceKernelLoadExec will work, because you can't loadexec a module from flash as far as I'm aware, but if you know of any way that this can be bypassed it would be extreamly useful :)

-Aura

11. Originally Posted by Auraomega
The .bin file is the new versions for the 3.50+ firmwares, its basically all the pspbtcnf files combined, so you have the VSH, GAME, UPDATER, POPS, and all the other types in it.

I doubt sceKernelLoadExec will work, because you can't loadexec a module from flash as far as I'm aware, but if you know of any way that this can be bypassed it would be extreamly useful :)

-Aura
Well, you can't use it when it's in the flash. But you can copy it to the MS, load it, then delete. It might work. I never really had a chance to get that in depth before I sold my PSP, so I'm just guessing here.

12. Ah, I need it to specifically load from the flash, thats whats causing me so many problems.

This question is most probably aimed at Raphael, is there anyway I can loadexec a module in flash? Or, if I load a module using sceKernelLoadExecBufferPl ain, and the file containing the buffer was on flash0, will it work, or just return the same error because the buffer came from something from flash?

-Aura

13. Originally Posted by Auraomega
Ah, I need it to specifically load from the flash, thats whats causing me so many problems.

This question is most probably aimed at Raphael, is there anyway I can loadexec a module in flash? Or, if I load a module using sceKernelLoadExecBufferPl ain, and the file containing the buffer was on flash0, will it work, or just return the same error because the buffer came from something from flash?

-Aura
Wait, I'm pretty sure you can load a module from the flash, as I once loaded an EBOOT that was written to the flash. Loading an EBOOT is a bit different, but it still uses sceKernelLoadExec.

14. Originally Posted by Auraomega
Ah, I need it to specifically load from the flash, thats whats causing me so many problems.

This question is most probably aimed at Raphael, is there anyway I can loadexec a module in flash? Or, if I load a module using sceKernelLoadExecBufferPl ain, and the file containing the buffer was on flash0, will it work, or just return the same error because the buffer came from something from flash?

-Aura
You can load modules from flash, and the LoadExecBufferPlain method doesn't know anything about where the buffer came from, so you definitely should be able to use it.
However, the pspbtcfn.bin file isn't an executable you can load like this. It's just a (binary) list of modules to load, so if you want to use a new created list on boot, you'd have to create a backup, overwrite the original and reboot the PSP, then restore the old one on startup. That or you find a way to tell the IPL to load the list from a different file. You'd have to ask DAX or someone knowledged on this topic though.

15. Well I want to either load a different module from flash, hence the sceKernelLoadExec, or load a pspbtcnf.bin file, for which I've been using sctrlKernelExitVSH and supplying a pspbtcnf.bin file to load:

Code:
```    struct SceKernelLoadExecVSHParam param;
u32 error;
u32 vshmain_args[0x20/4];

memset(&param, 0, sizeof(param));
memset(vshmain_args, 0, sizeof(vshmain_args));

vshmain_args[0/4] = 0x0400;
vshmain_args[4/4] = 0x20;
vshmain_args[0x14/4] = 0xFFFFFFFF;

param.size = sizeof(param);
param.args = 0x400;
param.argp = vshmain_args;
param.vshmain_args_size = 0x400;
param.vshmain_args = vshmain_args;
param.configfile = "flash0:/kn/pspbtcnf_alt.bin";

sctrlKernelExitVSH(&param);```
But it only ever loads pspbtcnf.bin. I've also tried writing a text format version too, just to make sure that it doesn't only accept that.

Also, when I try loadexec'ing a file from flash, I get this error, 0x80020147 (I think, can't check right now), which is SCE_KERNEL_ERROR_PROHIBIT _LOADEXEC_DEVICE, I also got 0x80020146 which is SCE_KERNEL_ERROR_PROHIBIT _LOADMODULE_DEVICE

-Aura
-= Double Post =-
Ok, I just checked, and it appears the error is 0x80020149 SCE_KERNEL_ERROR_ILLEGAL_ PERM_CALL.

16. oke it's a lon g time ago I have been programming but
vshmain_args[4/4] = 0x20;
=?=
vshmain_args[1] = 0x20;

17. What about it? It's the same thing. Alex used 4/4 to remind himself of the storage size of each element of the array (4 bytes).

18. Ah thanks for that, I did wonder myself, I just copied it from the OE source codes, I guess it explains and I can put it how I want without fear of it not working :)

-Aura

19. Hey guys, I was just wondering if there was a way to print an integer using printextscreen()? If i add in the [ , int to be printed] bit it comes up saying there are to many parameters. Any help would be great, thanks

Hey guys, I was just wondering if there was a way to print an integer using printextscreen()? If i add in the [ , int to be printed] bit it comes up saying there are to many parameters. Any help would be great, thanks
I don't know what parameters the function takes but I assume that it does not use variable argument list to the function. You can add one yourself then use sprintf to format the string in the way you want. Anyway, here's a quick way out.

char buffer[32];
sprintf(buffer, "%d", 3);
printTextScreen(...,buffe r,...);

I don't know the other arguments for the function so I just replace the ellipses with the proper arguments.

21. Originally Posted by Auraomega
Ah thanks for that, I did wonder myself, I just copied it from the OE source codes, I guess it explains and I can put it how I want without fear of it not working :)

-Aura
Originally Posted by FreePlay
What about it? It's the same thing. Alex used 4/4 to remind himself of the storage size of each element of the array (4 bytes).
Another thing learned

22. Code:
```G.Ninja@moordoor ~/bouncing
\$ make
make: execvp: /usr/local/pspdev/psp/bin: Permission denied
make: execvp: /usr/local/pspdev/psp/bin: Permission denied
make: execvp: /usr/local/pspdev/psp/bin: Permission denied
make: *** No rule to make target `Bouncing.o', needed by `Bouncing.elf'.  Stop.```
What do these two errors mean?

I am an admin on xp so I know it cant be that.

23. Hmm the first error I've never seen before, and I'm not sure what to even suggest could be the cause, but the latter error normally occurs when the system can't find the source file in respective possition to the makefile, remember if its in a different directory you need to point it to the correct directory, I.E:

E:/EBOOT/ (makefile plus eboot output)
E:/Source/ (source codes, plus .o outputs)

The makefile would need:

objs =
../source/main.o
../source/Bouncing.o

of course, the error may just be caused by the former error, and solving that may solve this also.

-Aura

24. :Argh: Ive googled and found nothing on the error. It has got to be my makefile because the usb sample compiles fine.

- Thanks Aura

25. Originally Posted by Blackbelttcon
when i run the program the variables pass comes out with a line and a half of spaces after it. how do i get rid of that.

Gets the variable from the Conn file
Code:
```     // Opens pass
{
ifstream OpenFile("pass.conn");

char pass1;
while(!OpenFile.eof())
{
OpenFile.get(pass1);

pass += pass1;
}

}```
this is were the line and a half of spaces comes after this is your password=
Code:
`     cout << " this is your password= " << pass <<endl;`

does anyone no

26. Post full code and the example data.

27. ill pm you

28. Hey everyone, I was wondering if there's any alternative to PSP_CTRL so that it just records the initial press of a button and not you constantly holding it. Any help would be great, thanks

29. triEngine again :P

30. dang it! lol, i would usually have no problem because id be using OSLib but im not using it so yeah. How big is TriEngine?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

All times are GMT -8. The time now is 07:26 AM.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY