home *** CD-ROM | disk | FTP | other *** search
/ Emulator Universe CD / emulatoruniversecd1998.iso / Speccy / Emulators / winemu / SOURCES / Z80 / INTR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-23  |  2.6 KB  |  83 lines

  1. /* Intr.c: Z80 interrupts -- basic support routines.
  2.  *
  3.  * Copyright 1996 Rui Fernando Ferreira Ribeiro.
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20.  
  21. #include "env.h"
  22.  
  23. /*=========================================================================*
  24.  *                           do_interrupt                                  *
  25.  *=========================================================================*/
  26. void do_interrupt()
  27. {
  28.    /* At the begin of a interrupt, interrupt signals are deactivated
  29.     */
  30.    IFF1 = IFF2 = 0;
  31.  
  32.    push((USHORT)PC);
  33.  
  34.    /* Do interrupt acord to _IM
  35.      _IM can be 0, 1 or 2
  36.    */
  37.    switch(_IM)
  38.    {
  39.       case (UCHAR)1: /* IM 1 */
  40.             /* If IM_1 calls 0x38
  41.             */
  42.             clock_ticks = /*6*/ 13; /* Time : Ian Collier */
  43.             PutPC(0x38);
  44.          break;
  45.       case (UCHAR)2: /* IM 2 */
  46.         clock_ticks = /*16*/ 19; /* Time : Ian Collier */
  47.             /* PC = readword( (USHORT) ( ((USHORT)I << 8) + DATA_BUS) );
  48.             */
  49.             PutPC(readword( (USHORT) ( ((USHORT)I << 8) + 0xff) ));
  50.          break;
  51.       default:
  52.         /*
  53.          In IM_0 the Z80 processor waits for a instruction opcode
  54.          in the data bus (this mode was created for compatibility
  55.          with the 8080). In the Spectrum 0xFF is inserted in the
  56.          data bus, wich is 0x38 opcode, being so IM_0 = IM_1
  57.             */
  58.             clock_ticks = 10;
  59.             /* execute_one_inst(DATA_BUS);
  60.             */
  61.             PutPC(0x38);
  62.          break;
  63.    }
  64. }
  65.  
  66. /*=========================================================================*
  67.  *                           do_nmi_int                                    *
  68.  *=========================================================================*/
  69. void do_nmi_int()
  70. {
  71.    T(11); /* Acording to Ian Collier */
  72.    /*T(6); */
  73.  
  74.    /* Deactivate interrupts -- but IIF2 keeps copy of last IFF1 */
  75.    IFF1 = 0;
  76.  
  77.    push((USHORT)PC);
  78.  
  79.    PutPC(0x66);
  80. }
  81.  
  82. /* EOF: Intr.C */
  83.