Post some C samples
This is a discussion on Post some C samples within the Developer's Dungeon forums, part of the PSP Development Forum category; here is an example of rebooting the PSP (THERE ARE 100 ways ) I found this one the best: scepower.S ...
-
12-10-2006, 12:50 AM #31The Unique Developer

- Registriert seit
- Oct 2006
- Ort
- Canada
- Beiträge
- 1.059
- Points
- 7.101
- Level
- 55
- Downloads
- 0
- Uploads
- 0
here is an example of rebooting the PSP (THERE ARE 100 ways ) I found this one the best:
scepower.S
scepower.hCode:.set noreorder #include "pspstub.s" STUB_START "scePower", 0x40010000, 0x20005 STUB_FUNC 0x0442D852, scePower_0442D852 STUB_END
usage:Code:#ifndef PSP_POWER_H #define PSP_POWER_H #ifdef __cplusplus extern "C" { #endif /* Simply reboots the PSP @code @unknown - unknown just pass 50000 or any more then 0 only tested that */ int scePower_0442D852(int unknown); #ifdef __cplusplus } #endif #endif
Thanks to moonlight for finding the functions address .....Code://this should work tested 100% success scePower_0442D852(50000);
Best,
TUW
Malloc.Us Network Administrator
Decryption of the Encrypted
You are the unseen, the unstoppable and in power of your code. The God of your software.
-
12-14-2006, 11:18 AM #32
Does anybody have a function to do a FloodFill like you get in paint applications...?
If there is one kicking around it would really save me some time...
Cheers
ADePSPGeändert von ADePSP (12-14-2006 um 11:44 AM Uhr)
-
12-18-2006, 04:10 AM #33Bush Programmer

- Registriert seit
- Nov 2005
- Beiträge
- 3.658
- Points
- 60.149
- Level
- 100
- Downloads
- 0
- Uploads
- 0
That's interesting.. I just came to ask for the same thing.
I want a routine to floodfill circles.
-
12-18-2006, 08:31 PM #34Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von ADePSP
well the concept isnt too hard. just take a point, and go in a circular motion around it until you hit a pixel taht not the same color. im oo lazy to write actual code.
--------------------------------------------------------------------------------------
-
12-18-2006, 11:17 PM #35Bush Programmer

- Registriert seit
- Nov 2005
- Beiträge
- 3.658
- Points
- 60.149
- Level
- 100
- Downloads
- 0
- Uploads
- 0
That's not how it's done, that would be slow as hell.
the filling is done in pixel wide horizontal lines.
You can see a floodfill happening live on a computer that is old and slow enough.
-
12-20-2006, 09:13 PM #36
If your doing a lot of matrix math in your app, it might help to speed up things a bit with the help of the VFPU on the psp. The VFPU is a special coprocessor that deals specifically with vector and matrix math, and trig functions as well.
For example, I use this routine a lot in my game SnakeSP to translate and rotate the snake segments in one shot:
Another little routine I use that does sin and cos in one shot (way faster than calling sinf/cosf seperately on same angle)Code:void matTransRotZ(ScePspFMatrix4 *m, ScePspFVector3 *t, float rz) { __asm__ volatile ( "vmidt.q M200\n" "ulv.q C100, %1\n" "vmov.t C230, C100\n" // M200 = translation matrix "mtv %2, S100\n" "vcst.s S101, VFPU_2_PI\n" "vmul.s S100, S101, S100\n" "vrot.q C000, S100, [ c, s, 0, 0]\n" "vrot.q C010, S100, [-s, c, 0, 0]\n" // M000 = rotate Z matrix "vmmul.q M100, M200, M000\n" // M100 = final trans/rotate matrix "usv.q C100, 0 + %0\n" "usv.q C110, 16 + %0\n" "usv.q C120, 32 + %0\n" "usv.q C130, 48 + %0\n" : "+m"(*m) : "m"(*t), "r"(rz)); } ScePspFMatrix4 mModel; ScePspFVector3 trans = { -1.0f, 2.0f, -30.0f }; matTransRotz(&mModel, &trans, 45 * (GU_PI/180.0f)); sceGuSetMatrix(GU_MODEL, &mModel);
Some other tips to improve performance when dealing with floating point math:Code:void vsincos(ScePspFVector4 *result, float r) { __asm__ volatile ( "mtv %1, S100\n" "vcst.s S101, VFPU_2_PI\n" "vmul.s S100, S101, S100\n" "vrot.q C110, S100, [ s, c, 0, 0]\n" "usv.q C110, 0 + %0\n" : "+m"(*result) : "r"(r)); } ScePspFVector4 res; float f, triglut[256][2]; int x; for (x=0; x<256; x++) { f = x * ((M_PI*2)/256.0f); vsincos(&res, f); triglut[x][0] = res.x; // sin value in x component triglut[x][1] = res.y; // cos value in y component }
1) Stay away from doubles. The psp has hardware that can only handle 32 bit floats, and the vfpu also works with 32bit floats...when you introduce doubles, gcc will step in and throw in emulated code to handle them. The psp has no native support for double.
2) use the f versions of math functions...for example: sinf, cosf, floorf, atan2f...without those f's, you are really telling the compiler to use the double versions of those functions, again hitting performance with emulated code.
3) on any floating point constants, use the f postfix character..like 3.0f, 0.5f. Without it, gcc will generate double format numbers, again using emulated code to handle them.
4) avoid divides where you can. Its much faster to multiply with the inverse of a number. For example:
f = x / 4.0f;
can be rewritten as:
f = x * 0.25f; // 1/4 = 0.25
To give an idea of how drastic an improvement these tips produce...the first builds of my game, SnakeSP, could not handle more than 70 segments on screen before framerates dropped. Someone pointed out to me to switch to all floats, and now the game can draw 300 translated, rotated segments at 60 frames per second..I've yet to see the game slow down on me, and I've heard of longer chains with no slowdown.
EDIT: I'm putting together a collection of all the little helper routines I use in my projects. If you want, I'll post here
Do a search on google for michael abrash. He published a book a long time ago called Graphics Programming Black Book. That will turn up links to pdf's to the chapters in that book, including quite a few pages describing all sorts of different floodfill algorithms. There's also some pretty good routines in there like fast line drawing, circles, raster polygons, zbuffer techniques, line and polygon clipping, depth sorting...theres a LOT of good material in that book related to graphics programming.
Zitat von ADePSP
Geändert von MrMr[iCE] (12-20-2006 um 09:16 PM Uhr) Grund: Automerged Doublepost
-
02-17-2007, 01:38 PM #37is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
tuw- what is "pspstub.s"
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
03-01-2007, 03:18 PM #38QJ Gamer Bronze

- Registriert seit
- Jun 2006
- Beiträge
- 144
- Points
- 7.047
- Level
- 55
- Downloads
- 0
- Uploads
- 0
it's a SDK file. don't bother about it. It just defines the PSP_STUB macros.
Adrahil - Software architect and specialist in Reverse Engineering.
Spoiler for Guilt of a Dev:
Spoiler for me:
-
03-04-2007, 07:41 AM #39QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
MrMrIce mentioned the Graphics Prgramming Blacnk Book. If anyone is still looking for it, you can find it here:
http://www.gamedev.net/reference/art...rticle1698.asp[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]
-
03-16-2007, 01:51 PM #40Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
dunno i just posted it in the help thread so why not here;)
Code:#include <psprtc.h> #include <psphprm.h> #include <math.h> #include <pspkernel.h> #include <pspdebug.h> #include <pspctrl.h> #include <pspdisplay.h> #define printf pspDebugScreenPrintf int getcurrenthour() { /*by hallo007*/ pspTime rtime; sceRtcGetCurrentClockLocalTime(&rtime); int hour = rtime.hour; return hour; } int getCurrentMinutes() { /*by hallo007*/ pspTime rtime; sceRtcGetCurrentClockLocalTime(&rtime); int minutes = rtime.minutes; return minutes; } char * printfCurrentTime() { /*by hallo007*/ char timeText[200]; sprintf(timeText , "%i : %i" , getCurrentHour() , getcurrentMinutes()); return timetext; }
-
03-22-2007, 07:45 PM #41words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Optimised ;)
I believe those will work. Just small, not 100% needed otpimizations.Code:#include <psprtc.h> #include <psphprm.h> // this really needed for RTC functions? int getcurrenthour() { pspTime rtime; sceRtcGetCurrentClockLocalTime(&rtime); return int(rtime.hour); } int getCurrentMinutes() { pspTime rtime; sceRtcGetCurrentClockLocalTime(&rtime); return int(rtime.minutes); } char *CurrentTime() { char timeText[8]; snprintf(timeText, 8, "%i : %i" , getCurrentHour() , getcurrentMinutes()); return timeText; } ... //example: //printf ( CurrentTime );
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
03-23-2007, 02:54 AM #42QJ Gamer Bronze

- Registriert seit
- Jun 2006
- Beiträge
- 144
- Points
- 7.047
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Calling function twice is not what i call optimisation :P Just use it once every time you need it. And, the optimisations you had done didn't optimise anything as GCC does all of it by itself ;)Code:#include <psprtc.h> #include <psphprm.h> // this really needed for RTC functions? char *CurrentTime() { char timeText[8]; pspTime rtime; sceRtcGetCurrentClockLocalTime(&rtime); snprintf(timeText, 8, "%i : %i" , rtime.hour , rtime.minutes); return timeText; } ... //example: //printf ( CurrentTime );Adrahil - Software architect and specialist in Reverse Engineering.
Spoiler for Guilt of a Dev:
Spoiler for me:
-
03-29-2007, 08:24 AM #43Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
I think the app wont compille without this#include <psphprm.h> // this really needed for RTC functions?
-
03-29-2007, 05:54 PM #44QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
As someone in the C help thread pointed out, that is wrong. The char ends when you do return timeText, so it displays the battery scrambled (like the problem i had and others did too).
Zitat von adrahil
Here is the time code that worked for me:
I also made it so that if the minutes are less than 10 (single digits), add a zero before the minutes. If the minutes are greater than 9 (double digits), keep it the way it is.Code:void CurrentTime( char * timeText) { pspTime rtime; sceRtcGetCurrentClockLocalTime(&rtime); if ( rtime.minutes > 9) { snprintf(timeText, 8, "%i:%i" , rtime.hour , rtime.minutes); } if ( rtime.minutes < 10) { snprintf(timeText, 8, "%i:0%i" , rtime.hour , rtime.minutes); } } //later in main loop char aTime[16] = ""; CurrentTime( aTime ); printf( aTime);Geändert von SuperBatXS (03-29-2007 um 06:09 PM Uhr)
Calypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
03-31-2007, 03:29 AM #45QJ Gamer Platinum

- Registriert seit
- Sep 2005
- Ort
- Edinburgh, UK
- Beiträge
- 2.388
- Points
- 25.089
- Level
- 95
- Downloads
- 0
- Uploads
- 0
Or easier, of course:
Learn about printf modifiers. They're your friends.Code:void CurrentTime( char * timeText) { pspTime rtime; sceRtcGetCurrentClockLocalTime(&rtime); snprintf(timeText, 8, "%i:%02i" , rtime.hour , rtime.minutes); }Using firmware v2.00-v3.50? Open up a whole world of homebrew here
The PSP Homebrew Database needs YOU!
Your ISP may be illegally wiretapping all your web activity. Stop Phorm Now!
Visiting the Edinburgh Festivals? Get practical advice from experts.
-
03-31-2007, 02:14 PM #46QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Hey, first of all, i would like to thank the C help thread for helping me learn file writing X to Y bytes. I thought it would be necessary to post an example, for it could help and a lot of people who are confused with this like i was. Anyways, this helps you learn this in 5 easy steps.
File I/O: Writing X to Y Bytes in a file
In the number "123456789", what if you wanted to replace the 5 with a 0 ("123406789")? Using simple file i/o writing functions, we can easily do this.
1) Assign your file a variable:
In this function, we declare a file with the name "example".Code:FILE* example;
2) Open your the file you assigned the "example" variable to.
Also, note that there is a "r+b". Here are some simple definitions:Code:example = fopen("./example.txt","r+b");
"r"- open a file for reading only
"w"- open a file for writing only
"b"- open a file in binary mode
"rb"- open a file for reading only in binary mode
"wb"- open a file for writing only in binary mode
"r+b"- open a file for reading and writing in binary mode
Note: If you don't use "r+b" in this case, and you use "wb" instead, then you can not read the bytes from X to Y (you must read the file for writing X to Y bytes; hard to learn at first).
3) After opening your file, add this line:
"fseek- "Reposition stream's position indicator." This requires 3 parameters, the pointer to an open file, the offset (how many bytes from the origin) and the origin." from psp-programmingCode:fseek(example, 4, SEEK_SET);
SEEK_SET goes to the beginning of the file.
The "4" goes, literally, four characters right from the beginning of the file. After adding this line, you can edit the next character, in this case, being "5".
4) Now, this code (fprintf) lets you write a character to the example variable we indicated earlier:
Note: the "0" is the character that we want to write in place of the 5. Any number or letters that you want can be replaced by the zero to write to the file (of course, it would be writing to the file after the fourth character that we "fseek"ed earlier).Code:fprintf(example, "0");
5) Close the file before continuing the program:
Yes, it took me around 5 hours to figure this out (until the C help thread helped). As sad as my situation was, hopefully this will help you learn this in less than 5 minutes.fclose(example);
Btw, what is up with "5" today? Is this a coincidence or what?
Anyways, i hope this helps. ;)Geändert von SuperBatXS (05-13-2007 um 11:06 AM Uhr)
Calypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
03-31-2007, 03:10 PM #47QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
For more info:
http://www.cppreference.com/stdio/fopen.html
http://www.cppreference.com/stdio/fseek.html
This is actually a C++ snippet taken from various sources. It is used to easily create a Singleton design pattern:
Code:/** @file singleton.hpp @brief Template class to create a singleton class Taken from: http://www.gamedev.net/reference/articles/article1954.asp which in turn is taken from Game Programming Gems @author Steven Yau @date 17 Mar 2007 */ #ifndef SINGLETON_HPP #define SINGLETON_HPP #include <cassert> namespace Core { template<typename T> class cSingleton { static T* m_Singleton; public: cSingleton() { assert( !m_Singleton ); // use a cunning trick to get the singleton pointing to the start of // the whole, rather than the start of the Singleton part of the object int offset = (int)(T*)1 - (int)(cSingleton <T>*)(T*)1; m_Singleton = (T*)((int)this + offset); } ~cSingleton() { assert( m_Singleton ); m_Singleton = 0; } static T& GetSingleton() { assert( m_Singleton ); return *m_Singleton; } static T* GetSingletonPtr() { assert( m_Singleton ); return m_Singleton; } }; template <typename T> T* cSingleton <T>::m_Singleton = 0; } #endif // SINGLETON_HPP /* Usage: Taken from http://www.ogre3d.org/wiki/index.php/Singleton How to use it [edit] Making a class a singleton Pretend we want to convert the class MyManager to a Singleton. class MyManager { public: MyManager(); void doSomething(); } So we need to extend and instatiate the Ogre::Singleton template and override the singleton access methods. Our header file will look like this: #include <OgreSingleton.h> class MyManager : public Ogre::Singleton<MyManager> { public: MyManager(); void doSomething(); static MyManager& getSingleton(void); static MyManager* getSingletonPtr(void); } You don't have to override getSingleton() and getSingletonPtr() if your Singleton is not used outside of your EXE/DLL, but else you have to. The source file would now look like this: #include "MyManager.h" template<> MyManager* Singleton<MyManager>::ms_Singleton = 0; MyManager* MyManager::getSingletonPtr(void) { return ms_Singleton; } MyManager& MyManager::getSingleton(void) { assert( ms_Singleton ); return ( *ms_Singleton ); } // The rest of your implementation is following. ... [todo] Do some more explaining. [edit] Using a singleton // Creating the manager. This may only be called once! new MyManager(); // Obtaining a reference to the manager instance MyManager& mgr = MyManager::getSingleton(); // Obtaining a pointer to the manager instance MyManager* pMgr = MyManager::getSingletonPtr(); Note: You may call the Singleton constructor only once. Calling it more often will result in a runtime exception. There is another semantical difference between getSingleton() and getSingletonPtr(): If the constructor is not called beforehand getSingletonPtr() will return a NULL-Pointer and getSingleton() will throw a runtime exception. So it is probably better to use getSingleton() most of the time, even though it is slightly slower. But you get a clearer response when you set something up wrongly. */[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]
-
04-01-2007, 02:33 PM #48The Unique Developer

- Registriert seit
- Oct 2006
- Ort
- Canada
- Beiträge
- 1.059
- Points
- 7.101
- Level
- 55
- Downloads
- 0
- Uploads
- 0
As Adra said before, pspstub.S defines the PSP_STUB macros. Its located in /local/pspdev/sdk/includes/ . The function has changed from 2.xx to 3.xx , so I'll repeat my example with some changes.
Zitat von Glynnder
scepower.S
scepower.hCode:.set noreorder #include "pspstub.s" STUB_START "scePower_driver", 0x40010000, 0x20005 STUB_FUNC 0x0442D852, scePower_0442D852 STUB_END
Yes I'm surprised it worked for me on 2.71 although I was stubbing it from the wrong libraryCode:#ifndef PSP_POWER_H #define PSP_POWER_H #ifdef __cplusplus extern "C" { #endif /* Simply reboots the PSP @code: scePower_0442D852(); // The function has changed through 2.xx to 3.xx from 3.xx they're not using any arguments to reboot the system. */ int scePower_0442D852(void); #ifdef __cplusplus } #endif #endif
.
Best,
TUWMalloc.Us Network Administrator
Decryption of the Encrypted
You are the unseen, the unstoppable and in power of your code. The God of your software.
-
04-02-2007, 04:51 PM #49QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Here is a little something SG57 made to load a lot of images quickly:
Btw, don't forget to add "int i = 0;" anywhere before the "i" is used.
Zitat von SG57
Geändert von SuperBatXS (04-04-2007 um 05:55 PM Uhr)
Calypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
04-06-2007, 12:58 AM #50Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Get firmware version
I hope i got them all
a firmware version is build like thisCode:int getFirmwareVersion(void) { switch(sceKernelDevkitVersion()) { case 0x01000300: return 100; case 0x01050001: return 150; case 0x01050100: return 151; case 0x01050200: return 152; case 0x02000010: return 200; case 0x02000110: return 201; case 0x02050010: return 250; case 0x02060010: return 260; case 0x02070010: return 270; case 0x02070110: return 271; case 0x02080010: return 280; case 0x02080110: return 281; case 0x02080210: return 282; case 0x03000010: return 300; case 0x03000110: return 301; case 0x03000210: return 302; case 0x03000310: return 303; case 0x03010010: return 310; case 0x03010110: return 311; case 0x03030010: return 330; default: return 0;//unkow firmware } return 0; }
firstnumber-point-secondnumer-thirtnumber
0x0firstnumber0secondnumb er0thirdnumber10:
enjoy:Punk:
-
04-06-2007, 05:01 AM #51sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
That could be optimized like this:
Zitat von TMNT
The compiler my optimize it all ready though ;)Code:Image *image[10]; int *numberPtr = 0 int *endPtr = 10; ... while( numberPtr < endPtr ) { image[i] = loadImage(image_name); numberPtr = endPtr++; }
-
04-07-2007, 08:04 AM #52QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Bad! Bad! Bad! You are making integer pointers point to random parts of memory and I can't see it making any logical sense nor compiling.Code:Image *image[10]; int *numberPtr = 0 int *endPtr = 10; ... while( numberPtr < endPtr ) { image[i] = loadImage(image_name); numberPtr = endPtr++; }
TMNT: No, it is slower then loading it manually because you are calling sprintf 10 times.[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]
-
04-07-2007, 08:40 AM #53QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Oh......so then how would i make it faster? Is a code that is fast for image buffering that you know of/can make? The one SG57 posted was, in my opinion, the best, but apparently it's not anymore now that you made me realize it. Thanks. ;)
Zitat von yaustar
Calypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
04-09-2007, 05:21 AM #54QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Arguably, the 'fastest' way is to manually unroll the loop:
But is not very maintainable. SG57's function is more maintainable and is the method that I would use. The performance offset is minor compared to maintainability.Code:image[0] = loadImage("1.png"); image[1] = loadImage("2.png"); image[2] = loadImage("3.png"); image[3] = loadImage("4.png"); image[4] = loadImage("5.png"); // etc[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]
-
04-10-2007, 03:02 PM #55sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
Hmmm, I read in an optimization article that showed something almost exactly like that, except it printed the pointer, instead of using it as an index of the array, must of been a bad resource (I wish I could remember where the article was).... Thanks for correcting me!
Zitat von yaustar
-
04-11-2007, 09:18 AM #56Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
this is the only i found out at themoment , as soon as i get my psp back i will update thisCode:char *getOeFirmware() { switch(sctrlSEGetVersion()) { case 0x00000100: return "2.71 SE-A"; case 0x00000200: return "2.71 SE-B"; case 0x00000300: return "2.71 SE-C"; } return 0; }
-
04-11-2007, 09:55 AM #57QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You are probably thinking along the lines of this:
Zitat von Bronx
-= Double Post =-Code:int Blah[10]; int * pBlahStart = &Blah[0]; int * pBlahEnd = &Blah[9]; while( pBlahStart <= pBlahEnd ) { (*pBlahStart) = 0; ++pBlahStart; }
Not 100% on how C would normally handle C strings but this may cause problems. You are returning a pointer to a C string that is local to the function. This means as soon as the function finishes, the string that is on the stack gets popped off and whatever you assigned the pointer address to is now pointing to garbage.
Zitat von hallo007
ie
Code:char * firmware = getOeFirmware(); int Blah = 10; printf( firmware ); // firmware may now point to garbage
Geändert von yaustar (04-11-2007 um 10:04 AM Uhr) Grund: Automerged Doublepost
[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]
-
04-11-2007, 01:50 PM #58QJ Gamer Silver

- Registriert seit
- May 2006
- Ort
- Behind you.
- Beiträge
- 1.814
- Points
- 10.921
- Level
- 69
- Downloads
- 0
- Uploads
- 0
Um, i was asked to go to another thread to ask this, and i thought it would be appropriate here- Could anyone give me the source to loading a simple eboot in 3.10 oe-a?
Calypso - Enjoy the excellent 2D space shooter:
http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195
"Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)
-
04-11-2007, 03:19 PM #59
You could write it like this so any new firmwars come along, no need to add another case, your software allways up to date
Zitat von hallo007
-= Double Post =-Code:int getFirmwareVersion(void) { u32 firmware=(u32) sceKernelDevkitVersion(); // Return BCD as DEC return (int)(((firmware&0x0f000000)>>24)*100)+(((firmware&0x000f0000)>>16)*10)+((firmware&0x00000f00)>>8)); }
Zitat von Art
Here is the correct way of drawing elipses.
Notice no SIN, COS or float is used, SIN, COS and float, floats should only be used when it is the only way and best way of doing somthink, like in this drawOval you will see that integer can do the same job and actually draw it better.
try use floats only when you have to use them, don't use them as a quick way of solving somethink, if integers can no matter how complex can do the same job better use intergers.
Code:void Graphics::drawOval(int x, int y, int width, int height) { int xc=x, yc=y; long a=(long)width, b=(long)height, aa=a*a, bb=b*b, aa2=aa<<1, bb2=bb<<1, d=bb-aa*b+(aa>>2), dx=0, dy=aa2*b; x = 0, y = height; while (dx < dy) { *(u32*)pixel(xc+x, yc+y)=foreColor; *(u32*)pixel(xc-x, yc-y)=foreColor; if (d > 0L) { y--; dy -= aa2; d -= dy; } x++; *(u32*)pixel(xc+x, yc-y)=foreColor; *(u32*)pixel(xc-x, yc+y)=foreColor; dx += bb2; d += bb + dx; } while (y > 0L) { *(u32*)pixel(xc+x, yc+y)=foreColor; *(u32*)pixel(xc-x, yc-y)=foreColor; if (d < 0L) { x++; dx += bb2; d += dx; } y--; *(u32*)pixel(xc+x, yc-y)=foreColor; *(u32*)pixel(xc-x, yc+y)=foreColor; dy -= aa2; d += aa - dy; } }Geändert von xart (04-12-2007 um 08:30 AM Uhr) Grund: Automerged Doublepost
-
04-12-2007, 01:14 AM #60QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I disagree with the float part. Float should only be avoided if the platform has no FPU. If it does, the floats are likely to be faster then integers as it has to cast/emulate(? I can't remember) integers up to floats to compute.Here is the correct way of drawing elipses.
Notice no SIN, COS or float is used, SIN, COS and float are a big no no in game coding.[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]


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