C/C++ Programming Help Thread
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; Zitat von eldiablov And ulink() ? Never used it before and i'm not gonna start now. Never heard of it ...
-
05-28-2008, 11:29 AM #8581
dont try and learn anything, it might hurt your pea sized brain. lol you say that like you've been programming for decades when its been what? a day judging by your poor code posted. unlink is posix, its always nice to cleanup after yourself removing unneeded output files :) fscanf, bleagh, welcome to buffer overruns and stack smashing.
Zitat von eldiablov
-- Code Monkey : Sarien, Fishguts, Cracks and Crevices --
"Did IQ's just drop sharply while I was away?" (Ripley)
-
05-28-2008, 11:37 AM #8582Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
No need to be a ****ing ass about it. So what if i'm learning? Who gives a ****? I'm sorry I dont know everything like you. I merely meant that I havent got to the stage where I need to use that stuff yet. (it's on like page 200 in C programming) which i'm reading btw.
Zitat von _df_
-
05-28-2008, 03:28 PM #8583
Well the whole 'never used it not gonna start now' is not indicative of 'learning' its more indicative of acting like an ass. you asked a question to which I responded and you come back with a talk to the hand I dont want to know about it.... If you wanted help like you did originally, dont act like a brick wall.
-- Code Monkey : Sarien, Fishguts, Cracks and Crevices --
"Did IQ's just drop sharply while I was away?" (Ripley)
-
05-29-2008, 01:24 AM #8584QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Why are you open a file to write when yo are actually you are reading from it?Code:text = fopen("crash.log", "w");Geändert von yaustar (05-29-2008 um 01:56 AM Uhr)
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-29-2008, 03:22 AM #8585Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
observe my double post, I noticed my mistake and corrected it before anyone replied ...
Thanks anyway
-
05-31-2008, 01:14 PM #8586QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
hey how do i get it so that my function can have multiple variables, like for example printf("string %i%i%i", 1, 2, 3); <--their won't always be the extra variables in their...so how can i do that with my own functions?
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-31-2008, 01:15 PM #8587It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You don't really want to. It's possible, but it's a pain and there's no real good way to do it. Look up C varargs on Google if you really want to know.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-31-2008, 01:19 PM #8588QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
thanks archarmic, i'll look it up
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
06-01-2008, 12:47 PM #8589
- Registriert seit
- Jan 2008
- Beiträge
- 25
- Points
- 2.931
- Level
- 33
- Downloads
- 0
- Uploads
- 0
Well I downloaded OSlib mod 1.0.1 and I'm trying to get it in VC++ 9. Is there an already set up development environment with OSlib that I can just write code in, or if not, how can I set it up in VC++ 9?
Thanks in advance. Please help
-
06-02-2008, 01:25 AM #8590QJ Gamer Silver

- Registriert seit
- Sep 2007
- Ort
- AUS
- Beiträge
- 284
- Points
- 12.501
- Level
- 73
- Downloads
- 0
- Uploads
- 0
hi,
i have been struggling with geting the current working directory (getcwd(path,265)). i am trying to be able to acsess the flash directories and be able to browse throught them. and return the cwd.
here is some of my code
Code:
Regardsint fcwd = 0;
char *cwdpath = "";
static int lua_getCurrentDirectory(l ua_State *L)
{
char path[256];
//cwdpath = getcwd(path,256);
lua_pushstring(L, cwdpath);
return 1;
}
static int lua_setCurrentDirectory(l ua_State *L)
{
char *path = luaL_checkstring(L, 1);
if(!path) return luaL_error(L, "Argument error: System.currentDirectory(f ile) takes a filename as string as argument.");
char *ddp = strpbrk (":",path);
if(ddp != NULL)
{
sceIoChdir(path);
chdir(path);
cwdpath = path;
lua_pushstring(L, cwdpath);
return 1;
}
if(strcmp(cwdpath,"ms0:/") == 0)
{
sceIoChdir(path);
chdir(path);
strcat(cwdpath, path);
lua_pushstring(L, cwdpath);
return 1;
}
if(strcmp(cwdpath,"disc0:/") == 0)
{
sceIoChdir(path);
chdir(path);
strcat(cwdpath, path);
lua_pushstring(L, cwdpath);
return 1;
}
sceIoChdir(path);
chdir(path);
strcat(cwdpath, "/");
strcat(cwdpath, path);
lua_getCurrentDirectory(L );
return 1;
}
HomemisterWyvern. That is all
-
06-02-2008, 04:23 AM #8591
I the problems I see is your not re-allocing the size of the current buffer (or freeing... lots of mem leaks) your using for the path when your strcatting. Are you getting any specific error on calling getcwd? if getcwd doesnt work against ms0/disc0 etc then you'll need to do something like what you are doing.
As a personal rule ;) I dislike calling one lua function from another, they are doorways for the lua interpreter, rather than general shared functions to be called by anything else.
untested yadda yadda yadda. getcwd would be the best solution if it worked ;)
Code:int fcwd = 0; char *cwdpath = ""; static int lua_getCurrentDirectory(l ua_State *L) { lua_pushstring(L, cwdpath); return 1; } static char* realloc_path(char *cpath, char *add) { char *q; q = malloc(strlen(cpath) + strlen(add) + 4); strcpy(q, cpath); strcat(q, add); free(cpath); return q; } static int lua_setCurrentDirectory(l ua_State *L) { char *path = luaL_checkstring(L, 1); if(!path) return luaL_error(L, "Argument error: System.currentDirectory(file) takes a filename as string as argument."); char *ddp = strpbrk (":",path); sceIoChdir(path); chdir(path); if(ddp != NULL) { free(cwdpath); cwdpath = path; } else if(strcmp(cwdpath,"disc0:/") == 0 || strcmp(cwdpath,"ms0:/") == 0) { cwdpath = realloc_path(cwdpath, path); } else { free(cwdpath); cwdpath = strdup("/"); cwdpath = realloc_path(cwdpath, path); } return lua_getCurrentDirectory(L); }-- Code Monkey : Sarien, Fishguts, Cracks and Crevices --
"Did IQ's just drop sharply while I was away?" (Ripley)
-
06-02-2008, 05:38 AM #8592
- Registriert seit
- May 2008
- Beiträge
- 5
- Points
- 2.523
- Level
- 30
- Downloads
- 0
- Uploads
- 0
hello, i want to do multiple threading.. how can i do that?
actually i'm trying to do two process at once and it is quiet difficult with one "while(1){ }"
please tell me any alternatives if multiple-threading is not possible...
thnx
-
06-02-2008, 06:02 AM #8593QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Why do you need two things to be done at the same time opposed to doing two things done in one frame?
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
06-02-2008, 06:58 AM #8594
- Registriert seit
- May 2008
- Beiträge
- 5
- Points
- 2.523
- Level
- 30
- Downloads
- 0
- Uploads
- 0
i want to do like because its too difficult to control and animate two objects simultanously
-= Double Post =-
hey, i'm having a problem in using triEngine... its showing me only the blue colour of the image file... the text are printing in the colour that i tell them to print but the image is not showing its all the colours... here is the main() code:
Code:int main() { SetupCallbacks(); triInit(GU_PSM_8888); triInputInit(); triFontInit(); // Colors enum colors { RED = 0xFF0000FF, GREEN = 0xFF00FF00, BLUE = 0xFFFF0000, WHITE = 0xFFFFFFFF }; triImage *bg = triImageLoad("./BG.png", TRI_VRAM); triImage *img = triImageLoad("./Paused.png", TRI_VRAM); triFont *font = triFontLoad("./Verdana.ttf", 12, TRI_FONT_SIZE_PIXELS, 128, TRI_FONT_VRAM); triVec2f *Stick = triInputGetStick(); while(isrunning == 1) { triClear(0xFF0000); triInputUpdate(); triDrawImage2(0, 0, bg); triDrawImage2(0, 0, img); triFontActivate(font); triFontPrint(font, 2, 2, RED, "aLy"); triFontPrintf(font, 2, 30, GREEN, "x: %.5f\ny: %.5f", Stick->x, Stick->y); triSwapbuffers(); } triFontUnload(font); triFontShutdown(); triClose(); sceKernelExitGame(); return 0; }Geändert von extremealy (06-03-2008 um 03:53 AM Uhr) Grund: Automerged Doublepost
-
06-02-2008, 07:31 AM #8595Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
1. Use the CODE tags.
2. Call triImageNoTint() before triSwapBuffers().
3. Multi-threading would make what you are trying to achieve even more difficult. Perhaps you need to re-think the logic that you're using to achieve the animation.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
06-02-2008, 08:33 AM #8596QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
How so?
Zitat von extremealy
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
06-02-2008, 05:16 PM #8597
I asked the exact same question in the beginning... I laugh @ what I posted.
Zitat von extremealy
Let me dig that post. :ROFL:
-
06-03-2008, 11:40 PM #8598QJ Gamer Silver

- Registriert seit
- Sep 2007
- Ort
- AUS
- Beiträge
- 284
- Points
- 12.501
- Level
- 73
- Downloads
- 0
- Uploads
- 0
dear _df_
thx for the help. i have tryed you code and fixed some of it to work with mine. With the getcwd() it returns the last path that i acsessed on the ms0:/
I think it could be a proplem with R/W permisions.
Regards
HomemisterWyvern. That is all
-
06-04-2008, 06:34 AM #8599
The problem with getcwd probably goes back to the same problem does has. You have multiple drives, and it has to guess (which sounds like defaults to ms0:/ all the time) which drive you want. Since getcwd is posix, posix FS's all stem from the root so you dont have this problem.
Zitat von homemister91
Maybe there needs to be more of an abstraction. Since there is multiple drives. Maybe there needs to be stored the current directiory of each 'drive' (and when luaplayer starts it can default them all to the root, except for ms0 which could default to the app start directory), and could have a current drive function to return ms0/flash1 etc etc etc..
that might be a big change since it would require other IO funcs be changed to force to use the current drive info unless using absolute paths..
blah. rambling on :)-- Code Monkey : Sarien, Fishguts, Cracks and Crevices --
"Did IQ's just drop sharply while I was away?" (Ripley)
-
06-04-2008, 09:53 AM #8600QJ Gamer Blue
- Registriert seit
- Nov 2007
- Beiträge
- 29
- Points
- 2.981
- Level
- 33
- Downloads
- 0
- Uploads
- 0
So, well, in c numbers can be represented as hexadecimals, that is, they can be shown as 0xXXXX, for example
int x = 0x0012
But, what if i had a text file, for example:
Then, how can i load it? of course,Code:0x0000 0x0013 0x3394 ... ...
THe most blatant approach is totally stupind and of course not-working at all. Theoritically, i could check it symbol-by-symbol and convert it manually, but that wouldn't be so good. So, how can i do this (using c++ standart and PSPSDK, that is both of them)?Code:int x =0; ifstream plik("test.txt"); plik >> x; cout << x << "\n";
-
06-04-2008, 11:28 AM #8601Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Use fscanf() with the %x argument.

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
06-05-2008, 02:39 AM #8602
- Registriert seit
- May 2008
- Beiträge
- 5
- Points
- 2.523
- Level
- 30
- Downloads
- 0
- Uploads
- 0
Hello, thanks for help and this did the trick! But in the example that came with triEngine lib, it doesn't uses anything like tint and working fine. I recheck the whole code several times... It doesn't have much different things... Here is the sample code:
Zitat von Insert_Witty_Name
Code:#include <pspkernel.h> #include "../../triImage.h" #include "../../triGraphics.h" #include "../../triTypes.h" #include "../../triLog.h" #include "../../triMemory.h" PSP_MODULE_INFO("triGfxTest", 0x0, 1, 1); PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VFPU); PSP_HEAP_SIZE_KB(20480); static int isrunning = 1; /* ALL CALLBACKS HERE */ BLAH BLAH /* ALL CALLBACKS HERE */ /* Simple thread */ int main(int argc, char **argv) { SetupCallbacks(); triLogInit(); triMemoryInit(); triInit( GU_PSM_8888 ); triImage* triTri = triImageLoad( "sprite_gzip.tri", 0 ); if (triTri==0) { triLogError("Error loading sprite_gzip.tri!\n"); sceKernelExitGame(); return 0; } triImageToVRAM( triTri ); triImageAnimation* triAni = triImageAnimationFromSheetTga( "ani.tga", 40, 40, 5, 1, 250 ); //triImageAnimation* triAni = triImageAnimationFromSheet( triAniImg, 40, 40, 5, 1, 250 ); if (triAni==0) { triLogError("Error creating triImageAnimation!\n"); sceKernelExitGame(); return 0; } triImageAnimationStart( triAni ); triImage* triBig = triImageLoad( "wallpaper.png",0 ); if (triBig==0) { triLogError("Error loading wallpaper.png!\n"); sceKernelExitGame(); return 0; } if (triBig==0) { triLogError("Error loading wallpaper.raw!\n"); sceKernelExitGame(); return 0; } triBig->bits = 32; triBig->format = GU_PSM_8888; triBig->width = 864; triBig->height = 648; triBig->stride = 864; triBig->tex_height = 1024;*/ triSpriteMode( 480, 272, 0 ); triFloat x = 0.f, y = 0.f; triFloat dx = 2.f, dy = 1.0f; triFloat angle = 0.0f; triEnable(TRI_PSEUDO_FSAA); triEnable(TRI_VBLANK); while (isrunning) { triClear( 0xFF0000 ); triDrawSprite( 0.f, 0.f, x, y, triBig ); x += dx; y += dy; if (x>=(triBig->width-480) || x<=0) dx = -dx; if (y>=(triBig->height-272) || y<=0) dy = -dy; triDrawRectRotate( 32, 32, 64, 64, 0xff0000ff, angle ); triDrawImageRotate2( 128, 32, angle, triTri ); triDrawImageAnimation( 280, 32, triAni ); triImageAnimationUpdate( triAni ); triSwapbuffers(); angle += 0.5f; } triImageAnimationFree( triAni ); triImageFree( triTri ); triClose(); triMemoryCheck(); triMemoryShutdown(); sceKernelExitGame(); return 0; }
-
06-05-2008, 04:37 AM #8603Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
It doesn't have fonts...

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
06-05-2008, 04:56 AM #8604
- Registriert seit
- May 2008
- Beiträge
- 5
- Points
- 2.523
- Level
- 30
- Downloads
- 0
- Uploads
- 0
aaaaaaaah..... got it! thanks!
it means whenever i use font, i should use notint function...
some font's function might change the tint settings....but that function should change it back to what user has set...
anyways, thanks :)
-
06-06-2008, 01:27 AM #8605QJ Gamer Blue
- Registriert seit
- Nov 2007
- Beiträge
- 29
- Points
- 2.981
- Level
- 33
- Downloads
- 0
- Uploads
- 0
Thank you
Zitat von Insert_Witty_Name
-
06-09-2008, 03:33 PM #8606Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
HELP
no c history
so
can anyone explain this section of makefile
TARGET = hello
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = xxxxxxx
whats OBJECT
and TARGET mainly mean?
i think thats what im confused with, and everything else is default
-
06-09-2008, 03:54 PM #8607It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
OBJS are the object files to build
TARGET is the name of the final executablepəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
06-09-2008, 04:07 PM #8608Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
okay..
because in the hello world example
i dont know why it is "main.O" in TARGET
and why it says "hello" in OBJS
okay so hello world executes fine
but the problem is where do i insert where i want it?? (eg x,y or 100,100)
right now the HELLO WORLD text is at the top left corner
what if i want it in the middle? (126, 110)
-
06-09-2008, 04:22 PM #8609QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
main.o compiled you main.c file.
hello it the target and later becomes hello.elf
printf("\n\n\n\n\n\n")
\n = Newline \n\n\n\n\n\n\n = takes 7 new lines
-
06-09-2008, 04:27 PM #8610Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
wait so in C you cannot define where text goes like LUA???
you have to skip lines??


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum