跳到主要内容

2 篇博文 含有标签「dos」

查看所有标签

WhereQ-DOSBox 的中断地图:模拟器里每一个 INT 都在干什么

· 阅读需 14 分钟
WhereQ-DOSBoxWhereQ-DOSBox

所有 DOS 程序唯一都认同的那一个接口​

有一件事是我没料到自己会在意,然后一旦在意就停不下来的。

1987 年的 DOS 游戏并不知道显卡是什么。它不知道鼠标存在,也不知道键盘有个缓冲区。它只认一件事:往栈里推一个数,执行 INT,机器就会回答。INT 10h,机器把一个字符画到屏幕上。INT 16h,机器交出一个按键。INT 33h,机器告诉你鼠标在哪、哪些按钮按着。

契约就这么多。1991 到 1994 年的每一个游戏都是照着它写的,而且它从来没有变过。

为了写这篇文章,我把 DOSBox 的中断层认真读了一遍。它是整个模拟器里建得最用心的部分之一——同时也是这个移植版被迫想得最多的部分之一,因为触摸屏不是鼠标,手机也不是 PC。

所以,地图在这里。

WhereQ-DOSBox interrupts: the map of every INT in the emulator

· 阅读需 14 分钟
WhereQ-DOSBoxWhereQ-DOSBox

The one interface every DOS program agrees on​

Here is something I did not expect to care about, and then could not stop caring about.

A DOS game from 1987 does not know what a graphics card is. It does not know that a mouse exists, or that a keyboard has a buffer. It knows exactly one thing: it can ask the machine a question by pushing a number onto the stack and executing INT. INT 10h and the machine will put a character on the screen. INT 16h and the machine will hand over a keystroke. INT 33h and the machine will tell it where the mouse is and which buttons are down.

That is the whole contract. Every game from 1991 to 1994 is written against it, and it never changed.

I have been reading DOSBox's interrupt layer properly for this article, and it turns out to be one of the most carefully built parts of the emulator — and one of the parts this port has had to think about hardest, because a touch screen is not a mouse and a phone is not a PC.

So here is the map.