开发者

Which type of design pattern should be used to create an emulator?

I have programmed an emulator, but I have some doubts about how to organizate it properly, because, I see that it has some probl开发者_开发百科ems about classes connection (CPU <-> Machine Board). For example: I/O ports, interruptions, communication between two or more CPU, etc.

I need for the emulator to has the best performance and good understanding of the code.

PD: Sorry for my bad English.

EDITED:

Asking for multiple patterns.


You have two closely-related things going on here.

  1. The emulator is a collection of Command definitions. Each thing the emulator can do is a command. Some commands are nested sequences of commands.

  2. The emulator has a number of internal State definitions. Each thing the emulator does updates one or more state objects.


Build your software without regard to "patterns." The patterns will fall naturally out of your work if they are intended to be there. Building your software to fit preconceived notions of what patterns they will tend to make it bulkier and more resistant to change.

(If you haven't yet, download a unit testing framework for your language and use it to guide your development!)


First have a look at wiki. It seems to give some entry point to art of emulation. Second I would look how QEMU or DOSBox are structured. Also have a look at SourceForge. Simple query gives following software emulators:

  • PearPC - PowerPC Emulator
  • Atari 2600 emulator
  • Gens - Sega Genesis / Sega CD / Sega 32X emulator

In general there is no single pattern for such complicated task. You will definitely need State Machine pattern and you might use Command pattern for dispatching actions. But I really suggest that you will look on other peoples work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜