Skip to content

Modularising the emulator #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Conversation

algodesigner
Copy link
Contributor

These are a few steps towards modularising the emulator and decoupling the key components, namely: z80, bdos, bios, vm (virtual machine) and subsequently peripherals, terminal emulators, generalised hooks, etc. I made them backward-compatible.

I have encapsulated most of the states into the respective classes. vm will be shortly separated from main.c. The naming convention is mostly preserved, the class method prefixes along with constructors and destructors have been added.

It is worth spending some time on the initial set of unit tests when the model stabilises.

The CPU fails ZEXALL. There are more compliant implementations out there. It appears to be easier to replace it than incrementally fixing it. I could write a new one, but that might take a little bit longer.

It has the remaining dependencies on vm class:

vm_read_mem
vm_write_mem
vm_haltcpu
vm_input
vm_output
vm_undefinstr

We can have a single pure virtual class (well, a table of of function pointers for those hooks) or hide them and provide binding methods, e.g. z80_set_memory_man, z80_set_io, z80_set_inst_brk.

Functionally, bdos needs some work and tidying up, but most of the hard work has been done. (The proposed change set contains an intermittent fix of BDOS 33 resulting in an endless loop in GEN80 with the files sizes == 128 bytes)

I fully understand that these changes might come across as too radical and deviate from your vision on how the emulator should evolve, but if you are interested, please let me know.

@algodesigner
Copy link
Contributor Author

I have decoupled z80 and added the binding methods for:

  • Instruction-related breakouts (halt CPU & invalid instruction)
  • Port I/O
  • Memory Interface
proc_halt_cpu
proc_undefinstr

io_input
io_output

mem_read
mem_write

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants