Show HN: Doom (1993) in a PDF
369 points| vk6 | 1 year ago |doompdf.pages.dev
I was inspired by the recent HN post about Tetris in a PDF (https://news.ycombinator.com/item?id=42645218) and I wondered if I could get Doom to run using a similar method.
It turns out that old versions of Emscripten can compile C to asm.js code that will happily run inside the limited JS runtime of the PDF engine. I used the doomgeneric (https://github.com/ozkl/doomgeneric) fork of the original Doom source, as that made writing the IO fairly easy. All I had to do was implement a framebuffer and keyboard inputs.
Unlike previous interactive PDF demos, the output for DoomPDF is achieved by creating a text field for each row of pixels in the screen, then setting their contents to various ASCII characters. This gives me a 6 color monochrome display, that can be updated reasonably quickly (80ms per frame).
The source code is available at: https://github.com/ading2210/doompdf
Note that this PDF can only run in Chromium-based browsers that use the PDFium engine.
[+] [-] ThomasRinsma|1 year ago|reply
Great work! We had the same idea at the same time, here's my version of PDF Doom:
Source: https://github.com/thomasRinsma/pdfdoom
Playable here: https://th0mas.nl/downloads/doom.pdf
Yours is neater in many ways though!
[+] [-] OnionBlender|1 year ago|reply
[+] [-] wingi|1 year ago|reply
[+] [-] daredevil49|1 year ago|reply
[+] [-] pavo-etc|1 year ago|reply
humanity has gone too far
[+] [-] miki123211|1 year ago|reply
1. Can be easily and freely shared by email / cloud drive, including assets, images and fonts.
2. Supports form filling and saving the form data in the file directly (as opposed to sending it somewhere over HTTP). Basically the electronic equivalent of a paper form that can be filled, send by email and stay filled.
3. Supports (cryptographic) signatures that are again part of the document, and can easily and securely be verified by end users. This is a very important use case in the EU, where electronic signatures are based on cryptography, not "I pinky swear I'm John Smith" DocuSign.
4. Has perfect print fidelity.
We keep complaining about PDF (and rightly so), but there's truly no other format to replace it. The W3c / Whatwg / whatever could probably come up with one based on web technologies, but they haven't yet.
There's Epub which solves a very narrow use case of PDF (electronic book distribution where perfect control over presentation is not required), but nothing that solves the "business" use cases.
[+] [-] quotemstr|1 year ago|reply
[+] [-] hardwaresofton|1 year ago|reply
[+] [-] luismedel|1 year ago|reply
Next step: embed Bellard's JSLinux (https://bellard.org/jslinux/) and have a fullblown OS with development environment, office suite and all inside a PDF.
[+] [-] khaledh|1 year ago|reply
[+] [-] takeda|1 year ago|reply
[+] [-] Narishma|1 year ago|reply
[+] [-] antics|1 year ago|reply
Sadly, I was not able to run Doom in a PDF, in Emacs. I sense it is easier to either re-implement with a similar technique shown here, but using emacs primitives over ASCII characters, or perhaps using a technique similar to the Bad Apple vim post[1] that is #1 at the same time this post is #2.
[1]: https://news.ycombinator.com/item?id=42674116
[+] [-] extraduder_ire|1 year ago|reply
Reminded me of how modern linux distros decide how to execute a file. When I learned about that years ago, I spent far too long getting .exe files to run in either wine or mono when run on my machine. Fun exercise, not worth it.
[+] [-] nomilk|1 year ago|reply
Press z several times to start
w, a, s, d to move, e to use, space to shoot. z is enter
[+] [-] anilakar|1 year ago|reply
[+] [-] joelvalleroy|1 year ago|reply
[+] [-] mdaniel|1 year ago|reply
[+] [-] em3rgent0rdr|1 year ago|reply
[+] [-] MarekKnapek|1 year ago|reply
[+] [-] peterburkimsher|1 year ago|reply
Can you get it as small as the DOOM1.WAD file? (4 MB)
[+] [-] Uptrenda|1 year ago|reply
But do you all think there are other use-cases for this technology? Like, could you distribute apps using PDFs on highly constrained devices (like iphone possibly, or maybe managed devices e.g. play station, xbox, kiosks?) Just throwing out ideas.
Are there other obvious uses for this?
I think when I was playing around with adobe reader I saw you could put movies in them, too. I believe that you're able to make customization's to the menu bar. It seems to be fairly flexible for what it is.
[+] [-] anthk|1 year ago|reply
Inb4 "this is the true hacker spirit", I know, yes, this is cool stuff and the true meaning of a hacker, but in the end I'd choose DJVU for a document format.
[+] [-] einpoklum|1 year ago|reply
[+] [-] maCDzP|1 year ago|reply
[+] [-] anthk|1 year ago|reply
[+] [-] vk6|1 year ago|reply
However, I chose the shareware version since the file size is a lot smaller and it's more recognizable to people.
[+] [-] peterburkimsher|1 year ago|reply
[+] [-] crtasm|1 year ago|reply
[+] [-] yoz|1 year ago|reply
[+] [-] SparrowRat|1 year ago|reply
[+] [-] RajT88|1 year ago|reply
[+] [-] PierCecco|1 year ago|reply
[+] [-] unknown|1 year ago|reply
[deleted]