Better HN
topnewbestaskshowjobs
Log inSign up

phoboslab

5,828 karma · joined Feb 16, 2010 (16y ago) · 420 submissions

X: https://x.com/phoboslab

Blog: https://phoboslab.org/

Submissions

comment 5y ago · link · parent

The linked vsync-tester[1] is very cool. But it's sad to see that (at least on my system) nothing has changed since 2012[2] - Firefox still misses frames; Chrome consistently lags an extra frame.

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

[2] https://phoboslab.org/log/2012/06/measuring-input-lag-in-bro...

comment 5y ago · link · parent

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/

comment 5y ago · link · parent

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

comment 5y ago · link · parent

`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

comment 5y ago · link · parent

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#...

comment 5y ago · link · parent

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.

comment 5y ago · link · parent

Roadroller was the reason I was able to find the second level in. Thank you so much! :)

comment 5y ago · link · parent

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.

69.

Appfleet Joins Cloudflare(appfleet.com ↗)

3 points · by phoboslab · 5y ago · discuss

70.

Freespin – demo running on c64 floppy drive(youtube.com ↗)

6 points · by phoboslab · 5y ago · 1 comment

comment 5y ago · link · parent

MPEG1 over WebSockets: https://jsmpeg.com/

comment 5y ago · link · parent

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/

comment 5y ago · link · parent

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?

comment 6y ago · link · parent

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!

comment 6y ago · link · parent

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...

comment 6y ago · link · parent

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.

comment 6y ago · link · parent

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.

comment 6y ago · link · parent

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.

comment 6y ago · link · parent

Quite the hack: https://i.imgur.com/rG0p0b2.gif

comment 6y ago · link · parent

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...

comment 6y ago · link · parent

Shameless plug: here's an MPEG1 player in 400 lines and the decoder in 4000: https://github.com/phoboslab/pl_mpeg

comment 6y ago · link · parent

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.

comment 6y ago · link · parent

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!

comment 6y ago · link · parent

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_...

85.

Deep Thoughts Engineering Speaker Series: John Carmack(youtube.com ↗)

1 points · by phoboslab · 6y ago · discuss

comment 6y ago · link · parent

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.

comment 7y ago · link · parent

> 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.

comment 7y ago · link · parent

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...

89.

MPEG1 Single file C library(phoboslab.org ↗)

96 points · by phoboslab · 7y ago · 25 comments

90.

The world's worst video card? [video](youtube.com ↗)

3 points · by phoboslab · 7y ago · discuss

12345
14