HNHacker News
TopNewBestAskShowJobs

phoboslab

5,828 karma · joined February 16, 2010

X: https://x.com/phoboslab

Blog: https://phoboslab.org/

submissionscomments
phoboslab··on Q1K3 - An homage to Quake in 13kb of JavaScript
I used TrenchBroom[1] to build the levels. It was initially created to build Quake maps but now supports many derivative games like Half-Life, too. I can't speak highly enough of it; it's really really good!

[1] https://trenchbroom.github.io/

phoboslab··on 14kb WASM game written in D
For what it's worth, the original 13kb JS only version[1] does not have these problems.

I was confused for a second why this game made its way to HN again (there's a making of for the game itself from 2018[2]). This seems to be a port of the game to D[3] as a demo for a WASM runtime, Spasm, which is also written in D[4].

[1] https://phoboslab.org/underrun/

[2] https://news.ycombinator.com/item?id=18031024

[3] https://github.com/skoppe/spasm/tree/master/examples/underru...

[4] https://github.com/skoppe/spasm

phoboslab··on Q1K3 - An homage to Quake in 13kb of JavaScript
`l` is the binary data for the levels, `m` is for the models. These are loaded in the map.js[1] and models.js[2].

JS13k, the contest this game was made for, has the 13kb size limit for a ZIP containing all necessary files. The build process[3] produces a q1k3.zip[4] that sits at 13309 bytes.

Granted, the JS and assets without ZIP compression are a bit bigger, but when sent out over http with fast gzip compression there's still only around 15kb going through the wire.

[1] https://github.com/phoboslab/q1k3/blob/master/source/map.js

[2] https://github.com/phoboslab/q1k3/blob/master/source/model.j...

[3] https://github.com/phoboslab/q1k3/blob/master/build.sh

[4] https://phoboslab.org/q1k3/q1k3.zip

phoboslab··on Q1K3 - An homage to Quake in 13kb of JavaScript
The levels are stored as 6 bytes per "brush" (i.e. block): 1 byte per each x, y, z coordinates and width, depth and length[1]. The y (vertical) resolution of these values is a bit higher than the x/z resolution to allow for stairs while allowing for bigger levels on the horizontal plane. So the level files are not directly stored as a grid, but as a collection of axis aligned blocks.

The collision detection however builds a grid out of these, so the game can quickly look up any position within the game world[2].

[1] https://github.com/phoboslab/q1k3/blob/master/pack_map.c#L78... [2] https://github.com/phoboslab/q1k3/blob/master/source/map.js#...

phoboslab··on Q1K3 - An homage to Quake in 13kb of JavaScript
Upon popular demand, there's now a checkbox to have the vertical mouse axis move the wrong way :)

Play: https://phoboslab.org/q1k3/

Code: https://github.com/phoboslab/q1k3/commit/a522cb597d805ef7e9d... - curiously this only increased the final ZIP size by one byte. 13309 bytes in total now. ZIP compression (and by extension: Roadroller compression) can be very non-intuitive.

phoboslab··on Q1K3 - An homage to Quake in 13kb of JavaScript
Roadroller was the reason I was able to find the second level in. Thank you so much! :)
phoboslab··on What it was like developing for NES back in 1990
Very cool! Sounds a lot like all the tricks you had to employ for the Atari 2600. If someone is interested in this, I can highly recommend the book "Racing The Beam". It's hard to imagine these days how complicated even the simplest things were back then.

15 years back I did some hobbyist programming for the GameBoy. Drawing a status bar there was comparatively easy. The hardware allowed you to set some registers to define a "window region", overlaying the main background map.

phoboslab··on A simple C implementation to stream H.264 to browser using WebRTC
MPEG1 over WebSockets: https://jsmpeg.com/
phoboslab··on Show HN: WebAssembly and ffmpeg = Quick clip, overlay, resize and GIF-ize videos
Very cool! I see that SharedArrayBuffers are enabled again, after they were disable due to spectre!?

I have previously tinkered with ffmpeg in the browser and implemented a workaround[1] for the (then) missing pthread support. It turned out quite clunky, but worked.

[1] https://phoboslab.org/files/ffmpeg-mt-fixed/

phoboslab··on Tesla buys $1.5B in Bitcoin, may accept it as payment in the future
SEPA payments with my bank here in Germany typically take 3 business days, not 10 seconds. Reading about it, it seems that my bank doesn't support SEPA Instant Credit Transfer!? I'm not sure if any bank here in Germany does (never looked, though).

No one here can pay for their pizza delivery through SEPA. Intermediaries like PayPal are still needed. I'm baffled that banks can't get their shit together to offer an instant payment solution that works over the internet (ie. no card reader) for small purchases.

What's the problem?

phoboslab··on I launched a paid community in one month
About 20 years ago I was coming across a website called something like filthyrichguy.com (I can't remember the exact name). This site described how rich the guy owning this site was and how you could become rich too. How? By just buying his book, of course. I was mesmerized by this site and it's audacious design for a solid hour or two. I searched around the web for more information and ended up in this circle jerk of sites promoting each other. None with any substance.

This feels similar. The blog post and the site is beautifully designed (really!) but I have a hard time figuring out what I'm buying. Is it access to a chat where everyone tries to sell you their "startups"?

I guess it's not for me, but congratz to your success!

phoboslab··on Piipcam – 1080P IP Camera on a Raspberry Pi Zero W
It's not that "well-packaged" but last time I tried it, JSMpeg worked nicely when streaming from an RPi3. It has very low latency (~70ms), reasonable quality/bitrate (MPEG1, rather than MJPEG) and is viewable in any browser.

https://github.com/phoboslab/jsmpeg#example-setup-for-stream...

phoboslab··on Top games from the JS13K 2020 competition
Island Not Found deserves a mention: http://js13kgames.com/entries/island-not-found

Gameplay falls a bit short, but in my opinion it's the technically most impressive entry this year.

phoboslab··on Raspberry Pi – UASP, Trim, and Boot Performance via USB
Not related to USB, but flash storage quality in general varies a lot.

We have a few hundred Raspberry Pi in operation at customer sites, running 24/7. Back when we started our business we used generic Micro SD (can't remember the brand). They would fail after 2-6 months. This was a big hassle. We have customers all over Germany and would need to ship them a complete RPI as a replacement, as the customers are usually not tech-savvy enough to just replace the SD.

We now use SanDisk's "Industrial" Micro SD and haven't had this problem since.

Also, reducing writes to the SD is certainly a good idea. Ideally - if you can - mount the system as read only.

phoboslab··on Why are currently no ads on Techdirt? apparently Google thinks we're dangerous
I'm curious, what are the "plenty of alternatives" exactly?

We have tried a lot of different advertising networks and sadly we have found none that's even in the same ballpark as AdSense (revenue wise). Advertising on the web is a shit show.

phoboslab··on Windows98 Running in the Browser
Quite the hack: https://i.imgur.com/rG0p0b2.gif
phoboslab··on 3K, 60fps, 130ms: achieving it with Rust
Interframes are not a problem, as long as they only reference previous frames, not future ones.

I was able to get latency down to 50ms, streaming to a browser using MPEG1[1]. The latency is mostly the result of 1 frame (16ms) delay for a screen capture on the sender + 2-3 frames of latency to get through the OS stack to the screen at the receiving end. En- and decoding was about ~5ms. Plus of course the network latency, but I only tested this on a local wifi, so it didn't add much.

[1] https://phoboslab.org/log/2015/07/play-gta-v-in-your-browser...

phoboslab··on How to Write a Video Player in Less Than 1000 Lines (2015)
Shameless plug: here's an MPEG1 player in 400 lines and the decoder in 4000: https://github.com/phoboslab/pl_mpeg
phoboslab··on PostgreSQL is the worlds’ best database
I'm curious to hear why and how Maria failed you.

For a reddit-like social site, we have a Maria database with around 3 billion rows in total, with the largest table (votes) spanning about 1,5 billion rows.

We can select data within ~3ms for about 20k-40k concurrent visitors on the site. Our setup is a simple Master-Slave config, with the slave only as backup (not used for selects in production). Our 2 DB servers have 128gb of RAM and cost around 200 EUR/month each - so, nothing special.

Of course you have to design your schema with great care to get to this point, but I imagine PG to be as lost as any other database if a crucial index is missing.

phoboslab··on Achieving full-motion video on the Nintendo 64 (2000) [pdf]
Thanks for the write-up! This is really interesting.

I wouldn't have thought it's possible to get H264 running at reasonable speeds on the N64. Congratz for pulling it off!

phoboslab··on Achieving full-motion video on the Nintendo 64 (2000) [pdf]
Lately there has also been an effort by a hobbyist to use an MPEG1 decoder (PL_MPEG)[1] on the N64[2].

Disclaimer: I wrote PL_MPEG, but not the N64 port.

[1] https://github.com/phoboslab/pl_mpeg

[2] https://www.reddit.com/r/n64/comments/dr15py/i_just_started_...

phoboslab··on Million WebSockets and Go (2017)
It's surprising to me that you apparently have to fight for memory usage for these cases when using Go.

A while ago I ran a (quite naively written) nodejs application that maxed out at ~700k WebSocket connections per server - using only 4GB of RAM. Here CPU became the bottleneck.

phoboslab··on Deep learning has a size problem
> I doubt anyone is going to want to run a 33GB model on their phone.

Why not? Many modern phones have upwards of 512GB of storage. 33 GB for a useful model seems entirely reasonable to me.

phoboslab··on MPEG1 Single file C library
Thanks for the explanation! It hadn't occurred to me that an encoder would spit out packets for part of a frame, while it's still encoding. For what it's worth, ffmpeg's public API - at least the one I used in a previous project[1] - only produces full frames.

The MPEG-2 state object you linked to looks a lot like the private data of my decoder already[2]. I wonder if there's any restriction on when a packet may be concluded. I.e. do MPEG-PS packets have to contain full slices, or can they be cut off in the middle of slice?

The "hairy" part with my current design would be to reproduce the call stack. Again, if the decoder would live in its own thread, it would be a no-brainer.

> and it's been done successfully by every major decoder implementation afaik

As far as I can tell, ffmpeg's decoder does not allow for this. It always searches for the next picture's START_CODE before starting to decode the frame. Similarly, the libmpeg2 source you linked to doesn't seem to provide any functionality to resume decoding from anywhere in the stream either!? The NEEDBITS and DUMPBITS macros just assume there's always more data.

[1] https://github.com/phoboslab/jsmpeg-vnc/blob/master/source/e...

[2] https://github.com/phoboslab/pl_mpeg/blob/master/pl_mpeg.h#L...

phoboslab··on Show HN: IPFS-Deploy – Zero-Config CLI to Deploy Static Websites to IPFS
So what stops me from abusing Cloudflare's gateway as a free CDN for petabytes of traffic? There has to be a catch?

Edit: found it. https://www.reddit.com/r/ipfs/comments/al8emd/cloudflare_ban...

phoboslab··on Super Mario Bros. has been released for the Commodore 64
IIRC the NES PPU only supports one background layer. You can just change the scroll position mid-frame to give it the illusion of multiple background layers.

See here for some clever examples of this technique. Everything that's overlapping is done with sprites:

https://youtu.be/ZGyFQ9aRp_U?t=579

phoboslab··on Pig brains partially revived four hours after death
The 2015 game SOMA[1] paints a far darker picture of precisely this topic: a brain donated to research. It really explores this in depth. If you're remotely interested in games I can only recommend it.

[1] https://www.somagame.com/

phoboslab··on Ask HN: Is it practical to create a software-controlled model rocket?
BPS.space is attempting it.

Test Launch: https://www.youtube.com/watch?v=QQt-9SSJ51c

Test Landing: https://www.youtube.com/watch?v=lXy-x6lkQvQ

phoboslab··on Reflecting on My Failure to Build a Billion-Dollar Company
Ha, didn't expect to find my own comment there.

I also mentioned selling jQuery plugins (remember jQuery?) and advertising my own game engine (now free) in the thread. Feels like such a long time ago.

Gratz for pulling it off, Sahil!

phoboslab··on Ambient Cruelty
Wider columns are harder to read. That's why newspapers and magazines typically divide a page into slimmer columns.

https://baymard.com/blog/line-length-readability

← PreviousPage 3 of 13Next →