《毁灭战士》已被移植到耳机上。
Doom has been ported to an earbud

原始链接: https://doombuds.com

该项目成功地将DOOM移植到无线耳机上运行,并通过Web服务器将游戏画面流式传输到浏览器。核心挑战在于耳机的硬件限制:数据传输依赖于2.4Mbps的UART连接,而非较慢的蓝牙,且RAM仅有约992KB。 为了克服带宽限制,游戏将视频流作为MJPEG流(顺序显示的JPEG图像)传输,而不是使用复杂的编解码器。尽管将耳机的CPU超频至300MHz,编码限制了帧率为每秒约18帧。 RAM限制通过对DOOM引擎的大量优化来解决——预生成查找表、利用闪存存储常量以及禁用缓存,从而将游戏内存占用从4MB减少到足以适应可用空间。最后,一个经过特别裁剪的DOOM 1资源文件(“Squashware”)使游戏能够适应耳机的4MB闪存。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 工作 | 提交 登录 Doom 已被移植到耳塞 (doombuds.com) 14 分,由 arin-s 2 小时前发布 | 隐藏 | 过去 | 收藏 | 3 条评论 branon 10 分钟前 | 下一个 [–] 有人用过 PineBuds Pro 吗?Pine64 IRC 网络没有 PineBuds 讨论频道,所以我没有机会轻易提问。回复 arin-s 2 小时前 | 上一个 | 下一个 [–] 你好,我将 DOOM 移植到 Pinebuds Pro 耳塞上。 可以通过互联网访问,你可以加入队列,从你的电脑上玩 DOOM! 更多信息以及 github 仓库的链接可以在网站上找到。回复 jurakis 2 小时前 | 上一个 [–] 太棒了!Doom 运行过的设备数量一天天减少。回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

Let's switch to a more readable font first.

I'll put out an article / video diving deeper into this later, but here are a few bits of info:
This project is made up of four parts:

  1. The DOOM port that runs on the earbuds
  2. The 'serial server' that acts as a bridge between the earbuds and the web server and also transcodes the MJPEG stream to twitch
  3. The web server that serves assets, manages the queue, forwards keypresses and displays the MJPEG stream
  4. The static webpage that tells your browser what to display on the screen and how to communicate with the web server

The firmware pushes up against a few hardware limitations:

  1. Serial Connection

    Earbuds don't have displays, so the only way to transfer data to/from them is either via bluetooth, or the UART contact pads.
    Bluetooth is pretty slow, you'd be lucky to get a consistent 1mbps connection, UART is easily the better option.
    DOOM's framebuffer is (width * height) bytes, 320 * 200 = 96kB. (doom's internal framebuffer is 8-bit not 24-bit)
    The UART connection provides us with 2.4mbps of usable bandwidth. 2,400,000 / 8 / 96,000 gives us... 3 frames per second.
    Clearly we need to compress the video stream. Modern video codecs like h264 consume way too much CPU and RAM.
    The only feasible approach is sending the video as an MJPEG stream. MJPEG is a stream of JPEG images shown one after the other.
    I found an excellent JPEG encoder for embedded devices here, thanks Larry!
    A conservative estimate for the average HIGH quality JPEG frame is around 13.5KB, but most scenes (without enemies) are around 11kb.
    Theoretical maximum FPS:
    - Optimistic: `2,400,000 / (11,000 * 8)` = 27.3 FPS
    - Conservative: `2,400,000 / (13,500 * 8)` = 22.2 FPS

  2. CPU

    The stock open source firmware has the CPU set to 100mhz, so I cranked that up to 300mhz and disabled low power mode.
    The Cortex-M4F running at 300mhz is actually more than enough for DOOM, however it struggles with JPEG encoding.
    This is why it maxes out at ~18fps, I don't think there's much else I can do to speed it up.

  3. RAM

    By default, we only have access to 768KB of RAM, after disabling the co-processor it gets bumped up to the advertised 992KB.
    DOOM requires 4MB of RAM, though there are plenty of optimisations that can reduce this amount.
    Pre-generating lookup tables, making variables const, reading const variables from flash, disabling DOOM's caching system, removing unneeded variables. It all adds up!

  4. FLASH

    The shareware DOOM 1 wad (assets file) is 4.2MB and the earbuds can only store 4MB of data.
    Thankfully, fragglet, a well-known doom modder, has already solved this issue for me.
    Squashware is his trimmed-down DOOM 1 wad that is only 1.7MB in size.
    With this wad file, everything comfortably fits in flash.

联系我们 contact @ memedata.com