历史与人物trixter.oldskool.org
8088 MPH:打破所有模拟器的演示程序
8088 MPH: We Break All Your Emulators
2015 — 2018,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
8088 MPH 是 2015 年发布在初代 IBM PC(8088)上的 demo,文章详细拆解它如何在 CGA/复合输出等严苛限制下做出看似不可能的效果,并因此让当时的模拟器难以准确运行。文中涉及大量底层技巧,包括精确周期计数、DRAM 刷新时序调整和“编译式精灵”渲染等。
为什么经久不衰:它把老 PC 的硬件限制、精确时序和 demoscene 编程技巧讲透,既是经典作品的技术复盘,也让今天的人看到在极限约束下做工程的乐趣。
HN 评论精选
编译式精灵把每个可见像素展开成无分支的写指令,以代码体积换速度,是老硬件上极端的渲染优化。
简要解释一下“编译式精灵”:通常精灵是二维像素数组,用 X/Y 循环加数学或分支混合到屏幕上,但这样读写很多,而且大量不可见像素的计算是白费。可以用可见/不可见 RLE 跳过透明像素,但仍是很复杂的循环且要读很多像素。于是许多疯狂的 democoder 写“精灵编译器”,读取精灵的二维颜色数组,输出精确的汇编指令,把每个可见像素作为无分支的线性指令序列逐个写入;精灵随后被汇编链接进程序,成为独立函数。我相信它们甚至能只用指令内编码的立即值来表示颜色,而不从单独内存地址读颜色。这样就不再是“读指令、读数据、写数据”,而变成“读指令、写数据”两条连续内存操作。
corysama查看英文原文
Quick explanation of compiled sprites: Most commonly a sprite is represented as a 2d array of pixels that you for X, for Y over and use math or branching to blend on to the screen. But, that's a lot of reading and writing, and a lot of the math ends up doing nothing because a lot of the pixels are intentionally invisible. So, you could do some sort of visible/invisible RLE to skip over the invisible pixels. That's better, but it's still a complicated loop and still a lot of reading pixels. So, many crazy democoders have decided to write "sprite compilers" that read the 2D color array of a sprite and spits out the assembly for the exact instructions needed to write each visible pixel one at a time as a linear instruction sequence with no branching. The sprites are then assembled and linked into the program code as individual functions. I believe they can even exclusively use immediate values encoded inside the instructions rather than reading the colors from a separate memory address. So, rather than read instruction, read data, write data; it becomes a read instruction, write data in two straight lines in memory.
效果依赖精确到周期的时序,甚至要调整 DRAM 刷新间隔来对齐 CRTC 访问。
我最喜欢的部分:这是一个靠周期计数的效果,因为根本没有时间监测水平回扫。为保证周期计数一致,他们做了几件事,包括把系统默认的 DRAM 刷新间隔从 18 改成 19,让 DRAM 刷新周期与 CRTC 访问对齐。
caf查看英文原文
My favourite part: It’s a cycle-counting effect, as there is simply no time to monitor for horizontal retrace. To ensure the cycle counting was consistent, several things were done including changing the system default DRAM refresh from it’s default interval of 18 to 19, to get the DRAM refresh periods to line up with CRTC accesses. (previous HN discussion: https://news.ycombinator.com/item?id=9338944)
demo 作者后来在做周期精确的 8088 模拟器,以能正确运行这个 demo 为目标。
我是这个 demo 的作者之一。过去几个月我一直在做一个周期精确的 8088 模拟器(最终要能正确运行 8088 MPH)。目前还没接音频或视频输出,但昨晚它第一次整夜运行自动生成的测试用例,没有发现与真实硬件的任何差异。
ajenner查看英文原文
I'm one of the creators of this demo. For the past several months I've been working on a cycle-exact 8088 emulator (that will eventually be able to run 8088 MPH properly). I don't have it hooked up to any audio or video output yet, but for the first time last night it ran automatically-generated testcases all night without finding any differences from the real hardware.
在真实老 IBM PC 上运行这个 demo 的体验,并提到复合输出和内存故障等实际限制。
几年前我看到它时,通过串口线把它传到我第一台电脑 IBM PC 上(我仍装着 Telix),从同样有串口的 Windows XP 台式机用 Hyperterminal 发送文件;为了把它弄到那台电脑上,我还得先放到 U 盘里。看它跑起来很酷。那台 PC 我从 1987 年用到 1993 年,期间大多已过时,但我尽量榨干它。当时没有什么东西在图形上接近这个 demo(不过那时 PC 喇叭上已经有很多很酷的音乐程序)。只是 demo 跑到一半我会遇到内存奇偶校验错误,因为内存扩展卡上有坏芯片,没有完整的 640K。它针对复合输出设计也有帮助,因为我没有 CGA 显示器了,但仍可以接到电视上。
drivers99查看英文原文
When I ran across this a couple years ago, I transferred this to the IBM PC (which was my first computer) over a serial cable (I still have Telix installed) from a Windows XP desktop since it also had a serial port, and use Hyperterminal to transmit the file. And in order to get it to that computer I had to put it on a USB drive. It was pretty cool seeing it run. That PC was what I used from 1987-1993 and it was mostly obsolete during that time but I tried to get everything I could out of it. There was nothing that approached what this demo was able to do graphically. (There were a lot of cool music programs even for the PC speaker back then though.) Although, I get a memory parity error partway through the demo because I don't have the full 640k due to some bad memory chips on the memory expansion card. It helps that they designed it for composite output, since I no longer have a CGA monitor, but you can still hook it up to TVs.
历次讨论
同类还值得读
开发者无薪坚持完成 Mac 图形计算器:一个秘密项目的故事
Dev stays without pay to finish Mac Graphing Calculator as skunkworks project
苹果 Mac 图形计算器(Graphing Calculator)开发者的亲述:在项目被砍后,几位工程师在没有报酬、没有正式授权的情况下,以“地下项目”方式偷偷留在公司把软件做完…
历史与人物上首页 6 次 · 2009–2022pacifict.com理查德·费曼与 Connection Machine
Richard Feynman and the Connection Machine
长文回忆费曼晚年参与 Connection Machine 并行计算机项目的经历:他分析路由器、用自创的并行 Basic 编写 QCD 程序,也涉足细胞自动机等主题。
历史与人物上首页 5 次 · 2010–2021longnow.org编辑精选负 2000 行代码
-2000 Lines of Code
folklore.org 上 Andy Hertzfeld 记录的一则苹果 Macintosh 开发轶事:Bill Atkinson 被问到写了多少行代码时,回答“-2000 行…
历史与人物上首页 4 次 · 2014–2022folklore.org编辑精选Dennis Ritchie 的第一版 C 编译器(约 1972 年)
Dennis Ritchie’s first C compiler (c. 1972)
这个 GitHub 仓库保存了 Dennis Ritchie 约 1972 年编写的最早 C 编译器源码,是 C 语言和 Unix 早期历史的一手材料。
历史与人物上首页 4 次 · 2013–2025github.com一位破解赛马密码的赌徒
A Gambler Who Cracked the Horse-Racing Code (2018)
彭博社 2018 年的长篇特写,讲述数学家 Bill Benter 如何用统计模型和算法在赛马博彩中持续盈利、累计赢得近十亿美元的故事。
历史与人物上首页 4 次 · 2018–2024bloomberg.com