示例#1
0
void MDDBG_CPUHook(void)	//uint32 PC, uint16 op)
{
 uint32 PC = C68k_Get_PC(&Main68K);
 std::vector<MD_BPOINT>::iterator bpit;

 FoundBPoint = 0;

 for(bpit = BreakPointsPC.begin(); bpit != BreakPointsPC.end(); bpit++)
 {
  if(PC >= bpit->A[0] && PC <= bpit->A[1])
  {
   FoundBPoint = TRUE;
   break;
  }
 }

 if(BPNonPCActive)
 {
  MD_HackyHackyMode++;

  C68k_Copy_State2(&Main68K, &Main68K_BP);

  //printf("Moo: %08x\n", C68k_Get_PC(&Main68K_BP)); //, (int)(((uint8 *)&(Main68K.dirty1)) - ((uint8 *)&(Main68K.D[0]))));

  C68k_Exec(&Main68K_BP);

  MD_HackyHackyMode--;
 }

 if(FoundBPoint)
  BPCallB(PC);

 if(DriverCPUHook)
  DriverCPUHook(PC);
}
示例#2
0
文件: c68k.c 项目: tmaul/FBA4PSP
void C68k_Init(c68k_struc *CPU)
{
	//CPU->Interrupt_CallBack = C68k_InterruptCallback;
	//CPU->Reset_CallBack = C68k_ResetCallback;
	if ( !bC68KInit ) {
		C68k_Exec(NULL, 0);
		bC68KInit = 1;
	}
}
示例#3
0
inline void M68K_Exec(s32 cycles)
{
#ifdef CPU68K_USE_MUSASHI
    m68k_execute(cycles);
#endif

#ifdef CPU68K_USE_C68K
    C68k_Exec(&C68K, cycles);
#endif
}
示例#4
0
文件: m68kc68k.c 项目: Amon-X/yabause
static s32 FASTCALL M68KC68KExec(s32 cycle) {
#ifdef PROFILE_68K
    static u32 tot_cycles = 0, tot_usec = 0, tot_ticks = 0, last_report = 0;
    u32 start, end;
    start = (u32) YabauseGetTicks();
    int retval = C68k_Exec(&C68K, cycle);
    end = (u32) YabauseGetTicks();
    tot_cycles += cycle;
    tot_ticks += end - start;
    if (tot_cycles/1000000 > last_report) {
        tot_usec += (u64)tot_ticks * 1000000 / yabsys.tickfreq;
        tot_ticks = 0;
        fprintf(stderr, "%ld cycles in %.3f sec = %.3f nsec/cycle\n",
                (long)tot_cycles, (double)tot_usec/1000000,
                ((double)tot_usec / (double)tot_cycles) * 1000);
        last_report = tot_cycles/1000000;
    }
    return retval;
#else
	return C68k_Exec(&C68K, cycle);
#endif
}
示例#5
0
void C68k_Init(c68k_struc *CPU)
{
	int i;

	memset(CPU, 0, sizeof(c68k_struc));

	CPU->Interrupt_CallBack = C68k_InterruptCallback;
	CPU->Reset_CallBack = C68k_ResetCallback;

	memset(c68k_bad_address, 0xff, sizeof(c68k_bad_address));

	for (i = 0; i < C68K_FETCH_BANK; i++)
		CPU->Fetch[i] = (UINT32)c68k_bad_address;

	C68k_Exec(NULL, 0);
}
示例#6
0
文件: m68000.c 项目: 173210/px68k
void m68000_execute2(UINT32 start, UINT32 break_point)
{
	int nest_counter = 0;
	UINT32 pc, old_pc, opcode;
	c68k_struc C68K_temp;

	old_pc = C68k_Get_Reg(&C68K, M68K_PC);

	memcpy(&C68K_temp, &C68K, sizeof(c68k_struc));

	C68k_Set_Reg(&C68K_temp, C68K_PC, start);
	C68K_temp.A[5] = 0x108000;
	C68K_temp.A[7] -= 4 * 8 * 2;

	while ((pc = C68k_Get_Reg(&C68K_temp, M68K_PC)) != break_point)
	{
		opcode = Memory_ReadW(pc);
		if (opcode == 0x4e75)
		{
			// rts
			nest_counter--;
			if (nest_counter < 0) break;
		}
		else if (opcode == 0x6100)
		{
			// bsr 16
			nest_counter++;
		}
		else if ((opcode & 0xff00) == 0x6100)
		{
			// bsr 8
			nest_counter++;
		}
		else if ((opcode & 0xffc0) == 0x4e80)
		{
			// jsr
			nest_counter++;
		}

		C68k_Exec(&C68K_temp, 1);
	}

	C68k_Set_Reg(&C68K, C68K_PC, old_pc);
}
示例#7
0
void C68k_Init(c68k_struc *cpu, C68K_INT_CALLBACK *int_cb)
{
    memset(cpu, 0, sizeof(c68k_struc));

    C68k_Set_ReadB(cpu, C68k_Read_Dummy);
    C68k_Set_ReadW(cpu, C68k_Read_Dummy);

    C68k_Set_WriteB(cpu, C68k_Write_Dummy);
    C68k_Set_WriteW(cpu, C68k_Write_Dummy);

    if (int_cb) cpu->Interrupt_CallBack = int_cb;
    else cpu->Interrupt_CallBack = C68k_Interrupt_Ack_Dummy;
    cpu->Reset_CallBack = C68k_Reset_Dummy;

    // used to init JumpTable
    cpu->Status |= C68K_DISABLE;
    C68k_Exec(cpu, 0);
    
    cpu->Status &= ~C68K_DISABLE;
}
示例#8
0
static int system_frame(int do_skip)
{
 run_cpu = TRUE;

 while(run_cpu > 0)
 {
  if(suspend68k)
  {
   Main68K.timestamp += 4;
  }
  else
  {
   #ifdef WANT_DEBUGGER
   if(MD_DebugMode)
    MDDBG_CPUHook();
   #endif

   C68k_Exec(&Main68K);
  }

  MD_UpdateSubStuff();
 }
 return gen_running;
}
示例#9
0
文件: m68000.c 项目: 173210/px68k
int m68000_execute(int cycles)
{
	return C68k_Exec(&C68K, cycles);
}
示例#10
0
文件: winx68k.cpp 项目: ptitSeb/px68k
// -----------------------------------------------------------------------------------
//  �����Τᤤ��롼��
// -----------------------------------------------------------------------------------
void WinX68k_Exec(void)
{
	if(!(Memory_ReadD(0xed0008)==ram_size)){
		Memory_WriteB(0xe8e00d, 0x31);             // SRAM write permission
		Memory_WriteD(0xed0008, ram_size);         // Define RAM amount
	}

	//char *test = NULL;
	int clk_total, clkdiv, usedclk, hsync, clk_next, clk_count, clk_line=0;
	int KeyIntCnt = 0, MouseIntCnt = 0;
	DWORD t_start = timeGetTime(), t_end;

	if ( Config.FrameRate == 0)
		Config.FrameRate = 7;

	if ( Config.FrameRate != 7 ) {
		DispFrame = (DispFrame+1)%Config.FrameRate;
	} else {				// Auto Frame Skip
		if ( FrameSkipQueue ) {
			if ( FrameSkipCount>15 ) {
				FrameSkipCount = 0;
				FrameSkipQueue++;
				DispFrame = 0;
			} else {
				FrameSkipCount++;
				FrameSkipQueue--;
				DispFrame = 1;
			}
		} else {
			FrameSkipCount = 0;
			DispFrame = 0;
		}
	}

	vline = 0;
	clk_count = -ICount;
	clk_total = (CRTC_Regs[0x29] & 0x10) ? VSYNC_HIGH : VSYNC_NORM;

	clk_total = (clk_total*clockmhz)/10;
	clkdiv = clockmhz;

	/*if (Config.XVIMode == 1) {
		clk_total = (clk_total*16)/10;
		clkdiv = 16;
	} else if (Config.XVIMode == 2) {
		clk_total = (clk_total*24)/10;
		clkdiv = 24;
	} else {
		clkdiv = 10;
	}*/

	if(clkdiv != old_clkdiv || ram_size != old_ram_size){
		printf("CPU Clock: %d%s\n",clkdiv,"MHz");
		printf("RAM Size: %ld%s\n",ram_size/1000000,"MB");
		old_clkdiv = clkdiv;
		old_ram_size = ram_size;	
	}


	ICount += clk_total;
	clk_next = (clk_total/VLINE_TOTAL);
	hsync = 1;

	do {
		int m, n = (ICount>CLOCK_SLICE)?CLOCK_SLICE:ICount;
		//C68K.ICount = m68000_ICountBk = 0;			// ������ȯ������Ϳ���Ƥ����ʤ��ȥ����CARAT��

		if ( hsync ) {
			hsync = 0;
			clk_line = 0;
			MFP_Int(0);
			if ( (vline>=CRTC_VSTART)&&(vline<CRTC_VEND) )
				VLINE = ((vline-CRTC_VSTART)*CRTC_VStep)/2;
			else
				VLINE = (DWORD)-1;
			if ( (!(MFP[MFP_AER]&0x40))&&(vline==CRTC_IntLine) )
				MFP_Int(1);
			if ( MFP[MFP_AER]&0x10 ) {
				if ( vline==CRTC_VSTART )
					MFP_Int(9);
			} else {
				if ( CRTC_VEND>=VLINE_TOTAL ) {
					if ( (long)vline==(CRTC_VEND-VLINE_TOTAL) ) MFP_Int(9);		// ���������ƥ��󥰥���Ȥ���TOTAL<VEND��
				} else {
					if ( (long)vline==(VLINE_TOTAL-1) ) MFP_Int(9);			// ���쥤�������饤�ޡ��ϥ���Ǥʤ��ȥ��ᡩ
				}
			}
		}

#ifdef WIN68DEBUG
		if (traceflag/*&&fdctrace*/)
		{
			FILE *fp;
			static DWORD oldpc;
			int i;
			char buf[200];
			fp=fopen("_trace68.txt", "a");
			for (i=0; i<HSYNC_CLK; i++)
			{
				m68k_disassemble(buf, C68k_Get_Reg(&C68K, C68K_PC));
//				if (MEM[0xa84c0]) /**test=1; */tracing=1000;
//				if (regs.pc==0x9d2a) tracing=5000;
//				if ((regs.pc>=0x2000)&&((regs.pc<=0x8e0e0))) tracing=50000;
//				if (regs.pc<0x10000) tracing=1;
//				if ( (regs.pc&1) )
//				fp=fopen("_trace68.txt", "a");
//				if ( (regs.pc==0x7176) /*&& (Memory_ReadW(oldpc)==0xff1a)*/ ) tracing=100;
//				if ( (/*((regs.pc>=0x27000) && (regs.pc<=0x29000))||*/((regs.pc>=0x27000) && (regs.pc<=0x29000))) && (oldpc!=regs.pc))
				if (/*fdctrace&&*/(oldpc != C68k_Get_Reg(&C68K, C68K_PC)))
				{
//					//tracing--;
				  fprintf(fp, "D0:%08X D1:%08X D2:%08X D3:%08X D4:%08X D5:%08X D6:%08X D7:%08X CR:%04X\n", C68K.D[0], C68K.D[1], C68K.D[2], C68K.D[3], C68K.D[4], C68K.D[5], C68K.D[6], C68K.D[7], 0/* xxx �Ȥꤢ����0 C68K.ccr */);
				  fprintf(fp, "A0:%08X A1:%08X A2:%08X A3:%08X A4:%08X A5:%08X A6:%08X A7:%08X SR:%04X\n", C68K.A[0], C68K.A[1], C68K.A[2], C68K.A[3], C68K.A[4], C68K.A[5], C68K.A[6], C68K.A[7], C68k_Get_Reg(&C68K, C68K_SR) >> 8/* regs.sr_high*/);
					fprintf(fp, "<%04X> (%08X ->) %08X : %s\n", Memory_ReadW(C68k_Get_Reg(&C68K, C68K_PC)), oldpc, C68k_Get_Reg(&C68K, C68K_PC), buf);
				}
				#ifdef CYCLONE
				oldpc = m68000_get_reg(M68K_PC);
				// * C68KICount = 1;
				m68000_execute(1);
				#else
				oldpc = C68k_Get_Reg(&C68K, C68K_PC);
				//C68K.ICount = 1;
				//C68k_Exec(&C68K, C68K.ICount);
				C68k_Exec(&C68K, 1);
				#endif
			}
			fclose(fp);
			usedclk = clk_line = HSYNC_CLK;
			clk_count = clk_next;
		}
		else
#endif
		{
			//C68K.ICount = n;
			#ifdef CYCLONE
			m68000_execute(n);
			#else
			C68k_Exec(&C68K, n);
			#endif
			m = (n-m68000_ICountBk);
			//m = (n-C68K.ICount-m68000_ICountBk);			// clockspeed progress
			ClkUsed += m*10;
			usedclk = ClkUsed/clkdiv;
			clk_line += usedclk;
			ClkUsed -= usedclk*clkdiv;
			ICount -= m;
			clk_count += m;
			//C68K.ICount = m68000_ICountBk = 0;
		}

		MFP_Timer(usedclk);
		RTC_Timer(usedclk);
		DMA_Exec(0);
		DMA_Exec(1);
		DMA_Exec(2);

		if ( clk_count>=clk_next ) {
			//OPM_RomeoOut(Config.BufferSize*5);
			//MIDI_DelayOut((Config.MIDIAutoDelay)?(Config.BufferSize*5):Config.MIDIDelay);
			MFP_TimerA();
			if ( (MFP[MFP_AER]&0x40)&&(vline==CRTC_IntLine) )
				MFP_Int(1);
			if ( (!DispFrame)&&(vline>=CRTC_VSTART)&&(vline<CRTC_VEND) ) {
				if ( CRTC_VStep==1 ) {				// HighReso 256dot��2���ɤߡ�
					if ( vline%2 )
						WinDraw_DrawLine();
				} else if ( CRTC_VStep==4 ) {		// LowReso 512dot
					WinDraw_DrawLine();				// 1��������2�������ʥ��󥿡��졼����
					VLINE++;
					WinDraw_DrawLine();
				} else {							// High 512dot / Low 256dot
					WinDraw_DrawLine();
				}
			}

			ADPCM_PreUpdate(clk_line);
			OPM_Timer(clk_line);
			MIDI_Timer(clk_line);
#ifndef	NO_MERCURY
			Mcry_PreUpdate(clk_line);
#endif

			KeyIntCnt++;
			if ( KeyIntCnt>(VLINE_TOTAL/4) ) {
				KeyIntCnt = 0;
				Keyboard_Int();
			}
			MouseIntCnt++;
			if ( MouseIntCnt>(VLINE_TOTAL/8) ) {
				MouseIntCnt = 0;
				SCC_IntCheck();
			}
			DSound_Send0(clk_line);

			vline++;
			clk_next  = (clk_total*(vline+1))/VLINE_TOTAL;
			hsync = 1;
		}
	} while ( vline<VLINE_TOTAL );