how to decrease size of 4kb intro

category: code [glöplog]
Hi all,

I have been coding a 4kb intro. After compression size of the intro is 4295 bytes. I am using Visual Studio for conding and Crinkler for compression. How to decrease size of intro? Any Visual Studio or Crinkler tricks and tips? Is there something I need to change/set-up in VS?

added on the 2009-08-28 23:53:04 by Sir Sir
um... i know this sounds trivial but have you tried optimizing your code? :)
added on the 2009-08-28 23:58:09 by Gargaj Gargaj
what I did not dare to say, but Gargaj said
added on the 2009-08-29 00:05:54 by Sir Sir
just cut off the end bit with a pair of scissors
added on the 2009-08-29 00:11:34 by Maali Maali
Gargaj: code is optimized
Maali: I used an axe to cut 4kb from 64kb:)
Gargaj: code is optimized
Then it is no 4k.
Maali: I used an axe to cut 4kb from 64kb:)
Then it is a 60k.
added on the 2009-08-29 00:21:43 by Sir Sir
tip: read here for inspiration.
littlejerome: have you tried looking through the crinkler report to see which functions / data blobs are bigger than they should be?
added on the 2009-08-29 00:43:12 by Gargaj Gargaj
Taking a hint from iq, save yourself some bytes and use magical floats instead!
[url text="\:D/"]http://tmd.freeshell.org/floats.h[/url]
added on the 2009-08-29 00:48:51 by sigflup sigflup
added on the 2009-08-29 00:50:23 by sigflup sigflup
whatever, the link is in there
added on the 2009-08-29 00:50:52 by sigflup sigflup
also, assuming you have triple checked all the compile options (/QIfist, /Gs, /Os, /Oi, etc etc) and that you have also gone thru in4k and that you have cross checked your code with all the 4k source codes and frameworks out there for ensuring you have a minimal setupcode, then the rest is optimizing the code.

Are you using DX, or OpenGL? Is your code using extensive (ab)use of shaders like in most recent intros? Are you using a softhsynth or gm.dls?

It's difficult without looking to the code. Also, how long did you try to remove those 200 bytes? I think two weeks going thru the code everyday for few hours removing byte by byte is what might you need?
added on the 2009-08-29 01:04:06 by iq iq
oh, I can share a trick for shaders. On top of the usual offuscation (like calling all the variables a, b, c, etc, removing the spaces, the unnecessary { }, and so on), you should try to make the code repetitive. In Elevated there are quite a lot of smoothstep(a,b,x) calls, and we replaced them all with smoothstep(0.0,1.0,(x-a)/(b-a)) so that a longer string "smoothstep(0.0,1.0," was repeated over the code (often the "/(b-a)" becomes a constant tho, like "*0.25"). In the same idea, don't mix writing conventions like "2.", "3" and "4.0"; instead choose one (whatever) and consistently use it. So, the advice is that prior to offuscation make sure you have consistent and repeatable code. Part can be done automatically by simple offuscation tools, but other things like the smoothstep require some more advanced parser, so do them by hand. Speaking of what, nobody ready to make a serius stable and advanced offuscator and release it as demotool (a good one I mean which does tricks like the smoothstep one)?
added on the 2009-08-29 01:23:37 by iq iq
added on the 2009-08-29 01:36:14 by bdk bdk
all: thanks for hints
iq: I am using opengl (no shaders) and a softh synth.
iq: i guess the problem is that it wouldnt be obfuscation, but instead optimization for context modelling, and i'm not sure if you can automate that easily...
added on the 2009-08-29 01:56:17 by Gargaj Gargaj
littlejerome, give us size-updates and let us know when it's 4k or under
added on the 2009-08-29 02:01:01 by sigflup sigflup
iq: I did a basic glsl parser/ofuscator/text2h for my latest 4k, it should evolve onto a full brute force shader permutator to obtain somewhat more compressible shaders automagically in the near/far future. Not sure if it'll released publicly any time soon, but it's something I'm going to work for the next 4k after the experience gained on our latest 4k. Not sure if this is helpful at all, I'm tired and asleep.
added on the 2009-08-29 03:11:51 by shash shash
littlejerome: what crinkler settings are you using? which compiler settings?
added on the 2009-08-29 08:17:24 by src src
Some mixed tricks that helped on Linux at least: try different compiler options - compressed code is rather unpredictable, define local arrays as static, inline subroutines that are called only once, use as little different external functions as possible (for example don't import both glVertex2f and glVertex3f), use float versions of math functions instead of doubles. As a last resort to get some precious bytes you might even change the order of some lines of code where appropriate to see if it compresses better :)
added on the 2009-08-29 08:23:46 by Marq Marq
you could also find some tricks here
added on the 2009-08-29 08:41:32 by pohar pohar
iq: like shash, we also have an own glsl obfuscator, but is not that sophisticated, it'd need a major rewrite and some inspiration to do automatic code optimization (function inlining, elimination of dead code, etc.), to be release-worthy :)
added on the 2009-08-29 11:50:09 by xTr1m xTr1m
it would be interesting to see how well such a tool would perform.
but i guess manual tweaking of the shader source with the help of crinkler reports will still be unmatched.
added on the 2009-08-29 13:46:07 by gopher gopher
All: Thank you for all tips. Some VS tricks made life easy:) The size of the intro is less than 4096 bytes.