Author | Best Practices for porting Apps | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | ![]() 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 | ![]() 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 | ![]() 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 | ![]() 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 | ![]() 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 | ![]() 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 | ![]() define this : #define unlink(foobar) { remove(foobar); }   ![]() ![]() ![]() ![]() ![]() ![]() | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | ![]() 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 | ![]() add some stack :
  ![]() ![]() ![]() ![]() ![]() ![]() | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | ![]() For games based on floats, always use a :
  ![]() ![]() ![]() ![]() ![]() ![]() | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | ![]() 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 | ![]() 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 | ![]() Convert little-endian float to big-endian float :
  ![]() ![]() ![]() ![]() ![]() ![]() | |||||||||||||||
Admin Joined: Apr 11, 2001 Posts: 284 | ![]() 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 | ![]() optimised SQRT() functions : http://ilab.usc.edu/wiki/index.php/Fast_Square_Root   ![]() ![]() ![]() ![]() ![]() ![]() |