Ejemplo n.º 1
0
		void do_rtcc()
		{
			if (!(++cycle_counter & rtcc_prescale_mask))
			{
				if (++ram( sx_ram::RTCC) == 0 && enable_rtcc_interrupt)
				{
					do_interrupt();
				}
			}
		}
Ejemplo n.º 2
0
/*===========================================================================*
 *				main					     *
 *===========================================================================*/
int main(int argc, char *argv[])
{
  dpeth_t *dep;
  message m;
  int ipc_status;
  int r;

  /* SEF local startup. */
  env_setargs(argc, argv);
  sef_local_startup();
  
  while (TRUE)
    {
      if ((r= netdriver_receive(ANY, &m, &ipc_status)) != OK)
	panic("netdriver_receive failed: %d", r);

		if(is_ipc_notify(ipc_status)) {
			switch(_ENDPOINT_P(m.m_source)) {
				case CLOCK:
					do_watchdog(&m);
					break;

	case HARDWARE:
	  dep = &de_state;
	  if (dep->de_mode == DEM_ENABLED) {
	    do_interrupt(dep);
	    if (dep->de_flags & (DEF_ACK_SEND | DEF_ACK_RECV))
	    do_reply(dep);
	    sys_irqenable(&dep->de_hook);
	  }
	  break;
	 default:
	 	printf("ignoring notify from %d\n", m.m_source);
	 	break;
			}
			continue;
		}
      
      switch (m.m_type)
	{
	case DL_WRITEV_S:  do_vwrite_s(&m, FALSE); break;
	case DL_READV_S:   do_vread_s(&m, FALSE);  break;	  
	case DL_CONF:      do_conf(&m);            break;  
	case DL_GETSTAT_S: do_get_stat_s(&m);      break;

	default:  
		printf("message 0x%x; %d from %d\n",
			m.m_type, m.m_type-DL_RQ_BASE, m.m_source);
		panic("illegal message: %d", m.m_type);
	}
    }
}
Ejemplo n.º 3
0
void
mainloop(void) {
  unsigned char a, f, b, c, d, e, h, l;
  unsigned char r, a1, f1, b1, c1, d1, e1, h1, l1, i, iff1, iff2, im;
  unsigned short pc;
  unsigned short ix, iy, sp;
  extern unsigned long tstates,tsmax;
  unsigned int radjust;
  unsigned char ixoriy, new_ixoriy;
  unsigned char intsample;
  unsigned char op;
  
  a=f=b=c=d=e=h=l=a1=f1=b1=c1=d1=e1=h1=l1=i=r=iff1=iff2=im=0;
  ixoriy=new_ixoriy=0;
  ix=iy=sp=pc=0;
  tstates=radjust=0;
  while(1) {
    ixoriy=new_ixoriy;
    new_ixoriy=0;
    intsample=1;
    op=fetch(pc);
    pc++;
    radjust++;

    switch(op) {
      #include "z80ops.c"
    }

    if(tstates>tsmax)
      fix_tstates();

    if(interrupted == 1 && intsample && iff1) {
      do_interrupt();
      push2(pc);
      pc=0x38;
      interrupted=0;
    }

    if (reset_ace) {
      /* actually a kludge to let us do a reset */
      a=f=b=c=d=e=h=l=a1=f1=b1=c1=d1=e1=h1=l1=i=r=iff1=iff2=im=0;
      ixoriy=new_ixoriy=0;
      ix=iy=sp=pc=0;
      tstates=radjust=0;
      reset_ace = 0;
    }
  }
}
Ejemplo n.º 4
0
void
mainloop(void) {
  unsigned char a, f, b, c, d, e, h, l;
  unsigned char r, a1, f1, b1, c1, d1, e1, h1, l1, i, iff1, iff2, im;
  unsigned short pc;
  unsigned short ix, iy, sp;
  unsigned int radjust;
  unsigned char ixoriy, new_ixoriy;
  unsigned char intsample;
  unsigned char op;

  a=f=b=c=d=e=h=l=a1=f1=b1=c1=d1=e1=h1=l1=i=r=iff1=iff2=im=0;
  ixoriy=new_ixoriy=0;
  ix=iy=sp=pc=0;
  tstates=radjust=0;

  while(1) {
    ixoriy=new_ixoriy;
    new_ixoriy=0;
    intsample=1;
    op=fetch(pc);
    pc++;
    radjust++;

    switch(op) {
      #include "z80ops.c"
    }

    syncIntWithEmuSpeed();

    if(vRefreshInt == 1 && intsample && iff1) {
      do_interrupt();
      push2(pc);
      pc=0x38;
      vRefreshInt=0;
    }

    if (reset_flag) {
      /* actually a kludge to let us do a reset */
      a=f=b=c=d=e=h=l=a1=f1=b1=c1=d1=e1=h1=l1=i=r=iff1=iff2=im=0;
      ixoriy=new_ixoriy=0;
      ix=iy=sp=pc=0;
      tstates=radjust=0;
      reset_flag = 0;
    }

  }
}
Ejemplo n.º 5
0
void melps4_cpu_device::check_interrupt()
{
	if (!m_inte)
		return;

	int which = 0;
	
	// assume that lower irq vectors have higher priority
	if (m_irqflag[0])
		which = 0;
	else if (m_irqflag[1] && m_tmr_irq_enabled[0])
		which = 1;
	else if (m_irqflag[2] && m_tmr_irq_enabled[1])
		which = 2;
	else
		return;
	
	do_interrupt(which);
}
Ejemplo n.º 6
0
inline void Replication::interrupt() noexcept
{
    do_interrupt();
}
Ejemplo n.º 7
0
/* read a file and play it. sound_init() should already have been called,
 * and sound device should still be open when we exit.
 */
void mainloop(void)
{
int oldfile=-1;

aydata.filedata=NULL;
aydata.tracks=NULL;

/* this is kind of a weird multi-level event loop (if
 * you consider do_interrupt()); it's difficult to do it very
 * differently without turning the Z80 emulation inside-out.
 */
while(!want_quit)
  {
  /* load a new file if we need to */
  if(ay_file!=oldfile)
    {
    if(aydata.tracks) free(aydata.tracks);
    if(aydata.filedata) free(aydata.filedata);
    
    if(!read_ay_file(ay_filenames[ay_file]))
      {
      ui_end();
      if(sound_enabled) sound_end();
      fprintf(stderr,"%s: reading `%s' failed.\n",
              progname,ay_filenames[ay_file]);
      exit(1);
      }

    if(!play_one_track_only)
      ay_track=0;
    else
      {
      ay_track=play_one_track_only-1;
      
      if(ay_track>=aydata.num_tracks)
        {
        ui_end();
        if(sound_enabled) sound_end();
        fprintf(stderr,"%s: `%s' has only %d track%s.\n",
                progname,ay_filenames[ay_file],
                aydata.num_tracks,(aydata.num_tracks==1)?"":"s");
        exit(1);
        }
      }

    if(go_to_last)
      {
      go_to_last=0;
      ay_track=aydata.num_tracks-1;
      }
    }
  
  oldfile=ay_file;

  /* only do the whole emulation thing if we're actually playing... */
  if(playing)
    {
    /* re-enable sound after stopping, if needed */
    if(!sound_enabled && !sound_init())
      {
      ui_end();
      fprintf(stderr,"%s: couldn't reopen sound device.\n",progname);
      exit(1);
      }
  
    ay_current_reg=0;
    sound_ay_reset();
    mem_init(ay_track);
    tunetime_reset();
    tsmax=FRAME_STATES_128;
    do_cpc=0;
    z80loop(aydata.tracks[ay_track].data,
            aydata.tracks[ay_track].data_stacketc);
    }

  /* if stopped, close sound device */
  if(sound_enabled && !playing)
    sound_end();
  
  /* do reset now, so any paused/stopped status time makes sense */
  tunetime_reset();
  while((!playing || paused) && ay_file==oldfile)
    do_interrupt();
  }

free(aydata.tracks);
free(aydata.filedata);
}
Ejemplo n.º 8
0
Archivo: z80.c Proyecto: epatel/iACE
void mainloop()
{
    extern unsigned long tstates, tsmax;

#define op g.op
#define a g.a
#define f g.f
#define b g.b
#define c g.c
#define d g.d
#define e g.e
#define h g.h
#define l g.l
#define r g.r
#define a1 g.a1
#define f1 g.f1
#define b1 g.b1
#define c1 g.c1
#define d1 g.d1
#define e1 g.e1
#define h1 g.h1
#define l1 g.l1
#define i g.i
#define iff1 g.iff1
#define iff2 g.iff2
#define im g.im
#define pc g.pc
#define ix g.ix
#define iy g.iy
#define sp g.sp
#define radjust g.radjust
#define ixoriy g.ixoriy
#define new_ixoriy g.new_ixoriy
#define intsample g.intsample
    
    a=f=b=c=d=e=h=l=a1=f1=b1=c1=d1=e1=h1=l1=i=r=iff1=iff2=im=0;
    ixoriy=new_ixoriy=0;
    ix=iy=sp=pc=0;
    tstates=radjust=0;
    
    while (1) {
        ixoriy=new_ixoriy;
        new_ixoriy=0;
        intsample=1;
        op=fetch(pc);
        pc++;
        radjust++;
        
        switch(op) {
#include "z80ops.c"
        }
        
        if (tstates > tsmax) {
            memcpy(&savedG, &g, sizeof(g));
            fix_tstates();
        }
        
        if (interrupted == 1 && intsample && iff1) {
            do_interrupt();
            push2(pc);
            pc=0x38;
            interrupted=0;
        }
        
        if (reset_ace) {
            /* actually a kludge to let us do a reset */
            a=f=b=c=d=e=h=l=a1=f1=b1=c1=d1=e1=h1=l1=i=r=iff1=iff2=im=0;
            ixoriy=new_ixoriy=0;
            ix=iy=sp=pc=0;
            tstates=radjust=0;
            reset_ace = 0;
        }
    }
}
Ejemplo n.º 9
0
void ucom4_cpu_device::execute_run()
{
	while (m_icount > 0)
	{
		// handle interrupt, but not during LI($9x) or EI($31) or while skipping
		if (m_int_f && m_inte_f && (m_op & 0xf0) != 0x90 && m_op != 0x31 && !m_skip)
		{
			do_interrupt();
			if (m_icount <= 0)
				break;
		}

		// remember previous state
		m_prev_op = m_op;
		m_prev_pc = m_pc;

		// fetch next opcode
		debugger_instruction_hook(this, m_pc);
		m_icount--;
		m_op = m_program->read_byte(m_pc);
		m_bitmask = 1 << (m_op & 0x03);
		increment_pc();
		fetch_arg();

		if (m_skip)
		{
			m_skip = false;
			m_op = 0; // nop
		}

		// handle opcode
		switch (m_op & 0xf0)
		{
			case 0x80: op_ldz(); break;
			case 0x90: op_li(); break;
			case 0xa0: op_jmpcal(); break;
			case 0xb0: op_czp(); break;

			case 0xc0: case 0xd0: case 0xe0: case 0xf0: op_jcp(); break;

			default:
				switch (m_op)
				{
			case 0x00: op_nop(); break;
			case 0x01: op_di(); break;
			case 0x02: op_s(); break;
			case 0x03: op_tit(); break;
			case 0x04: op_tc(); break;
			case 0x05: op_ttm(); break;
			case 0x06: op_daa(); break;
			case 0x07: op_tal(); break;
			case 0x08: op_ad(); break;
			case 0x09: op_ads(); break;
			case 0x0a: op_das(); break;
			case 0x0b: op_clc(); break;
			case 0x0c: op_cm(); break;
			case 0x0d: op_inc(); break;
			case 0x0e: op_op(); break;
			case 0x0f: op_dec(); break;
			case 0x10: op_cma(); break;
			case 0x11: op_cia(); break;
			case 0x12: op_tla(); break;
			case 0x13: op_ded(); break;
			case 0x14: op_stm(); break;
			case 0x15: op_ldi(); break;
			case 0x16: op_cli(); break;
			case 0x17: op_ci(); break;
			case 0x18: op_exl(); break;
			case 0x19: op_adc(); break;
			case 0x1a: op_xc(); break;
			case 0x1b: op_stc(); break;
			case 0x1c: op_illegal(); break;
			case 0x1d: op_inm(); break;
			case 0x1e: op_ocd(); break;
			case 0x1f: op_dem(); break;

			case 0x30: op_rar(); break;
			case 0x31: op_ei(); break;
			case 0x32: op_ip(); break;
			case 0x33: op_ind(); break;

			case 0x40: op_ia(); break;
			case 0x41: op_jpa(); break;
			case 0x42: op_taz(); break;
			case 0x43: op_taw(); break;
			case 0x44: op_oe(); break;
			case 0x45: op_illegal(); break;
			case 0x46: op_tly(); break;
			case 0x47: op_thx(); break;
			case 0x48: op_rt(); break;
			case 0x49: op_rts(); break;
			case 0x4a: op_xaz(); break;
			case 0x4b: op_xaw(); break;
			case 0x4c: op_xls(); break;
			case 0x4d: op_xhr(); break;
			case 0x4e: op_xly(); break;
			case 0x4f: op_xhx(); break;

			default:
				switch (m_op & 0xfc)
				{
			case 0x20: op_fbf(); break;
			case 0x24: op_tab(); break;
			case 0x28: op_xm(); break;
			case 0x2c: op_xmd(); break;

			case 0x34: op_cmb(); break;
			case 0x38: op_lm(); break;
			case 0x3c: op_xmi(); break;

			case 0x50: op_tpb(); break;
			case 0x54: op_tpa(); break;
			case 0x58: op_tmb(); break;
			case 0x5c: op_fbt(); break;
			case 0x60: op_rpb(); break;
			case 0x64: op_reb(); break;
			case 0x68: op_rmb(); break;
			case 0x6c: op_rfb(); break;
			case 0x70: op_spb(); break;
			case 0x74: op_seb(); break;
			case 0x78: op_smb(); break;
			case 0x7c: op_sfb(); break;
				}
				break; // 0xfc

				}
				break; // 0xff

		} // big switch
	}
}