Skip to content

Commit 00cc779

Browse files
committed
Configuration options.
This commit contains the following changes: * The value of `Z80_OPTION_HALT_SKIP` has been changed to 4. This makes room for a 2-bit integer in the most significant bits of `Z80::options`, which may be useful for future emulation of Soviet and MME chips. * `Z80_WITH_RETX_NOTIFICATIONS_IN_IM0` has been renamed to `Z80_WITH_IM0_RETX_NOTIFICATIONS`. * Added `Z80_OPTION_IM0_RETX_NOTIFICATIONS` for enabling at runtime the notifications of the execution of `reti` and `retn` during the interrupt mode 0 response. * Updated the documentation accordingly.
1 parent ace4e2a commit 00cc779

File tree

10 files changed

+55
-43
lines changed

10 files changed

+55
-43
lines changed

.github/workflows/build_and_test_library.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ env:
3434
Z80_WITH_TESTS: YES
3535
Z80_WITH_EXECUTE: YES
3636
Z80_WITH_FULL_IM0: YES
37+
Z80_WITH_IM0_RETX_NOTIFICATIONS: YES
3738
Z80_WITH_Q: YES
38-
Z80_WITH_RETX_NOTIFICATIONS_IN_IM0: YES
3939
Z80_WITH_SPECIAL_RESET: YES
4040
Z80_WITH_UNOFFICIAL_RETI: NO
4141
Z80_WITH_ZILOG_NMOS_LD_A_IR_BUG: YES
@@ -80,8 +80,8 @@ jobs:
8080
-DZ80_WITH_TESTS=${{env.Z80_WITH_TESTS}}
8181
-DZ80_WITH_EXECUTE=${{env.Z80_WITH_EXECUTE}}
8282
-DZ80_WITH_FULL_IM0=${{env.Z80_WITH_FULL_IM0}}
83+
-DZ80_WITH_IM0_RETX_NOTIFICATIONS=${{env.Z80_WITH_IM0_RETX_NOTIFICATIONS}}
8384
-DZ80_WITH_Q=${{env.Z80_WITH_Q}}
84-
-DZ80_WITH_RETX_NOTIFICATIONS_IN_IM0=${{env.Z80_WITH_RETX_NOTIFICATIONS_IN_IM0}}
8585
-DZ80_WITH_SPECIAL_RESET=${{env.Z80_WITH_SPECIAL_RESET}}
8686
-DZ80_WITH_UNOFFICIAL_RETI=${{env.Z80_WITH_UNOFFICIAL_RETI}}
8787
-DZ80_WITH_ZILOG_NMOS_LD_A_IR_BUG=${{env.Z80_WITH_ZILOG_NMOS_LD_A_IR_BUG}}

API/Z80.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,21 +447,26 @@ typedef struct {
447447

448448
#define Z80_OPTION_LD_A_IR_BUG 2
449449

450+
/** @brief <tt>@ref Z80::options</tt> bitmask that enables the HALTskip
451+
* optimization. */
452+
453+
#define Z80_OPTION_HALT_SKIP 4
454+
450455
/** @brief <tt>@ref Z80::options</tt> bitmask that enables the XQ factor in the
451456
* emulation of the @c ccf and @c scf instructions. */
452457

453458
#define Z80_OPTION_XQ 8
454459

460+
/** @brief <tt>@ref Z80::options</tt> bitmask that enables notifications for any
461+
`reti` or `retn` instruction executed during the interrupt mode 0 response. */
462+
463+
#define Z80_OPTION_IM0_RETX_NOTIFICATIONS 16
464+
455465
/** @brief <tt>@ref Z80::options</tt> bitmask that enables the YQ factor in the
456466
* emulation of the @c ccf and @c scf instructions. */
457467

458468
#define Z80_OPTION_YQ 32
459469

460-
/** @brief <tt>@ref Z80::options</tt> bitmask that enables the HALTskip
461-
* optimization. */
462-
463-
#define Z80_OPTION_HALT_SKIP 64
464-
465470
/** @brief <tt>@ref Z80::options</tt> bitmask that enables full emulation of the
466471
* Zilog NMOS models. */
467472

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ option(${PROJECT_NAME}_WITH_FULL_IM0
9292
reduced one."
9393
NO)
9494

95-
option(${PROJECT_NAME}_WITH_Q
96-
"Build the implementation of Q."
97-
NO)
98-
99-
option(${PROJECT_NAME}_WITH_RETX_NOTIFICATIONS_IN_IM0
95+
option(${PROJECT_NAME}_WITH_IM0_RETX_NOTIFICATIONS
10096
"Enable optional notifications for any `reti` or `retn` instruction \
10197
executed during the interrupt mode 0 response."
10298
NO)
10399

100+
option(${PROJECT_NAME}_WITH_Q
101+
"Build the implementation of Q."
102+
NO)
103+
104104
option(${PROJECT_NAME}_WITH_SPECIAL_RESET
105105
"Build the implementation of the special RESET."
106106
NO)
@@ -192,8 +192,8 @@ target_compile_definitions(
192192
${PROJECT_NAME} PRIVATE
193193
$<$<BOOL:${${PROJECT_NAME}_WITH_EXECUTE}>:Z80_WITH_EXECUTE>
194194
$<$<BOOL:${${PROJECT_NAME}_WITH_FULL_IM0}>:Z80_WITH_FULL_IM0>
195+
$<$<BOOL:${${PROJECT_NAME}_WITH_IM0_RETX_NOTIFICATIONS}>:Z80_WITH_IM0_RETX_NOTIFICATIONS>
195196
$<$<BOOL:${${PROJECT_NAME}_WITH_Q}>:Z80_WITH_Q>
196-
$<$<BOOL:${${PROJECT_NAME}_WITH_RETX_NOTIFICATIONS_IN_IM0}>:Z80_WITH_RETX_NOTIFICATIONS_IN_IM0>
197197
$<$<BOOL:${${PROJECT_NAME}_WITH_SPECIAL_RESET}>:Z80_WITH_SPECIAL_RESET>
198198
$<$<BOOL:${${PROJECT_NAME}_WITH_UNOFFICIAL_RETI}>:Z80_WITH_UNOFFICIAL_RETI>
199199
$<$<BOOL:${${PROJECT_NAME}_WITH_ZILOG_NMOS_LD_A_IR_BUG}>:Z80_WITH_ZILOG_NMOS_LD_A_IR_BUG>)

README

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ library by predefining macros that enable optional features:
185185
reduced one.
186186
The default is `NO`.
187187

188-
-DZ80_WITH_Q=(YES|NO)
189-
Build the implementation of Q.
190-
The default is `NO`.
191-
192-
-DZ80_WITH_RETX_NOTIFICATIONS_IN_IM0=(YES|NO)
188+
-DZ80_WITH_IM0_RETX_NOTIFICATIONS=(YES|NO)
193189
Enable optional notifications for any `reti` or `retn` instruction
194190
executed during the interrupt mode 0 response.
195191
The default is `NO`.
196192

193+
-DZ80_WITH_Q=(YES|NO)
194+
Build the implementation of Q.
195+
The default is `NO`.
196+
197197
-DZ80_WITH_SPECIAL_RESET=(YES|NO)
198198
Build the implementation of the special RESET.
199199
The default is `NO`.
@@ -300,6 +300,7 @@ the following macros:
300300

301301
#define Z80_WITH_EXECUTE
302302
#define Z80_WITH_FULL_IM0
303+
#define Z80_WITH_IM0_RETX_NOTIFICATIONS
303304
#define Z80_WITH_Q
304305
#define Z80_WITH_SPECIAL_RESET
305306
#define Z80_WITH_UNOFFICIAL_RETI
@@ -329,4 +330,4 @@ You should have received a copy of the GNU Lesser General Public License along
329330
with this library. If not, see <http://www.gnu.org/licenses/>.
330331

331332
________________________________________________________________________________
332-
Last update: 2022-02-12 README EOF
333+
Last update: 2023-02-14 README EOF

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,12 @@ If in doubt, read the [CMake documentation](https://cmake.org/documentation/) fo
467467
Build the full implementation of the interrupt mode 0 rather than the reduced one.
468468
The default is `NO`.
469469
470-
* <span id="option_Z80_WITH_Q">**`-DZ80_WITH_Q=(YES|NO)`**</span>
471-
Build the implementation of [Q](https://worldofspectrum.org/forums/discussion/41704).
470+
* <span id="option_Z80_WITH_IM0_RETX_NOTIFICATIONS">**`-DZ80_WITH_IM0_RETX_NOTIFICATIONS=(YES|NO)`**</span>
471+
Enable optional notifications for any `reti` or `retn` instruction executed during the interrupt mode 0 response.
472472
The default is `NO`.
473473
474-
* <span id="option_Z80_WITH_RETX_NOTIFICATIONS_IN_IM0">**`-DZ80_WITH_RETX_NOTIFICATIONS_IN_IM0=(YES|NO)`**</span>
475-
Enable optional notifications for any `reti` or `retn` instruction executed during the interrupt mode 0 response.
474+
* <span id="option_Z80_WITH_Q">**`-DZ80_WITH_Q=(YES|NO)`**</span>
475+
Build the implementation of [Q](https://worldofspectrum.org/forums/discussion/41704).
476476
The default is `NO`.
477477
478478
* <span id="option_Z80_WITH_SPECIAL_RESET">**`-DZ80_WITH_SPECIAL_RESET=(YES|NO)`**</span>
@@ -631,8 +631,8 @@ There are several macros that can be used to configure the source code of the li
631631
632632
* **<code>#define [Z80_WITH_EXECUTE](#option_Z80_WITH_EXECUTE)</code>**
633633
* **<code>#define [Z80_WITH_FULL_IM0](#option_Z80_WITH_FULL_IM0)</code>**
634+
* **<code>#define [Z80_WITH_IM0_RETX_NOTIFICATIONS](#option_Z80_WITH_IM0_RETX_NOTIFICATIONS)</code>**
634635
* **<code>#define [Z80_WITH_Q](#option_Z80_WITH_Q)</code>**
635-
* **<code>#define [Z80_WITH_RETX_NOTIFICATIONS_IN_IM0](#option_Z80_WITH_RETX_NOTIFICATIONS_IN_IM0)</code>**
636636
* **<code>#define [Z80_WITH_SPECIAL_RESET](#option_Z80_WITH_SPECIAL_RESET)</code>**
637637
* **<code>#define [Z80_WITH_UNOFFICIAL_RETI](#option_Z80_WITH_UNOFFICIAL_RETI)</code>**
638638
* **<code>#define [Z80_WITH_ZILOG_NMOS_LD_A_IR_BUG](#option_Z80_WITH_ZILOG_NMOS_LD_A_IR_BUG)</code>**

documentation/APIReference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Configuration
9292
-------------
9393

9494
.. doxygendefine:: Z80_OPTION_HALT_SKIP
95+
.. doxygendefine:: Z80_OPTION_IM0_RETX_NOTIFICATIONS
9596
.. doxygendefine:: Z80_OPTION_LD_A_IR_BUG
9697
.. doxygendefine:: Z80_OPTION_OUT_VC_255
9798
.. doxygendefine:: Z80_OPTION_XQ

documentation/Installation.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ The second group of package-specific options configures the source code of the l
153153
Build the full implementation of the interrupt mode 0 rather than the reduced one. |br| |nl|
154154
The default is ``NO``.
155155

156-
.. option:: -DZ80_WITH_Q=(YES|NO)
156+
.. option:: -DZ80_WITH_IM0_RETX_NOTIFICATIONS=(YES|NO)
157157

158-
Build the implementation of `Q <https://worldofspectrum.org/forums/discussion/41704>`_. |br| |nl|
158+
Enable optional notifications for any ``reti`` or ``retn`` instruction executed during the interrupt mode 0 response. |br| |nl|
159159
The default is ``NO``.
160160

161-
.. option:: -DZ80_WITH_RETX_NOTIFICATIONS_IN_IM0=(YES|NO)
161+
.. option:: -DZ80_WITH_Q=(YES|NO)
162162

163-
Enable optional notifications for any ``reti`` or ``retn`` instruction executed during the interrupt mode 0 response. |br| |nl|
163+
Build the implementation of `Q <https://worldofspectrum.org/forums/discussion/41704>`_. |br| |nl|
164164
The default is ``NO``.
165165

166166
.. option:: -DZ80_WITH_SPECIAL_RESET=(YES|NO)

documentation/Integration.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ There are several macros that can be used to configure the source code of the li
7878
7979
Enables the full implementation of the interrupt mode 0.
8080

81-
.. c:macro:: Z80_WITH_Q
81+
.. c:macro:: Z80_WITH_IM0_RETX_NOTIFICATIONS
8282
83-
Enables the implementation of `Q <https://worldofspectrum.org/forums/discussion/41704>`_.
83+
Enables optional notifications for any ``reti`` or ``retn`` instruction executed during the interrupt mode 0 response.
8484

85-
.. c:macro:: Z80_WITH_RETX_NOTIFICATIONS_IN_IM0
85+
.. c:macro:: Z80_WITH_Q
8686
87-
Enables optional notifications for any ``reti`` or ``retn`` instruction executed during the interrupt mode 0 response.
87+
Enables the implementation of `Q <https://worldofspectrum.org/forums/discussion/41704>`_.
8888

8989
.. c:macro:: Z80_WITH_SPECIAL_RESET
9090

sources/Z80.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,9 +2031,12 @@ INSTRUCTION(hook)
20312031
static void im0_ld_r_a(IM0 const *self) {NOTIFY(ld_r_a);}
20322032

20332033

2034-
# ifdef Z80_WITH_RETX_NOTIFICATIONS_IN_IM0
2034+
# ifdef Z80_WITH_IM0_RETX_NOTIFICATIONS
20352035
#define IM0_NOTIFY_RETX(callback) \
2036-
if (self->callback != Z_NULL) \
2036+
if ( self->callback != Z_NULL && \
2037+
(self->z80->options & \
2038+
Z80_OPTION_IM0_RETX_NOTIFICATIONS) \
2039+
) \
20372040
{ \
20382041
self->z80->data.uint8_array[2] |= 2; \
20392042
self->callback(CONTEXT); \

sources/Z80.pas

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,17 @@ TZ80 = record
127127
PZ80 = ^TZ80;
128128

129129
const
130-
Z80_OPTION_OUT_VC_255 = 1;
131-
Z80_OPTION_LD_A_IR_BUG = 2;
132-
Z80_OPTION_XQ = 8;
133-
Z80_OPTION_YQ = 32;
134-
Z80_OPTION_HALT_SKIP = 64;
135-
Z80_MODEL_ZILOG_NMOS = (Z80_OPTION_LD_A_IR_BUG or Z80_OPTION_XQ or Z80_OPTION_YQ);
136-
Z80_MODEL_ZILOG_CMOS = (Z80_OPTION_OUT_VC_255 or Z80_OPTION_XQ or Z80_OPTION_YQ);
137-
Z80_MODEL_NEC_NMOS = Z80_OPTION_LD_A_IR_BUG;
138-
Z80_MODEL_ST_CMOS = (Z80_OPTION_OUT_VC_255 or Z80_OPTION_LD_A_IR_BUG or Z80_OPTION_YQ);
130+
Z80_OPTION_OUT_VC_255 = 1;
131+
Z80_OPTION_LD_A_IR_BUG = 2;
132+
Z80_OPTION_HALT_SKIP = 4;
133+
Z80_OPTION_XQ = 8;
134+
Z80_OPTION_IM0_RETX_NOTIFICATIONS = 16;
135+
Z80_OPTION_YQ = 32;
136+
137+
Z80_MODEL_ZILOG_NMOS = (Z80_OPTION_LD_A_IR_BUG or Z80_OPTION_XQ or Z80_OPTION_YQ);
138+
Z80_MODEL_ZILOG_CMOS = (Z80_OPTION_OUT_VC_255 or Z80_OPTION_XQ or Z80_OPTION_YQ);
139+
Z80_MODEL_NEC_NMOS = Z80_OPTION_LD_A_IR_BUG;
140+
Z80_MODEL_ST_CMOS = (Z80_OPTION_OUT_VC_255 or Z80_OPTION_LD_A_IR_BUG or Z80_OPTION_YQ);
139141

140142
Z80_REQUEST_REJECT_NMI = 2;
141143
Z80_REQUEST_NMI = 4;

0 commit comments

Comments
 (0)