I recently found this article about how some guy managed to write a super mario game in just 14k of javascript code. Ok, it's not a full game, it's not even a full level, but still - 14k of javascript, without any external graphics files... I, for one, congratulate the person that managed to do that..
Then I found this article about Wolfenstein 3d, also written in javascript(!).
Anyway, I was wondering if any of you know of a similar amazing/weird/fun coding achievement that you would like to share with the rest of us.
Write about things like extreme examples of optimization, or successful use of some language/technology to do things it was never intended for.
views:
2533answers:
22Elite ran on a 2 MHz 6502, doing 3D wireframe graphics in a little over 20k of available RAM. It defined its own screen mode (which was actually fairly straightforward to do on a BBC) and timed a change between two and four colour modes to within a single scan line on the display (which was somewhat more clever).
DOOM did texture-mapped graphics fast enough to run playably on a 386 (I played the game on a 20 MHz 386 with an ISA video card). It was also portable - originally developed on a NeXT computer and subsequently ported to DOS. The entire game engine was something like 30K lines of code.
Many years ago A friend of mine implemented a 64 channel data logging system on a Cosmac with 256 bytes of RAM and 2K of ROM. In order to do this, he wrote a FORTH VM in 30 bytes of code and wrote most of the system in Forth. To develop this, he wrote an emulator for the RCA 1802 instruction set on his PDP-11/03.
I always find the entries in the International Obfuscated C Code Contest fascinating. Some of the techniques that have been used over the years are truly magnificent.
I remember on various home computers there were quite a few programs that changed screen mode half way down the screen. All fairly clever, but I can understand how they did it, you count hsync interrupts and change mode (by register tweaking rather than an API call) after you've had a certain number of them.
But I saw one program, a 3D modeller whose name I've long since forgotten, which changed mode half way across the screen. Presumably it changes to one mode on the hsync interrupt then uses a timing loop to wait until it's time to switch back, and puts up with wasting half of the limited CPU power (but if all you're doing is running the GUI you can probably afford this).
(This was on the Atari ST. ST Medium res was 640x200 4 colours; ST Low res has 320x200 16 colours).
The most amazing for me was ZX81 chess, which you could play against the computer in just 1k. And that 1k was the entire system memory, some of which was used for display, stack, etc... I don't see many of us ever getting that efficient again.
You may want to look into the Demoscene. For example, .kkrieger is a 3d FPS which takes up only 97,280 bytes of disk space.
Another example of some of these is here.
I've made this when i was entering university some years ago (yeah i've been doing it slowly and partyfull, improving softskills)
4KBintro: Made in opengl, it's a heart generated with a particle engine. Is actualy 3d but if you rotate it, it will look like a ice cream so i let it stay static. When i showed it to my girlfriend at the time she replied "So!? i've seen much better on tv"
64KBinto: actualy cheated the exe is 88KB but with zip it went to 64KB. It has 2 parts first with a couple of cubes and the second with a particle generator and some attempts to make cool efects.
This were my first attempts with opengl so don't mind if they look newbish compared with the pros :)
As a personal achievement, yeah it did feel good to make it, to bad i don't got more time to keep learning opengl and graphical computing :( i love the field
Heaven 7 by Exceed is simply amazing. See for yourself! It's an intro, real-time ray-tracing in 64kb, written in assembly.
Really the best such stories you are going to find are in the annals of computer Folklore. Back in the day programs weren't quite so big and people had to do really insane things to get them to fit and run properly on the tiny, slow machines that were available then. These days we are kinda spoiled.
One of my personal favorites is the story of Mel. I'll give an executive summary here:
Imagine a system where memory (including instruction memory) was a constantly rotating drum. Now imagine a programming language where every line had a goto (for the location of the next instruction on the drum) at the end. The idea would be that you optimize your program's execution time by scattering your instructions across the drum in such a way that the next instruction always happens to be right under the read head when you are ready to read it. Now imagine that you decide to further optimize things by using instruction codes for constants when the values you need happen to match one of them. Imagine that your method for programming delays would be to ask for memory acesses that you knew would be on the far side of the drum when needed. You'd have to be some kind of genius to keep all this straight in your head, right? That was Mel.
Mel was told to make a Blackjack program for tradeshows. Mel dutifully did so. Mel was then asked to make it cheat in favor of the human when a secret switch was thrown, so their preferred customers wouldn't loose as much. Mel didn't like making his program cheat, and did so only under extreme duress. However, it turned out there was a bug, and instead it cheated it it's own favor when the "cheat" switch was thrown. Mel, happy now, claimed that clearly his "subconcious was uncontrollably ethical" and refused to fix it.
So one day, after Mel leaves, the narrator is asked to look at the code and see if it can be "fixed". A large exposition of various discovered optimizing tricks follows. The final straw came when the narrator came across a loop with no test for exiting whatsoever. It nonetheless exited just fine when run. It turned out Mel used arithmatic overflow to change a neighboring instruction into a branch. Seeing this, the narrator admited defeat and told managment it couldn't be done.
I'd encourage reading the full story though.
Mandelblot in less than 128 bytes of html is amazing. Mandelblot is represented by numbers.
This is 113 bytes cheating (but browser readable) DHTML.
I guess I'll contribute my own 64k intro here, since we're posting a lot of demoscene examples: Shaven Raven. To be honest, the intro is insanely crap from an artistic point of view, but the code is alright I guess. Somehow, it still managed to win a competition though. And it's 64k. Size optimizing is fun.
I know assembly has been a bit overdone but my favourites are from the Assembly Competitions. Here is one of my favourites.
For me, it would have to be Omar Al Zabir's portal, where he is able to simulate the Windows 2000 interface using just HTML and Javascript. I discovered it sometime in 2005 or so. It was a revelation to me!!
Sadly, the link doesn't seem to work nowadays!! It keeps reporting an error (atleast for me) saying "the line or server is too slow". Not sure what it is though... Hope Omar Al Zabir fixes it soon!!
The Lone TeXnician, who -- all by himself -- put up a convincing entry for the ICFP contest written completely in teX and ended up getting the Judges prize.
A long time ago there was a 256 byte game competition. The two games I wrote were too late for the deadline, but I did have a great time writing them.
You can download my entries here (along with all of the games): http://www.geocities.com/boltbaits/256byte/games.html
(Commented source code included)
The game that impressed me the most was called Indecent. It is a 2D sideways scroller with 256 color graphics and sound effects. It has Guraud shaded mountains and multiple levels of parallax backgrounds. Even with the commented source code I don't understand how it was done.
I am always amazed at what the computers on the original Apollo missions could achieve. Todays computers are so much more powerful yet they still keep crashing landers into Mars! http://www.abc.net.au/science/moon/computer.htm
I worked on the Robocom BitStik CAD system in 1981. That was at least 90+k of 6502 assembler running on an Apple ][ in 16k Pages on 128k a bankswitched ram card.
The first version was built without a linker and their was no hard disk so it took 2 hours to assemble on 7 floppy disk drives!
Tony
php playing tetris (just press start)
coded this around 2003 in school because i was bored... the algorithm needs to be tuned some more, btw ;)
Some early (c1979) portable chess machines had 4-bit cpus with 320 bytes of RAM and 2k bytes of ROM.
http://www.chesscomputeruk.com/html/chess_champion_pocket_chess.html
They played at nine levels and could give you a fair game at about level 5.
I also think that the 6 line (472-char) perl program qrpff that cracks CSS DVD encryption deserves a mention.
Two things come to mind...
Back in the day of the ActiveX Notepad I did a Tangram. Div's and 'javascript' only.
Not long after that, using HTML 'Cougar' (3.2 ?), some script and IE's cache control I made a 'PAC' : Portable Application Catalog for automotive after-market spare parts.
It ran from a floppy, no database, no dll's, nada. Just a couple of HTML files and some CSV's. (assuming IE 5 or higher)
You would select Make, Model and Type of Vehicle and the appropriate oil, air, water and other filters would appear. (around 14k 'Vehicles' and well over 30k 'Applications')
The cache control is still available and the old 'PAC' still runs in IE 7.
I never understood why, assuming IE is a given in the environment, that cache control was never put to any use. 'PAC' is the only thing I have ever seem making constructive use of it.
Still think 't was a 'kewl' hack.
A well-known (in computer chess circles that is...) small chess program is Micro-Max by H.G. Muller. There are a few versions, one of which is about 2000 characters of C-source code, and plays at about the 2000 ELO level, giving an impressive 1 ELO / character ratio!