Author | Best Practices for porting Apps | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2009-02-17 14:58   I'll try to post here some best practices when porting applications to Morphos. As they are developped for Over Powered Computers, SDL coders usually don't activate all accelerations. ------------------------------------------ Find SDL_SetColorKey() function an look if SDL_RLEACCEL flag have been used. Note that SDL_RLAACCEL must be used with SDL_SRCALPHA to be accelerated
------------------------------------------ Some coders never use the SDL_HWSURFACE flag. An easy optimisation is then to replace SDL_SWSURFACE by SDL_HWSURFACE
Best is to have a look at the Surface use before using SDL_HWSURFACE ------------------------------------------ SDL games may crash on Morphos when cursor is customized by the game. It's safer to remove all SDL_SetCursor() calls and only reactivate them once you're sure there is no other bug
------------------------------------------ Some apps try to save and read environnement variables. This usually try to acces Unix paths (you will find things like this (getenv("HOME");)that are not available for amiga. Find getenv or setenv calls
------------------------------------------ Some games need to run a configure file trying to test various exotics library. It may be usefull to skip all errors avoiding the Makefile creation.
[ This Message was edited by: admin on 2010-03-25 18:55 ]   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2009-02-18 16:30   RGB Big and little Endian Masks :
[ This Message was edited by: Admin on 2009-02-18 16:39 ] [ This Message was edited by: Admin on 2009-02-18 17:08 ] [ This Message was edited by: admin on 2010-02-25 23:51 ]   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2009-02-18 17:35   An interesting Note about Mix_OpenAudio that may explain why lots of games crash when playing music :
I had a problem too with powersdl_mixer.library crashing when compiling with -O3 option... [ This Message was edited by: admin on 2009-02-18 23:30 ]   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2009-02-27 20:46   When debugging, remove all optimisations and don't strip the executable. Here is the command to disassemble a binary :
[ This Message was edited by: admin on 2009-12-21 15:20 ] [ This Message was edited by: admin on 2009-12-21 17:12 ]   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2009-03-01 20:33   Some options that can be added to LD parameters -ffunction-sections -Wl,--gc-sections This should remove all unused functions. This can be added in makefile with this parametre : LDFLAGS=" -ffunction-sections -Wl,--gc-sections "   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2009-03-08 13:49   Round function is missing on amiga plateform. It's possible to use this define : #define round(x) (int)(x+(x<0? -0.5 : 0.5))   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2009-07-16 21:56   define this : #define unlink(foobar) { remove(foobar); }   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2009-10-19 13:56   sentenv can be replaced by SetVar() from DOS functions. A stub can be created too : int setenv(const char *name, const char *value, int overwrite) { printf("DTCn"); } dos/dos.h proto/dos.h SetVar(name, buffer, size, flags) size = -1 flags = (GVF_LOCAL_ONLY ou GVF_GLOBAL_ONLY) [ This Message was edited by: admin on 2009-10-19 14:00 ] [ This Message was edited by: admin on 2009-10-19 14:06 ]   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2009-12-21 21:08   add some stack :
  | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2010-01-10 22:50   For games based on floats, always use a :
  | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2010-02-16 22:47   conflict functions or types : #undef myfunc or find . |grep ".cpp|.h" |xargs sed -i 's/func/myFunc/g' find . |grep ".cpp|.h" |xargs sed -i -r "s|bla|myBla|g" [ This Message was edited by: admin on 2014-04-02 23:45 ]   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2010-03-18 19:54   Seem's that SDL_RWops are broken at least in powerSDL 14.0 You may encounter such code that will explode :
Problem can be solved like this :
[ This Message was edited by: admin on 2010-04-13 22:07 ]   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2010-03-24 00:20   Convert little-endian float to big-endian float :
  | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2010-08-02 23:02   Replace socklen_t : typedef int socklen_t; Replace ioctl : IoctlSocket(s, FIONBIO, &on_mode); Dont forget to close the socket : close(s); : CloseSocket(s); [ This Message was edited by: admin on 2011-01-01 21:03 ]   | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | Posted: 2011-01-13 00:09   optimised SQRT() functions : http://ilab.usc.edu/wiki/index.php/Fast_Square_Root   |