
/***************************************************************************
**
**    $Header:   D:/EPSLDV1/SRC/LOG/NWMEM.H__   1.8   20 Jun 1996 09:26:12   ZJRD  $
**
**    $Log:   D:/EPSLDV1/SRC/LOG/NWMEM.H__  $
** 
**    Rev 1.8   20 Jun 1996 09:26:12   ZJRD
** EasyPack/SLD Version 1.20a
** 
**    Rev 1.6   10 Jun 1996 10:20:50   ZJRD
** EasyPack/SLD Version 1.20
** 
**    Rev 1.4   29 May 1996 09:30:42   ZJRD
** No change.
** 
**    Rev 1.3   16 May 1996 09:03:58   ZJRD
** No change.
** 
**    Rev 1.2   10 May 1996 09:12:50   ZJRD
** No change.
** 
**    Rev 1.1   02 May 1996 10:27:44   ZJRD
** EasyPack/SLD Version 1.92
** 
**    Rev 1.31   18 Apr 1996 13:01:28   Shirley
** EasyPack/SLD Version 1.91
** 
**    Rev 1.30   12 Apr 1996 10:38:26   Shirley
** EasyPack/SLD Version 1.90
** 
**    Rev 1.28   15 Feb 1996 08:51:24   Shirley
** No change.
** 
**    Rev 1.27   12 Feb 1996 14:05:52   Shirley
** No change.
** 
**    Rev 1.26   06 Feb 1996 15:32:24   Shirley
** No change.
** 
**    Rev 1.25   06 Feb 1996 13:46:40   Shirley
** No change.
** 
**    Rev 1.24   01 Feb 1996 10:13:10   Shirley
** EasyPack/SLD Version 0.35b
** 
**    Rev 1.23   26 Jan 1996 09:17:24   Shirley
** No change.
** 
**    Rev 1.22   25 Jan 1996 13:17:18   Shirley
** No change.
** 
**    Rev 1.21   24 Jan 1996 10:38:22   Shirley
** No change.
** 
**    Rev 1.20   23 Jan 1996 11:23:32   Shirley
** No change.
** 
**    Rev 1.19   18 Jan 1996 10:13:00   Shirley
** No change.
** 
**    Rev 1.18   15 Jan 1996 16:10:28   Shirley
** No change.
** 
**    Rev 1.17   04 Jan 1996 11:09:46   Shirley
** No change.
** 
**    Rev 1.16   30 Nov 1995 09:13:08   Shirley
** No change.
** 
**    Rev 1.15   28 Nov 1995 15:35:28   Shirley
** No change.
** 
**    Rev 1.14   21 Nov 1995 11:24:40   Shirley
** No change.
** 
**    Rev 1.13   13 Nov 1995 09:25:34   Shirley
** No change.
** 
**    Rev 1.12   12 Nov 1995 11:28:30   Shirley
** EasyPack/SLD Version 0.24
** 
**    Rev 1.11   08 Nov 1995 16:29:18   Shirley
** No change.
** 
**    Rev 1.10   08 Nov 1995 12:39:48   Shirley
** EasyPack/SLD Version 0.22
**
**    Rev 1.4   13 Oct 1995 13:22:58   Shirley
** EasyPack/SLD Version 0.1d
**
**    Rev 1.3   29 Sep 1995 09:49:56   Shirley
** No change.
**
**    Rev 1.2   20 Sep 1995 10:52:58   Shirley
** No change.
**
**    Rev 1.1   15 Sep 1995 09:48:40   Shirley
** EasyPack/SLDV0.1a
**
**    Rev 1.0   07 Sep 1995 09:53:52   Shirley
** Initial revision.
**
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
//
//  File name:  NWMEM.H
//
//  Description:The header file for the class: CNewMemory
//
//  Author:     Lane Li
//
//  Modification:
//
//      3. 03/15/1996   1.0 version          Daniel Lin
//                   Add some remark
//
//      2. 19/10/95, 0.1d version
//                   Modified        CNewMemory
//                                   add private variable m_lLastStart;
//
//
//  Modification:
//
//      1. 09/10/95, Initial version
//
//
//  Copyright (C) 1995 Microtek International. All rights reserved.
//
/////////////////////////////////////////////////////////////////////////////

// nwmem.h : header file

/////////////////////////////////////////////////////////////////////////////
// CNewMemory frame

class CNewMemory : public CMDIChildWnd
{
        DECLARE_DYNCREATE(CNewMemory)
public:
        CNewMemory();                   // protected constructor used by dynamic creation
        BOOL Create(LPCSTR szTitle, LONG style = 0,
                    const RECT& rect = rectDefault, 
                    CMDIFrameWnd * pParent = NULL );

// Attributes
public:
        //CWnd* m_wnd;
        static CMenu NEAR m_menu;
        unsigned char m_nSpaceType;
        long  m_lStartAddress;
        int m_nWndNo;
        BOOL m_bFocus;

        int m_nLines;
        BOOL m_bModeLine;
        BYTE* m_byMem;
        struct dsm *m_dsm;

        BOOL m_bGetMemory;
        BOOL m_bEndOfMem;

        CGrid m_gridAddr;           // Address grid
        CGrid m_gridMem;            // Memory grid
        CGrid m_gridAscii;          // Ascii grid
        CGrid m_gridInstruction;    // Instruction grid(only for disassembly)
        UINT m_nInstructionWidth;

        BOOL m_bGridRedraw;
        BOOL m_bGridDrawn;
        int m_nScrollFlags;
        
        // m_nViewMode1    1  --    Byte
        //                 2  --    WORD
        //                 3  --    LONG
        //
        // m_nViewMode2    1  --    Signed Decimal
        //                 2  --    Unsigned Decimal
        //                 3  --    Hexdecimal
        //                 4  --    Disassenbly
        //
        
        int m_nViewMode1;
        int m_nViewMode2;
        BOOL m_bShowAscii;

        int m_nPosX;          // Scroll increase
        

        UINT m_nCaretPosX1;   // Indicate the every grid position
        UINT m_nCaretPosX2;   // Indicate every char in one grid
        UINT m_nCaretPosY;
        int m_nCaretArea;

        int m_nCharWidth;

        int m_nCursor;

        int m_nKeyFlag;

        long m_lValue;
        WORD m_wValue;
        BYTE m_byValue;
        char* m_lpszValue;

        static char m_searchStr[200];

// Operations
public:             
        void   ShowStatusGo();
        
        void SetWindowTitle();

        void GetMemory();

        void FillText(LPCSTR,UINT,RECT,CDC*);
        void FillText2(LPCSTR,UINT,RECT,CDC*);
        void FillText3(LPCSTR,UINT,RECT,CDC*);
        void SetScrollBar();
        void ScrollMemWnd(int);

        void SetByteSignedDecimal();
        void SetWordSignedDecimal();
        void SetLongSignedDecimal();

        void SetByteUnsignedDecimal();
        void SetWordUnsignedDecimal();
        void SetLongUnsignedDecimal();

        void SetByteHexadecimal();
        void SetWordHexadecimal();
        void SetLongHexadecimal();

        void SetDisassemble();

        void SetAddress();

        void SetAscii();

        void SetInstruction();

        void SetMemoryWindow();

        void ShowByteSignedDecimal(CDC*);
        void ShowWordSignedDecimal(CDC*);
        void ShowLongSignedDecimal(CDC*);

        void ShowByteUnsignedDecimal(CDC*);
        void ShowWordUnsignedDecimal(CDC*);
        void ShowLongUnsignedDecimal(CDC*);

        void ShowByteHexadecimal(CDC*);
        void ShowWordHexadecimal(CDC*);
        void ShowLongHexadecimal(CDC*);

        void ShowDisassemble(CDC*);

        void ShowAddress(CDC*);

        void ShowAscii(CDC*);

        void ShowInstruction(CDC*);

        void ShowMemoryWindow(CDC*);

        void SetMyCaretPos();

        void GotoCursor();

        BOOL InWnd();

        void Right();
        void Left();
        void Up();
        void Down();
        void Home();
        void End();
        void Tab();
        void Tab2();
        void Back();
        void Space();

        BOOL InputCheck(UINT);
        void WriteMemory(UINT);
        void GetValue();
        void ValueToStr();
        BOOL StrToValue();

// Implementation
public:
        virtual ~CNewMemory();

        // Generated message map functions
        //{{AFX_MSG(CNewMemory)
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
        afx_msg void OnPaint();
        afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
        afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
        afx_msg void OnViewByte();
        afx_msg void OnUpdateViewByte(CCmdUI* pCmdUI);
        afx_msg void OnViewWord();
        afx_msg void OnUpdateViewWord(CCmdUI* pCmdUI);
        afx_msg void OnViewLong();
        afx_msg void OnUpdateViewLong(CCmdUI* pCmdUI);
        afx_msg void OnViewFloat();
        afx_msg void OnUpdateViewFloat(CCmdUI* pCmdUI);
        afx_msg void OnViewDouble();
        afx_msg void OnUpdateViewDouble(CCmdUI* pCmdUI);
        afx_msg void OnViewSigneddecimal();
        afx_msg void OnUpdateViewSigneddecimal(CCmdUI* pCmdUI);
        afx_msg void OnViewHexadecimal();
        afx_msg void OnUpdateViewHexadecimal(CCmdUI* pCmdUI);
        afx_msg void OnViewDisassemble();
        afx_msg void OnUpdateViewDisassemble(CCmdUI* pCmdUI);
        afx_msg void OnViewAscii();
        afx_msg void OnUpdateViewAscii(CCmdUI* pCmdUI);
        afx_msg void OnViewUnsigneddecimal();
        afx_msg void OnUpdateViewUnsigneddecimal(CCmdUI* pCmdUI);
        afx_msg void OnSize(UINT nType, int cx, int cy);
        afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
        afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
        afx_msg void OnSetFocus(CWnd* pOldWnd);
        afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
        afx_msg void OnMouseMove(UINT nFlags, CPoint point);
        afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
        afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
        afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
        afx_msg long OnXMRepaint(UINT,LONG);
        afx_msg void OnKillFocus(CWnd* pNewWnd);
        afx_msg void OnEditGoto();
        afx_msg void OnUpdateEditGoto(CCmdUI* pCmdUI);
        afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);
        afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
        afx_msg void OnViewRefresh();
        afx_msg void OnUpdateViewRefresh(CCmdUI* pCmdUI);
        afx_msg void OnEditSearch();
        afx_msg void OnUpdateEditSearch(CCmdUI* pCmdUI);
        afx_msg void OnEditSearchnext();
        afx_msg void OnUpdateEditSearchnext(CCmdUI* pCmdUI);
        afx_msg void OnStkTab();
        afx_msg void OnShiftreturn();
        afx_msg void OnGroupMemory();
        afx_msg void OnMap();
        afx_msg void OnUpdateMap(CCmdUI* pCmdUI);
        afx_msg void OnUpdateGroupMemory(CCmdUI* pCmdUI);
   afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
	afx_msg UINT OnNcHitTest(CPoint point);
	afx_msg void OnClose();
	//}}AFX_MSG
        DECLARE_MESSAGE_MAP()
private:
        //long  m_lLastStart;           // Added by Daniel Lin.  
        unsigned short pMax,pMin,xMax,xMin,iMax,iMin;        
};

/////////////////////////////////////////////////////////////////////////////
#define AddressWidth       36//66
#define AsciiWidth         130
#define InstructionWidth   200

#define ByteSignedDecimalWidth   38   //34
#define WordSignedDecimalWidth   55   //50
#define LongSignedDecimalWidth   95   //90

#define ByteUnsignedDecimalWidth 30 //26
#define WordUnsignedDecimalWidth 47 //42
#define LongUnsignedDecimalWidth 87 //82

#define ByteHexadecimalWidth  22  //18
#define WordHexadecimalWidth  38  //34
#define LongHexadecimalWidth  72  //66

#define DisassembleWidth      80

struct dsm
{
        long address;
        char code[10];
        char instruction[256];
};
