1 /* z80_ops.c: Process the next opcode
2    Copyright (c) 1999-2005 Philip Kendall, Witold Filipczyk
3 
4    $Id: z80_ops.c 4624 2012-01-09 20:59:35Z pak21 $
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License along
17    with this program; if not, write to the Free Software Foundation, Inc.,
18    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 
20    Author contact information:
21 
22    E-mail: philip-fuse@shadowmagic.org.uk
23 
24 */
25 
26 #include "z80.h"
27 namespace Mednafen
28 {
29 #include "z80_macros.h"
30 
z80_set_interrupt(int set)31 void z80_set_interrupt(int set)
32 {
33  z80_iline = set;
34 }
35 
z80_do_opcode(void)36 int z80_do_opcode( void )
37 {
38  if(z80_iline)
39  {
40   if(z80_interrupt())
41   {
42    int ret = z80_tstates - last_z80_tstates;
43    last_z80_tstates = z80_tstates;
44    return(ret);
45   }
46  }
47 
48  uint8 opcode;
49 
50     /* Check to see if M1 cycles happen on even z80_tstates */
51     //if( z80_tstates & 1 )
52     // z80_tstates++;
53     //uint16 lastpc = PC;
54 
55     opcode = Z80_RB_MACRO( PC );
56     //printf("Z80-op: %04x, %02x\n", PC, opcode);
57     z80_tstates++;
58 
59     PC++;
60     R++;
61 
62     switch(opcode)
63     {
64      #include "opcodes_base.c"
65     }
66 
67    int ret = z80_tstates - last_z80_tstates;
68    last_z80_tstates = z80_tstates;
69 
70    //printf("PC: %04x, %02x, time=%d\n", lastpc, opcode, ret);
71 
72    return(ret);
73 }
74 
75 }
76