org.razvan.jzx
Class Z80

java.lang.Object
  extended by org.razvan.jzx.BaseComponent
      extended by org.razvan.jzx.Z80

public class Z80
extends BaseComponent

The Z80 CPU component of the Spectrum emulator.

Author:
Razvan Surdulescu (c) 2001 - 2006
You may use and distribute this software for free provided you include this copyright notice. You may not sell this software, use my name for publicity reasons or modify the code without permission from me.
See Also:
BaseSpectrum

Field Summary
protected  boolean m_pause
          Indicates that the emulate() method should pause.
protected  boolean m_stop
          Indicates that the emulate() method should end.
 
Fields inherited from class org.razvan.jzx.BaseComponent
m_logger, m_spectrum
 
Constructor Summary
Z80()
           
 
Method Summary
 void addTStates(int val)
          Add a number to the current value of T-States.
 void decodeXX(int op8)
          Decode the index register operations.
 void emulate()
          Decode one instruction: call mone8() to retrieve the opcode, decode it and execute it.
 int getTStates()
          Trivial accessor for the T-States value.
 void init(BaseSpectrum spectrum, ILogger logger)
          Cache references to the memory and I/O objects.
 void interrupt()
          Interrupt the CPU.
 void load(BaseLoader loader)
          Load the CPU contents from the loader object.
 void nmi()
          Generates a non-maskable interrupt (NMI.)
 void pause()
          Pause the emulation (asynchronous).
 void reset()
          Set the PC, I, R, IM and IFF* registers to 0.
 void setTStates(int tstates)
          Trivial mutator for the T-States value.
 void stop()
          Stop the emulation (asynchronous.)
 void terminate()
          Does nothing.
 java.lang.String toString()
          Return a string representation of the CPU state, which is useful for debugging purposes.
 void unpause()
          Unpause the emulation (asynchronous).
 
Methods inherited from class org.razvan.jzx.BaseComponent
getSpectrum
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_stop

protected volatile boolean m_stop
Indicates that the emulate() method should end.


m_pause

protected volatile boolean m_pause
Indicates that the emulate() method should pause.

Constructor Detail

Z80

public Z80()
Method Detail

init

public void init(BaseSpectrum spectrum,
                 ILogger logger)
Cache references to the memory and I/O objects.

Overrides:
init in class BaseComponent

reset

public void reset()
Set the PC, I, R, IM and IFF* registers to 0.

Specified by:
reset in class BaseComponent

terminate

public void terminate()
Does nothing.

Overrides:
terminate in class BaseComponent

interrupt

public void interrupt()
Interrupt the CPU.

If IFF1a is not zero, set both IFF flags to 0 and push the value of PC on the stack. If the IM is 2, jump to the address (I, 0xFF), otherwise jump to 0x38.


nmi

public void nmi()
Generates a non-maskable interrupt (NMI.)

Set IFF1b = IFF1a, and set IFF1a to 0 (disable regular interrupts.) Push the PC on the stack, then jump to address 0x66.


getTStates

public int getTStates()
Trivial accessor for the T-States value.


setTStates

public void setTStates(int tstates)
Trivial mutator for the T-States value.


addTStates

public void addTStates(int val)
Add a number to the current value of T-States.


stop

public void stop()
Stop the emulation (asynchronous.)


pause

public void pause()
Pause the emulation (asynchronous).


unpause

public void unpause()
Unpause the emulation (asynchronous).


emulate

public void emulate()
Decode one instruction: call mone8() to retrieve the opcode, decode it and execute it.


decodeXX

public void decodeXX(int op8)
Decode the index register operations.

This method only operates on the m_xx16 variable, following that the caller of this method will assign m_xx16 to the appropriate index register (m_ix16 or m_iy16).


toString

public java.lang.String toString()
Return a string representation of the CPU state, which is useful for debugging purposes.

Overrides:
toString in class java.lang.Object

load

public void load(BaseLoader loader)
Load the CPU contents from the loader object.

Specified by:
load in class BaseComponent