Giter Club home page Giter Club logo

Comments (1)

redcode avatar redcode commented on May 21, 2024

WAIT is not explicity set by using any function. Instead, you should directly add to Z80::cycles the desired wait T-states. Do it within the callback corresponding to the M-cycle in which the WAIT signal is generated.

As for BUSREQ, there is a limitation, although I have not yet explained it adequately in the documentation: A real Z80 CPU responds to the BUSREQ signal at the end of each M-cycle. That means that as long as the signal lasts, the M-cycle is frozen and the CPU does not go to the next one until the signal ends. If the signal is short, this can be emulated in the same way as WAIT, that is, by adding to Z80::cycles the duration of the signal. However, if the signal is very long, for example in the case of a DMA operation that moves a large amount of memory or similar, then we have the problem that, even if we add the T-states:

  1. if that amount makes the global T-state counter of your machine object exceed the total T-states of 1 emulated machine frame,
  2. and the signal does not occur in the last M-cycle of the instruction,
  3. and there are still others in which memory will be accessed,

problems may arise (depending on what is being emulated and whether a precise control of the T-state within the frame in which a memory access is performed is required, of course).

I think the best solution is to handle BUSREQ in your side between your calls to z80_run or z80_execute, and assume that the signal always starts during the last M-cycle of an instruction.

The alternative would be to save the state of the Z80 object and use setjmp() or similar in the callback where the signal occurs to avoid finishing executing the instruction. But I don't think it would be worth it, it would be quite complex to do.

from z80.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.