예제 #1
0
파일: z80.cpp 프로젝트: IcooN/OpenEmu
/* Process a z80 maskable interrupt */
int z80_interrupt( void )
{
  if( IFF1 ) {

    /* If interrupts have just been enabled, don't accept the interrupt now,
       but check after the next instruction has been executed */
    if( z80_tstates == z80.interrupts_enabled_at ) 
    {
     return(0);
    }
      //event_add( z80_tstates + 1, EVENT_TYPE_INTERRUPT );
	//puts("Oops");
    //  return 0;
    //}

    if( z80.halted ) { PC++; z80.halted = 0; }
    IFF1=IFF2=0;

    Z80_WB_MACRO( --SP, PCH ); Z80_WB_MACRO( --SP, PCL );

    R++; 

    //printf("IMode: %02x, I: %02x\n", IM, I);

    switch(IM) {
      case 0: PC = 0x0038; z80_tstates += 6; break;
      case 1: PC = 0x0038; z80_tstates += 7; break;
      case 2: 
	{
	  uint16 inttemp=(0x100*I)+0xff;
	  PCL = Z80_RB_MACRO(inttemp++); PCH = Z80_RB_MACRO(inttemp);
	  z80_tstates += 7;
	  break;
	}
    }

    return 1;			/* Accepted an interrupt */

  } else {

    return 0;			/* Did not accept an interrupt */

  }
}
예제 #2
0
파일: z80.cpp 프로젝트: Oggom/mednafen-git
/* Process a z80 maskable interrupt */
int z80_interrupt( void )
{

  if( IFF1 ) {

    /* If interrupts have just been enabled, don't accept the interrupt now,
       but check after the next instruction has been executed */
    if( z80_tstates == z80.interrupts_enabled_at ) {
      return 0;
    }

    if( z80.halted ) { PC++; z80.halted = 0; }
    
    IFF1=IFF2=0;

    Z80_WB_MACRO( --SP, PCH ); Z80_WB_MACRO( --SP, PCL );

    R++;

    switch(IM) {
      case 0: PC = 0x0038; z80_tstates += 7; break;
      case 1: PC = 0x0038; z80_tstates += 7; break;
      case 2: 
	{
	  uint16 inttemp=(0x100*I)+0xff;
	  PCL = Z80_RB_MACRO(inttemp++); PCH = Z80_RB_MACRO(inttemp);
	  z80_tstates += 7;
	  break;
	}
      //default:
      //	ui_error( UI_ERROR_ERROR, "Unknown interrupt mode %d", IM );
      //	fuse_abort();
    }

    return 1;			/* Accepted an interrupt */

  } else {

    return 0;			/* Did not accept an interrupt */

  }
}
예제 #3
0
int z80_do_opcode( void )
{
 if(z80_iline)
 {
  if(z80_interrupt())
  {
   int ret = z80_tstates - last_z80_tstates;
   last_z80_tstates = z80_tstates;
   return(ret);
  }
 }

 uint8 opcode;

    /* Check to see if M1 cycles happen on even z80_tstates */
    //if( z80_tstates & 1 )
    // z80_tstates++;
    //uint16 lastpc = PC;

    opcode = Z80_RB_MACRO( PC ); 
    //printf("Z80-op: %04x, %02x\n", PC, opcode);
    z80_tstates++;

    PC++; 
    R++;

    switch(opcode) 
    {
     #include "opcodes_base.c"
    }

   int ret = z80_tstates - last_z80_tstates;
   last_z80_tstates = z80_tstates;

   //printf("PC: %04x, %02x, time=%d\n", lastpc, opcode, ret);

   return(ret);
}