/*************************************************
*            BK Emulator for Window 3.0          *
*************************************************/

/*
File: RegDumpDlg.h
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.
*/


#pragma once
#include "afxcmn.h"
#include "resource.h"
#include "GFResizeDialogHelper.h"
#include "MultiEditListCtrl.h"
#include "Debugger.h"
// RegDumpDlg.h : header file
//

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

class CRegDumpDlg : public CDialogEx
{
		GFResizeDialogHelper m_Resizer;
		CDebugger           *m_pDebugger;
		CMultiEditListCtrl   m_listCPU;
		CMultiEditListCtrl   m_listSys;
		CMultiEditListCtrl   m_listAltPro;
		CMultiEditListCtrl   m_listFDD;
		CFont                hFont;
		HACCEL               m_hAccelTable;

		static const UINT m_pListCpuIDs[9];
		static const UINT m_pListSysIDs[2][9];
		static const UINT m_pListSysRegs[2][9];
		static const UINT m_pListAltProIDs[2];
		static const UINT m_pLISTFDDIDs[4];

		//номера колонок для listCPU
		enum
		{
			LISTCPU_NAME_COL = 0,
			LISTCPU_VALUE_COL
		};
		//номера строк для listCPU
		enum
		{
			R0_LINE = 0,
			R1_LINE,
			R2_LINE,
			R3_LINE,
			R4_LINE,
			R5_LINE,
			SP_LINE,
			PC_LINE,
			PSW_LINE
		};

		//номера колонок для listSys
		enum
		{
			LISTSYS_NAME1_COL = 0,
			LISTSYS_VALUE1_COL,
			LISTSYS_NAME2_COL,
			LISTSYS_VALUE2_COL
		};
		//номера строк для listSys, колонки 0,1
		enum
		{
			REG177660_LINE = 0,
			REG177662IN_LINE,
			REG177662OUT_LINE,
			REG177664_LINE,
			REG177714IN_LINE,
			REG177714OUT_LINE,
			REG177716IN_LINE,
			REG177716OUT_TAP_LINE,
			REG177716OUT_MEM_LINE
		};
		//номера строк для listSys, колонки 2,3
		enum
		{
			REG177700_LINE = 0,
			REG177702_LINE,
			REG177704_LINE,
			REG177706_LINE,
			REG177710_LINE,
			REG177712_LINE
		};

		//номера колонок для listAltPro
		enum
		{
			LISTALTPRO_NAME_COL = 0,
			LISTALTPRO_VALUE_COL
		};
		//номера строки для listAltPro
		enum
		{
			ALTPRO_MODE_LINE = 0,
			ALTPRO_CODE_LINE
		};
		//номера строки для listFDD
		enum
		{
			FDDREG177130IN_LINE = 0,
			FDDREG177130OUT_LINE,
			FDDREG177132IN_LINE,
			FDDREG177132OUT_LINE
		};

		enum    {COLUMN_WIDTH = 60};
		enum    {COLUMN_WIDTH_PRT = 70};
		enum    {COLUMN_WIDTH_REG = 38};
		enum    {COLUMN_WIDTH_TXT = 70};

// Construction
	public:
		CRegDumpDlg(CWnd *pParent = NULL);   // standard constructor
		virtual ~CRegDumpDlg();

		enum { IDD = IDD_REGDUMP_DLG };

		void                AttachDebugger(CDebugger *pDbgr)
		{
			m_pDebugger = pDbgr;
		}
		void                SetPSW(WORD value);
		void                SetPortRegs();
		void                SetRegisters();
		void                SetAltProData(int n, WORD value);
		void                SetFDDData(int n, WORD value);
		WORD                GetPSW(CString &strPSW);

	protected:
		virtual void DoDataExchange(CDataExchange *pDX);    // DDX/DDV support
		virtual BOOL PreTranslateMessage(MSG *pMsg);

		void                InitLayout();
		CString             FormatPSW(WORD value);
		void                ResizeList(CMultiEditListCtrl *list, int height);
		// Generated message map functions
		virtual BOOL OnInitDialog();
		virtual void OnOK();
		virtual void OnCancel();
		afx_msg void OnSize(UINT nType, int cx, int cy);
		afx_msg void OnLvnItemchangedMdCpuRegisters(NMHDR *pNMHDR, LRESULT *pResult);
		afx_msg void OnLvnItemchangedMdAltProData(NMHDR *pNMHDR, LRESULT *pResult);
		afx_msg void OnLvnItemchangedMdSysRegisters(NMHDR *pNMHDR, LRESULT *pResult);
		afx_msg void OnLvnItemchangedMdFddData(NMHDR *pNMHDR, LRESULT *pResult);
		DECLARE_MESSAGE_MAP()
};
