/*************************************************
*           BK Emulator v3.8 for Windows         *
*************************************************/

/*
File: RegDumpDlg.cpp
Version: 1.0.0
Written by: Yuriy Kalmykov <kalmykov@stoik.com>
    Copyright (c) 2002-2004 Yuriy Kalmykov

    BK Emulator is a program emulated hardware environment for running
code for BK 0010(01) in different configurations.

    This code may be used in compiled form in any way you desire.
This file or it's parts can't be redistributed without the authors
written consent, but can be modified for your private needs.
    Providing that this notice and the authors name and all copyright
notices remains intact.

    Please, an email me to know how you are using it and where. You can
ask me for any information about this below code or any attendant
knowledge.

    This file is provided "as is" with no expressed or implied warranty.
The author accepts no liability for any damage or loss of business that
this product may cause.
*/


// RegDumpDlg.cpp : implementation file
//

#include "stdafx.h"
#include "RegDumpDlg.h"
#include "afxdialogex.h"
#include "Board.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRegDumpDlg dialog

CRegDumpDlg::CRegDumpDlg(CWnd *pParent /*=NULL*/)
	: CDialogEx(CRegDumpDlg::IDD, pParent)
	, m_pDebugger(NULL)
	, m_hAccelTable(NULL)
	, m_nCurrCPUFreq(0)
{
}

CRegDumpDlg::~CRegDumpDlg()
{
	hFont.DeleteObject();
}

void CRegDumpDlg::DoDataExchange(CDataExchange *pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_MD_CPU_REGISTERS, m_listCPU);
	DDX_Control(pDX, IDC_MD_SYS_REGISTERS, m_listSys);
	DDX_Control(pDX, IDC_MD_ALTPRO_DATA, m_listAltPro);
	DDX_Control(pDX, IDC_MD_FDD_DATA, m_listFDD);
	DDX_Text(pDX, IDC_EDIT_DBG1_CPUFREQ, m_nCurrCPUFreq);
	DDX_Control(pDX, IDC_SPIN_DBG1_CPUFREQ, m_spinCPUFreq);
}


BEGIN_MESSAGE_MAP(CRegDumpDlg, CDialogEx)
	ON_WM_SIZE()
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_MD_CPU_REGISTERS, &CRegDumpDlg::OnLvnItemchangedMdCpuRegisters)
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_MD_SYS_REGISTERS, &CRegDumpDlg::OnLvnItemchangedMdSysRegisters)
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_MD_ALTPRO_DATA, &CRegDumpDlg::OnLvnItemchangedMdAltProData)
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_MD_FDD_DATA, &CRegDumpDlg::OnLvnItemchangedMdFddData)
	ON_EN_CHANGE(IDC_EDIT_DBG1_CPUFREQ, &CRegDumpDlg::OnEnChangeEditDbg1Cpufreq)
	ON_BN_CLICKED(IDC_BUTTON_DBG1_CPUFREQ_DEC, &CRegDumpDlg::OnBnClickedButtonDbg1CpufreqDec)
	ON_BN_CLICKED(IDC_BUTTON_DBG1_CPUFREQ_INC, &CRegDumpDlg::OnBnClickedButtonDbg1CpufreqInc)
	ON_BN_CLICKED(IDC_BUTTON_DBG1_CPUFREQ_BASESET, &CRegDumpDlg::OnBnClickedButtonDbg1CpufreqBaseset)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRegDumpDlg message handlers
const UINT CRegDumpDlg::m_pListCpuIDs[9] =
{
	IDS_MEMORY_R0, IDS_MEMORY_R1, IDS_MEMORY_R2, IDS_MEMORY_R3,
	IDS_MEMORY_R4, IDS_MEMORY_R5, IDS_MEMORY_SP, IDS_MEMORY_PC,
	IDS_MEMORY_PSW
};

const UINT CRegDumpDlg::m_pListSysIDs[2][9] =
{
	{
		IDS_MEMORY_177660, IDS_MEMORY_177662IN, IDS_MEMORY_177662OUT, IDS_MEMORY_177664,
		IDS_MEMORY_177714IN, IDS_MEMORY_177714OUT, IDS_MEMORY_177716IN, IDS_MEMORY_177716OUT_TAP,
		IDS_MEMORY_177716OUT_MEM
	},
	{
		IDS_MEMORY_177700, IDS_MEMORY_177702, IDS_MEMORY_177704, IDS_MEMORY_177706,
		IDS_MEMORY_177710, IDS_MEMORY_177712, 0, 0, 0
	}
};

const UINT CRegDumpDlg::m_pListSysRegs[2][9] =
{
	{
		SYS_PORT_177660, SYS_PORT_177662_IN, SYS_PORT_177662_OUT, SYS_PORT_177664,
		SYS_PORT_177714_IN, SYS_PORT_177714_OUT, SYS_PORT_177716_IN, SYS_PORT_177716_OUT_TAP,
		SYS_PORT_177716_OUT_MEM
	},
	{
		SYS_PORT_177700, SYS_PORT_177702, SYS_PORT_177704, SYS_PORT_177706,
		SYS_PORT_177710, SYS_PORT_177712, 0, 0, 0
	}
};


const UINT CRegDumpDlg::m_pListAltProIDs[2] =
{
	IDS_ALTPRO_MODE, IDS_ALTPRO_CODE
};

const UINT CRegDumpDlg::m_pLISTFDDIDs[4] =
{
	IDS_MEMORY_177130IN, IDS_MEMORY_177130OUT,
	IDS_MEMORY_177132IN, IDS_MEMORY_177132OUT
};

void CRegDumpDlg::ResizeList(CMultiEditListCtrl *list, int height)
{
	CRect rect, irect;
	list->GetWindowRect(&rect);
	ScreenToClient(&rect);
	list->GetItemRect(0, irect, LVIR_BOUNDS);
	int cx = irect.Width() + 4;
	int cy = irect.Height() * height + 4;
	list->SetWindowPos(NULL, rect.left, rect.top, cx, cy, SWP_SHOWWINDOW);
}

BOOL CRegDumpDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	m_hAccelTable = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));
	LOGFONT lf;
	::GetObject((HGDIOBJ)::SendMessage(GetSafeHwnd(), WM_GETFONT, 0, 0), sizeof(LOGFONT), &lf);
	_tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Courier New\0"));

	if (hFont.CreateFontIndirect(&lf) == NULL)
	{
		_tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Lucida Console\0"));
		hFont.CreateFontIndirect(&lf);
	}

	// Создадим список регистров CPU
	// 2 колонки, 1-я - имя регистра, 2-я - его значение
	CString strHeader;
	m_listCPU.SetFont(&hFont, FALSE);
	m_listCPU.InsertColumn(LISTCPU_NAME_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH_REG);
	m_listCPU.InsertColumn(LISTCPU_VALUE_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH);

	for (int i = R0_LINE; i <= PSW_LINE; ++i)
	{
		strHeader.LoadString(m_pListCpuIDs[i]);
		m_listCPU.InsertItem(i, strHeader);
		m_listCPU.SetItem(i, LISTCPU_VALUE_COL, LVIF_TEXT, NULL, 0, 0, 0, 0);
	}

	m_listCPU.SetColumnBkColor(::GetSysColor(COLOR_BTNFACE), LISTCPU_NAME_COL);
	m_listCPU.EnableColumnEdit(FALSE, LISTCPU_NAME_COL);
	m_listCPU.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	ResizeList(&m_listCPU, PSW_LINE + 1);
	// Создадим список портов и системных регистров
	// 4 колонки, 1-я и 3-я - адрес порта/регистра, 2-я и 4-я - их значения
	m_listSys.SetFont(&hFont, FALSE);
	m_listSys.InsertColumn(LISTSYS_NAME1_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH_PRT);
	m_listSys.InsertColumn(LISTSYS_VALUE1_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH);
	m_listSys.InsertColumn(LISTSYS_NAME2_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH);
	m_listSys.InsertColumn(LISTSYS_VALUE2_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH);

	for (int i = REG177660_LINE; i <= REG177716OUT_MEM_LINE; ++i)
	{
		strHeader.LoadString(m_pListSysIDs[0][i]);
		m_listSys.InsertItem(i, strHeader);
		m_listSys.SetItem(i, LISTSYS_VALUE1_COL, LVIF_TEXT, NULL, 0, 0, 0, 0);

		if (m_pListSysIDs[1][i])
		{
			strHeader.LoadString(m_pListSysIDs[1][i]);
		}
		else
		{
			strHeader = _T("");
		}

		m_listSys.SetItem(i, LISTSYS_NAME2_COL, LVIF_TEXT, strHeader, 0, 0, 0, 0);
		m_listSys.SetItem(i, LISTSYS_VALUE2_COL, LVIF_TEXT, NULL, 0, 0, 0, 0);
	}

	m_listSys.SetColumnBkColor(::GetSysColor(COLOR_BTNFACE), LISTSYS_NAME1_COL);
	m_listSys.EnableColumnEdit(FALSE, LISTSYS_NAME1_COL);
	m_listSys.SetColumnBkColor(::GetSysColor(COLOR_BTNFACE), LISTSYS_NAME2_COL);
	m_listSys.EnableColumnEdit(FALSE, LISTSYS_NAME2_COL);

	//ещё надо запретить редактировать свободные ячейки в 3-м столбце
	for (int i = REG177712_LINE + 1; i <= REG177716OUT_MEM_LINE; ++i)
	{
		m_listSys.EnableEdit(FALSE, i, LISTSYS_VALUE2_COL);
	}

	m_listSys.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	ResizeList(&m_listSys, REG177716OUT_MEM_LINE + 1);
	//создание списка режимов AltPro
	m_listAltPro.SetFont(&hFont, FALSE);
	m_listAltPro.InsertColumn(LISTALTPRO_NAME_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH_PRT);
	m_listAltPro.InsertColumn(LISTALTPRO_VALUE_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH);

	for (int i = ALTPRO_MODE_LINE; i <= ALTPRO_CODE_LINE; ++i)
	{
		strHeader.LoadString(m_pListAltProIDs[i]);
		m_listAltPro.InsertItem(i, strHeader);
		m_listAltPro.SetItem(i, LISTALTPRO_VALUE_COL, LVIF_TEXT, NULL, 0, 0, 0, 0);
	}

	m_listAltPro.SetColumnBkColor(::GetSysColor(COLOR_BTNFACE), LISTALTPRO_NAME_COL);
	m_listAltPro.EnableColumnEdit(FALSE, LISTALTPRO_NAME_COL);
	m_listAltPro.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	ResizeList(&m_listAltPro, ALTPRO_CODE_LINE + 1);
	// Создадим список регистров FDD
	// 2 колонки, 1-я - имя регистра, 2-я - его значение
	m_listFDD.SetFont(&hFont, FALSE);
	m_listFDD.InsertColumn(LISTCPU_NAME_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH_PRT);
	m_listFDD.InsertColumn(LISTCPU_VALUE_COL, LPSTR_TEXTCALLBACK, LVCFMT_LEFT, COLUMN_WIDTH);

	for (int i = FDDREG177130IN_LINE; i <= FDDREG177132OUT_LINE; ++i)
	{
		strHeader.LoadString(m_pLISTFDDIDs[i]);
		m_listFDD.InsertItem(i, strHeader);
		m_listFDD.SetItem(i, LISTCPU_VALUE_COL, LVIF_TEXT, NULL, 0, 0, 0, 0);
	}

	m_listFDD.SetColumnBkColor(::GetSysColor(COLOR_BTNFACE), LISTCPU_NAME_COL);
	m_listFDD.EnableColumnEdit(FALSE, LISTCPU_NAME_COL);
	m_listFDD.EnableColumnEdit(FALSE, LISTCPU_VALUE_COL); //запретим редактировать. только для просмотра
	m_listFDD.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	ResizeList(&m_listFDD, FDDREG177132OUT_LINE + 1);
	InitLayout();
	return TRUE; // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
void CRegDumpDlg::AttachDebugger(CDebugger *pDbgr)
{
	m_pDebugger = pDbgr;
}
void CRegDumpDlg::SetFreqParam()
{
	CMotherBoard *pChip = m_pDebugger->GetChip();
	ASSERT(pChip);
	m_nCurrCPUFreq = pChip->GetCPUFreq();
	m_spinCPUFreq.SetRange32(pChip->GetLowBound(), pChip->GetHighBound());
	m_spinCPUFreq.SetPos32(m_nCurrCPUFreq);
	m_spinCPUFreq.SetBuddy(GetDlgItem(IDC_EDIT_DBG1_CPUFREQ));
	UpdateData(FALSE);
}
//отменяем действие кнопок enter и esc в диалоге
void CRegDumpDlg::OnOK()
{
}

void CRegDumpDlg::OnCancel()
{
}


void CRegDumpDlg::InitLayout()
{
	// Create layout
	m_Resizer.Init(this);
	m_Resizer.AddCtrl(IDC_MD_CPU_REGISTERS, DT_LEFT | DT_TOP, TRUE, TRUE);
	m_Resizer.AddCtrl(IDC_MD_SYS_REGISTERS, DT_LEFT | DT_TOP, TRUE, TRUE);
	m_Resizer.AddCtrl(IDC_MD_ALTPRO_DATA, DT_LEFT | DT_TOP, TRUE, TRUE);
	m_Resizer.AddCtrl(IDC_MD_FDD_DATA, DT_LEFT | DT_TOP, TRUE, TRUE);
}


void CRegDumpDlg::OnSize(UINT nType, int cx, int cy)
{
	CDialogEx::OnSize(nType, cx, cy);
	// Resize layout to current window size
	m_Resizer.OnSize(cx, cy);
}


void CRegDumpDlg::SetPSW(WORD value)
{
	m_listCPU.SetItemWithModifiedASCII(FormatPSW(value), PSW_LINE, 1);
}


WORD CRegDumpDlg::GetPSW(CString &strPSW)
{
	strPSW.MakeUpper();
	strPSW.Trim();
	int strLength = strPSW.GetLength();
	WORD psw = 0;

	if (strLength) //если что-то есть
	{
//		хоть мы и имеем доступными по записи все 3 бита приоритета PSW, но реально
//		используется только один 7й бит. и отображать приоритет цифрой - не очень наглядно.
//      TCHAR p = strPSW[0]; //смотрим, какой символ первый
//
//      if ((_T('0') <= p) && (p <= _T('7'))) //если цифра 0..7
//      {
//          psw |= ((WORD)p & 07) << 5; //то это приоритет
//      }

		//если что-то другое, то проверим.
		//все остальные символы могут быть любыми, но воспринимаются только те, что нужны.
		//причём порядок следования не важен, количество символов не важно
		for (int n = 0; n < strLength; n++)
		{
			switch (strPSW[n])
			{
				case _T('C'):
					psw |= PSW_C;
					break;

				case _T('V'):
					psw |= PSW_V;
					break;

				case _T('Z'):
					psw |= PSW_Z;
					break;

				case _T('N'):
					psw |= PSW_N;
					break;

				case _T('T'):
					psw |= PSW_T;
					break;

				case _T('P'):
					psw |= PSW_P;
					break;
			}
		}
	}

	return psw;
}


CString CRegDumpDlg::FormatPSW(WORD value)
{
	CString strPSW;
	//strPSW = (TCHAR)(((value & 0340) >> 5) + 060);
	strPSW  = ((value & PSW_P) ? _T('P') : _T('-'));
	strPSW += ((value & PSW_T) ? _T('T') : _T('-'));
	strPSW += ((value & PSW_N) ? _T('N') : _T('-'));
	strPSW += ((value & PSW_Z) ? _T('Z') : _T('-'));
	strPSW += ((value & PSW_V) ? _T('V') : _T('-'));
	strPSW += ((value & PSW_C) ? _T('C') : _T('-'));
	return strPSW;
}

void CRegDumpDlg::SetPortRegs()
{
	if (m_pDebugger)
	{
		for (int i = REG177660_LINE; i <= REG177716OUT_MEM_LINE; ++i)
		{
			m_listSys.SetItemWithModified(m_pDebugger->GetPortValue(m_pListSysRegs[0][i]), i, LISTSYS_VALUE1_COL);
		}

		for (int i = REG177700_LINE; i <= REG177712_LINE; ++i)
		{
			m_listSys.SetItemWithModified(m_pDebugger->GetPortValue(m_pListSysRegs[1][i]), i, LISTSYS_VALUE2_COL);
		}
	}
}

void CRegDumpDlg::SetRegisters()
{
	if (m_pDebugger)
	{
		for (int i = R0_LINE; i <= PC_LINE; ++i)
		{
			m_listCPU.SetItemWithModified(m_pDebugger->GetRegister(i), i, LISTCPU_VALUE_COL);
		}

		SetPSW(m_pDebugger->GetPSW());
	}
}

void CRegDumpDlg::SetAltProData()
{
	if (m_pDebugger)
	{
		m_listAltPro.SetItemWithModified(m_pDebugger->GetAltProData(ALTPRO_MODE_LINE), ALTPRO_MODE_LINE, LISTALTPRO_VALUE_COL);
		m_listAltPro.SetItemWithModified(m_pDebugger->GetAltProData(ALTPRO_CODE_LINE), ALTPRO_CODE_LINE, LISTALTPRO_VALUE_COL);
	}
}

void CRegDumpDlg::SetFDDData()
{
	if (m_pDebugger)
	{
		for (int i = FDDREG177130IN_LINE; i <= FDDREG177132OUT_LINE; ++i)
		{
			m_listFDD.SetItemWithModified(m_pDebugger->GetFDDData(i), i, LISTCPU_VALUE_COL);
		}
	}
}


void CRegDumpDlg::OnLvnItemchangedMdCpuRegisters(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLISTVIEW pNMListView = reinterpret_cast<LPNMLISTVIEW >(pNMHDR);

	if (pNMListView->iSubItem == LISTCPU_VALUE_COL)
	{
		ASSERT(pNMListView->iItem <= R_PSW);
		int addr = pNMListView->iItem;
		CString *str = reinterpret_cast<CString *>(pNMListView->lParam);
		WORD value = (addr == R_PSW) ?
		             GetPSW(*str) : OctStringToWord(*str);
		m_listCPU.SetEndEdit(addr, pNMListView->iSubItem);

		if (m_pDebugger)
		{
			m_pDebugger->OnDebugModify_Regs(addr, value);
		}

		if (addr == R_PSW)
		{
			SetPSW(value);
		}
		else
		{
			m_listCPU.SetItemWithModified(value, addr, pNMListView->iSubItem);
		}
	}

	*pResult = S_OK;
}

void CRegDumpDlg::OnLvnItemchangedMdAltProData(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLISTVIEW pNMListView = reinterpret_cast<LPNMLISTVIEW >(pNMHDR);

	if (pNMListView->iSubItem == ALTPRO_CODE_LINE)
	{
		int addr = pNMListView->iItem;
		CString *str = reinterpret_cast<CString *>(pNMListView->lParam);
		WORD value = OctStringToWord(*str);
		m_listAltPro.SetEndEdit(addr, pNMListView->iSubItem);

		if (m_pDebugger)
		{
			m_pDebugger->OnDebugModify_AltProData(addr, value);
		}

		m_listAltPro.SetItemWithModified(value, addr, pNMListView->iSubItem);
		//Тут надо принудительно обновить содержимое дампера
		::SendMessage(AfxGetMainWnd()->GetSafeHwnd(), WM_MEMDUMP_NEED_UPDATE, 0, 0);
	}

	*pResult = S_OK;
}


void CRegDumpDlg::OnLvnItemchangedMdSysRegisters(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLISTVIEW pNMListView = reinterpret_cast<LPNMLISTVIEW >(pNMHDR);
	*pResult = S_OK;
	int addr = -1;

	if (pNMListView->iSubItem == LISTSYS_VALUE1_COL)
	{
		ASSERT(pNMListView->iItem <= REG177716OUT_MEM_LINE);
		addr = m_pListSysRegs[0][pNMListView->iItem];
	}
	else if (pNMListView->iSubItem == LISTSYS_VALUE2_COL)
	{
		ASSERT(pNMListView->iItem <= REG177712_LINE);
		addr = m_pListSysRegs[1][pNMListView->iItem];
	}
	else
	{
		return;
	}

	CString *str = reinterpret_cast<CString *>(pNMListView->lParam);
	WORD value = OctStringToWord(*str);
	m_listSys.SetEndEdit(pNMListView->iItem, pNMListView->iSubItem);

	if (m_pDebugger)
	{
		m_pDebugger->OnDebugModify_Ports(addr, value);
	}

	m_listSys.SetItemWithModified(value, pNMListView->iItem, pNMListView->iSubItem);
}

void CRegDumpDlg::OnLvnItemchangedMdFddData(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW >(pNMHDR);
	// TODO: добавьте свой код обработчика уведомлений
	*pResult = S_OK;
}

//для того, чтобы акселераторы работали, их надо загрузить и в этот диалог
//и передавать главному фрейму.
// способа проще найти не получилось.
BOOL CRegDumpDlg::PreTranslateMessage(MSG *pMsg)
{
	if (m_hAccelTable)
	{
		if (::TranslateAccelerator(AfxGetMainWnd()->GetSafeHwnd(), m_hAccelTable, pMsg))
		{
			return TRUE;
		}
	}

	return CDialogEx::PreTranslateMessage(pMsg);
}



void CRegDumpDlg::OnEnChangeEditDbg1Cpufreq()
{
	// TODO:  Если это элемент управления RICHEDIT, то элемент управления не будет
	// send this notification unless you override the CDialogEx::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	// TODO:  Добавьте код элемента управления
	UpdateData(TRUE);
	CMotherBoard *pChip = m_pDebugger->GetChip();
	ASSERT(pChip);

	if (m_nCurrCPUFreq < pChip->GetLowBound())
	{
		m_nCurrCPUFreq = pChip->GetLowBound();
	}
	else if (m_nCurrCPUFreq > pChip->GetHighBound())
	{
		m_nCurrCPUFreq = pChip->GetHighBound();
	}

	pChip->SetCPUFreq(m_nCurrCPUFreq);
}


void CRegDumpDlg::OnBnClickedButtonDbg1CpufreqDec()
{
	// TODO: добавьте свой код обработчика уведомлений
	CMotherBoard *pChip = m_pDebugger->GetChip();
	ASSERT(pChip);

	if (pChip->CanSlowDown())
	{
		pChip->SlowdownCPU();
		m_nCurrCPUFreq = pChip->GetCPUFreq();
		UpdateData(FALSE);
	}
}


void CRegDumpDlg::OnBnClickedButtonDbg1CpufreqInc()
{
	// TODO: добавьте свой код обработчика уведомлений
	CMotherBoard *pChip = m_pDebugger->GetChip();
	ASSERT(pChip);

	if (pChip->CanAccelerate())
	{
		pChip->AccelerateCPU();
		m_nCurrCPUFreq = pChip->GetCPUFreq();
		UpdateData(FALSE);
	}
}


void CRegDumpDlg::OnBnClickedButtonDbg1CpufreqBaseset()
{
	// TODO: добавьте свой код обработчика уведомлений
	CMotherBoard *pChip = m_pDebugger->GetChip();
	ASSERT(pChip);
	pChip->NormalizeCPU();
	m_nCurrCPUFreq = pChip->GetCPUFreq();
	UpdateData(FALSE);
}
