Skip to content
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

IO system #5

Open
gusmanb opened this issue Sep 18, 2022 · 0 comments
Open

IO system #5

gusmanb opened this issue Sep 18, 2022 · 0 comments

Comments

@gusmanb
Copy link

gusmanb commented Sep 18, 2022

Hi.

I'm using the project to create an emulator and I found that the IO system does not work as a real Z80 so a lot of machines will not work as expected.

When an IO request is issued the Z80 places in the upper part of the address bus the contents of A or B (depending on which IO instruction is used) which is not happening in the Z80dotNet. A lot of machines use this upper byte to determine which function of the port has been requested and without it all these calls fail (for example, in the Spectrum the ULA listens to port 254 requests and uses the upper part of the address to determine which keyboard lines should be scanned).

I would propose to change the IO system to work like this:

  • Create a new sepparated interface for IO instead of reusing the IMemory interface as these will become very different.
  • The IO interface would expose the ports as a double index property, it will use "Port" and "UpperAddress" as their indexes.
  • It will also expose a function to retrieve the WAIT states of the IO request, as these can be controlled by external devices each port/address combination can have different WAIT states
  • It will not contain size, the implementation of the IO must answer to any request even if not used, any unused port should return the machine's default bus value (some machines use pull-ups, others pull-downs so better allow the implementation to choose the value to return).

It could be possible to just leave most of the code as-is and only change the IO instructions to send the address to the IMemory interface as an ushort combining the port number and the upper addres register in a single value, but this has the inconvenience that when you imlpement the interface you must split the port and the address manually to determine what to do which is a lot less efficient.

Cheers.

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

No branches or pull requests

1 participant