PDA

View Full Version : Small EXE - How?


Phil Steinmeyer
11-11-2005, 03:12 PM
So I'm making an ActiveX version of my game. My budget is 1MB for everything, compressed. Unfortunately, just my EXE alone is about 310K, compressed. I'm not thrilled about using 1/3 of my budget on that.

I've never really had to optimize for small EXE size before, so I'm looking for thoughts/suggestions.

1) I'm not linking in any DLLs - had to move needed functionality into my EXE.
2) My framework is fairly thin, though I've brought in some bits of the PopCap framework to replace SDL stuff I linked to in DLLs
3) I'm using VS.Net 2003. Unfortunately, if I dynamic link in the main DLL, it links to msvcr71.dll, which few users have, unlike the older msvcrt.dll, which was universal on my target audience. So I have to static link instead (which is still much more efficient than packaging in msvcr71.dll, but it does add 50K to my compressed EXE size.
4) I played a bit with compiler settings. I can't turn off exceptions because of the PopCap stuff - not sure if that bloats things or not anyways. 'Favor size over speed' option was only a small win - 8KB compressed. Not sure if there are any other 'flip this bit and make your EXE 50K smaller' options - anyone know of any?

Other suggestions?

And for those of you making web versions of your games, what's your overall size budget (compressed)?

soniCron
11-11-2005, 03:38 PM
Check this out:
http://msdn.microsoft.com/msdnmag/issues/01/01/hood/default.aspx

I'm aiming for a ~200KB web game. Of course, I'm also aiming for a sub-5 megabyte download.

ggambett
11-11-2005, 04:10 PM
I can think of a couple of things... don't inline anything, use inheritance over templates, don't duplicate code, strip the EXE and the DLLs, pack it with upx if applicable, #ifdef out library code that you don't use (say, the 8 bit SDL blitters),...

James C. Smith
11-11-2005, 06:33 PM
I went though this with Ricochet Lost Worlds. It started out at 1MB compressed. (just the exe). In the end I only got it down to 500k. The biggest gains were removing code that wasn't needed. Apparently I have a lot of that still.

Here are the results of some compiler setting changes

Compressed EXE was 830k
Optimize for min size took it down to 706k
Disable Exception handling took it down to 647k

HairyTroll
11-12-2005, 01:01 AM
Try compressing the executable using LZMA (http://en.wikipedia.org/wiki/LZMA). It can be almost 40%-50% more efficient than Pkzip.

The nullsoft installer (http://nsis.sourceforge.net/Features) is able to create LZMA compressed installs.

cliffski
11-12-2005, 02:02 AM
google for ezip, thats the one I use. I've used upx too.

Sol_HSA
11-12-2005, 03:02 AM
While a lot of the tricks used in 4k intros are not applicable for real-world applications, you might find some useful stuff at http://in4k.untergrund.net

Jim Buck
11-12-2005, 03:24 PM
Microsoft compilers don't strip out code/data that's not used?

James C. Smith
11-12-2005, 04:39 PM
Not if it's a virtual function. Actually, there are all kind of things that the compiler would have no way of knowing whether they used or not. Things like support for different image file formats, custom blitters for specific bit depths that the game never uses, and scripting commands supported by the scripting system but never called by any of the scripts in the game. All our games a very data driven. The engine supports all kinds of things that may or may not existing in the data files.

Jim Buck
11-13-2005, 12:22 AM
Other than virtual functions, it can generate a graph at link-time of stuff that's called from *somewhere* in code (even if it's never called by scripts). I'm just not sure if MS-based compilers did this. SN Systems' stuff does this for console games, though, and it saves a ton of memory.

revve
11-14-2005, 12:27 PM
Don't know how relevant this is to you - had this link floating around on my work PC for a while now. Just never had access to it when I saw this post before.

http://www.catch22.net/tuts/minexe.asp

Indiepath.T
11-16-2005, 10:41 AM
We got cbubble 8.5MB down to 1.8Mb by halving the texture sizes, making all the .png 8bit, compressing the hell out of the .jpg and reducing the quality of the .ogg files. Remember that you got to give some incentive to the player to buy the full version - like better quality GFX, SFX and more features.

Phil Steinmeyer
11-16-2005, 05:48 PM
I'm already down from about 8.9MB for the downloadable to 1.15MB for the web version, and I have a bit more hacking to go...

(That's total, compressed, not just the EXE size)

dislekcia
11-19-2005, 05:31 AM
Code obfuscation?

I know that a lot of cellphone games use obfuscation to make their exes much smaller.