DWORD RunInterpreterCPU(DWORD Cycles) {
	DWORD CycleCount;
	RSP_Running = TRUE;
	Enable_RSP_Commands_Window();
	CycleCount = 0;

	while (RSP_Running) {
		if (NoOfBpoints != 0) {
			if (CheckForRSPBPoint(*PrgCount)) {
				if (InRSPCommandsWindow) {
					Enter_RSP_Commands_Window();
					if (Stepping_Commands) {
						DisplayError ( "Encounted a R4300i Breakpoint" );
					} else {
						DisplayError ( "Encounted a R4300i Breakpoint\n\nNow Stepping" );
						SetRSPCommandViewto( *PrgCount );
						SetRSPCommandToStepping();
					}
				} else {
					DisplayError ( "Encounted a RSP Breakpoint\n\nEntering Command Window" );
					Enter_RSP_Commands_Window();
				}
			}
		}
		
		if (Stepping_Commands) {
			WaitingForStep = TRUE;
			SetRSPCommandViewto( *PrgCount );
			UpdateRSPRegistersScreen();
			while ( WaitingForStep == TRUE ){ 
				Sleep(20);						
				if (!Stepping_Commands) {
					WaitingForStep = FALSE;
				}
			}
		}

		RSP_LW_IMEM(*PrgCount, &RSPOpC.Hex);
		((void (*)()) RSP_Opcode[ RSPOpC.op ])();

		switch (RSP_NextInstruction) {
		case NORMAL: 
			*PrgCount = (*PrgCount + 4) & 0xFFC; 
			break;
		case DELAY_SLOT:
			RSP_NextInstruction = JUMP;
			*PrgCount = (*PrgCount + 4) & 0xFFC; 
			break;
		case JUMP:
			RSP_NextInstruction = NORMAL;
			*PrgCount  = RSP_JumpTo;
			break;
		}
	}
	*PrgCount -= 4;

	return Cycles;
}
Example #2
0
__declspec(dllexport) DWORD DoRspCycles ( DWORD Cycles ) {
    extern BOOL AudioHle, GraphicsHle;
    DWORD TaskType = *(DWORD*)(RSPInfo.DMEM + 0xFC0);

    /*	if (*RSPInfo.SP_STATUS_REG & SP_STATUS_SIG0) {
    		*RSPInfo.SP_STATUS_REG &= ~SP_STATUS_SIG0;
    		*RSPInfo.MI_INTR_REG |= MI_INTR_SP;
    		RSPInfo.CheckInterrupts();
    		return Cycles;
    	}
    */
    if (TaskType == 1 && GraphicsHle && *(DWORD*)(RSPInfo.DMEM + 0x0ff0) != 0) {
        if (RSPInfo.ProcessDList != NULL) {
            RSPInfo.ProcessDList();
        }
        *RSPInfo.SP_STATUS_REG |= (0x0203 );
        if ((*RSPInfo.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0 ) {
            *RSPInfo.MI_INTR_REG |= R4300i_SP_Intr;
            RSPInfo.CheckInterrupts();
        }

        *RSPInfo.DPC_STATUS_REG &= ~0x0002;
        return Cycles;
    } else if (TaskType == 2 && AudioHle) {
        if (RSPInfo.ProcessAList != NULL) {
            RSPInfo.ProcessAList();
        }
        *RSPInfo.SP_STATUS_REG |= (0x0203 );
        if ((*RSPInfo.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0 ) {
            *RSPInfo.MI_INTR_REG |= R4300i_SP_Intr;
            RSPInfo.CheckInterrupts();
        }
        return Cycles;
    } else if (TaskType == 7) {
        RSPInfo.ShowCFB();
    }

    Compiler.bAudioUcode = (TaskType == 2) ? TRUE : FALSE;

    /*
    	*RSPInfo.SP_STATUS_REG |= (0x0203 );
    	if ((*RSPInfo.SP_STATUS_REG & SP_STATUS_INTR_BREAK) != 0 ) {
    		*RSPInfo.MI_INTR_REG |= R4300i_SP_Intr;
    		RSPInfo.CheckInterrupts();
    	}
    	//return Cycles;
    */

    if (Profiling && !IndvidualBlock) {
        StartTimer(Timer_RSP_Running);
    }

    WaitForSingleObjectEx(hMutex, 1000 * 100, FALSE);

    if (BreakOnStart)
    {
        Enter_RSP_Commands_Window();
    }
    RSP_MfStatusCount = 0;

    switch (CPUCore) {
    case RecompilerCPU:
        RunRecompilerCPU(Cycles);
        break;
    case InterpreterCPU:
        RunInterpreterCPU(Cycles);
        break;
    }
    ReleaseMutex(hMutex);

    if (Profiling && !IndvidualBlock) {
        StartTimer(Timer_R4300_Running);
    }

    return Cycles;
}