Example #1
0
int DisplayRSPCommand (DWORD location, int InsertPos)
{
	uint32_t OpCode;
	DWORD LinesUsed = 1, status;
	BOOL Redraw = FALSE;

	RSP_LW_IMEM(location, &OpCode);

	status = 0;
	if (location == *PrgCount) {status = RSP_Status_PC; }
	if (CheckForRSPBPoint(location)) { status |= RSP_Status_BP; }
	if (RSPCommandLine[InsertPos].opcode != OpCode) { Redraw = TRUE; }
	if (RSPCommandLine[InsertPos].Location != location) { Redraw = TRUE; }
	if (RSPCommandLine[InsertPos].status != status) { Redraw = TRUE; }
	if (Redraw)
	{
		RSPCommandLine[InsertPos].Location = location;
		RSPCommandLine[InsertPos].status = status;
		RSPCommandLine[InsertPos].opcode = OpCode;
		sprintf(RSPCommandLine[InsertPos].String," 0x%03X\t%s",location, 
			RSPOpcodeName ( OpCode, location ));
		if ( SendMessage(hList,LB_GETCOUNT,0,0) <= InsertPos)
		{
			SendMessage(hList,LB_INSERTSTRING,(WPARAM)InsertPos, (LPARAM)location);
		}
		else
		{
			RECT ItemRC;
			SendMessage(hList,LB_GETITEMRECT,(WPARAM)InsertPos, (LPARAM)&ItemRC);
			RedrawWindow(hList,&ItemRC,NULL, RDW_INVALIDATE );
		}
	}
	return LinesUsed;
}
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 #3
0
LRESULT CALLBACK RSP_Commands_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	case WM_INITDIALOG:
		RSPCommandshWnd = hDlg;
		RSP_Commands_Setup( hDlg );
		break;
	case WM_MOVE:
		//StoreCurrentWinPos("RSP Commands",hDlg);
		break;
	case WM_DRAWITEM:
		if (wParam == IDC_LIST)
		{
			DrawRSPCommand (lParam);
		}
		break;
	case WM_PAINT:
		Paint_RSP_Commands( hDlg );
		RedrawWindow(hScrlBar,NULL,NULL, RDW_INVALIDATE |RDW_ERASE);
		return TRUE;
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDC_LIST:
			if (HIWORD(wParam) == LBN_DBLCLK )
			{
				LRESULT Selected;
				DWORD Location;

				Selected = SendMessage(hList, LB_GETCURSEL, 0, 0);
				Location = RSPCommandLine[Selected].Location;
				if (Location != (DWORD)-1)
				{
					if (CheckForRSPBPoint(Location))
					{
						RemoveRSPBreakPoint(Location);
					}
					else
					{
						AddRSP_BPoint(Location, FALSE);
					}
					RefreshRSPCommands();
				}
			}
			break;
		case IDC_ADDRESS:
			if (HIWORD(wParam) == EN_CHANGE )
			{
				RefreshRSPCommands();
			}
			break;
		case IDC_GO_BUTTON:
			SetRSPCommandToRunning();
			break;
		case IDC_BREAK_BUTTON:	
			SetRSPCommandToStepping();
			break;
		case IDC_STEP_BUTTON:			
			WaitingForStep = FALSE;
			break;
		/*case IDC_SKIP_BUTTON:
			SkipNextRSPOpCode = TRUE;
			WaitingFor_RSPStep   = FALSE;
			break;*/
		case IDC_BP_BUTTON:	
			if (DebugInfo.Enter_BPoint_Window != NULL)
			{
				DebugInfo.Enter_BPoint_Window();
			}
			break;
		case IDC_RSP_REGISTERS_BUTTON:
			Enter_RSP_Register_Window();
			break;
		case IDC_R4300I_DEBUGGER_BUTTON: 
			if (DebugInfo.Enter_R4300i_Commands_Window != NULL)
			{
				DebugInfo.Enter_R4300i_Commands_Window();
			}
			break;
		case IDC_R4300I_REGISTERS_BUTTON:
			if (DebugInfo.Enter_R4300i_Register_Window != NULL)
			{
				DebugInfo.Enter_R4300i_Register_Window();
			}
			break;
		case IDC_MEMORY_BUTTON:
			if (DebugInfo.Enter_Memory_Window != NULL)
			{
				DebugInfo.Enter_Memory_Window();
			}
			break;
		case IDCANCEL:			
			EndDialog( hDlg, IDCANCEL );
			break;
		}
		break;
	case WM_VSCROLL:
		if ((HWND)lParam == hScrlBar)
		{
			DWORD location;
			char Value[20];
			SCROLLINFO si;

			GetWindowText(hAddress,Value,sizeof(Value));
			location = AsciiToHex(Value) & ~3;

			switch (LOWORD(wParam))
			{
			case SB_THUMBTRACK:
				sprintf(Value,"%03X",((short int)HIWORD(wParam) << 2 ));
				SetWindowText(hAddress,Value);
				si.cbSize = sizeof(si);
				si.fMask  = SIF_POS;
				si.nPos   = (short int)HIWORD(wParam);
				SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
				break;
			case SB_LINEDOWN:
				if (location < 0xF88)
				{
					sprintf(Value,"%03X",location + 0x4);
					SetWindowText(hAddress,Value);
					si.cbSize = sizeof(si);
					si.fMask  = SIF_POS;
					si.nPos   = ((location + 0x4) >> 2);
					SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
				}
				else
				{
					sprintf(Value,"%03X",0xF88);
					SetWindowText(hAddress,Value);
					si.cbSize = sizeof(si);
					si.fMask  = SIF_POS;
					si.nPos   = (0xFFC >> 2);
					SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
				}
				break;
			case SB_LINEUP:
				if (location > 0x4 )
				{
					sprintf(Value,"%03X",location - 0x4);
					SetWindowText(hAddress,Value);
					si.cbSize = sizeof(si);
					si.fMask  = SIF_POS;
					si.nPos   = ((location - 0x4) >> 2);
					SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);
				}
Example #4
0
void DrawRSPCommand ( LPARAM lParam )
{
	char Command[150], Offset[30], Instruction[30], Arguments[40];
	int printed_offset, printed_instruction, printed_arguments;
	LPDRAWITEMSTRUCT ditem;
	COLORREF oldColor = {0};
	int ResetColor;
	HBRUSH hBrush;
	RECT TextRect;
	char *p1, *p2;

	ditem  = (LPDRAWITEMSTRUCT)lParam;
	strcpy(Command, RSPCommandLine[ditem->itemID].String);

	if (strchr(Command,'\t'))
	{
		p1 = strchr(Command,'\t');
		printed_offset = sprintf(Offset, "%.*s", p1 - Command, Command);
		p1++;
		if (strchr(p1,'\t'))
		{
			p2 = strchr(p1,'\t');
			printed_instruction = sprintf(Instruction, "%.*s", p2 - p1, p1);
			printed_arguments   = sprintf(Arguments, "%s", p2 + 1);
		}
		else
		{
			printed_instruction = sprintf(Instruction, "%s", p1);
			printed_arguments   = sprintf(Arguments, "\0");
		}
		Command[0] = '\0';
	}
	else
	{
		printed_offset      = sprintf(Offset, "\0");
		printed_instruction = sprintf(Instruction, "\0");
		printed_arguments   = sprintf(Arguments, "\0");
	}

	if (printed_offset < 0 || printed_instruction < 0 || printed_arguments < 0)
	{
		DisplayError("Failed to sprintf from item %u.", ditem -> itemID);
	}

	if (*PrgCount == RSPCommandLine[ditem->itemID].Location)
	{
		ResetColor = TRUE;
		hBrush     = (HBRUSH)(COLOR_HIGHLIGHT + 1);
		oldColor   = SetTextColor(ditem->hDC,RGB(255,255,255));
	}
	else
	{
		ResetColor = FALSE;
		hBrush     = (HBRUSH)GetStockObject(WHITE_BRUSH);
	}

	if (CheckForRSPBPoint( RSPCommandLine[ditem->itemID].Location ))
	{
		ResetColor = TRUE;
		if (*PrgCount == RSPCommandLine[ditem->itemID].Location)
		{
			SetTextColor(ditem->hDC,RGB(255,0,0));
		}
		else
		{
			oldColor = SetTextColor(ditem->hDC,RGB(255,0,0));
		}
	}

	FillRect( ditem->hDC, &ditem->rcItem,hBrush);
	SetBkMode( ditem->hDC, TRANSPARENT );

	if (Command[0] == '\0')
	{
		SetRect(&TextRect,ditem->rcItem.left,ditem->rcItem.top, ditem->rcItem.left + 83,
			ditem->rcItem.bottom);
		DrawText(
			ditem->hDC,
			&Offset[0], printed_offset,
			&TextRect,
			DT_SINGLELINE | DT_VCENTER
		);

		SetRect(&TextRect,ditem->rcItem.left + 83,ditem->rcItem.top, ditem->rcItem.left + 165,
			ditem->rcItem.bottom);
		DrawText(
			ditem->hDC,
			&Instruction[0], printed_instruction,
			&TextRect,
			DT_SINGLELINE | DT_VCENTER
		);

		SetRect(&TextRect,ditem->rcItem.left + 165,ditem->rcItem.top, ditem->rcItem.right,
			ditem->rcItem.bottom);
		DrawText(
			ditem->hDC,
			&Arguments[0], printed_arguments,
			&TextRect,
			DT_SINGLELINE | DT_VCENTER
		);
	}
	else
	{
		DrawText(
			ditem->hDC,
			&Command[0], (signed int)strlen(Command),
			&ditem->rcItem,
			DT_SINGLELINE | DT_VCENTER
		);
	}

	if (ResetColor == TRUE) {
		SetTextColor( ditem->hDC, oldColor );
	}
}
Example #5
0
void DrawRSPCommand ( LPARAM lParam )
{
	char Command[150], Offset[30], Instruction[30], Arguments[40];
	LPDRAWITEMSTRUCT ditem;
	COLORREF oldColor = {0};
	int ResetColor;
	HBRUSH hBrush;
	RECT TextRect;
	char *p1, *p2;

	ditem  = (LPDRAWITEMSTRUCT)lParam;
	strcpy(Command, RSPCommandLine[ditem->itemID].String);

	if (strchr(Command,'\t'))
	{
		p1 = strchr(Command,'\t');
		sprintf(Offset,"%.*s",p1 - Command, Command);
		p1++;
		if (strchr(p1,'\t'))
		{
			p2 = strchr(p1,'\t');
			sprintf(Instruction,"%.*s",p2 - p1, p1);
			sprintf(Arguments,"%s",p2 + 1);
		}
		else
		{
			sprintf(Instruction,"%s",p1);
			sprintf(Arguments,"\0");
		}
		sprintf(Command,"\0");
	}
	else
	{
		sprintf(Offset,"\0");
		sprintf(Instruction,"\0");
		sprintf(Arguments,"\0");
	}

	if (*PrgCount == RSPCommandLine[ditem->itemID].Location)
	{
		ResetColor = TRUE;
		hBrush     = (HBRUSH)(COLOR_HIGHLIGHT + 1);
		oldColor   = SetTextColor(ditem->hDC,RGB(255,255,255));
	}
	else
	{
		ResetColor = FALSE;
		hBrush     = (HBRUSH)GetStockObject(WHITE_BRUSH);
	}

	if (CheckForRSPBPoint( RSPCommandLine[ditem->itemID].Location ))
	{
		ResetColor = TRUE;
		if (*PrgCount == RSPCommandLine[ditem->itemID].Location)
		{
			SetTextColor(ditem->hDC,RGB(255,0,0));
		}
		else
		{
			oldColor = SetTextColor(ditem->hDC,RGB(255,0,0));
		}
	}

	FillRect( ditem->hDC, &ditem->rcItem,hBrush);
	SetBkMode( ditem->hDC, TRANSPARENT );

	if (strlen (Command) == 0 )
	{
		SetRect(&TextRect,ditem->rcItem.left,ditem->rcItem.top, ditem->rcItem.left + 83,
			ditem->rcItem.bottom);
		DrawText(ditem->hDC,Offset,strlen(Offset), &TextRect,DT_SINGLELINE | DT_VCENTER);

		SetRect(&TextRect,ditem->rcItem.left + 83,ditem->rcItem.top, ditem->rcItem.left + 165,
			ditem->rcItem.bottom);
		DrawText(ditem->hDC,Instruction,strlen(Instruction), &TextRect,DT_SINGLELINE | DT_VCENTER);

		SetRect(&TextRect,ditem->rcItem.left + 165,ditem->rcItem.top, ditem->rcItem.right,
			ditem->rcItem.bottom);
		DrawText(ditem->hDC,Arguments,strlen(Arguments), &TextRect,DT_SINGLELINE | DT_VCENTER);
	}
	else
	{
		DrawText(ditem->hDC,Command,strlen(Command), &ditem->rcItem,DT_SINGLELINE | DT_VCENTER);
	}

	if (ResetColor == TRUE) {
		SetTextColor( ditem->hDC, oldColor );
	}
}