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.
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.
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:
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.