Thanks. :)Zitat:
Zitat von Waterbottle
Printable View
Thanks. :)Zitat:
Zitat von Waterbottle
Code:== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
& Bitwise AND
| Bitwise Inclusive OR
^ Bitwise Exclusive OR
~ Unary complement (bit inversion)
<< Shift Left
>> Shift Right
|| means or and & means and right?Zitat:
Zitat von SG57
lol your about eight minutes late but thanks anyway.
I just need to clarify something -
Now if I press up it would just change p1x and not ms?Code://let's say I have this
void game() {
if(pad.Buttons & PSP_CTRL_UP) {
p1x = p1x + 2;
}
int main() {
if(pad.Buttons & PSP_CTRL_UP) {
ms = ms + 1;
}
if(pad.Buttons & PSP_CTRL_START) {
game();
}
Well I just saw the small list waterbottle gave you, so I did a quick write up of all I knew, then a few defintions I had to google about. And your 1/2 right...
& is bitwise 'and'.
| is bitwise 'or'.
& will copy a bit to the result if it exists in both operands.
| will copy a bit if it exists in either operand.Code:unsigned int a = 60; // 60 = 0011 1100
unsigned int b = 13; // 13 = 0000 1101
unsigned int c = 0;
c = a & b; // 12 = 0000 1100
You were talking about the logical operations of the two.Code:unsigned int a = 60; // 60 = 0011 1100
unsigned int b = 13; // 13 = 0000 1101
unsigned int c = 0;
c = a | b; //61 = 0011 1101
Yeah I was.Zitat:
Zitat von SG57
The makefile for these includes would be:
would beCode:#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <stdio.h>
#include "graphics.h"
I'm not good with makefiles so I haven't the foggiest idea.Code:TARGET = lol
OBJS = main.o graphics.o framebuffer.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu -lz -lm
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = secret
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
EDIT -
Ok now I need some help with my code.
Now this problem may seem obvious to solve but it isn't IMO...
what it is that I defined all my variables in the main loop, but the function is outside of the main loop. The function refers to the variables, thus I get undefined errors.
Help?
Add:
Else when using GU calls it may complain it about undefined references to GUM functions...Code:-lpspgum
Hey,
i was just trying to make a code to assign the value of 1 to base, if Circle is pressed...i tried this
but that dosn't work :(...it just assigns 1 to base and carries on with the rest of the code...i tired Break; but that doesnt work....what should i be doing to achive this?Code:if(pad.Buttons & PSP_CTRL_CIRCLE){
base=1;
}
thanks for any help :)
Did that, and it still gives me the undeclared errors. (it was undeclared not undefined)Zitat:
Zitat von SG57
Ok now I need help with this error:
Maybe for the undeclared I could have a file with all the declarations(ie int, char, my colors) and #include it.Code:main.c:23: error: syntax error before numeric constant
Line 23:
sceCtrlSetSamplingCycle(0);
[action=PSPduh]goes tries[/action]
ok now this is annoying but I'm not giving up.
lol.h:Code:$ make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai
n.c
In file included from main.c:9:
lol.h:11: warning: implicit declaration of function 'RGB'
lol.h:11: error: initializer element is not constant
lol.h:12: error: initializer element is not constant
lol.h:13: error: initializer element is not constant
lol.h:14: error: initializer element is not constant
lol.h:15: error: initializer element is not constant
lol.h:16: error: initializer element is not constant
lol.h:17: error: initializer element is not constant
lol.h:20: error: initializer element is not constant
lol.h:21: error: initializer element is not constant
lol.h:22: error: initializer element is not constant
main.c:24: error: syntax error before numeric constant
main.c:24: warning: type defaults to 'int' in declaration of 'sceCtrlSetSampling
Cycle'
main.c:24: warning: data definition has no type or storage class
main.c:25: warning: type defaults to 'int' in declaration of 'sceCtrlSetSampling
Mode'
main.c:25: warning: parameter names (without types) in function declaration
main.c:25: warning: data definition has no type or storage class
main.c: In function 'game':
main.c:52: error: 'pad' undeclared (first use in this function)
main.c:52: error: (Each undeclared identifier is reported only once
main.c:52: error: for each function it appears in.)
main.c: In function 'main':
main.c:108: error: 'sceCtrlData' undeclared (first use in this function)
How the *bleep* do I fix that sceCtrlData error?Code:Color blue = RGB(0,0,255);
Color red = RGB(255,0,0);
Color green = RGB(0,255,0);
Color white = RGB(255,255,255);
Color black = RGB(0,0,0);
Color orange = RGB(255,140,0);
Color yellow = RGB(255,255,0);
//char the colors
char p1c = white;
char bc = red;
char p2c = white;
@willolner - What do you mean it doesn't work? If it assigns 1 to base then isn't it mission accomplished?
PSPduh - Give me the snippet of your code that that is found in... Like line 20 to 30 or so...
willolner - Im confused as well... Pressing O will set base to the value of 0. Unless somewhere else in the infinite loop your setting it NOT to 0, then it should be fine (im guessing your initlizing 'base' in your main loop, hence why it doesnt work as you thought)
ok this code works fine when i make it a eboot but i need to make it a prx and when i try it doesn't load can anyone help
Code:#include <pspkernel.h>
#include <pspdebug.h>
#include <string.h>
#include <pspctrl.h>
PSP_MODULE_INFO("AUTOBOOT", 0x1000, 1, 1);
void loadeboot(char *pbpath)
{
//char *pbpath;
const u32 pbplen = strlen(pbpath)+1;
struct SceKernelLoadExecParam eloader;
eloader.args = pbplen;
eloader.argp = pbpath;
eloader.key = NULL;
eloader.size = sizeof(eloader) + pbplen;
if(sceKernelLoadExec(pbpath,&eloader)<0) {
printf("EBOOT NOT FOUND, PLZ CHECK THE FILE AND TRY AGAIN\n");
}
}
int main()
{
loadeboot("ms0:/PSP/GAME/irshell/EBOOT.PBP");
}
thx mafia1ftCode:TARGET = EBOOTLOADER
OBJS = main.o
BUILD_PRX=1
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
All prx's need exports. Check C:\cygwin\usr\local\pspde v\psp\sdk\samples\prx\tes tprx for an example of exports.
PRXs shouldnt have a PSP_MODULE_INFO, I think Ive heard that somewhere... But then again Ive been PSPless for 4 months now, so my memory is fading *sad song plays*
They do, nothing in the PSPSDK will compile without the PSP_MODULE_INFO :)
PSPduh: you seem to be lacking on some of the fundamentals of what you need to know. May I recommend taking my 'Full game' tutorial series (in 3 parts). It deals with variable scope and using multiple files/headers.
Part one starts here: http://www.psp-programming.com/forum....php?topic=359
fixed
Hey :)
compiling this
cygwin saysCode:#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#define printf pspDebugScreenPrintf
int i = 0;
SceCtrlData pad;
/* 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;
}
PSP_MODULE_INFO("PSPointles", 0, 1, 1);
int main ()
{
pspDebugScreenInit();
SetupCallbacks();
/*logo*/
printf("\n\\\\ //// //// //// //// /////////\n \\\\ ////\\\\ //// //// //// /// ///\n \\\\ //// \\\\ //// //// //// //// /// ///\n \\\\//// \\\\//// //// /////// /////// /////////\n ");
/*Menu code*/
printf("Welcome To Willo's Absalootly Pointless Game \nPress X To Continue: \n");
while(1) {
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS) {
break;
}
}
pspDebugScreenClear();
/*Data input for User */
printf("Press Triangle, and try to fill the screen with 1s")
while(1) {
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_TRIANGLE) {
printf("1");
}
}
http://img406.imageshack.us/img406/4300/errorrd5.png
whats wrong with the sorce?
thanks for any help :)
You forgot the semicolon on the printf before the second while loop.Zitat:
Zitat von willolner
*slaps self on forehead*
lol
thank you :)
i dunno if anyone have any experience at all with SDL (Simple DirectMedia Layer) but i have some issues using the SDL_EnableKeyRepeat(3, 3); function but i really need to have that explained maybe an example or something cause i cant get it working at all :)
Never mind ive solved the problem :)
Quick question:
Is there any way to draw a circle? I mean is there already a predefined function that can draw a circle? Or will I have to go out of my way to make my own?
@Insomniac -
Thanks, I'll take a look. :)
I just like to do things by myself :)
I'll definitely try collision by myself. (Always something I wanted to try.)
PSPduh - Using the graphics library I believe so. If not, just look in the Developers Dungeon for a thread on circles... I created it, i cant remember the name right now.
i am trying to how many space there is left on flash0:
this should prinf the used space on flash0Code:int totalegrote=0;
void check_space( const char *root)
{
int dfd;
char next_root[256];
char next_write[256];
sceIoUnassign("flash0:");
sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
dfd = sceIoDopen(root);
if(dfd > 0)
{
SceIoDirent dir;
while(sceIoDread(dfd, &dir) > 0)
{
if(dir.d_stat.st_attr & FIO_SO_IFDIR)
{
if(dir.d_name[0] != '.')
{
build_path(next_root, root, dir.d_name, 1);
check_space(next_root);
}
}
else
{
struct stat fileStats;
if (stat(root, &fileStats) == 0) {
int grote=fileStats.st_size;
totalegrote=totalegrote+grote;
}
}
}
sceIoDclose(dfd);
}
}
int main() {
check_space("flash0:/");
printf("\n%i", totalegrote);
return 0;
}
while i test this , it prints 6209536 (5,9mb) , thats fault there is more than 20mb used!!!
what did i wrong??
Hmm, I scanned graphics.c and I didn't find a circle function.Zitat:
Zitat von SG57
Yeah I seen the thread for snippets and found one but I'm trying to make one but the best I have is a rounded rectangle. :(
EDIT -
If anybody wants the code for the rounded rectangle or a triangle here it is:
Spoiler for code:
Um I need some help now...collision. Okay I know there are guides around the forums dealing with collision but I can make one by myself if I know the answer to this question:
-When you blit the image, using x and y, what would the right side of the figure be? Top side? Bottom side? Left side? (In relation to x and y I mean. (like if the bottom side is y + something))
PSPduh - Your confusing.
Collision, boudning boxes, compares to rectangles and checks whether one would be in side the other (rectangles as in just there size and placement).
So, to start you off:
Then youcould do:Code:int Collision ( int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2 ) {
if (blah collide checks==true) { return true; }
else { return false; }
}
}
As you can guess...Code:if (Collision ( guy.x, guy.y, guy.width, guy.height,
enemy.x, enemy.y, enemy.width, enemy.height)) {
// collision!
} else {
// no collision!
}
x1 = x placement of first object
y1 = y placement of first object
w1 = width of first object
h1 = hieght of first object
Same with the 2's but for the seconf object. And it doesnt have to be an image, you can compare numbers for all i care... In that LUA tutorial i did on bounding boxes (search these forums) I had 2 strings move around, and if collided print on them they collied, else print they didnt.
Collision is very very easy stuff, should be the least of peoples worries when making agame.
Also, to answer your question... The 'right' side of an image is the X placement of the image + the images width. So,,,
guy.x + guy.width = right side of guy image
Oh ok, I gotcha. I know collision is easy, I just was confused on what the right side of what image is and what side blah is etc.Zitat:
Zitat von SG57
so:
guy.x + guy.width = right side
guy.x - guy.width = left side (?)
guy.y + guy.height = top side
guy.y - guy.height = bottom side
Right?
You arent thinking logically PSPduh... Why would we ADD the width of the image to its X coordinate, if the PSP blits images from teh top left (lua i mean).
Subtracting the width from the X will give you leftside-width of what you want. The left side of the image is just its X value. Same with top of image ;)
See I didn't now where the PSP blits the image. Whether it be the center, top left, bottom, but now I know that it is the top left. OH I GET it.Zitat:
Zitat von SG57
so...(let's try this again lol)
Now I'm sure that's right?Code:left side = x
right side = x + width
top side = y
bottom side = y - height
Still need to find out how to draw a circle. I just don't like using outside images...I like doing everything inside the code, for some reason it feels like I have more control over everything.
And now that I know what the sides are then I can do the collision...but dang it I still need to figure out how to do speed.
WAIT HOLY FO SHNIZZLE I THINK I GOT TEH SPEEd.
Here's a circle drawing function a found awhile back, its not a perfect circle, but good enough for my purposes at least. It's also fairly fast. Just change DrawPixel() to whatever your pixel drawing function is. I think it's pretty self explanatory on how to use it.
Code:void drawCircle(int x, int y, int r, Color color)
{
int pos_x,
pos_y = -r,
tx = 0,
ty = 4*r,
a = 0,
b = 2*ty+9,
x1 = int(r*0.707010678 + 0.5);
DrawPixel(x+r,y,color);
DrawPixel(x-r,y,color);
DrawPixel(x,y+r,color);
DrawPixel(x,y-r,color);
DrawPixel(x+x1,y+x1,color);
DrawPixel(x+x1,y-x1,color);
DrawPixel(x-x1,y+x1,color);
DrawPixel(x-x1,y-x1,color);
for(pos_x = 1;pos_x < x1;pos_x++)
{
a += 8;
tx += a;
if(tx > ty)
{
pos_y++;
b -= 8;
ty += b;
}
DrawPixel(x+pos_x,y+pos_y,color);
DrawPixel(x-pos_x,y+pos_y,color);
DrawPixel(x+pos_x,y-pos_y,color);
DrawPixel(x-pos_x,y-pos_y,color);
DrawPixel(x+pos_y,y+pos_x,color);
DrawPixel(x-pos_y,y+pos_x,color);
DrawPixel(x+pos_y,y-pos_x,color);
DrawPixel(x-pos_y,y-pos_x,color);
}
}
*takes off belt*
PSPduh... you know I dont like being lied to... ok, maybe you didnt know but you know now... The PSP blits the image from the top left of the image... so... the top of the image is the y coordinate, the left is the x, the bottom is y + height, the right is x + width.
*puts belt back on before pants fall down and lets PSPDuh away with a warning and a firm shaking finger*
Er?Zitat:
Zitat von SG57
Oh yeah I forgot that the y increments downward...whoops. :o
@trevis - thanks. :)
Now I need to tweak it to make a filled in circle. (which is what I need)
Now I think I can commence making the actual game...
My method of drawing a filled circle (note this is just written up, havent tried it if itll work, so give it a shot)
Thats if your using graphics library.Code:#include <math.h>
#define DEG2RAD 3.14159/180
void drawFilledCircle(int x,int y, float radius)
{
for (int i=0; i < 360; i++)
{
float degInRad = i*DEG2RAD;
drawLineScreen(x+radius,y+radius,cos(degInRad)*radius,sin(degInRad)*radius);
}
}
No it won't, and even if it did, it would be a lot slower than the previous code :P
can anyone give me some help on recompiling this code
http://0okm.blogspot.com/2006/11/3rd...in-sample.html
thx mafia1ft
Why dont you compile it??
how big is flash0 (in bytes) ?
Right here.Zitat:
Zitat von hallo007
I think it is like 20 MB or something but I'm not sure.
yeah ,a bit more ,but i need to now in bytes exactly and where is the system version name stored?
well i guess, it checks your sceKernelDevKitVersion number and then does if statements to print to the screen the right one...
no i mean on flash , so i can reflash it
Raphael - Can you explain your reasoining? Im learning here, and you arent too helpful by not giving a reason :o