Skip to content

Commit

Permalink
Increased granularity; Comments and references.
Browse files Browse the repository at this point in the history
  • Loading branch information
redcode committed Sep 18, 2022
1 parent ac3a72d commit a6f02d7
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 149 deletions.
37 changes: 17 additions & 20 deletions API/Z80.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@

#define Z80_CYCLE_LIMIT (Z_USIZE_MAXIMUM - Z_USIZE(30))

#define Z80_CYCLES_PER_RESET 5

/** @brief Opcode interpreted as a hook by the Z80 library, which
* corresponds to the <tt>ld h,h</tt> instruction of the Z80 ISA. */

Expand Down Expand Up @@ -320,6 +318,10 @@ typedef struct {

ZInt32 data;

ZInt16 ix_iy[2]; /**< @brief IX and IY registers. */
ZInt16 pc; /**< @brief PC register. */
ZInt16 sp; /**< @brief SP register. */

/** @brief Temporary IX/IY register.
*
* All instructions with @c DDh prefix behave in exactly the same way
Expand All @@ -336,10 +338,6 @@ typedef struct {
ZInt16 xy;

ZInt16 memptr; /**< @brief MEMPTR register. */
ZInt16 pc; /**< @brief PC register. */
ZInt16 sp; /**< @brief SP register. */
ZInt16 ix; /**< @brief IX register. */
ZInt16 iy; /**< @brief IY register. */
ZInt16 af; /**< @brief AF register. */
ZInt16 bc; /**< @brief BC register. */
ZInt16 de; /**< @brief DE register. */
Expand All @@ -354,7 +352,7 @@ typedef struct {
/** @brief The most significant bit of the R register.
*
* The Z80 CPU increments the R register during each M1 cycle without
* altering its most significant bit, commonly known as R7. However,
* altering its most significant bit, commonly known as R7. However,
* the Z80 library performs normal increments for speed reasons, which
* eventually corrupts R7.
*
Expand Down Expand Up @@ -479,20 +477,19 @@ typedef struct {

#define Z80_REQUEST_INT 64

/** @brief @ref Z80 resume code that is set when the emulator runs out of clock
/** @brief @ref Z80 resume code indicating that the emulator ran out of clock
* cycles during the HALT state. */

#define Z80_RESUME_HALT 1

/** @brief @ref Z80 resume code that is set when the emulator runs out of clock
* cycles by fetching a prefix sequence or an illegal instruction with @c DDh
* or @c FDh prefix. */
/** @brief @ref Z80 resume code indicating that the emulator ran out of clock
* cycles by fetching a @c DDh or @c FDh prefix. */

#define Z80_RESUME_XY 2

/** @brief @ref Z80 resume code that is set when the emulator runs out of clock
* cycles during a maskable interrupt response in mode 0, by fetching a prefix
* sequence or an illegal instruction with @c DDh or @c FDh prefix. */
/** @brief @ref Z80 resume code indicating that the emulator ran out of clock
* cycles by fetching a @c DDh or @c FDh prefix during a maskable interrupt
* response in mode 0. */

#define Z80_RESUME_IM0_XY 3

Expand All @@ -514,11 +511,11 @@ typedef struct {

/** @brief Accesses the IX register of a @ref Z80 @p object. */

#define Z80_IX(object) (object).ix.uint16_value
#define Z80_IX(object) (object).ix_iy[0].uint16_value

/** @brief Accesses the IY register of a @ref Z80 @p object. */

#define Z80_IY(object) (object).iy.uint16_value
#define Z80_IY(object) (object).ix_iy[1].uint16_value

/** @brief Accesses the AF register of a @ref Z80 @p object. */

Expand Down Expand Up @@ -586,19 +583,19 @@ typedef struct {

/** @brief Accesses the IXH register of a @ref Z80 @p object. */

#define Z80_IXH(object) (object).ix.uint8_values.at_1
#define Z80_IXH(object) (object).ix_iy[0].uint8_values.at_1

/** @brief Accesses the IXL register of a @ref Z80 @p object. */

#define Z80_IXL(object) (object).ix.uint8_values.at_0
#define Z80_IXL(object) (object).ix_iy[0].uint8_values.at_0

/** @brief Accesses the IYH register of a @ref Z80 @p object. */

#define Z80_IYH(object) (object).iy.uint8_values.at_1
#define Z80_IYH(object) (object).ix_iy[1].uint8_values.at_1

/** @brief Accesses the IYL register of a @ref Z80 @p object. */

#define Z80_IYL(object) (object).iy.uint8_values.at_0
#define Z80_IYL(object) (object).ix_iy[1].uint8_values.at_0

/** @brief Accesses the A register of a @ref Z80 @p object. */

Expand Down
17 changes: 10 additions & 7 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,18 @@ Changes:
50. Added optional emulation of the bug affecting the `ld a,{i|r}` instructions
(Zilog Z80 NMOS). If enabled at compile-time, the P/V flag is reset when an
INT is accepted during the execution of these instructions.
51. Removed `Z80::state`. Replaced with individual members for the registers,
51. Increased granularity. The emulator can now stop directly after fetching a
DDh or FDh prefix if it runs out of clock cycles. This also works during the
INT response in mode 0.
52. Removed `Z80::state`. Replaced with individual members for the registers,
the interrupt enable flip-flops and the interrupt mode.
52. Removed the superfluous EI flag. The previous opcode is checked instead,
53. Removed the superfluous EI flag. The previous opcode is checked instead,
which is faster and makes the `Z80` object smaller.
53. Removed all module-related stuff.
54. Optimizations in flag computation and condition evaluation.
55. New source code comments and improvements to existing ones.
56. Improved code aesthetics.
57. Other improvements, optimizations and minor changes.
54. Removed all module-related stuff.
55. Optimizations in flag computation and condition evaluation.
56. New source code comments and improvements to existing ones.
57. Improved code aesthetics.
58. Other improvements, optimizations and minor changes.


Z80 v0.1 (2018-11-10)
Expand Down
15 changes: 8 additions & 7 deletions documentation/VersionHistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ Changes:
48. Added emulation options that can be configured at runtime.
49. Added emulation of the ``out (c),255`` instruction (Zilog Z80 CMOS).
50. Added optional emulation of the bug affecting the ``ld a,{i|r}`` instructions (Zilog Z80 NMOS). If enabled at compile-time, the P/V flag is reset when an INT is accepted during the execution of these instructions.
51. Removed ``Z80::state``. Replaced with individual members for the registers, the interrupt enable flip-flops and the interrupt mode.
52. Removed the superfluous EI flag. The previous opcode is checked instead, which is faster and makes the ``Z80`` object smaller.
53. Removed all module-related stuff.
54. Optimizations in flag computation and condition evaluation.
55. New source code comments and improvements to existing ones.
56. Improved code aesthetics.
57. Other improvements, optimizations and minor changes.
51. Increased granularity. The emulator can now stop directly after fetching a ``DDh`` or ``FDh`` prefix if it runs out of clock cycles. This also works during the INT response in mode 0.
52. Removed ``Z80::state``. Replaced with individual members for the registers, the interrupt enable flip-flops and the interrupt mode.
53. Removed the superfluous EI flag. The previous opcode is checked instead, which is faster and makes the ``Z80`` object smaller.
54. Removed all module-related stuff.
55. Optimizations in flag computation and condition evaluation.
56. New source code comments and improvements to existing ones.
57. Improved code aesthetics.
58. Other improvements, optimizations and minor changes.

v0.1 (2018-11-10)
=================
Expand Down
Loading

0 comments on commit a6f02d7

Please sign in to comment.