home *** CD-ROM | disk | FTP | other *** search
-
- /* Z80 Emulator
- Copyright (C) 1994 G.Woigk
-
- This file is part of Mac Spectacle and it is free software
- See application.c for details
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- 01.Mai.94 Started work on this file KIO !
- 11.Dec.94 Now preserving all bits with push/pop AF KIO !
- 18.Jan.95 Improved interrupt dispatcher KIO !
- 22.Jan.95 Trace mode KIO !
- 28.Jan.95 CMD_PROFILE KIO !
- 05.Mar.95 full r-register emulation KIO !
- 12.Mar.95 T cycle counter KIO !
- 17.Mar.95 revised exception handling of Z80() KIO !
- 23.Mar.95 now always including both Z80() and Z80_T() KIO !
- 29.Mrz.95 Separated this file from Init_Z80.c KIO !
- 10.Apr.95 ROM write protection KIO !
- */
-
-
- #include <AppleEvents.h>
- #include <quickdraw.h>
-
- #include "kio.h"
- #include "z80.h"
- #include "application.h"
- #include "display.h"
- #include "console.h"
-
- #include "z80.options"
- #include "z80.macros"
-
-
- /* ----- The Z80 engine ----------------------------------------------------------
-
- There are two versions:
- • Z80(): exact_timing = rom_protection = false
- no T cycle counting; no ROM write protection; fastest;
- no timing-loop depending sound, tape i/o etc. possible
- • Z80_T(): exact_timing = rom_protection = true
- T cycle counting; ROM write protection; 40% slower;
- Do-Cycles() is used; timing loop depending sound, tape i/o possible
-
- On entry/return some registers are loaded from and written back to 'zreg'
-
- WUFF (irpt and nmi flags) is tested
- • on entry of Z80()
- • after ei instruction
- • Z80_T(): after Do_Cycles() after CYCLES reached 0 and EXIT is not set
-
- EXIT (watchdog) and WUFF (nmi/irpt) are tested
- • Z80_T(): Do_Cycles() is called after CYCLES reaches 0
- after Do_Cycles() returns, EXIT and WUFF are tested
- • Z80(): after every bra/jp/call/ret/rst
-
- Single instructions may be executed by calling Z80_T() with CYCLES=4
- Then one of the following is processed: (in priority order)
- • handle nmi request
- • handle irpt request (if interrupts are enabled)
- • execute one instruction, except:
- • if instruction is EI, handle EI and next instruction in one go
-
- If Z80() returns, it's result value indicates one of the following conditions:
- • not supported instruction at zreg.IP
- • rst0 instruction at zreg.IP-1
- • halt instruction at zreg.IP-1
- • EXIT set
- */
-
-
- // ----- Fastest interpreter: no T cycle counting, no ROM write protection ---------------
- #define exact_timing false
- #define rom_protection false
- #define exact_bit false
- #define exact_xy_bit false
-
- short asm Z80 ( )
- {
- #include "Z80_proc.c"
- }
-
-
- // ----- T cycle counting and ROM write protection ------------------------------
- #define exact_timing true
- #define rom_protection true
- #define exact_bit true
- #define exact_xy_bit false
-
- asm short Z80_T ( )
- {
- #include "Z80_proc.c"
- }
-
-
-
-