Z80 CPU emulation engine v0.0.1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  I'M NOT NATIVE ENGLISH-SPEAKING CREATURE, SO MY ENGLISH IS AWFUL, I KNOW IT.
IF YOU CAN CORRECT THIS DOCUMENT, PLEASE DO IT & SEND ME THE NEW VERSION. I'LL
INCLUDE IT IN THE NEXT DISTRIBUTION (WITH CREDITS, OF COURSE %-).


-1. thanx
~~~~~~~~~
  to Chris Cowley <ccowley@grok.co.uk> for vbSpec, from which DelphiSpec was
derived.
  to Jari Korhonen <jarit.korhonen@luukku.com> for DelphiSpec from which this
engine was derived.
  to Philip Kendall <pak21-fuse@srcf.ucam.org> for FUSE
<http://fuse-emulator.sourceforge.net/> from which I took the test
package & some aspects of Z80 behavior.
  to SMT for UnrealSpeccy from which I took some code too %-)
  to Christian Hackbart for Yase2 from which I took nothing %-)


0. what is it?
~~~~~~~~~~~~~~
  this is Z80 CPU emulation engine %-) for all Delphi-addicted creatures. I think
that this is the most correct Z80 engine written in Delphi (ha! %-).


1. little dox %-)
~~~~~~~~~~~~~~~~~
  real R register is:
    (regR and $80) or (regRTemp and $7F)

  halted flag:
    this is set when Z80 HALT's. engine will not execute enything until this
    flag is set. when HALT instruction executed, regPC is points to the
    next instruction, so you can just set this flag to FALSE & continue
    executing.

  tStates: Integer;
    tick counter.

  orgPC: Word;
    address of the 1st byte of the current (executing) instruction.

  userData:
    you can use this filed to hold anything you want. the engine itself never
    changes this field.

  breaked:
    set 'breaked' to TRUE in PeekBExecProc to break Execute(). registers R, PC &
    tStates value will not be changed by Execute() in this case.
    setting 'breaked' to TRUE somewhere inside the prefixed op PeekBExecProc or
    inside the PeekBProc/PokeBProc will cause break after executing of the
    current op finishes.

  inPrefix: Boolean;
    TRUE: PeekBExecProc() is reading prefixed instruction bytes
          (not the prefix itself!). useful for debuggers (all "prefixed"
          opcodes are reading with PeekBExecProc(), which can cause
          strange and funny breakpoints %-). so check out this flag and
          do not process debugger actions when it is set.

  nextOpFetched:
    TRUE: opcode already fetched into 'nextOp', t-states incremented properly.
  nextOp:
    fetched opcode (if nextOpFetched is TRUE)
  this two fields introduced for I? prefix sequence interpreting.
    'nextOpFetched' MUST be reset in the interrupt processing code.

  PeekBProc:
    peek data byte, do contention
  PeekBExecProc: function (z80cpu: PZ80CPU; addr: Word): Byte;
    peek opcode byte, do contention.
    this thing is separated from PeekB to allow TR-DOS ROM stamping, for
    example.
  PeekBInternalProc: function (z80cpu: PZ80CPU; addr: Word): Byte;
    peek data byte w/o changing the 'tStates' field.
  PokeBProc: procedure (z80cpu: PZ80CPU; addr: Word; b: Byte);
    poke data byte, do contention.
  PokeBInternalProc: procedure (z80cpu: PZ80CPU; addr: Word; b: Byte);
    poke data byte w/o changing the 'tStates' field.
  PortInProc: function (z80cpu: PZ80CPU; port: Word): Byte;
    you can do contention here too.
  PortOutProc: procedure (z80cpu: PZ80CPU; port: Word; b: Byte);
    you can do contention here too.

  opTraps: array [0..255] of function (z80cpu: PZ80CPU): Boolean;
    when this is called, opcode already fetched, PC & R incremented by 1,
    t-states incremented by 4 (+possible contention).
    return FALSE to continue as usual.
    return TRUE to fetch & interpret new instruction.
    set 'breaked' to break immediately (res=TRUE) or after interpretation
    of the current opcode (res=FALSE). no state unrolling will be made
    on immediate break.

  opTrapsED: array [0..255] of function (z80cpu: PZ80CPU): Boolean;
    the same as the previous one, but this time for EDxx opcode.
    byte after ED prefix still not fetched when this trap called.


  procedure Z80ClearTraps (z80cpu: PZ80CPU);
  procedure Z80ClearTrapsED (z80cpu: PZ80CPU);
    this procedures MUST be called before setting any traps. note that
    Z80Reset() will not change the trap arrays.
