模拟器是如何工作的?当我看到NES/SNES或C64模拟器时,我很震惊。
您是否必须通过解释特定的组装指令来模拟这些机器的处理器?还有什么?它们通常是如何设计的?
你能给那些对编写模拟器(特别是游戏系统)感兴趣的人一些建议吗?
模拟器是如何工作的?当我看到NES/SNES或C64模拟器时,我很震惊。
您是否必须通过解释特定的组装指令来模拟这些机器的处理器?还有什么?它们通常是如何设计的?
你能给那些对编写模拟器(特别是游戏系统)感兴趣的人一些建议吗?
当前回答
关于模拟真实系统或你自己的东西的建议? 我可以说模拟器通过模拟整个硬件来工作。也许不是电路(像HW那样四处移动比特)。移动字节是最终结果,所以复制字节是好的)。模拟器是很难创建的,因为有很多黑客(如在不寻常的效果),时间问题,等等,你需要模拟。如果一个(输入)部分是错误的,那么整个系统就会崩溃,或者最多出现一个bug/小故障。
其他回答
还可以查看Darek Mihocka的Emulators.com,获得关于jit指令级优化的建议,以及许多关于构建高效模拟器的其他好东西。
在创建了我自己的80年代BBC微型计算机模拟器(类型VBeeb到谷歌)后,有许多事情要知道。
You're not emulating the real thing as such, that would be a replica. Instead, you're emulating State. A good example is a calculator, the real thing has buttons, screen, case etc. But to emulate a calculator you only need to emulate whether buttons are up or down, which segments of LCD are on, etc. Basically, a set of numbers representing all the possible combinations of things that can change in a calculator. You only need the interface of the emulator to appear and behave like the real thing. The more convincing this is the closer the emulation is. What goes on behind the scenes can be anything you like. But, for ease of writing an emulator, there is a mental mapping that happens between the real system, i.e. chips, displays, keyboards, circuit boards, and the abstract computer code. To emulate a computer system, it's easiest to break it up into smaller chunks and emulate those chunks individually. Then string the whole lot together for the finished product. Much like a set of black boxes with inputs and outputs, which lends itself beautifully to object oriented programming. You can further subdivide these chunks to make life easier.
Practically speaking, you're generally looking to write for speed and fidelity of emulation. This is because software on the target system will (may) run more slowly than the original hardware on the source system. That may constrain the choice of programming language, compilers, target system etc. Further to that you have to circumscribe what you're prepared to emulate, for example its not necessary to emulate the voltage state of transistors in a microprocessor, but its probably necessary to emulate the state of the register set of the microprocessor. Generally speaking the smaller the level of detail of emulation, the more fidelity you'll get to the original system. Finally, information for older systems may be incomplete or non-existent. So getting hold of original equipment is essential, or at least prising apart another good emulator that someone else has written!
模拟器很难创建,因为有很多黑客(在不寻常的 效果),时间问题,等等,你需要模拟。
有关示例,请参见http://queue.acm.org/detail.cfm?id=1755886。
这也会告诉你为什么你需要一个多ghz的CPU来模拟一个1MHz的CPU。
当你开发一个模拟器时,你是在解释系统正在运行的处理器组件(Z80、8080、PS CPU等)。
您还需要模拟系统拥有的所有外设(视频输出、控制器)。
你应该开始为简单的系统编写模拟器,比如旧的Game Boy(使用Z80处理器,我是不是没有弄错)或C64。
值得一看的是Imran Nazar尝试用JavaScript编写Gameboy模拟器。