亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lcd.cpp

?? 講解用ARM來控制LCD以及鍵盤的很好的源代碼
?? CPP
字號:

// ARM Ltd
// Copyright 1998 All Rights reserved

// David Earlam 22.9.1998
// Updated by David Roberts 8.8.2001

// Virtual LCD.

// First hack set individual pixels in an offscreen memory DC and bitblatted the memory to the screen.
// This worked -slowly- and was not very succesful if the screen was resized (StretchBlt).

// But why call GDI for every pixel with lots of bit manipulations and stacking of parameters.
// Second hack uses a Device Independent Bitmap and converts from an in memory frame buffer
// simulating the frame buffer of an actual LCD and converts the bits therein 
// to a DIB compatible format, then blats this to the screen.
// The conversion from frame buffer to DIB format is done by a dynamically constructed
// lookup table improving screen refresh rates about 80,000 times for a 480x240x2 LCD
// over the 'First hack'. 
// Screen resizing is ever so nice too.
//
// A refreshTimer controls how frequently the framebuffer is inspected to deduce the minimum that must
// be repainted. 
  

#include <afxwin.h>
#include <io.h>

#include "CPixelDepthChanger.h"

#include "CIntervalTimer.h"

#include "resource.h"

#include "..\console.h"
#include "..\console_rpc.h"

unsigned lcd_width, lcd_height;

// Define the application class
class CApp : public CWinApp
{
public:
	BOOL bArmulator;
	void CloseRPC(void);
	void SetupRPC();
	virtual BOOL InitInstance();
	virtual int ExitInstance( );

	COLORREF lcdcolor[256]; 

	unsigned char* pszStringBinding;
	RPC_STATUS status;	
};

CApp App;  



// Define the window class
class CWindow : public CFrameWnd
{ 
	CDC memDC;
	CBitmap *oldMemDCBitmap, *newMemDCBitmap;
public:
	LPVOID lpMemFile;
	CWindow(DWORD _threadID);
	~CWindow();
	afx_msg void OnPaint();
	afx_msg void OnChar( UINT nChar, UINT nRepCnt, UINT nFlags );

	void RePaint();
	void DoPaint();

	virtual BOOL PreCreateWindow( CREATESTRUCT& cs );

	void DoAbout( void );
	void DoChangeRefresh1( void );
	void DoChangeRefresh2( void );
	void DoChangeRefresh5( void );
	void DoChangeRefresh10( void );
	void CheckMenu( int id );

	CDib *pdisplayDib;
	int displayDibBitsperpixel;

	CPixelDepthChanger *pdisplayPixelDepthChanger;

	int srcBitsperpixel;

	CIntervalTimer refreshTimer;

	CDib realbitmap;

	DWORD threadID;

	DECLARE_MESSAGE_MAP()
};

// The constructor for the window
CWindow::CWindow(DWORD _threadID) : threadID(_threadID)
{ 
// Should use GetSystemMetrics for 'correction factor' of 4 below
// GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER)
// but still doesn't give correct adjustment???
	CApp* theApp = (CApp*)AfxGetApp();

	if( theApp->bArmulator == TRUE ) {
		lcd_width = getPixelsX();
		lcd_height = getPixelsY();
	} else {
		lcd_width = 480;
		lcd_height = 240;
	}

	CRect myrect = CRect(CPoint(50,50), CSize(
		lcd_width+8,
		lcd_height+46));

	Create(NULL, "ARM Virtual LCD", WS_OVERLAPPEDWINDOW, myrect, NULL,
		MAKEINTRESOURCE(IDR_MENU_MAIN));

	CSize sizeDib(lcd_width,lcd_height);
	displayDibBitsperpixel = 8;

	pdisplayDib = new CDib(sizeDib,displayDibBitsperpixel);

	if (_threadID == 0) {
	// need to get a pointer to shared memory contating the source frame buffer here

		//LPBYTE psrcBits = new BYTE[WIDTH * HEIGHT / srcBitsperpixel];
		srcBitsperpixel = BITS_PER_PIXEL;
		BOOL result = realbitmap.AttachMapFile("logo_back.bmp",TRUE);

		// DR added - make sure that the display dib and loaded dib have same palette!!
		// Copy palette from source DIB to new DIB
		pdisplayDib->SetColorTable( (RGBQUAD*)realbitmap.m_lpvColorTable, realbitmap.m_nColorTableEntries );

		pdisplayPixelDepthChanger = new CPixelDepthChanger(lcd_width,lcd_height,realbitmap.m_lpBMIH->biBitCount,(void*) realbitmap.m_lpImage, *pdisplayDib);
	} else {
		WORD srcBitsperpixel = BITS_PER_PIXEL;

		HANDLE hMap = ::OpenFileMapping(FILE_MAP_READ, FALSE, "wince");
#if 0
		char buf[100];
		DWORD dwErr = ::GetLastError();
		sprintf(buf, "hmap = %d, dwerr = %d\n", hMap, dwErr);
		MessageBox(buf, "2", MB_OK);
#endif
		if(hMap == NULL) {
			AfxMessageBox("Cannot open file mapping to 'wince' memory");
		}
		LPVOID lpvFile = ::MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0); // map whole file

		
		BOOL result;
		
		switch( BITS_PER_PIXEL ) {
		case 8:
			result = realbitmap.AttachMapFile("palette8.bmp",TRUE);
			pdisplayDib->SetColorTable( (RGBQUAD*)realbitmap.m_lpvColorTable, realbitmap.m_nColorTableEntries );
			break;

		case 2:
			// design a palette
			int i;
			for( i = 0; i < 4; i++ )
				theApp->lcdcolor[i] = RGB( i * 85, i * 85, i * 85 );

			pdisplayDib->SetColorTable( (RGBQUAD*)theApp->lcdcolor, 4 );
			break;

		default:
			// not supported
			AfxMessageBox("Unsupported colour depth!");
		}

		pdisplayPixelDepthChanger = new CPixelDepthChanger(lcd_width,lcd_height,srcBitsperpixel,lpvFile, *pdisplayDib);
	}

	DoChangeRefresh5();
}

extern "C"
{
	void CALLBACK yourMMTimeProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1,
    DWORD dw2)
	{
		CWindow* pThis = (CWindow*) dwUser;
		pThis->RePaint();
	}

}
CWindow::~CWindow()
{
#if FIRSTHACK
	memDC.SelectObject(oldMemDCBitmap);
	delete newMemDCBitmap;
#endif

	delete pdisplayDib;
	delete pdisplayPixelDepthChanger;
}

// The message map
BEGIN_MESSAGE_MAP( CWindow, CFrameWnd )
	ON_WM_PAINT()
	ON_WM_CHAR()
	
	ON_COMMAND( IDM_ABOUT, DoAbout )
	ON_COMMAND( ID_HZ_1, DoChangeRefresh1 )
	ON_COMMAND( ID_HZ_2, DoChangeRefresh2 )
	ON_COMMAND( ID_HZ_5, DoChangeRefresh5 )
	ON_COMMAND( ID_HZ_10, DoChangeRefresh10 )
END_MESSAGE_MAP()


// Handle exposure events
void CWindow::OnPaint()
{

	DoPaint();
	
		
#if FIRSTHACK	
	CRect borderrect(0,0,WIDTH,HEIGHT);
	
	// Paint into the memory DC pixel by pixel ... sloooow even with SetPixelV which is claimed faster than SetPixel  
	{
	int x;
	int y;

	for (x=0;
      x< WIDTH ;
	  ++x)
	  {
		  for (y=0;
      y < HEIGHT;
	   ++y)
	  {
		memDC.SetPixelV(x,y,((CApp*)AfxGetApp())->lcdcolor[x%4]);
	  }
	  }
	}

	// Transfer the memory DC to the screen
	 //use this if fixed size window
	 dc.BitBlt(0,0,borderrect.Width(),borderrect.Height(),&memDC,0,0,SRCCOPY);

	 //use this if allow resize
     //dc.StretchBlt(0, 0, clirect.Width(),clirect.Height(), &memDC, 0,0,borderrect.Width(),borderrect.Height(), SRCCOPY );

#endif
 
}

extern "C" int _confh;

/*
BOOL CWindow::PreTranslateMessage( MSG* pMsg )
{
	int err; char buf[30];

	switch (pMsg->message)
	{
	case WM_KEYDOWN:
	case WM_KEYUP:
		::PostThreadMessage(threadID, WM_USER, pMsg->wParam, pMsg->lParam);
	}
	return CFrameWnd::PreTranslateMessage(pMsg);
}
*/

void CWindow::DoPaint()
{

	CRect clirect;
    GetClientRect(clirect);

	CPaintDC dc(this);

	pdisplayPixelDepthChanger->Update(); //convert source frame buffer bits to Windows Dib very quickly

	pdisplayDib->Draw( &dc, CPoint(0,0), CSize(clirect.Width(),clirect.Height()));

	// DEBUG
	/*
	char buf[100];
	wsprintf( buf, "Contents of pdisplayDib->m_lpImage[0] = %02x", *pdisplayDib->m_lpImage );
	CRect theRect( 10, 10, 450, 100 );
	dc.DrawText( buf, strlen(buf), theRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
	*/
}


void CWindow::RePaint()
{
	CRect rect;
//	rect = pdisplayPixelDepthChanger->GetInvalidRect(); //what has changed since the last paint

	CClientDC dc(this);
	dc.SetMapMode(MM_ANISOTROPIC);
	//dc.SetWindowExt(pdisplayPixelDepthChanger->GetSrcSize());
	dc.SetWindowExt(pdisplayDib->GetDimensions());

	CRect cliRect;
	GetClientRect(cliRect);
	dc.SetViewportExt(cliRect.right, cliRect.bottom);
	dc.SetViewportOrg(0,0);

//	dc.LPtoDP(rect); // we need to invalidate with device coordinates

	InvalidateRect(&cliRect,FALSE);
//	InvalidateRect(&rect);
//	UpdateWindow(); // don't wait for WM_PAINT to percolate thru the message queue
	
}

void CWindow::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags )
{
	// RPC call
	QueueKey( nChar, nFlags & 0x8000 );
}

BOOL CWindow::PreCreateWindow( CREATESTRUCT& cs ) {
	// Determine the class ID for FindWindow call from the model
	// DEBUG
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;

	CApp* theApp = (CApp*)AfxGetApp();
	if( theApp->bArmulator == TRUE )
		cs.style &= ~WS_SYSMENU;

	cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
	cs.lpszClass = AfxRegisterWndClass(0);

	// DEBUG get the window class name!
	//MessageBox( cs.lpszClass );

	return TRUE;
}

void CWindow::DoAbout( void )
{
	MessageBox( "ARM LCD viewer\n\nCopyright 1998, 2001 ARM Ltd.\nDavid Earlam 22.9.1998\nUpdated by David Roberts 8.8.2001", "About" );
}

void CWindow::CheckMenu( int id )
{
	// clear checks
	CMenu *pMenu = GetMenu();

	pMenu->CheckMenuItem( ID_HZ_1, MF_UNCHECKED );
	pMenu->CheckMenuItem( ID_HZ_2, MF_UNCHECKED );
	pMenu->CheckMenuItem( ID_HZ_5, MF_UNCHECKED );
	pMenu->CheckMenuItem( ID_HZ_10, MF_UNCHECKED );

	// check correct one
	pMenu->CheckMenuItem( id, MF_CHECKED );
}

void CWindow::DoChangeRefresh1()
{
	refreshTimer.StopPeriodicTimer();
	refreshTimer.SetTimerCallback((DWORD)this, 1000, yourMMTimeProc);

	CheckMenu( ID_HZ_1 );
}

void CWindow::DoChangeRefresh2()
{
	refreshTimer.StopPeriodicTimer();
	refreshTimer.SetTimerCallback((DWORD)this, 500, yourMMTimeProc);

	CheckMenu( ID_HZ_2 );
}

void CWindow::DoChangeRefresh5()
{
	refreshTimer.StopPeriodicTimer();
	refreshTimer.SetTimerCallback((DWORD)this, 200, yourMMTimeProc);

	CheckMenu( ID_HZ_5 );
}

void CWindow::DoChangeRefresh10()
{
	refreshTimer.StopPeriodicTimer();
	refreshTimer.SetTimerCallback((DWORD)this, 100, yourMMTimeProc);

	CheckMenu( ID_HZ_10 );
}

// Init the application
BOOL CApp::InitInstance()
{
	DWORD armulator;  // thread ID passed in in argv[1]
	bArmulator = FALSE;

	lcdcolor[0] = 		RGB (0,0,0);
	lcdcolor[1] = 		RGB (128,128,128);
	lcdcolor[2] = 		RGB (192,192,192);
	lcdcolor[3] = 		RGB (255,255,255);

	CString sCommandLine = m_lpCmdLine; // parse this to get name of shared memory, frame buffer dimensions, depth, refresh rate. lcdcolor mappings

	if (__argc < 2) {
		armulator = 0;  // not invoked from ARMULATE.DLL
		bArmulator = FALSE;
		AfxMessageBox( "Not invoked from ARMULATE.DLL\n\nPlease run this via the ARMulator console model.", MB_OK, NULL );
		//return FALSE;
	}
	else {
		armulator = atoi(__argv[1]);
		bArmulator = TRUE;

		SetupRPC();
	}

	m_pMainWnd = new CWindow(armulator);
	m_pMainWnd->ShowWindow(m_nCmdShow);
	m_pMainWnd->UpdateWindow();

	return TRUE;
}

int CApp::ExitInstance()
{
	CloseRPC();

	return 0;
}

/******************************************************/
/*         MIDL allocate and free                     */
/******************************************************/
 
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
{
    return(malloc(len));
}
 
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
{
    free(ptr);
}

void CApp::SetupRPC()
{
	// Set up RPC
    unsigned char * pszUuid             = NULL;

	// If you run windows NT, this can be "ncacn_np" for named pipe
    unsigned char * pszProtocolSequence = (unsigned char*)"ncalrpc";
    unsigned char * pszNetworkAddress   = NULL;
    unsigned char * pszEndpoint    = NULL;
	//unsigned char * pszEndpoint    = (unsigned char*)"console_rdi";
    unsigned char * pszOptions          = NULL;
    pszStringBinding = NULL;
	char buf[150];

    status = RpcStringBindingCompose(pszUuid,
                                     pszProtocolSequence,
                                     pszNetworkAddress,
                                     pszEndpoint,
                                     pszOptions,
                                     &pszStringBinding);
    if (status != RPC_S_OK ) {
		// determine exactly what the error was
		wsprintf( buf, "Invalid client RPC String: status=%d", status );

		switch( status ) {
		case RPC_S_PROTSEQ_NOT_SUPPORTED:
			strcat( buf, "\n Protocol sequence not supported on this host" );
			break;

		case RPC_S_INVALID_RPC_PROTSEQ:
			strcat( buf, "\n Invalid protocol sequence" );
			break;

		case RPC_S_INVALID_ENDPOINT_FORMAT:
			strcat( buf, "\n Invalid endpoint format" );
			break;

		case RPC_S_OUT_OF_MEMORY:
			strcat( buf, "\n Out of memory" );
			break;

		case RPC_S_DUPLICATE_ENDPOINT:
			strcat( buf, "\n Endpoint is duplicate" );
			break;

		case RPC_S_INVALID_SECURITY_DESC:
			strcat( buf, "\n Security descriptor invalid" );
		}

		AfxMessageBox( buf, MB_OK, 0 );
	}

    status = RpcBindingFromStringBinding(pszStringBinding,
                                         &console_rpc_IfHandle);
}

void CApp::CloseRPC()
{
	if( bArmulator == TRUE ) {
		status = RpcStringFree(&pszStringBinding); 
		status = RpcBindingFree(&console_rpc_IfHandle);
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
丁香啪啪综合成人亚洲小说| 亚洲尤物视频在线| 经典一区二区三区| 欧美成人一区二区| 开心九九激情九九欧美日韩精美视频电影 | 日精品一区二区| 3d成人动漫网站| 琪琪久久久久日韩精品| 欧美一二三四区在线| 麻豆一区二区在线| 久久美女艺术照精彩视频福利播放| 国产一区二区三区四| 日本一区二区免费在线观看视频 | 日韩免费高清av| 精品一二三四区| 中文文精品字幕一区二区| av不卡免费电影| 亚洲国产综合视频在线观看| 51午夜精品国产| 黄页网站大全一区二区| 国产精品每日更新在线播放网址| 91免费版pro下载短视频| 亚洲午夜av在线| 精品区一区二区| 91香蕉国产在线观看软件| 午夜久久久影院| 久久精品在这里| 欧美性受xxxx黑人xyx| 九色综合狠狠综合久久| 亚洲天堂免费在线观看视频| 欧美日韩激情在线| 国产夫妻精品视频| 亚洲第四色夜色| 亚洲精品一区二区精华| 91麻豆高清视频| 蜜臀精品一区二区三区在线观看 | 欧美日韩美女一区二区| 国产精品一区二区在线看| 一区二区三区波多野结衣在线观看| 91精品国产综合久久久久久漫画| 国产成人综合在线观看| 午夜精品爽啪视频| 中文字幕在线不卡视频| 日韩手机在线导航| 一本大道久久a久久综合婷婷 | 一区二区三区欧美日| 精品国产伦一区二区三区观看体验| av在线不卡电影| 国产自产视频一区二区三区 | 偷窥少妇高潮呻吟av久久免费| 久久综合色8888| 欧美日韩成人综合| 99久久精品免费观看| 韩国中文字幕2020精品| 日韩精品视频网| 亚洲综合色区另类av| 欧美激情综合五月色丁香小说| 在线不卡免费av| 色婷婷激情综合| 成人国产精品免费网站| 国内精品免费在线观看| 五月综合激情婷婷六月色窝| 亚洲欧洲日本在线| 国产日韩亚洲欧美综合| 欧美精品一区二区高清在线观看| 欧美视频第二页| 91福利在线免费观看| www.在线成人| 丁香天五香天堂综合| 国产一区二区中文字幕| 美女一区二区久久| 日韩在线播放一区二区| 亚洲国产精品久久久男人的天堂| 亚洲日本在线视频观看| 国产精品久久久久四虎| 国产女主播一区| 国产精品婷婷午夜在线观看| 久久精品人人爽人人爽| 久久美女高清视频| 国产人成一区二区三区影院| 久久亚洲二区三区| 国产亚洲制服色| 亚洲国产精品ⅴa在线观看| 久久久亚洲精品石原莉奈 | 欧美妇女性影城| 欧美日韩精品一区二区| 欧美精品免费视频| 制服丝袜亚洲网站| 日韩欧美一二三四区| 精品久久久久久久久久久久包黑料| 日韩午夜av电影| 欧美精品一区二区久久婷婷| 久久九九久精品国产免费直播| 国产欧美日韩久久| 亚洲同性同志一二三专区| 亚洲色图欧美激情| 亚洲风情在线资源站| 午夜激情久久久| 精品一区二区三区免费| 国产成人午夜电影网| 99久久婷婷国产综合精品| 色哟哟一区二区在线观看| 欧美日韩另类一区| 精品国产乱码91久久久久久网站| 2欧美一区二区三区在线观看视频| 久久久91精品国产一区二区精品| 中文字幕+乱码+中文字幕一区| 亚洲欧美日韩精品久久久久| 亚洲电影中文字幕在线观看| 看电视剧不卡顿的网站| 大美女一区二区三区| 色悠悠亚洲一区二区| 91精品国产色综合久久不卡电影 | 久久久久亚洲综合| 国产精品嫩草久久久久| 亚洲一区日韩精品中文字幕| 日韩精品午夜视频| 丁香天五香天堂综合| 欧美午夜在线一二页| 欧美刺激脚交jootjob| 国产精品久久99| 日本特黄久久久高潮| 国产 欧美在线| 欧美视频在线不卡| 日本一区二区三区电影| 香蕉影视欧美成人| 成人午夜短视频| 欧美精品日日鲁夜夜添| 亚洲国产精品av| 蜜臀av性久久久久蜜臀aⅴ| 成人在线一区二区三区| 在线不卡中文字幕| 亚洲欧美国产三级| 国产综合色视频| 欧美日韩不卡一区| 亚洲欧美日韩国产成人精品影院| 美女精品一区二区| 在线国产亚洲欧美| 中文字幕一区二区三区乱码在线 | 午夜免费欧美电影| 成人不卡免费av| 欧美电影免费观看高清完整版在| 亚洲三级在线免费| 国产成人免费高清| 日韩欧美国产三级| 亚洲大尺度视频在线观看| 成人激情免费网站| 久久久美女毛片| 久久精品99久久久| 51精品国自产在线| 亚洲欧美成人一区二区三区| 国产尤物一区二区| 国产精品视频在线看| 不卡电影免费在线播放一区| 日韩欧美一区在线| 视频精品一区二区| 欧美日韩精品三区| 亚洲一区二区综合| 99精品国产视频| 国产精品卡一卡二卡三| 国产69精品一区二区亚洲孕妇| 欧美大片一区二区| 日韩**一区毛片| 4hu四虎永久在线影院成人| 亚洲成人在线观看视频| 在线免费观看不卡av| 亚洲精品乱码久久久久久久久 | 精品国产91乱码一区二区三区| 亚洲国产成人高清精品| 色成年激情久久综合| 亚洲三级电影网站| 色婷婷精品大视频在线蜜桃视频| 亚洲人精品午夜| 99热在这里有精品免费| 自拍偷拍亚洲综合| 91免费在线播放| 亚洲一区在线观看网站| 欧美午夜电影一区| 爽爽淫人综合网网站| 欧美一级黄色片| 国内精品国产成人国产三级粉色| 精品国产乱码久久久久久久久| 国产伦精一区二区三区| 日本一区二区三区视频视频| voyeur盗摄精品| 一区二区久久久| 欧美日韩一级二级三级| 日本不卡不码高清免费观看| 日韩免费福利电影在线观看| 国产美女精品人人做人人爽| 国产日产欧美精品一区二区三区| 99久久综合国产精品| 一二三四社区欧美黄| 欧美人xxxx| 国产精品一级二级三级| 亚洲日穴在线视频| 91精品国产综合久久久久久漫画 | 一区二区免费视频| 日韩一二三区视频| 国产成人午夜精品影院观看视频|