64kB demos, how do they work?
Asked Answered
G

3

17

I've seen some programs showing amazing highly detailed 3d scenes with soundtracks, but what shocked me is that they are all smaller than 64kB! How do these programs work?

enter image description here

Georgettegeorgi answered 21/5, 2011 at 11:20 Comment(9)
The rest of the files included with the demo are much larger. They include all the necessary resources.Zigmund
@Cody Gray there no other files. It's all within one executable. See CodeInChaos's answer.Adscription
@Cody I don't think so. Usually for a size limited demo the size of the executable and all resources needs to be below the limit. There are some differences on what runtime libraries you can use, but usually those are already part of the OS.Parrnell
@ba__friend: How in the world do you know how many files there are? It's not like the question contains any details about that. His guess is as good as mine.Zigmund
@Cody because it's no 64k demo anymore if you add resources exceeding that size. And 64k is already one of the larger size limits. Limits of 4-8k are common too.Parrnell
@CodeInChaos: The question is specifically about the size of the executable. Small executables with satellite DLLs and other resource files are an extremely common pattern. It's something worth knowing about. (Who places these arbitrary limits?)Zigmund
@Cody The topic says "64k demos". So it doesn't just talk about programs where the main program happens to be small. en.wikipedia.org/wiki/Demo_(computer_programming) Since many demos are competition entries the organizer sets the exact rules. There are certain popular limits such as 4kB and 64kB.Parrnell
My experience has been that making the assumption someone asking a question knows everything about the topic and gets all of the details right is rarely successful. Apparently your intuition tells you differently. The theories presented in your answer are certainly good ones, but far from the only plausible ones.Zigmund
Maybe "64k demo" is a known concept but i would expect to see some platform+language tags with this.Molarity
P
20

They generate their content procedurally. i.e. they don't add 3d models, bitmaps, sample based audio-files,... but generate that from code or some low detail representation.

Using self similarity(fractales) and building complex data by combining simple building blocks and formulas is usually the key to a compact representation.

The audio could be stored in some midi like format where the different notes are stored.

The textures are generated combining filters, fractales,... google for "Perlin noise" for a simple example. Shows how to create very different textures from perlin noise

3D models probably have some geometric description using formulas and the detail is added with techniques similar to procedural textures.


And most use some runtime unpacker. i.e. your normal executable is larger than the limit and gets compressed with an exe packer. Demos usually don't use UPX, but specialized packers which have a very small loader/unpacker and might even leak memory(who cares about memory leaks if you can safe a few bytes).

Parrnell answered 21/5, 2011 at 11:25 Comment(3)
"Might not be a" what?Lanam
@Lanam Don't ask me what my 2011 me thought when he wrote that.Parrnell
I think this is a good link to open a window on this world: llg.cubic.org/docs/farbrauschDemos together with pouet.netPeltast
B
5

Back in the day they were written in assembly language as COMs. There were even 16kb demos. I liked those demos very much and that's why Assembly was the first programming language I learned. I never managed to create a real demo but I was able to create a virus that cleared my hard disk. I don't have source code ;)

Bonanno answered 21/5, 2011 at 11:26 Comment(0)
T
2

They are:

  • code without useless (sic!) external libs (you really should know what you need to make it),
  • shaders compilers, compressors etc.
  • functional 3d graphics and 2d texture makers (but deterministic and constant, but related with many parameters),
  • procedural audio makers (the same each time).

Examples (code examples!) could be found here:

http://www.displayhack.org/2012/the-great-demoscene-sourcecode-giveaway/

Don`t be stupid guys - just use google!!!

Totemism answered 26/12, 2014 at 0:44 Comment(3)
Well, your 1st point is completely wrong regarding PC productions of current dates. They include the fully fledged OpenGL or DirectX libraries as well as more libs as needed. Just relate to your 2nd point: where does a shader compiler come from?Melena
Hi, thanks for comment. I guess you want to be strictly correct. /// Yes, sorry. Not any libs but only not useful, not needed. Another example, many people whole packet of sth, e.g. SFML for example to project even they don't need some of that. /// And, could you explain your question broadly? /// PS I saw npl.de and I appreciate! :)Totemism
Oh, my question was strictly rhetorical. Shaders need to be compiled on the current hardware, which is the job of the device driver (at least in windows). Thus there's another big fat block of foreign code used. It's just not the same anymore as 4k's were around the millenium change. Check out some raving tomatoes by t$ from that time.Melena

© 2022 - 2024 — McMap. All rights reserved.