www.pudn.com > GOS.rar > WinHAL.cpp


// WinVM.cpp: implementation of the WinVM class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "..\stdafx.h" 
#include "WinHAL.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
// WGOS.cpp : Defines the class behaviors for the application. 
// 
 
  
extern int* pOsHeap; 
extern "C" void Win_OnIdle(); 
 
USHORT m_aScreen[GUI_CXSCREEN*GUI_CYSCREEN]; 
BOOL m_bGuiPaint=FALSE; 
int aHeap[OS_HEAPSIZE]; 
int nHalRegister; 
USHORT aHalAD[256]; 
 
void Idle() 
{ 
	static nIdleCount=0; 
	while(1) 
	{ 
		Sleep(200); 
		if(GWnd::m_nWndCount>0) 
		{ 
			GWnd::m_aWnd[0]->PostMessage(WM_TIMER,100,nIdleCount++); 
		} 
	} 
} 
void HAL_ENTRY() 
{ 
	pOsHeap=aHeap; 
	OS_Init(); 
 
	KFile::Init(); 
	//CreateThread(Idle,0); 
	{ 
		CMainFrame m_pScreen; 
		m_pScreen.DoModal(); 
	} 
	KFile::Unload(); 
	HeapFree(GWnd::m_aWnd); 
	HeapFree(GWnd::m_aMsg); 
	ASSERT(pOsHeap[0]==OS_HEAPSIZE); 
} 
 
void HAL_Beep(int nType) 
{ 
	MessageBeep(nType); 
} 
 
void HAL_OnIdle()  
{ 
	Win_OnIdle(); 
} 
 
void HAL_Unload() 
{ 
	int x=GWnd::m_nWndCount; 
	while(x--) 
	{ 
		if(!GWnd::m_aWnd[x]->m_pParent) 
		{ 
			((GDialog*)(GWnd::m_aWnd[x]))->m_nDlgResult=-2; 
		} 
	} 
} 
 
void HAL_PIXEL(int x,int y,int c) 
{ 
	int r,g,b,i=(GUI_CYSCREEN-1-y)*GUI_CXSCREEN+x; 
	r=((c&0xff)*31)/255; 
	c>>=8;g=((c&0xff)*63)/255; 
	c>>=8;b=((c&0xff)*31)/255; 
	c=(r<<11)|(g<<5)|b; 
	m_aScreen[i]=c; 
	m_bGuiPaint=TRUE; 
} 
 
 
void HAL_FillRect(int x1,int y1,int x2,int y2,int nColor) 
{ 
	int x,y; 
	for(y=y1;y<=y2;y++) 
	{ 
		for(x=x1;x<=x2;x++) 
		{ 
			HAL_PIXEL(x,y,nColor); 
		} 
	} 
	 
	m_bGuiPaint=TRUE; 
} 
 
void HAL_Click(int x,int y,BOOL bDown) 
{ 
	GWnd::WM_Click(x,y,bDown); 
}