Using memset would be alot easier.Zitat:
Zitat von _dysfunctional
memset(string,0,sizeof(st ring));
That would set every byte in the buffer to 0.
Printable View
Using memset would be alot easier.Zitat:
Zitat von _dysfunctional
memset(string,0,sizeof(st ring));
That would set every byte in the buffer to 0.
Yes, he could, but I was only giving suggestions.
Eh... not really. All it would do is copy a '\0' to the first byte of the destination string. IMO, don't help if you don't know. You will end up giving bad information to someone...Zitat:
Zitat von JaSo PsP
Is there any way to run a kernel module on 3.40 kernel? I think I read somewhere that it was possible, but I can't for the life of me remember where or how I found it.
Its either that, or is there a way of using PSP_CTRL_WLAN_UP in user?
By the way, solved the fscanf as soon as I had drank my tea :ROFL:
Cheers.
-Aura
ahh shut up... he can use free()...Zitat:
Zitat von Moca
I have reinstalled cygwin 10 times and my sdl problem still is not solved :Argh:
whats wrong. just the part in bold doesnt seem to want to compile
Code:int main() {
dsxSystemInit();
pspTime time;
for(;;) {
dsxDrawingStart();
sceRtcGetCurrentClockLocalTime(&time);
dsxDrawFontDefault(0, 100, GU_RGBA(0, 0, 0, 255), "%i:%02i",time.hour,time.minutes);
unsigned short batteryLifeTime;
if (scePowerIsBatteryExist())
batteryLifeTime = scePowerGetBatteryLifeTime();
dsxDrawFontDefault(42, 18, GU_RGBA(255, 255, 255, 255),"%02dh%02dm" , batteryLifeTime/60, batteryLifeTime-(batteryLifeTime/60*60));
unsigned short pw;
if(scePowerIsBatteryExist())
pw = scePowerGetBatteryLifePercent();
else pw = 0;
dsxDrawFontDefault(0, 18, GU_RGBA(255, 255, 255, 255), "%u%%", pw);
if (scePowerGetBatteryLifePercent() < 100){
dsxDrawFontDefault(440, 18, GU_RGBA(255, 0, 0, 255), "/// ");
if ((scePowerGetBatteryLifePercent() < 66) {
dsxDrawFontDefault(440, 18, GU_RGBA(255, 0, 0, 255), "//");
if ((scePowerGetBatteryLifePercent() < 33 ){
dsxDrawFontDefault(440, 18, GU_RGBA(255, 0, 0, 255), "/");
if ((scePowerGetBatteryLifePercent() < 10) {
dsxDrawFontDefault(440, 18, GU_RGBA(255, 0, 0, 255), "");
}
}
}
}
dsxDrawingEnd();
}
return 0;
}
Zitat:
Zitat von vodkkaa
Drop the one of the first two '('s in those three lines. It's a simple syntax error.Code:if ((scePowerGetBatteryLifePercent() < 66) {
...
if ((scePowerGetBatteryLifePercent() < 33 ){
...
if ((scePowerGetBatteryLifePercent() < 10) {
I told you. You can only 'free()' something that you 'malloc()'d. You can't 'free()' a string like:Zitat:
ahh shut up... he can use free()...
Code:char buffer[80];
uneeded to do it that way , do it like thisCode:if ((scePowerGetBatteryLifePercent() < 66) {
...
if ((scePowerGetBatteryLifePercent() < 33 ){
...
if ((scePowerGetBatteryLifePercent() < 10) {
Code:int battery = 0;
battery = scePowerGetBatteryLifePercent() ;
if(battery > 60)
....
Your method is unneeded. Why waste memory storing the value in a variable? I suggest reading a decent programming book.
ow , so checking the battery three times is better then wasting a few bytes memorys?? lol , go read a book by yourself
Sorry, but an int is only 4 bytes on the PSP and it is better to do it hallo007's way (As much as I'd rather not say so). Not to mention that his original way is flawed in the first place.Zitat:
Zitat von AdjutantReflex
It doesn't matter how much space it saves, optimizations are optimizations, know matter how small.
Should you be doing more then just comparing the value 3 times, it might be better to store the value in in variable for better readability, but you'll survive otherwise.
hallo - Usually one reads a programming book by one's self. And yes, I've read many books that were recommended by more experienced programmers here and 3 software engineers and computer science professors in person.
but you dont need to say that when i am correct , you are correct to , there isnt something thats better , but when it comes to call larger function , (to check a folder size (with subfolders and files inside) , you betetr store it
This isn't really C++ but who cares I was making an Easy 3.52 M33 for all the noobs that want one I had all the file transfering just about done most it was done when I finally figured out how to work the comboBox is when i ran into the problem
This "{0} is the string that would be the drive letter but i get an error saying you can't convert string to bool and i don't know how to convert it in a differnt way for it to work for me anyways here's what my code used to look likeCode:string m;
m = comboBox1.SelectedItem.ToString();
if (File.Exists(path))
File.Copy(@"\M33CREATOR\150.PBP", @"{0}\PSP\GAME\M33CREATOR\150.PBP",m);
File.Copy(@"\M33CREATOR\351.PBP", @"{0}\PSP\GAME\M33CREATOR\351.PBP",m);
used to be neat like that can someone please tell me a better way to do thisCode:if (fw150.Checked)
{
string path8 = @"{0}\PSP\GAME\Kxploitpatcher";
string path9 = @"{0}\PSP\GAME\Kxploitpatcher%";
string copy1 = @"{0}\PSP\GAME\Kxploitpatcher\EBOOT.PBP";
string copy2 = @"{0}\PSP\GAME\Kxploitpatcher%\EBOOT.PBP";
string path10 = @"\M33CREATOR\Kxploitpatcher\EBOOT.PBP";
string path11 = @"\M33CREATOR\Kxploitpatcher%\EBOOT.PBP";
Directory.CreateDirectory(path8);
Directory.CreateDirectory(path9);
File.Copy(path10, copy1);
File.Copy(path11, copy2);
}
optimizations aren't just about saving space, code legibility is important tooZitat:
Zitat von AdjutantReflex
I think HE knows that -_-
The typical sentence of a person that first learned about optimization methods :)Zitat:
Zitat von AdjutantReflex
Only problem is your optimization goes completely in the wrong way and even in your own foot in this case, as the variable will only use 4 bytes of stack which is not any waste at all, but the function call creates an overhead regarding cpu time and stack as well (the function itself increases and pushes and pops values to the stack).
You should try to reflect a little bit more on what you learned from people and books. Blindly praising the sayings is gonna come back around to you :)
But at least you learn by reading too ;P
i think you're the one who needs to read a decent programming book. to add on to what rafa said:Zitat:
Zitat von AdjutantReflex
1. its ONE variable. if you want to optimize at that level, you can expect to never finish anything.
2. that last sentence was completely un-necessary, and hypocritical.
3. you just contradicted yourself right here:
anyway, rants aside, this is how i would do it:Zitat:
Zitat von AdjutantReflex
that way, when the control reaches main, the variable battery dies, saving us FOUR BYTES! OMG!Code:function doStuffWithBattPercentage()
{
int battery = scePowerGetBatteryLifePercent() ; // using storage class 'auto' //
if (battery < 60) {
...
}
etc.
}
Zitat:
Zitat von Grimfate126
Personal preference, as stated, and I assure you making optimizations at that 'level' is very much so finish able. Once again, goes back to personal preference. Maybe you don't see a need to make such extreme optimizations as you have no need.Zitat:
Zitat von grim
Notice how I used the qualifier 'might'. :down:Zitat:
Zitat von grim
I just got back from a camp where I developed the software for a mini sumo 'robot' with 4 kb of onboard memory. The example source given to use used up 3 and a half kilobytes and did the utmost basic AI (forward backward depending on what a sensor detected (black or white)). I ended up using somewhat - extreme optimization techniques to get just under 4 kb. Still having a mind set of that, I find memory precious, regardless of how much available. Regardless, the PSP with 24 mb ( 32 - 8mb or so for kernel and even more for other resources) should be something to worry about should you be developing something using a lot of resources or something of the sort.Zitat:
Zitat von grim
Anyhow, the rant was over.
IIRC, the return value of the function takes up room on the stack anyway so there is no optimisation. If space was an issue, I would have done:
The problem with scePowerGetBatteryLifePer cent(), it sounds volatile which means it might be one value at the start of a frame and another at the end. This might cause problems in some sections of the code. Caching the value at the start of the frame and then using that value for the rest of the code in the frame will ensure it remains consistent The same applies for timesteps.Code:// Some code
{ // Start scope
unsigned int batteryFactor = scePowerGetBatteryLifePercent() % 33;
switch( batteryFactor )
{
case 0: // less then 33%
{
// print some text
} break;
case 1: // between 33% and 66%
{
// print some text
} break;
default: // above 66%
{
// print some text
} break;
}
} // End scope, batteryFactor is popped off the stack
Edit: IIRC, the stack is static regardless right? Adding variables on the stack is near free and doesn't increase memory in any way?
Fixed :PZitat:
Zitat von yaustar
Yes.Zitat:
Edit: IIRC, the stack is static regardless right? Adding variables on the stack is near free and doesn't increase memory in any way?
Opps :$. Note to others, that would have been the point where I break out the debugger or trace lines to figure out why the battery would be full all the time.Zitat:
Zitat von Raphael
a small typo like that can be really hard to debug on the psp:p
Not really. PSPLink and Trace calls should be enough for most debugging purposes. Simply adding:Zitat:
Zitat von brethren
Would have been enough to narrow down the cause.Code:// The REAL printf, not the #define psp version which you should NEVER do
printf( "Battery factor %d\n", batteryFactor );
i get this error in psplink
functionCode:ms0:/psp/game/FA/> Exception - Bus error (instr)
Thread ID - 0x04D78301
Th Name - MENU
EPC - 0x0808BE64
Cause - 0x10000018
BadVAddr - 0x9140303F
Status - 0x20008603
zr:0x00000000 at:0x0008FF00 v0:0x00000200 v1:0xFFFFFFFF
a0:0x00000000 a1:0x88287760 a2:0x0000003C a3:0x00000200
t0:0x88287648 t1:0x00000000 t2:0x00001BB8 t3:0x88040000
t4:0x88287728 t5:0x00000E00 t6:0x08902668 t7:0x00008600
s0:0x00000000 s1:0x00000003 s2:0x88287760 s3:0x00000201
s4:0x08940000 s5:0x08940000 s6:0x08940000 s7:0x08940000
t8:0x00000070 t9:0x0000007D k0:0x00000000 k1:0x00000000
gp:0x0894B5C0 sp:0x88287728 fp:0x08941A1C ra:0x08902674
what's wrongCode:int IdDump(const char* dst)
{
char PrintBin[56] , dump[512];
int BinSave;
u16 idkey;
BinSave = sceIoOpen(dst, PSP_O_CREAT | PSP_O_TRUNC | PSP_O_WRONLY, 0777);
if(BinSave<0) { return 0; }
pspDebugScreenClear();
for(idkey=0x000;idkey<=0x200;idkey++) // Ampliado desde 0x000 hasta 0x200 (anterior 0x004-0x127)
{
pspDebugScreenPrintf("key 0x%03X\n",idkey);
sprintf(PrintBin,"KEY : 0x%03X\n",idkey);
sceIoWrite(BinSave, PrintBin, 512);
sceIdStorageReadLeaf(idkey, dump);
sceIoWrite(BinSave, dump, 512);
}
sceIoClose(BinSave);
return 0;
}
(btw it printf's "key 0x000" and the memory stick light shows once , so it crashes at sceIdStorageReadLeaf(idke y, dump);
hallo - Have you used PSPLink on it? Go to your source code dir.
That should help to the point you solve it yourself unless you've already done this.Code:addr2line -fie YourGame.elf 0x0808BE64
Btw, BinSave should really be type SceUID.
SceUID ist just a typedef int ;)
!Zitat:
Zitat von hallo007
It'd help my readability as I'd automatically know it's for IO where an integer can be for anything.
Anyhow, hallo - grammar does in fact impact one's code ;)
how do u load fonts with the oslib i've looked at it and found these(in the text.h) to load fonts with:
extern OSL_FONT *oslLoadFont(OSL_FONTINFO *fi);
extern OSL_FONT *oslLoadFontFile(const char *filename);
i'm unsure of what to do for the first one so instead i used the second like so:
however it keeps going to the fatal error i tried taking that out as it may not be the same as an image however it crashes the psp...so how do i load fonts with the oslib all the examples i have seen don't work with fontCode:OSL_FONT *font;
font = oslLoadFontFile("fonts/font.ttf");
if(!font){
oslFatalError("the font file is missing");
}
oslSetFont(font);
If you would read the documentation that comes with OSL, you'd read what font formats OSlib support (*.OFT). Conveniently enough, it comes with a TTF to OFT converter.
i copyed the oslib from a diffrent computer(a while ago) so i didn't relieze there was documentation that came with it thanks for reminding me sg
-= Double Post =-
well still didn't help i dl'ed the documentation and no referral to fonts what so ever the only thing i have for now is the converter which gave me two files which loading each does nothing
I can assure you it works. When I was developing Drakojan Skies (just needs a weapon and enemy class/system) I used OSLib with fonts. You are probably doing it incorrectly. Post your code. Ill post my method once I find it on assembla real quick.
nvm figured it out
wow , what a big mistake , i dindt even see it , thnx very much!!!Zitat:
Zitat von tommydanger
how do you pack folders or images or anything into an eboot?
i tried:
PSP_EBOOT_PACK = "images" //folder
and
PSP_EBOOT_PACK = "images/misc/parse bg.png"
however it doesn't pack them into my eboot
Not to be mean, but I giggled (funny word alone) a little at that slice ;)
I'm not sure whether you are trying to make your EBOOT sort of like a ZIP file or trying to get the background, ICON0, pmf video, sounds, etc. for your EBOOT in the XMB to show.
If the first one - no. You could probably find hunk of space in your EBOOT you could paste in and load from via fread, but Im not sure if an EBOOT has some check to make sure anything unsigned or something is there. If that's the case, then ZIP or 7Z is whatyou want (look in dl.qj.net source for a 7Z source or AT's IRShell plugin source (wasn't it released?))
well it was pretty much the first one i know how to do the rest with the icon0 and stuff i was hoping it to ensure people didn't have to worry about multiple files as i expect to have many i'll look into 7z/zip thanks
edit: the only reason i would think it is possible is because some games i know that have images don't appear to have images and is only 1 eboot
you could bin them to c;)
slice - As hallo said (but in a method not too understandable) you can convert an image to an unsigned char array. Take a look at GIMP for direct saving from just about any image format out there to C source.
Once in C source format, you link the file and include it and whatnot, then assign whatever your image structure's/class's 'data' member is to gimp_image.pixel_data (after allocating space for it). Then there is other members to assign values to (width, height, bytes p/pixel, etc.).
I think someone wrote a tutorial for usage with the graphics library.