c programming
c programming
when programming for the psp can you do like
char a;
a="a";
pgPrint4(1,4,0xffff,a);
char a;
a="a";
pgPrint4(1,4,0xffff,a);
Re: c programming
^^ is wrong. It should be:Squall333 wrote:a="a";
a='a';
Single quotes for characters, double quotes for strings... which are just character array's.
As far as the other code, I don't know.
Lego of my Ago!
Its in a while(1) loop but i looked at the parameters for pgPrint and i think the last thing has to be a string and cant be a variable
EDIT: i just decided to add my code its pretty short
EDIT: i just decided to add my code its pretty short
Code: Select all
// Hello World for PSP
#include "pg.h"
#define CTRL_SQUARE 0x8000
#define CTRL_TRIANGLE 0x1000
#define CTRL_CIRCLE 0x2000
#define CTRL_CROSS 0x4000
#define CTRL_UP 0x0010
#define CTRL_DOWN 0x0040
#define CTRL_LEFT 0x0080
#define CTRL_RIGHT 0x0020
#define CTRL_START 0x0008
#define CTRL_SELECT 0x0001
#define CTRL_LTRIGGER 0x0100
#define CTRL_RTRIGGER 0x0200
int n,x,y;
char a;
typedef struct _ctrl_data
{
int frame;
int buttons;
unsigned char analog[4];
int unused;
} ctrl_data_t;
void keyboardControl()
{
ctrl_data_t ctrl;
sceCtrlReadBufferPositive(&ctrl, 1);
if (ctrl.buttons & CTRL_UP) {
n = n+1;
} else if (ctrl.buttons & CTRL_DOWN) {
n = n+1;
} else if (ctrl.buttons & CTRL_LEFT) {
n = n+1;
} else if (ctrl.buttons & CTRL_RIGHT) {
n = n+1;
} else if (ctrl.buttons & CTRL_SQUARE) {
n = n+1;
} else if (ctrl.buttons & CTRL_CIRCLE) {
n = n+1;
} else if (ctrl.buttons & CTRL_TRIANGLE) {
n = n+1;
} else if (ctrl.buttons & CTRL_CROSS) {
n = n+1;
} else if (ctrl.buttons & CTRL_RTRIGGER) {
n = n+1;
} else if (ctrl.buttons & CTRL_LTRIGGER) {
n = n+1;
}
}
int xmain(void)
{
unsigned long fc;
unsigned long r,g,b,rgb;
pgInit();
pgScreenFrame(2,0);
while (1) {
keyboardControl();
a='a' ;
pgFillvram(0);
pgPrint4(1,4,0xffff,a);
pgScreenFlipV();
}
return 0;
}
yes, you are right. Please read some C learning book or website, then try to program on PC and then on Playstation. For your problem: if you want just one char, then call pgPutChar (or whatever it is called in Nem's lib). If the function expects a char*, don't pass a char.Squall333 wrote:Its in a while(1) loop but i looked at the parameters for pgPrint and i think the last thing has to be a string and cant be a variable
that is incorrect. you should use char a[2] or char* a. array brackets go after the variable name.Agoln wrote:char[2] a;
not char a[2];
ya, you could do that but doesn't it look like it'll get annoying? that's an array of pointers to "a\0", "b\0" and "c\0" (\0 is the NULL termination of a string). i recommend doing as you did before with a char array (char a[3] = "abc";)Squall333 wrote:actually i was wrong you can use chars in pgprint but my next question is can you use arrays like
char* a[3] = {"a","b","c"};
Code: Select all
void pgPrint4(unsigned long x,unsigned long y,unsigned long color,const char *str)
if had a 1.5 PSP to code on, i'd be able to test what you have there and possibly fix it but sadly i don't so i can't be much help on what will actually happen
You can use pspe as an emulator if you want. you can get it from www.dcemu.co.uk and then go to the psp news section then on the left under psp emulator
i have 2 more problems my program works in pspe but not on my psp. any ideas?
and two when i press a button and hold it down it makes code like x=x+1 going so isntead of making 1 increase to 2 it makes 1 go to like 3 or 4 because i cant press a key fast enough to make count as one press anyone understand what im saying?
i have 2 more problems my program works in pspe but not on my psp. any ideas?
and two when i press a button and hold it down it makes code like x=x+1 going so isntead of making 1 increase to 2 it makes 1 go to like 3 or 4 because i cant press a key fast enough to make count as one press anyone understand what im saying?