13 ms·
A bootable CD image with a retro game in a single tweet
- antoineMoPa 8y agoThat's the kind of thing I come here for! Tiny hacks of all sorts.
- vinhboy 8y agoSame. I come here to witness what is basically programming magic to me. I'll need a couple of life times before I can become this skilled.
- amenghra 8y agoYou can do “magic” with relatively easy things. For example, spend a weekend with https://forthsalon.appspot.com https://forthsalon.appspot.com or processing.org and see where you can get to...
- exikyut 8y agoAwww. That first link silently requires WebGL in order for the animations to work, and doesn't implement a fallback. :'(
- classichasclass 8y agoThere's almost as much header information as there is code!
- barbegal 8y agoI was confused as to how you could represent a bootable CD image in printable characters. It turns out that you can't. This is a tweet of a perl script which creates a cd.iso file that you can then boot from. The perl script significantly decompresses the data in the tweet. That said, this is a playable game in around 60 bytes of actual data which is impressive.
- makomk 8y agoIt's pretty light compression from what I can tell - basically just squashing down runs of nulls to a single count.
- wtmcc 8y agoThe compression is basic run-length encoding, leveraging the Perl repetition operator (x), and the property of the Perl print/say functions that they concat items passed in a list before writing to STDOUT. https://en.wikipedia.org/wiki/Run-length_encoding https://en.wikipedia.org/wiki/Run-length_encoding https://perldoc.perl.org/perlop.html#Multiplicative-Operators https://perldoc.perl.org/perlop.html#Multiplicative-Operator... https://perldoc.perl.org/functions/say.html https://perldoc.perl.org/functions/say.html https://perldoc.perl.org/functions/print.html https://perldoc.perl.org/functions/print.html
- lucb1e 8y agoI tried xz -9 on it and found, to my surprise, that it was actually longer than RLE! Then I tried gzip -9, because perhaps that has a smaller header? Yup, saved a few bytes, now it's about the same size. Finally, I remembered that bzip2 does a lot better on text than gzip, and who knows, it might also have a shorter header than xz. Again, a few more bytes saved! Down to 223, where the original is 249 bytes (including the 'say' part but excluding the unnecessary delimiting apostrophes or the rest of the command).
- mlindner 8y agoIt's not compressed. It's run length encoding which is an encoding, not compression.
- garaetjjte 8y agoNot CD images, but there is DOS C compiler generating executables with only printable characters (and also no self-modifying code that could contain non-printable characters) http://www.cs.cmu.edu/~tom7/abc/paper.txt http://www.cs.cmu.edu/~tom7/abc/paper.txt (view in monospace font, 160 character lines)
- deleted 8y ago[deleted]
- narrator 8y agoI remember x86 real mode back in the day. Pretty hideous and hacky compared to what we have now.
- bvc35 8y agoWhat's real mode?
- gknoy 8y agohttps://en.wikipedia.org/wiki/Real_mode https://en.wikipedia.org/wiki/Real_mode
- saagarjha 8y ago> what we have now x86 processors still boot into real mode…
- yjftsjthsd-h 8y agoIt's my understanding that UEFI actually comes up directly into long mode? "UEFI firmware performs those same steps, but also prepares a protected mode environment with flat segmentation and for x86-64 CPUs, a long mode environment with identity-mapped paging. The A20 gate is enabled as well." - https://wiki.osdev.org/UEFI https://wiki.osdev.org/UEFI
- basementcat 8y agoThis inadvertently triggered my A20 gate rage.
- dlubarov 8y agoUnfortunately most BIOS services are only available in real mode, so it's often necessary to switch back and forth.
- ghamrick 8y agoI grew up (career wise) on CTOS systems with 286/386 processors that could address the full 16MB in protected mode without memory extenders or expanders that were available for DOS back in the day. Also premptive multi tasking. It was a great OS to learn on. more info - https://web.archive.org/web/20080828190425/http://www.byte.com/art/9412/sec13/art2.htm https://web.archive.org/web/20080828190425/http://www.byte.c...
- starpilot 8y agoWow, that's pretty leet.
- yebyen 8y agoYour snake game doesn't even have food for the snake to eat? The snake just grows without eating, until the head collides with the tail somewhere? Pssh, amateur hour... /s (Just kidding this is actually super cool.)
- amenghra 8y agoIt's Tron-ish (the post says Tron, where did you read snake?) :P
- reificator 8y agoIt's a fair assumption to make, as the difference between Tron and Snake is effectively just single player vs multiplayer.
- derrasterpunkt 8y agoNo it isn't. In TRON you leave a trail behind. In Snake, you grow as you eat and drag your body along the path you crawled. TRON's trail is static, Snakes body is dynamic.
- reificator 8y agoI said effectively. > TRON's trail is static, Snakes body is dynamic. And that difference only exists to support the single player vs multiplayer dynamic. If Snake left a Tron tail then it would be a very short, unfun experience. If Tron didn't leave a permanent trail then matches would last too long.
- hacksoi 8y ago> And that difference only exists to support the single player vs multiplayer dynamic Maybe the single player vs multiplayer difference only exists to support the different tail mechanics.
- myth_drannon 8y agoIf you want to see demos (as in demoscene) in a tweet of 140 characters - https://www.dwitter.net/ https://www.dwitter.net/
- acutesoftware 8y agonice to see demos in action without running random code - thanks. Demos are without a doubt the best way to show the maths can look cool.
- deleted 8y ago[deleted]
- ryandrake 8y agoThis is great, and ironically it’s sitting next to another HN article where, in the comments, someone is actually defending a NYT news article that weighs in at 6MB. In a time when most software is filled with superfluous waste and endless layers of abstraction and libraries, it’s nice to see that the art of writing minimal software is not completely lost.
- icebraining 8y agoFurther irony: this page weighs over 30MBs, thanks to a huge GIF that is arguably not necessary for the article.
- flas9sd 8y agothat made me chuckle, judging from the whole idea, it's part of the fun
- mynewtb 8y agoYeah, not happy about that idiocy (probably 1MB as video) burning through 10% of my monthly bandwidth on the first day of the month...
- jasonmp85 8y agoI think "1MB as video" actually _hugely_ overestimates the size that file could be if it were just e.g. mp4 with the same frame rate, quality, etc.
- CydeWeys 8y agoWow, how low is your monthly download cap?? What ISP and where?
- flukus 8y agoProbably mobile, here are the plans mine offers (I'm on the 2GB one): https://www.whistleout.com.au/MobilePhones/Carriers/iiNet https://www.whistleout.com.au/MobilePhones/Carriers/iiNet So page bloat is a real issue, not just "old man rants about good old days". A shame really because the rest of the page is pretty light wieght, 5.2kb for the content and 2.2 for the css. Even worse is that the static preview of the monster gif is the second largest element.
- varjag 8y agoThe actual tweet: https://twitter.com/alokmenghrajani/status/1007514337592987648 https://twitter.com/alokmenghrajani/status/10075143375929876...
- rootbear 8y agoVery cool. My version of base64 wants -d, not -D, though.
- amenghra 8y agoLinux vs BSD (ie Mac OS X). Sorry about that. Also, you shouldn’t paste weird looking things from the internet in your console :P
- mygo 8y agoyeah paste it into your plain text editor first and then do a code review and then save it to a jump drive and spin up the old backup computer that’s been wiped clean and then open up a sandboxed vm and then remove the wifi chip and then run it
- exikyut 8y agoIf it was March last year, you wouldn't have wanted to run anything marked "only works in Edge", particularly if you were using Win10 on VMWare - https://arstechnica.com/information-technology/2017/03/hack-that-escapes-vm-by-exploiting-edge-browser-fetches-105000-at-pwn2own/ https://arstechnica.com/information-technology/2017/03/hack-...
- a1k0n 8y agoHats off for making use of the AAA instruction. That's a very clever sequence converting up/down/left/right to -320/+320/-1/+1.
- amenghra 8y agoFor those who don’t know, x86 had support for binary coded decimal (you end up wasting a bunch of bits). AAA converts the result of the addition of two valid unpacked BCD digits to a valid 2-digit BCD number.
- wintorez 8y agoWhat is this sorcery!?
- fmfamaral 8y agoWell done, sir.
- amenghra 8y agoMake sure you check out the floppy version from ~3 years ago. Fits in “old” tweets (ie 140 chars): https://www.quaxio.com/bootloader_retro_game_tweet/ https://www.quaxio.com/bootloader_retro_game_tweet/
- CGamesPlay 8y agoYou should investigate adding an RSS feed!
- Klathmon 8y agoMan I love these things. Back before Twitter upped their character limits, I remember a trick to cram more data in a tweet was to abuse how Twitter counts characters (it attempts to count visually rather than by byte), so by using a ton of multipart emojis or larger Unicode characters to over double the information that could fit in a tweet.
- amenghra 8y agoI thought about using Unicode, but it felt like cheating. Perhaps someone can fit two games in a single multibyte tweet?
- Klathmon 8y agoIIRC weren't the Twitter length changes only applied to languages that weren't benefiting from the more "dense" encodings. Meaning languages like Chinese and Japanese are still at the old limit.
- lucb1e 8y agoMultibyte chars is optimizing for Twitter, not for a set amount of bytes. If you try to fit in 140 bytes and you use >140 bytes because they are multibyte chars, then yeah, you're cheating. But if you're trying to "fit in a tweet", I'd say that's perfectly fair game. Anyhow, two games... cool, but to be perfectly honest, I thought the game was going to be more like the real snake than just drawing a non-overlapping line on screen. A more impressive game might be more impressive than two games. Then again, two games is also pretty darn cool.
- komali2 8y agoThis is the second time this week I've seen someone note that ISO standards are expensive - are they copyrighted or something? Why doesn't someone just publish them online for free?
- tomcam 8y agoYes, they are copyrighted. The link to article points to this equivalent, free ECMA 119 standard: https://www.quaxio.com/files/2018/bootable_cd_retro_game_tweet/ecma-119.pdf https://www.quaxio.com/files/2018/bootable_cd_retro_game_twe...
- robinwassen 8y agoI bought the ISO 14000 Standard Document (Environmental Management) for $170 earlier this year, so it is not expensive for a company. Not sure how the "technical documents" ala ISO 9660 differs in price. The certification on the other hand is a bit more costly though. My estimation of the certification cost for a ~20 people company if you do it as frugally as possible ended up at $18000 for the first year investment, and $6200 recurring the following years.
- tomxor 8y agoLooks like the turbo button needs to be in the on position for this one: 0.05 FPS in a qemu KVM on my old P8600... I presume the game loop uses the hardware clock :P btw my base64 util needed lower case -d
- amenghra 8y agoThere’s a comment on the page. For some reason, emulators (at least the ones I tried) wait 4x what real machines wait when you use BIOS int 15b 86h. You can tweak the code if you want to play at a faster speed. There’s probably a sound explanation for this discrepancy...
- BGZq7 8y agoI can't say I entirely understand how the Elapsed Time Wait works, but testing in qemu, I was able to get it to a good speed by replacing the inc cl with a nop inc dx By opening in a hex editor, finding bf86 fec1 and replacing with bf86 9042 If you're on a very slow system, maybe just use 2 nops or a 2-byte nop.
- exikyut 8y agoI couldn't find "bf86 fec1". I did however find "b486 fec1". "bf86 9042" made it literally so fast I physically couldn't keep up. The following worked for me (w/ QEMU on old (no KVM) Pentium M), this may be too fast on newer machines: xxd cd.iso | sed 's/89c3 01de b486 fec1 cd15 b445/89c3 01de b486 9042 cd15 b445/' | xxd -r > cd2.iso (Note the creation of "> cd2.iso")
- jobu 8y agoThis reminds me a bit of the science of nanoinformatics as described in one of the Expanse novellas (The Vital Abyss): "A thought experiment from my first course in the program: Take a bar of metal and put a single notch in it. The two lengths thus defined have a relationship that can be expressed as the ratio between them. In theory, therefore, any rational number can be expressed with a single mark on a bar of metal. Using a simple alphabetic code, a mark that calculated to a ratio of.12152205 could be read as 12-15-22-05, or “l-o-v-e.” The complete plays of Shakespeare could be written in a single mark, if it were possible to measure accurately enough. Or the machine language expression of the most advanced expert systems, though by then the notch might be small enough that Planck’s constant got in the way. How massive amounts of information could be expressed in and retrieved from infinitesimal objects was the driving concern of my college years." Pure fiction at this point, but it would be an interesting experiment to encode data into objects that could be expressed using the mathematical ratio of their shapes or sizes.
- dfcarney 8y agoCheck out Arithmetic Coding: https://en.m.wikipedia.org/wiki/Arithmetic_coding https://en.m.wikipedia.org/wiki/Arithmetic_coding
- utopcell 8y agoSo beautifully retro. Like twitter :-)
- dionna767675 8y agoAll the help you need to succeed in your business online marketing courses learn how to make money online step by step training http://gosmallbiz.club http://gosmallbiz.club
- KyeRussell 8y agoAs someone that develops almost exclusively in high-level languages on top of may levels of abstraction, it's nice to see what can be accomplished close to the metal. This reminds me of Steve Gibson's SpinRite, which (from what I recall) is a fully functional disk recovery utility written entirely in assembly. https://www.grc.com/spinrite.htm https://www.grc.com/spinrite.htm. Say what you want about the man, but this is something that's saved me on at least one occasion, and is smaller than things I produce that do a lot lot less.
- jjeaff 8y agoThere are people that will argue until they are blue in the face that his recovery software is useless. But I have also had some success with it. Everything that he releases is amazingly tiny. It just shows how much bloat modern software tends to have.
- exikyut 8y agoWhat I've read is that SpinRite simply just reads and writes to the disk, triggering the disk firmware to reallocate bad sectors. I think it just tries to read many times, which can sometimes help. The other argument is that the various things SR tries to "manage" (sector interleave, getting various timing parameters "perfect", etc) were only relevant with ST-506 (!!) and similar disks from the 80s/very early 90s, and that anything remotely modern (even IDE, virtually 100% of SATA) generally doesn't provide enough low-level control surface that trying to micro-manage the disk's behavior will do anything particularly special. Of course, I'm sure each manufacturer has their own tools and widgets that can use undocumented proprietary SATA/SCSI commands to control the drive's behavior at a very low level, but those kinds of tools are a) rare as hens' teeth and b) probably very easy to break disks with due to poor UI design and lack of documentation. Chances are the most expensive data recovery centers probably have some of these tools, and more importantly the training to know how not to kill HDDs with them :P TL;DR: Yes, SR works, but probably just as well as dd3rescue; as always, if you think a disk is this side of dead and you think you have a chance without specialized tools, just imaging it is probably the best first step, because SR and all other tools will of course stress it. With all of this said, I really, really like SR's startup animation :3 and I agree that it's refreshingly small.
- monikagab 8y agoEl editor de arrastrar y soltar de Exai es un verdadero ayudante al construir su sitio web. Puede editar el contenido usted mismo con nuestro editor WYSIWYG http://es.exai.com/funciones/wysiwyg-editor http://es.exai.com/funciones/wysiwyg-editor
- sjtrny 8y agoThe explanation is quite good but is there even more detail on what the assembly instructions are doing on a line by line basis? I’ve only written MIPS assembly and that was a long time ago.
- andyidsinga 8y agoi love love love this. This is a fantastic way to get into low level programming with a fun,tangible and approachable result. back in "the day (TM)", we used to do this with ..achem ..viruses on floppies :) Putting it in a tweet is just brilliant. anyone remember the one where it would say "smoke more weed dude"? (or something of the sort) :)
- xellisx 8y agoNot as cool as this, but here are some PHP "frameworks" in a tweet (140 characters): http://www.twitto.org/ http://www.twitto.org/ https://gist.github.com/mathiasverraes/9046427 https://gist.github.com/mathiasverraes/9046427 https://philsturgeon.uk/php/2009/12/15/Twiny-Framework-the-framework-small-enough-to-tweet/ https://philsturgeon.uk/php/2009/12/15/Twiny-Framework-the-f... https://gist.github.com/jeremeamia/2720020 https://gist.github.com/jeremeamia/2720020
- wojtczyk 8y agoLove it!