2

我想在 CP/M 2.X (Z80) 上编写一个游戏循环,并且需要等待一段时间,例如一秒钟。我看过 BDOS 但没有找到函数,循环取决于处理器(仿真速度),不存在垂直空白等中断。

关于如何编写游戏循环的任何想法?

[编辑]

z88dk CP/M 库说

不是(当然)没有实时功能的 CPM 1.x 和 2.x;,也不是 QX/M,它的时钟不是基于 BCD 的。

有像 LADDER 这样的动作游戏,所以应该有一种游戏循环的方式。

[编辑2]

我可以让用户用两次按键检查 5 秒并测量一次速度(双循环)来配置游戏 - 但仅作为最后的手段。

4

1 回答 1

6

There's no portable way of waiting for a certain amount of time under CP/M 2.2. CP/M doesn't require or use a real time clock or any kind of timer, and so you can't even assume one is present in the system, let alone that it uses any kind of common interface.

Turbo Pascal's Delay function worked by assuming a certain CPU frequency, one that was configured when Turbo Pascal was installed. The CP/M game Ladder was written in Turbo Pascal and used its Delay function, so it also assumed a certain CPU frequency. If you played on a faster or slower CPU the game would play faster or slower than intended.

The simplest solution would be to implement your own delay function that assumed a certain CPU frequency. I believe 4 MHz was the most common Z80 speed for CP/M. You can make this a configurable option so users can change the assumed CPU speed. You're probably also going to want to give users the option of changing the terminal type, just like Ladder did, as there are many possible terminals that can be used with CP/M.

于 2021-01-18T20:05:48.393 回答