www.pudn.com > GOS.rar > WGOS.cpp
// WGOS.cpp : Defines the class behaviors for the application. // #include "Wstdafx.h" #include "WGOS.h" #include "WMainFrm.h" #include "GOS_WIN.h" #include#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif typedef struct _tagTCB { PVOID sp; DWORD nTick; }OS_TCB,*POS_TCB; extern POS_TCB pOsCurThread; extern POS_TCB pOsNextThread; extern BOOL m_bGuiPaint; extern OS_TCB aOsThread[]; extern void HAL_ENTRY(void); extern void HeapFree(void*); extern int* pOsHeap; class KFile; PBITMAPINFO m_pBmpInfo; HACCEL m_hAccelTable; CView* m_pView; CFile fileVFS; ///////////////////////////////////////////////////////////////////////////// // WGOSApp BEGIN_MESSAGE_MAP(WGOSApp, CWinApp) //{{AFX_MSG_MAP(WGOSApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() extern "C" void HAL_CreateThread(int tcb,int sp1,int sp2,int pFunc) { static int i=THREAD_PRIORITY_NORMAL; HeapFree((PVOID)sp1); AfxBeginThread((AFX_THREADPROC)pFunc,NULL,++i); } extern "C" void Win_OnIdle() { // TODO: Add your specialized code here and/or call the base class MSG msg; // Main message loop: if(PeekMessage(&msg, NULL, 0, 0,PM_REMOVE)) { if (!TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } else if(m_bGuiPaint) { m_pView->Invalidate(FALSE); m_bGuiPaint=FALSE; } else { SleepEx(50,TRUE); } } BOOL File_WriteBlock(LPVOID pBuf,int nBlock) { UINT nNeedLen=FILE_BLOCKBYTES*(nBlock+1); if(fileVFS.GetLength() LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); // The one and only window has been initialized, so show and update it. pFrame->ShowWindow(SW_SHOW); pFrame->UpdateWindow(); CRect rView,rFrame; pFrame->GetWindowRect(rFrame); m_pView->GetClientRect(rView); rFrame.right+=GUI_CXSCREEN*2-rView.Width(); rFrame.bottom+=GUI_CYSCREEN*2-rView.Height(); pFrame->MoveWindow(rFrame); m_pBmpInfo=(PBITMAPINFO)malloc(sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*3); BITMAPINFOHEADER& bh=m_pBmpInfo->bmiHeader; RGBQUAD* bc=m_pBmpInfo->bmiColors; bh.biSize=sizeof(BITMAPINFOHEADER); bh.biWidth=GUI_CXSCREEN; bh.biHeight=GUI_CYSCREEN; bh.biPlanes=1; bh.biBitCount=16; bh.biCompression=BI_BITFIELDS; bh.biSizeImage=GUI_CXSCREEN*GUI_CYSCREEN*2; bh.biXPelsPerMeter=3270; bh.biYPelsPerMeter=3270; bh.biClrUsed=0; bh.biClrImportant=0; *PDWORD(&bc[0])=31<<11; *PDWORD(&bc[1])=63<<5; *PDWORD(&bc[2])=31; CString str; LPTSTR szPath=str.GetBuffer(1024); ::GetModuleFileName(NULL,szPath,1024); str.ReleaseBuffer(); int nAT=str.ReverseFind('.'); str=str.Left(nAT+1)+"TXT"; nAT=fileVFS.Open(str,CFile::modeReadWrite); if(!nAT) { nAT=fileVFS.Open(str,CFile::modeCreate); } HAL_ENTRY(); fileVFS.Close(); free(m_pBmpInfo); return FALSE; } ///////////////////////////////////////////////////////////////////////////// // WGOSApp message handlers ///////////////////////////////////////////////////////////////////////////// // WAboutDlg dialog used for App About class WAboutDlg : public CDialog { public: WAboutDlg(); // Dialog Data //{{AFX_DATA(WAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(WAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(WAboutDlg) // No message handlers //}}AFX_MSG DECLARE_MESSAGE_MAP() }; WAboutDlg::WAboutDlg() : CDialog(WAboutDlg::IDD) { //{{AFX_DATA_INIT(WAboutDlg) //}}AFX_DATA_INIT } void WAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(WAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(WAboutDlg, CDialog) //{{AFX_MSG_MAP(WAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() // App command to run the dialog void WGOSApp::OnAppAbout() { WAboutDlg aboutDlg; aboutDlg.DoModal(); } ///////////////////////////////////////////////////////////////////////////// // WGOSApp message handlers