bool Input::Init(HWND windowHandle) { if (!m_directInput) { HINSTANCE instanceHandle = GetModuleHandle(nullptr); if (FAILED(DirectInput8Create(instanceHandle, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_directInput, nullptr))) { MessageBox(NULL, L"DirectInput8Create Fail", L"Error", MB_OK | MB_ICONERROR); return false; } } if (m_windowHandle != windowHandle) { m_windowHandle = windowHandle; if (!InitKeyboard()) return false; if (!InitMouse()) return false; } return true; }
//初期化 HRESULT DirectInput::Init() { //DirectInputオブジェクトの作成 //hresultにはFAILED/SUCCEEDED等で真偽を確かめるのに使うもの HRESULT hresult = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&pDInput, NULL); if (FAILED(hresult)) { return hresult; } //キーボード初期化処理 hresult = InitKey(); if (FAILED(hresult)) { return hresult; } //マウス初期化 hresult = InitMouse(); if (FAILED(hresult)) { return hresult; } return S_OK; }
/* Init: * Initialise l'émulateur et réserve les ressources nécessaires. */ int to7_Init(int disk_ctrl) { /* on détecte les instances multiples */ if (to7_alive) return ErrorMessage(TO7_MULTIPLE_INIT, NULL); if (InitHardware(disk_ctrl) == TO7_ERROR) return TO7_ERROR; if (InitMemory() == TO7_ERROR) { to7_Exit(); return TO7_ERROR; } InitKeyboard(); InitMouse(); InitDisk(); InitK7(); to7_alive = TRUE; atexit(to7_Exit); return TO7_OK; }
void InputEngine::InitializeDInput(HINSTANCE hInstance, HWND hWnd) { // create the DirectInput interface DirectInput8Create(hInstance, // the handle to the application DIRECTINPUT_VERSION, // the compatible version IID_IDirectInput8, // the DirectInput interface version (void**)&din, // the pointer to the interface NULL); // COM stuff, so we'll set it to NULL // create the keyboard device din->CreateDevice(GUID_SysKeyboard, // the default keyboard ID being used &dinkeyboard, // the pointer to the device interface NULL); // COM stuff, so we'll set it to NULL dinkeyboard->SetDataFormat(&c_dfDIKeyboard); // set the data format to keyboard format // set the control you will have over the keyboard dinkeyboard->SetCooperativeLevel(hWnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND); InitMouse(hWnd); }
// Initialize Direct input object bool DXInput::Init() { // Create Direct Input object HRESULT hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&m_pDIObject, NULL) ; if (FAILED(hr)) { DXTRACE_ERR_MSGBOX(DXGetErrorString(hr), hr) ; //ERRORBOX(L"Create Direct Input object failed!") ; return false ; } // Initialize keyboard else if (!InitKeyboard()) { //ERRORBOX(L"Initialize keyboard failed!") ; DXTRACE_ERR_MSGBOX(DXGetErrorString(hr), hr) ; } // Initialize mouse else if (!InitMouse()) { //ERRORBOX(L"Initialize mouse failed!") ; DXTRACE_ERR_MSGBOX(DXGetErrorString(hr), hr) ; } return true ; }
void Input::Startup(HWND hWnd) { m_pDIObject = NULL; m_pDIKeyboardDevice = NULL; m_pDIMouseDevice = NULL; //Clears the buffer before use ZeroMemory(&KeyBuffer, 256); bool result = false; result = InitDirectInput(); if(!result) { MessageBox (NULL, "InitDirectInput Failed", "ERROR", MB_OK); } result = false; result = InitKeyboard(hWnd); if(!result) { MessageBox (NULL, "InitKeyboard Failed", "ERROR", MB_OK); } result = false; result = InitMouse(hWnd); if(!result) { MessageBox (NULL, "InitMouse Failed", "Error", MB_OK); } }
CMaze::CMaze() { chDXY[0] = 0x01; // N chDXY[1] = 0x10; // E chDXY[2] = -0x01; // S chDXY[3] = -0x10; // W InitMaze(); InitMouse(); }
void Init_All() { done = 0; nexttimer = -1; Init_Graphics(); InitFont(); InitMenu(); InitMouse(); atexit(CleanUpAll); }
InputHandler::InputHandler(HWND handleWindow) { handle = handleWindow; m_pDIObject = NULL; m_pDIKeyboardDevice = NULL; InitDirectInput(); InitKeyboard(); InitMouse(); }
// Set up controllers based on their type (zapper, gamepad, etc.) // For more info, see setInputFC, which sets the JSreturn variable void InitOtherInput(void) { void *InputDPtr; int t; int x; int attrib; for(t=0,x=0;x<2;x++) // For both controllers... { attrib=0; InputDPtr=0; switch(InputType[x]) // Switch on controller type { case SI_POWERPADA: case SI_POWERPADB:InputDPtr=&powerpadbuf[x];break; case SI_GAMEPAD: InputDPtr=&JSreturn; // JSreturn is a global that contains a map of keys and their pressed state // DEBUG -- YES, like we want, we hit this for both controllers break; case SI_ARKANOID:InputDPtr=MouseData;t|=1;break; case SI_ZAPPER:InputDPtr=MouseData; t|=1; attrib=1; break; } FCEUI_SetInput(x,InputType[x],InputDPtr,attrib); // Just updates pointers in Driver's input.c. Example call FCEUI_SetInput(0, SI_GAMEPAD, &JSreturn, 0); } attrib=0; InputDPtr=0; switch(InputType[2]) // Switch on game-specific settings { case SIFC_SHADOW:InputDPtr=MouseData;t|=1;attrib=1;break; case SIFC_OEKAKIDS:InputDPtr=MouseData;t|=1;attrib=1;break; case SIFC_ARKANOID:InputDPtr=MouseData;t|=1;break; case SIFC_FKB:InputDPtr=fkbkeys;break; case SIFC_HYPERSHOT:InputDPtr=&HyperShotData;break; case SIFC_MAHJONG:InputDPtr=&MahjongData;break; case SIFC_QUIZKING:InputDPtr=&QuizKingData;break; case SIFC_TOPRIDER:InputDPtr=&TopRiderData;break; case SIFC_BWORLD:InputDPtr=BWorldData;break; case SIFC_FTRAINERA: case SIFC_FTRAINERB:InputDPtr=&FTrainerData;break; } FCEUI_SetInputFC(InputType[2],InputDPtr,attrib); FCEUI_DisableFourScore(eoptions&EO_NOFOURSCORE); if(t) InitMouse(); }
static boolean InitGraphics() // returns true if initted ok { // init keyboard I_InitKeyboard(); if(1) InitMouse(); else noMouse = true; return true; }
void InitOtherInput(void) { void *InputDPtr; int t; int x; int attrib; for(t=0,x=0;x<2;x++) { attrib=0; InputDPtr=0; switch(InputType[x]) { case SI_POWERPADA: case SI_POWERPADB:InputDPtr=&powerpadbuf[x];break; case SI_GAMEPAD:InputDPtr=&JSreturn;break; case SI_ARKANOID:InputDPtr=MouseData;t|=1;break; case SI_ZAPPER:InputDPtr=MouseData; t|=1; attrib=1; break; } FCEUI_SetInput(x,InputType[x],InputDPtr,attrib); } attrib=0; InputDPtr=0; switch(InputType[2]) { case SIFC_SHADOW:InputDPtr=MouseData;t|=1;attrib=1;break; case SIFC_OEKAKIDS:InputDPtr=MouseData;t|=1;attrib=1;break; case SIFC_ARKANOID:InputDPtr=MouseData;t|=1;break; case SIFC_FKB:InputDPtr=fkbkeys;break; case SIFC_HYPERSHOT:InputDPtr=&HyperShotData;break; case SIFC_MAHJONG:InputDPtr=&MahjongData;break; case SIFC_QUIZKING:InputDPtr=&QuizKingData;break; case SIFC_TOPRIDER:InputDPtr=&TopRiderData;break; case SIFC_BWORLD:InputDPtr=BWorldData;break; case SIFC_FTRAINERA: case SIFC_FTRAINERB:InputDPtr=&FTrainerData;break; } FCEUI_SetInputFC(InputType[2],InputDPtr,attrib); FCEUI_DisableFourScore(eoptions&EO_NOFOURSCORE); if(t) InitMouse(); }
CInput::CInput(HWND hWnd, HINSTANCE hInst) { m_input = NULL; m_keyboardDevice = NULL; // Init keyboard if(!InitKeyboard(hWnd,hInst)) { MessageBox(hWnd,"Cannot initialize keyboard device","Error",MB_OK | MB_ICONERROR); } // Init mouse if(!InitMouse(hWnd,hInst)) { MessageBox(hWnd,"Cannot initialize mouse device","Error",MB_OK | MB_ICONERROR); } }
HRESULT CKeyMgr::Init(HINSTANCE _hInst, HWND _hWnd) { FAILED_CHECK_MSG(DirectInput8Create( _hInst , DIRECTINPUT_VERSION , IID_IDirectInput8 , (void**)&m_pInput , NULL), L"다이렉트 인풋 생성 실패"); FAILED_CHECK_MSG(InitKeyBoard(_hWnd), L"키보드 생성 실패"); FAILED_CHECK_MSG(InitMouse(_hWnd), L"마우스 생성 실패"); return S_OK; }
static boolean InitGraphics() // returns true if initted ok { // set scrptr scrptr = (char*) (__djgpp_conventional_base + 0xa0000); // init keyboard I_InitKeyboard(); if(1) //use_mouse) InitMouse(); else noMouse = true; return true; }
HRESULT CInput::InitDirectInput(const CInputConsoleSection_InitInput& initCommand) { HRESULT hr = 0; /* m_hInputLock = CreateEvent( NULL, FALSE, FALSE, NULL ); if (!m_hInputLock) { return E_FAIL; }*/ m_hMouseInput = CreateEvent( NULL, FALSE, FALSE, NULL ); if (!m_hMouseInput) { return E_FAIL; } m_hKeyboardInput = CreateEvent( NULL, FALSE, FALSE, NULL ); if (!m_hKeyboardInput) { return E_FAIL; } m_hJoystickInput = CreateEvent( NULL, FALSE, FALSE, NULL ); if (!m_hJoystickInput) { return E_FAIL; } hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&m_pDI, NULL ) ; if (initCommand.bNeedMouse) if (FAILED(hr=InitMouse(initCommand.hWnd))) return hr; if (initCommand.bNeedKeyboard) if (FAILED(hr=InitKeyboard(initCommand.hWnd))) return hr; m_hWnd = initCommand.hWnd; return hr; }
/** @brief Init OS after load. * @param NULL * @return NULL */ void OS_Init(void) { BOOTINFO* info; int32 screenWidth, screenHeight; uint8* bgBuf, *resVram; boolean re[2]; uint32 tmpAddr; InitPeripheralBuffer(); init_gdtidt(); init_pic(); io_sti(); // 恢复中断 tim_init(); io_out8(PIC0_IMR, 0xf8); /* PIT和PIC1和键盘设置为许可(11111000) */ io_out8(PIC1_IMR, 0xef); /* 鼠标设置为许可(11101111) */ info = (BOOTINFO*) ADR_BOOTINFO; screenHeight = info->screenHeight; screenWidth = info->screenWidth; init_palette(); mem_init(); fat_init(); re[0] = mem_alloc(768 * 1024, &tmpAddr); resVram = (uint8*)tmpAddr; sheet_init(resVram); InitMouse(); InitKeyboard(); re[1] = mem_alloc(768 * 1024, &tmpAddr); bgBuf = (uint8*)tmpAddr; //screenWidth * screenHeight sheet_add(bgBuf, screenWidth, screenHeight, 0, 0, NONE_COL, &bgSheet); fill_box(bgSheet, DARKGRASS, 0, 0, info->screenWidth, info->screenHeight); if(re[0] == FALSE || re[1] == FALSE) { fill_box(bgSheet, RED, 0, 0, info->screenWidth, info->screenHeight); } }
//============================================================================= // 入力処理の初期化 //============================================================================= HRESULT InitInput(HINSTANCE hInst, HWND hWnd) { HRESULT hr; if(!g_pDInput) { // DirectInputオブジェクトの作成 hr = DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&g_pDInput, NULL); } // キーボードの初期化 InitKeyboard(hInst, hWnd); // マウスの初期化 InitMouse(hInst, hWnd); return hr; }
int main(int argc, char **argv) { srand( (unsigned)time( NULL ) ); InitGLUT(argc, argv, "Shooter", 500, 500) ; InitDisplay(true, true, false) ; InitCamera(10) ; InitMouse() ; glutDisplayFunc(DisplayHandler) ; glutKeyboardFunc(KeyboardHandler) ; glutMouseFunc(MouseButtonHandler) ; glutMotionFunc(MotionHandler) ; InitOptions() ; glutMainLoop() ; return 0 ; }
void GetVertices() //initially take input in form of vertex { char name_v='A'; vcount=0; setcolor(WHITE); outtextxy(50,250,"MINIMUM COST SPANNING TREE...(PRESS ENTER TO CONTINUE)") ; getch(); cleardevice; setcolor(BLACK); outtextxy(50,250,"MINIMUM COST SPANNING TREE...(PRESS ENTER TO CONTINUE)") ; setcolor(LIGHTGREEN); outtextxy(4,1,"Click with mouse and press enter to add vertex"); outtextxy(4,10,"Press 1 if creation of vertices are done"); InitMouse(); ShowMouse(); do // while(!kbhit()) { if(IsClick()) { sprintf(vert[vcount].name,"%c",name_v++); vert[vcount].x=o.x.cx; vert[vcount].y=o.x.dx; vert[vcount].i=vcount; vert[vcount].number=vcount+1; vertex_fill(&vert[vcount],YELLOW); vcount++; // getch(); // if(kbhit()) // break; if(getch()=='1') break; } }while(vcount<MAX_VERT); //TOTAL VERTEX HideMouse(); }
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ // Name : 入力処理の初期化 // Description : 入力処理全般を初期化する // Arguments : hInst / インスタンス // hWnd / ウィンドウハンドル // Returns : 成否 //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ HRESULT CInput::InitInput(HINSTANCE hInst, HWND hWnd) { // ----- DirectInputオブジェクトの作成 if(FAILED(DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&m_pDInput, NULL))) return E_FAIL; // ----- キーボードの初期化 if(FAILED(InitKeyboard(hWnd))) return E_FAIL; // ----- マウスの初期化 if(FAILED(InitMouse(hWnd))) return E_FAIL; // ----- ゲームパッドの初期化 //if(FAILED(InitJoypad(hWnd))) // return E_FAIL; return S_OK; }
int main(int argc, char **argv) { InitGLUTWindow(argc, argv, "Scene", 400, 400) ; InitDisplay(true, true, true) ; // initialize variables and display modes InitMouse () ; InitCamera() ; glEnable(GL_AUTO_NORMAL) ; glEnable(GL_NORMALIZE) ; InitVars() ; ToggleLighting(true) ; glutDisplayFunc(DisplayHandler) ; glutKeyboardFunc(KeyboardHandler) ; glutSpecialFunc(SpecialKeyHandler) ; glutTimerFunc(20, UpdatePosition, 0); glutMainLoop() ; return 0 ; }
///Initialises DirectInput. ///hDlg: The window handler for which the input is initialised. void DirectXInputHandler::InitInput(Window* w) { _window = w; _hDlg = w->GetHWND(); //Gives the window the focus so it can find the input devices. HWND WINAPI SetFocus(_hDlg); // Register with the DirectInput subsystem and get a pointer // to a IDirectInput interface we can use. if( FAILED( DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, IID_IDirectInput8, ( VOID** )&_g_pDI, NULL ) ) ) { return; } //Initialises the different devices InitMouse(); InitKeyboard(); //TODO: Implement InitXBoxController(); //Writes an info message to the log. _logger->WriteLog("DirectInput initialised.", Logger::MessageType::Info); }
/****************************************************************** Function: InitiateControllers Purpose: This function initialises how each of the controllers should be handled. input: - A controller structure that needs to be filled for the emulator to know how to handle each controller. output: none *******************************************************************/ EXPORT void CALL InitiateControllers (CONTROL_INFO ControlInfo) #endif // SPECS_VERSION { DebugWriteA("CALLED: InitiateControllers\n"); if( !prepareHeap()) return; #if SPECS_VERSION == 0x0100 g_strEmuInfo.hMainWindow = hMainWindow; // g_strEmuInfo.HEADER = NULL; #elif SPECS_VERSION >= 0x0101 g_strEmuInfo.hMainWindow = ControlInfo.hMainWindow; // g_strEmuInfo.MemoryBswaped = ControlInfo.MemoryBswaped; // g_strEmuInfo.HEADER = ControlInfo.HEADER; // UNDONE: Instead of just storing the header, figure out what ROM we're running and save that information somewhere #endif // SPECS_VERSION // The emulator expects us to tell what controllers are plugged in and what their paks are at this point. if( !g_pDIHandle ) // if we don't have a directinput handle, we need to make one, attach it to the main window (so it will die if our emulator dies), and enumerate devices { if( InitDirectInput( g_strEmuInfo.hMainWindow )) { EnterCriticalSection ( &g_critical ); InitMouse(); g_pDIHandle->EnumDevices( DI8DEVCLASS_ALL, EnumMakeDeviceList, NULL, DIEDFL_ATTACHEDONLY ); LeaveCriticalSection ( &g_critical ); DebugWriteA("InitDirectInput run in InitiateControllers, g_nDevices=%d\n", g_nDevices); } else return; } int iDevice; EnterCriticalSection( &g_critical ); // ZeroMemory( g_apFFDevice, sizeof(g_apFFDevice) ); // NO, we'll reinit the existing reference if it's already loaded // ZeroMemory( g_apdiEffect, sizeof(g_apdiEffect) ); // NO, we'll release it with CloseControllerPak for( int i = 3; i >= 0; i-- ) { SaveControllerPak( i ); CloseControllerPak( i ); // freePakData( &g_pcControllers[i] ); // already called by CloseControllerPak freeModifiers( &g_pcControllers[i] ); SetControllerDefaults( &g_pcControllers[i] ); } g_pcControllers[0].fPlugged = true; if (! LoadConfigFromINI() ) { DebugWriteA("\tINI load failed, loading defaults from resource\n"); for ( int i = 0; i < 4; i++ ) LoadProfileFromResource( i, false ); LoadShortcutsFromResource(false); } for( int i = 0; i < 4; i++) // initiate xinput controller and plug then if connected --tecnicors { InitiateXInputController( &g_pcControllers[i].xiController, i ); if( g_pcControllers[i].xiController.bConnected ) { g_pcControllers[i].fPlugged = true; g_pcControllers[i].fGamePad = true; } } // END // Init: Find force-feedback devices and init for( int i = 3; i >= 0; i-- ) { DebugWriteA("Controller %d: ", i+1); if( g_pcControllers[i].xiController.bConnected && g_pcControllers[i].fXInput) // if xinput connected, we don't need other config --tecnicors continue; if( g_pcControllers[i].fPlugged ) { // Search for right Controller iDevice = FindDeviceinList( g_pcControllers[i].guidFFDevice ); if( iDevice != -1 && g_devList[iDevice].bEffType ) { DebugWriteA("rumble device set, "); } else // we couldn't find the device specified in the INI file, or it was already null { g_pcControllers[i].guidFFDevice = GUID_NULL; DebugWriteA("no rumble device/effect type set, "); } if( g_pcControllers[i].nModifiers > 0) SetModifier( &g_pcControllers[i] ); g_iFirstController = i; DebugWriteA("plugged in, with paktype %d, ", g_pcControllers[i].PakType); DebugWriteA("RawMode is %d\n", g_pcControllers[i].fRawData); } else { DebugWriteA("unplugged\n"); freePakData( &g_pcControllers[i] ); // we don't need to do this again, but there's not much overhead so I'll leave it --rabid freeModifiers( &g_pcControllers[i] ); } } PrepareInputDevices(); if( g_bExclusiveMouse ) { // g_sysMouse.didHandle->Unacquire(); // g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_MOUSE ); // PrepareInputDevices does this. g_sysMouse.didHandle->Acquire(); } InitiatePaks( true ); g_strEmuInfo.fInitialisedPlugin = true; LeaveCriticalSection( &g_critical ); #if SPECS_VERSION == 0x0100 FillControls(Controls); #elif SPECS_VERSION >= 0x0101 FillControls(ControlInfo.Controls); #endif // SPECS_VERSION return; } // end InitiateControllers
/****************************************************************** Function: DllConfig Purpose: This function is optional function that is provided to allow the user to configure the dll input: a handle to the window that calls this function output: none *******************************************************************/ EXPORT void CALL DllConfig ( HWND hParent ) { DebugWriteA("CALLED: DllConfig\n"); static bool bInitCC = false; if( !prepareHeap()) return; if( !g_pDIHandle ) { if( InitDirectInput( hParent )) { EnterCriticalSection ( &g_critical ); InitMouse(); g_pDIHandle->EnumDevices( DI8DEVCLASS_ALL, EnumMakeDeviceList, NULL, DIEDFL_ATTACHEDONLY ); LeaveCriticalSection ( &g_critical ); DebugWriteA("InitDirectInput run in DllConfig, g_nDevices=%d\n", g_nDevices); } } if( g_pDIHandle && !g_bConfiguring ) { g_bConfiguring = true; if( !bInitCC ) { INITCOMMONCONTROLSEX ccCtrls = { sizeof(INITCOMMONCONTROLSEX), ICC_BAR_CLASSES | ICC_TAB_CLASSES | ICC_LISTVIEW_CLASSES }; InitCommonControlsEx( &ccCtrls ); // needed for TrackBars & Tabs } EnterCriticalSection( &g_critical ); if( g_sysMouse.didHandle ) { // unlock mouse while configuring g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_DEVICE ); g_sysMouse.didHandle->Acquire(); } LeaveCriticalSection( &g_critical ); int iOK = DialogBox( g_hResourceDLL, MAKEINTRESOURCE( IDD_MAINCFGDIALOG ), hParent, MainDlgProc ); // If we go into the dialog box, and the user navigates to the Rumble window, our FF device can get unacquired. // So let's reinit them now if we're running, just to be safe --rabid if( g_bRunning ) { EnterCriticalSection( &g_critical ); // PrepareInputDevices resets g_bExclusiveMouse to false if no mouse keys are bound, and the only way to // re-enable exclusive mouse is with a shortcut. // This is undesirable behavior, but it beats the alternative (and we REALLY need to re-init FF devices here) PrepareInputDevices(); if (iOK) { InitiatePaks( false ); // only re-init the mempaks and such if the user clicked Save or Use } if( g_sysMouse.didHandle ) { if ( g_bExclusiveMouse ) { // if we have exclusive mouse, we need to relock mouse after closing the config g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_MOUSE ); g_sysMouse.didHandle->Acquire(); if (g_strEmuInfo.fDisplayShortPop) { LoadString( g_hResourceDLL, IDS_POP_MOUSELOCKED, g_pszThreadMessage, ARRAYSIZE(g_pszThreadMessage) ); // HWND hMessage = CreateWindowEx( WS_EX_NOPARENTNOTIFY | WS_EX_STATICEDGE | WS_EX_TOPMOST, _T("STATIC"), pszMessage, WS_CHILD | WS_VISIBLE, 10, 10, 200, 30, g_strEmuInfo.hMainWindow, NULL, g_strEmuInfo.hinst, NULL ); // SetTimer( hMessage, TIMER_MESSAGEWINDOW, 2000, MessageTimer ); CreateThread(NULL, 0, MsgThreadFunction, g_pszThreadMessage, 0, NULL); } } else { g_sysMouse.didHandle->SetCooperativeLevel( g_strEmuInfo.hMainWindow, DIB_KEYBOARD ); g_sysMouse.didHandle->Acquire(); } } LeaveCriticalSection( &g_critical ); } g_bConfiguring = false; } return; }
void GetEdges() //take weight from user { getch(); // cleardevice; setcolor(BROWN); outtextxy(4,1,"Point with mouse and press enter to add vertex"); outtextxy(4,10,"Press 1 if creation of vertices are done"); int i,j,p,q,p1,q1; int first_v,second_v,flag1,flag2; int count1=0,temp1=0; // flag1=flag2=0; for(i=0;i<vcount;i++) for(j=0;j<vcount;j++) { adj[i][j]=MAX_NUM; extra[i][j]=0; } InitMouse(); ShowMouse(); setcolor(LIGHTGREEN); outtextxy(10,20,"Create edges"); outtextxy(4,30,"Presss right mouse click to select first vertex"); outtextxy(4,40,"Press left mouse click to select other vertex."); outtextxy(4,50,"Press any keyboard key when done "); while(!kbhit()) { flag1=flag2=0; if(IsClick()) {if(count1==0&&o.x.bx==2&&temp1==0) //right button is clicked { p=o.x.cx; q=o.x.dx; count1=1; o.x.bx=0; temp1=1; for(int i=0;i<vcount;i++) { if((dist(vert[i].x,vert[i].y,p,q))<=20&& flag1==0) { first_v=i; vertex_fill(&vert[first_v],WHITE); //break; flag1=1; } } } } // getch(); if(IsClick()) { if(o.x.bx==1&&count1==1&&temp1==1) { count1=0; p1=o.x.cx; q1=o.x.dx; temp1=0; for(int j=0;j<vcount;j++) { if(dist(vert[j].x,vert[j].y,p1,q1)<=20&& flag2==0 && j!=first_v) { second_v=j; vertex_fill(&vert[second_v],WHITE); flag2=1; Edge_fill(&vert[first_v],&vert[second_v],RED,FALSE); adj[first_v][second_v]=adj[second_v][first_v]=-1; // break; } } } } } }
ProcessControls() { int xmax, ymax; xmax = (layer[0].sizex * 16) - sx; ymax = (layer[0].sizey * 16) - sy; if (key[SCAN_F5]) { key[SCAN_F5]=0; ShellMAP(); } if (key[SCAN_F6]) { key[SCAN_F6]=0; CompileAll(); } if (key[SCAN_F8]) { key[SCAN_F8]=0; ShellVERGE(); } if (key[SCAN_ALT] && key[SCAN_D]) { key[SCAN_D]=0; ShellToDOS(); } if (key[SCAN_ALT] && key[SCAN_L]) LoadMAPDialog(); if (key[SCAN_ALT] && key[SCAN_V]) ShellEditMAP(); if (key[SCAN_ALT] && key[SCAN_S]) ShellEditSystem(); if (key[SCAN_ALT] && key[SCAN_N]) NewMAP(); if (key[SCAN_ALT] && key[SCAN_P]) MPDialog(); if (!key[SCAN_ALT] && key[SCAN_P]) { pasting^=1; key[SCAN_P]=0; } // aen if (key[SCAN_A] && el<6) { lt++; if (lt==numtiles) lt=0; key[SCAN_A]=0; } if (key[SCAN_Z] && el<6) { if (lt) lt--; else lt=numtiles-1; key[SCAN_Z]=0; } if (key[SCAN_A] && el==7) { curzone++; key[SCAN_A]=0; } if (key[SCAN_Z] && el==7) { curzone--; key[SCAN_Z]=0; } if (key[SCAN_S]) { rt++; if (rt==numtiles) rt=0; key[SCAN_S]=0; } if (key[SCAN_X]) { if (rt) rt--; else rt=numtiles-1; key[SCAN_X]=0; } if (key[SCAN_F10]) { key[SCAN_F10]=0; if (random(0,255)<15) HAL(); SaveMAP(mapname); SaveVSP(vspname); CompileMAP(); Message("MAP/VSP saved.",100); modified=0; } if (key[SCAN_C]) { key[SCAN_C]=0; sprintf(strbuf,"Left: %d Right: %d", lt, rt); Message(strbuf, 300); } if (key[SCAN_M]) { key[SCAN_M]=0; GenerateMiniVSP(); MiniMAP(); } if (key[SCAN_H]) { key[SCAN_H]=0; mh=mh^1; if (mh) Message("MAP Tile Highlight enabled.",100); else Message("MAP Tile Highlight disabled.",100); } // *** // movement code moved to PollMovement() // *** if (key[SCAN_PGUP]) { key[SCAN_PGUP]=0; ywin -= sy; if (ywin < 0) ywin = 0; } if (key[SCAN_HOME]) { key[SCAN_HOME]=0; xwin -= sx; if (xwin < 0) xwin = 0; } if (key[SCAN_END]) { key[SCAN_END]=0; xwin += sx; if (xwin > xmax) xwin = xmax; } if (key[SCAN_PGDN]) { key[SCAN_PGDN]=0; ywin += sy; if (ywin > ymax) ywin = ymax; } if (key[SCAN_CTRL] && el<6) { key[SCAN_CTRL]=0; TileSelector(); } if (key[SCAN_CTRL] && el==7) { key[SCAN_CTRL]=0; ZoneEdDialog(); } if (key[SCAN_TAB]) { key[SCAN_TAB]=0; if (scrollmode) { scrollmode=0; xwin=xwin/16; xwin=xwin*16; ywin=ywin/16; ywin=ywin*16; Message("Tile scroll.",150); } else { scrollmode=1; Message("Pixel scroll.",150); } } if (key[SCAN_1]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[0]=0; return; } layertoggle[0]=1; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; el=0; key[SCAN_1]=0; } if (key[SCAN_2]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[1]=0; return; } key[SCAN_2]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>1) { layertoggle[1]=1; el=1; } } if (key[SCAN_3]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[2]=0; return; } key[SCAN_3]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>2) { layertoggle[2]=1; el=2; } } if (key[SCAN_4]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[3]=0; return; } key[SCAN_4]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>3) { layertoggle[3]=1; el=3; } } if (key[SCAN_5]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[4]=0; return; } key[SCAN_5]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>4) { layertoggle[4]=1; el=4; } } if (key[SCAN_6]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[5]=0; return; } key[SCAN_6]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>5) { layertoggle[5]=1; el=5; } } if (key[SCAN_O]) { key[SCAN_O]=0; layertoggle[6]=1; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; el=6; } if (key[SCAN_N]) { key[SCAN_N]=0; layertoggle[6]=0; layertoggle[7]=1; layertoggle[8]=0; layertoggle[9]=0; el=7; } if (key[SCAN_E]) { key[SCAN_E]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=1; layertoggle[9]=0; el=8; } if (key[SCAN_T]) { key[SCAN_T]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=1; el=9; } if (key[SCAN_F9]) { // aen key[SCAN_F9]=0; mouse_scroll^=1; sprintf(strbuf,"Mouse scroll %sabled.", mouse_scroll ? "en" : "dis"); Message(strbuf, 100); } if (key[SCAN_F11]) { key[SCAN_F11]=0; ScreenShot(); Message("Screen capture saved.",300); } if (key[SCAN_F12]) { key[SCAN_F12]=0; OutputVSPpcx(); Message("PCX file exported.",300); } if (key[SCAN_LANGLE]) { key[SCAN_LANGLE]=0; ShutdownVideo(); vm=0; InitVideo(0); set_intensity(63); InitMouse(); // aen -- gotta recalc this if you're in a lower res at the bottom of // the map and jump to a higher res. xmax = (layer[0].sizex * 16) - sx; ymax = (layer[0].sizey * 16) - sy; if (xwin > xmax) xwin=xmax; if (ywin > ymax) ywin=ymax; } if (key[SCAN_RANGLE]) { key[SCAN_RANGLE]=0; ShutdownVideo(); vm=1; InitVideo(1); set_intensity(63); InitMouse(); // aen -- gotta recalc this if you're in a lower res at the bottom of // the map and jump to a higher res. xmax = (layer[0].sizex * 16) - sx; ymax = (layer[0].sizey * 16) - sy; if (xwin > xmax) xwin=xmax; if (ywin > ymax) ywin=ymax; } if (CheckMouseTabs()) return; if (mb>=3) MainMenu(mx-4,my-5); if (key[SCAN_ESC]) DoMainMenu(); if (mb==1 && key[SCAN_SLASH] && el<6) { lt=layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16)]; return; } if (mb==2 && key[SCAN_SLASH] && el<6) { rt=layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16)]; return; } // aen; these must come before the tile plotting code just below // to work correctly. if (mb && el<6 && key[SCAN_LSHIFT] && !shifted) { selx1=(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16); sely1=(((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16); selx2=selx1; sely2=sely1; shifted=mb; return; } if (mb && el<6 && shifted) { selx2=(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16); sely2=(((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16); return; } if (!mb && el<6 && shifted) { int i,j; int x1,y1,x2,y2; x1=selx1; y1=sely1; x2=selx2; y2=sely2; if (x2<x1) x2^=x1,x1^=x2,x2^=x1; if (y2<y1) y2^=y1,y1^=y2,y2^=y1; copybuf_wide=x2-x1+1; copybuf_deep=y2-y1+1; if (shifted==2) { // block fill modified=1; for (j=0; j<copybuf_deep; j++) { for (i=0; i<copybuf_wide; i++) layers[el][((y1+j)*layer[el].sizex)+(x1+i)]=lt; } } if (shifted==1) { modified=1; if (copybuf) vfree(copybuf); copybuf=(word *)valloc(copybuf_wide*copybuf_deep*2, "copybuf", 0); // copy for (j=0; j<copybuf_deep; j++) { for (i=0; i<copybuf_wide; i++) copybuf[(j*copybuf_wide)+i]=layers[el][((y1+j)*layer[el].sizex)+(x1+i)]; } pasting=1; } selx1=sely1=0; selx2=sely2=0; shifted=0; } if (mb==1 && el<6 && !shifted && pasting) { int a,b,i,j; a=(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16); b=(((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16); // paste for (j=0; j<copybuf_deep; j++) { for (i=0; i<copybuf_wide; i++) { if (b+j<layer[el].sizey && a+i<layer[el].sizex) layers[el][((b+j)*layer[el].sizex)+(a+i)]=copybuf[(j*copybuf_wide)+i]; } } } if (mb==1 && el<6 && !shifted && !pasting) { if (mx>335) mx=334; modified=1; layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16) /16)]=lt; } if (mb==2 && el<6 && !shifted) { if (mx>335) mx=334; modified=1; layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16) /16)]=rt; } if (mb==1 && el==6) { modified=1; obstruct[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]=1; } if (mb==2 && el==6) { modified=1; obstruct[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]=0; } if (mb==1 && el==7 && (key[SCAN_LSHIFT] || key[SCAN_RSHIFT])) { curzone=zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]; WaitRelease(); ZoneEdDialog(); return; } if (mb==1 && el==7) { modified=1; zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]=curzone; } if (mb==2 && el==7) { modified=1; zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]=0; } if (mb==1 && el==8) { WaitRelease(); ProcessEntity((xwin+(mx-16))/16,(ywin+(my-16))/16); modified=1; } if (el==8 && EntityThere((mx-16+xwin)/16,(my+ywin-16)/16) && key[SCAN_DEL]) { WaitRelease(); DeleteEntity((mx-16+xwin)/16,(my-16+ywin)/16); modified=1; } }
void beforegame() /******游戏主界面*******/ { int i,j; fire(); ShowBmp256(70,65,".\\source\\login.bmp",1,0); InitGraph(); star=malloc(sizeof(struct STAR)*STARNUM); initstar(star); InitMouse(0,0,maxx,maxy); getdat(); handler=getvect(0x1c); mousex=getmaxx()/2; mousey=getmaxy()/2; logo=bmp_to_dat(".\\source\\snooker.bmp"); vs1=bmp_to_dat(".\\source\\head0.bmp"); vs2=bmp_to_dat(".\\source\\head1.bmp"); play(1); for (i=0;i<3;i++) { putimage(0,0,logo,NOT_PUT); for (j=20;j<=1000;j+=10) { delay(1000); } delay(3000); putimage(0,0,logo,COPY_PUT); for (j=1000;j>=20;j-=10) { delay(2000); } delay(3000); } putimage(0,0,logo,COPY_PUT); for (i=0;i<STARNUM;i++) drawstar(star); outchinese(400,80,s_cn,EOF,4,2); putimage(300,280,vs1,COPY_PUT); putimage(520,280,vs2,COPY_PUT); settextstyle(1,0,12); setcolor(GREEN); outtextxy(380,260,"Vs"); drawmouse(mousex,mousey); play(2); drawmenu(mm); while(1) { while(bioskey(1)!=0) getch(); position(1); mm=fill(); drawmouse(mousex,mousey); if (button==1) { switch (mm) { case 0: { free(logo); free(star); cleardevice(); return; } case 1: { practice(); restore(); break; } case 2: { noplay(); option(); break; } case 3: { noplay(); toprank(); restore(); break; } case 4: { if (Music_on==1) play(0); showhelp(); break; } case 5: { position(0); End(1); drawmouse(mousex,mousey); break; } } } button=0; } }
int main(int argc, char **argv) { unsigned short grafboard; extern int disk_error_handler(int errval, int ax, int bp, int si); char *p; allocatebuffers(); if (init_mem_err) { cprintf("\r\n\r\nSorry, not enough memory to run Toy Universes.\r\n"); return -1; } harderr(disk_error_handler); /* Find out if we have a VGA or EGA at all. */ grafboard = QueryGrafix(); if ((grafboard & 0x200) != 0x200) { printf("This programs requires EGA capability.\n"); exit(-1); } if (grafboard == 0xffff || InitGrafix(-EGA640x350) < 0) { printf("Metagraphics not installed. Execute the command:\n"); printf("metashel /i\n"); printf("and then try again.\n"); exit(-1); } vgaflag = -1; while (argc > 1) { if (argv[1][0] == '-') { switch (argv[1][1]) { case 'e': vgaflag = 0; break; case 'v': vgaflag = 1; break; } } argc--; argv++; } if (vgaflag == -1) { if ((grafboard & 0x300) == 0x300) vgaflag = 1; else vgaflag = 0; } Comm = QueryComm(); if (Comm == MsDriver) InitMouse(MsDriver); else if (Comm == MsCOM1) InitMouse(MsCOM1); else if (Comm == MsCOM2) InitMouse(MsCOM2); else if (Comm & 3) InitMouse(COM1); /* * Probably wrong. Need to check for MS mouse address in some special * way. */ randomize(); p = searchpath("system16.fnt"); if (p) LoadFont(p); installmode(); load_preset_palettes(); usepalette(); current_main_item = 0; usepalette(); TWICE(initialize_buttons()); ShowCursor(); if (allocatefailflag) ErrorBox("Not enough memory for hi-res."); /* Lets see if there is enough for a later gif */ if (!memok(20712L)) /* Added up mallocs in comprs.c */ ErrorBox("There may not be enough memory to save or view a Gif."); prog_init = 1; if (!setjmp(beatit)) { while (!exitflag) { rebuildflag = 0; if (newcaflag && !donescreenflag) { loadlookuptable(increment, maxstate); newcaflag = 0; } if (newcaoflag) { unsigned char *p1,*p2; static int firsttime = true; switch(caotype) { case CA_HODGE: p1 = (char *)HODGE_colortable; p2 = HODGE_ct; break; case CA_EAT: p1 = (char *)EAT_colortable; p2 = EAT_ct; break; case CA_TUBE: p1 = (char *)TUBE_colortable; p2 = TUBE_ct; break; case CA_NLUKY: p1 = (char *)NLUKY_colortable; p2 = NLUKY_ct; break; } memcpy(vgacolortable,p1,16*3); if (!hasVGA) memcpy(egacolortable,p2,16); if (!firsttime) { TWICE(initialize_numbers()); } else firsttime = false; usepalette(); newcaoflag = 0; current_main_item = -1; } if (blankflag) { blankbuffers(); blankflag = 0; } if (randomizeflag) { carandomize(); randomizeflag = 0; } while (!exitflag && !rebuildflag) { if (onestep || !stopped) { if (display_mode == HI) hiresupdate(); else loresupdate(); if (onestep) onestep--; } if (spinflag && (!stopped || (iteration++ > spinspeed))) { if (spinflag == 1) spinpalette(); else revspinpalette(); iteration = 0; } checkkeyboard(); if (newcaflag) rebuildflag = 1; } } } StopMouse(); StopEvent(); grayflag = 0; grayscale(); SetDisplay(TextPg0); return exitflag; }
/* * doInitializeEditor - do just that */ static void doInitializeEditor( int argc, char *argv[] ) { int i, arg, cnt, ocnt, startcnt = 0; srcline sline; int k, j; char tmp[FILENAME_MAX], c[1]; char buff[MAX_STR], file[MAX_STR], **list; char cmd[MAX_STR * 2]; char *parm; char *startup[MAX_STARTUP]; char *startup_parms[MAX_STARTUP]; vi_rc rc; vi_rc rc1; /* * Make sure WATCOM is setup and if it is not, make a best guess. */ watcom_setup_env(); /* * If EDPATH is not set, use system default %WATCOM%\EDDAT. */ if( getenv( "EDPATH" ) == NULL ) { char *watcom; watcom = getenv( "WATCOM" ); if( watcom != NULL ) { char edpath[FILENAME_MAX]; sprintf( edpath, "%s%c%s", watcom, FILE_SEP, "eddat" ); if( setenv( "EDPATH", edpath, 0 ) != 0 ) { /* * Bail out silently on error, as we will get error message later on. */ } } } /* * misc. set up */ MaxMemFree = MemSize(); StaticStart(); FTSInit(); BoundDataInit(); EditFlags.Starting = true; InitCommandLine(); ChkExtendedKbd(); SSInitBeforeConfig(); GetCWD1( &HomeDirectory ); GetCWD1( &CurrentDirectory ); SetCWD( HomeDirectory ); if( cfgFN == NULL ){ cfgFN = DupString( CFG_NAME ); } checkFlags( &argc, argv, startup, startup_parms, &startcnt ); ScreenInit(); SetWindowSizes(); EditFlags.ClockActive = false; SetInterrupts(); #ifdef __WIN__ InitClrPick(); InitFtPick(); SubclassGenericInit(); CursorOp( COP_INIT ); #else InitColors(); #endif InitSavebufs(); InitKeyMaps(); /* * initial configuration */ EditVars.Majick = MemStrDup( "()~@" ); EditVars.FileEndString = MemStrDup( "[END_OF_FILE]" ); MatchInit(); SetGadgetString( NULL ); WorkLine = MemAlloc( sizeof( line ) + EditVars.MaxLine + 2 ); WorkLine->len = -1; sline = 0; if( cfgFN[0] != 0 ) { c[0] = 0; rc = Source( cfgFN, c, &sline ); if( rc == ERR_FILE_NOT_FOUND ) { #ifdef __WIN__ CloseStartupDialog(); MessageBox( (HWND)NULLHANDLE, "Could not locate configuration information; please make sure your EDPATH environment variable is set correctly", EditorName, MB_OK ); ExitEditor( -1 ); #else rc = ERR_NO_ERR; #endif } } else { rc = ERR_NO_ERR; } if( wantNoReadEntireFile ) { EditFlags.ReadEntireFile = false; } VerifyTmpDir(); while( LostFileCheck() ); HookScriptCheck(); if( EditFlags.Quiet ) { EditFlags.Spinning = false; EditFlags.Clock = false; } ExtendedMemoryInit(); /* * more misc. setup */ if( EditVars.WordDefn == NULL ) { EditVars.WordDefn = DupString( &WordDefnDefault[6] ); InitWordSearch( EditVars.WordDefn ); } if( EditVars.WordAltDefn == NULL ) { EditVars.WordAltDefn = DupString( WordDefnDefault ); } if( EditVars.TagFileName == NULL ) { EditVars.TagFileName = DupString( "tags" ); } DotBuffer = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); AltDotBuffer = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); DotCmd = MemAlloc( (maxdotbuffer + 2) * sizeof( vi_key ) ); SwapBlockInit( EditVars.MaxSwapBlocks ); ReadBuffer = MemAlloc( MAX_IO_BUFFER + 6 ); WriteBuffer = MemAlloc( MAX_IO_BUFFER + 6 ); FindHistInit( EditVars.FindHist.max ); FilterHistInit( EditVars.FilterHist.max ); CLHistInit( EditVars.CLHist.max ); LastFilesHistInit( EditVars.LastFilesHist.max ); GetClockStart(); GetSpinStart(); SelRgnInit(); SSInitAfterConfig(); #if defined( VI_RCS ) ViRCSInit(); #endif /* * create windows */ StartWindows(); InitMouse(); rc1 = NewMessageWindow(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } DoVersion(); rc1 = InitMenu(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } EditFlags.SpinningOurWheels = true; EditFlags.ClockActive = true; EditFlags.DisplayHold = true; rc1 = NewStatusWindow(); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } EditFlags.DisplayHold = false; MaxMemFreeAfterInit = MemSize(); /* * look for a tag: if there is one, set it up as the file to start */ EditFlags.WatchForBreak = true; if( cTag != NULL && !EditFlags.NoInitialFileLoad ) { #if defined( __NT__ ) && !defined( __WIN__ ) { if( !EditFlags.Quiet ) { SetConsoleActiveScreenBuffer( OutputHandle ); } } #endif rc1 = LocateTag( cTag, file, buff ); cFN = file; if( rc1 != ERR_NO_ERR ) { if( rc1 == ERR_TAG_NOT_FOUND ) { Error( GetErrorMsg( rc1 ), cTag ); ExitEditor( 0 ); } FatalError( rc1 ); } } /* * start specified file(s) */ cmd[0] = 'e'; cmd[1] = 0; arg = argc - 1; k = 1; while( !EditFlags.NoInitialFileLoad ) { if( cFN == nullFN && !EditFlags.UseNoName ) { break; } #ifdef __NT__ { int k2; int arg2; char path[_MAX_PATH]; int found; int fd; size_t len; size_t len1; char *p; /* * check for the existence of a file name containing spaces, and open it if * there is one */ len = _MAX_PATH - 1; found = 0; p = path; arg2 = arg; for( k2 = k; argv[k2] != NULL; ) { len1 = strlen( argv[k2] ); if( len1 > len ) break; memcpy( p, argv[k2], len1 ); p += len1; *p = '\0'; len -= len1; --arg2; ++k2; fd = open( path, O_RDONLY ); if( fd != -1 ) { close( fd ); k = k2; arg = arg2; found = 1; break; } *p++ = ' '; } if( found ) { #ifndef __UNIX__ len1 = strlen( path ); if( path[len1 - 1] == '.' ) path[len1 - 1] = '\0'; #endif rc1 = NewFile( path, false ); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } cFN = argv[k]; if( arg < 1 ) { break; } continue; } } #endif strcat( cmd, SingleBlank ); strcat( cmd, cFN ); ocnt = cnt = ExpandFileNames( cFN, &list ); if( cnt == 0 ) { cnt = 1; } else { cFN = list[0]; } for( j = 0; j < cnt; j++ ) { rc1 = NewFile( cFN, false ); if( rc1 != ERR_NO_ERR && rc1 != NEW_FILE ) { FatalError( rc1 ); } if( EditFlags.BreakPressed ) { break; } if( cnt > 0 && j < cnt - 1 ) { cFN = list[j + 1]; } } if( ocnt > 0 ) { MemFreeList( ocnt, list ); } if( EditFlags.BreakPressed ) { ClearBreak(); break; } k++; arg--; if( cTag != NULL || arg < 1 ) { break; } cFN = argv[k]; } if( EditFlags.StdIOMode ) { rc1 = NewFile( "stdio", false ); if( rc1 != ERR_NO_ERR ) { FatalError( rc1 ); } } EditFlags.WatchForBreak = false; EditFlags.Starting = false; /* * if there was a tag, do the appropriate search */ if( cTag != NULL && !EditFlags.NoInitialFileLoad ) { if( buff[0] != '/' ) { i = atoi( buff ); rc1 = GoToLineNoRelCurs( i ); } else { rc1 = FindTag( buff ); } if( rc1 > 0 ) { Error( GetErrorMsg( rc1 ) ); } } /* * try to run startup file */ if( EditFlags.RecoverLostFiles ) { startcnt = 0; } for( i = 0; i < startcnt; i++ ) { GetFromEnv( startup[i], tmp ); ReplaceString( &cfgFN, tmp ); if( cfgFN[0] != 0 ) { if( startup_parms[i] != NULL ) { parm = startup_parms[i]; } else { c[0] = 0; parm = c; } #if defined( __NT__ ) && !defined( __WIN__ ) { if( !EditFlags.Quiet ) { SetConsoleActiveScreenBuffer( OutputHandle ); } } #endif sline = 0; rc = Source( cfgFN, parm, &sline ); } } if( rc > ERR_NO_ERR ) { Error( "%s on line %u of \"%s\"", GetErrorMsg( rc ), sline, cfgFN ); } if( argc == 1 ) { LoadHistory( NULL ); } else { LoadHistory( cmd ); } if( EditVars.GrepDefault == NULL ) { EditVars.GrepDefault = DupString( "*.(c|h)" ); } if( goCmd[0] != 0 ) { KeyAddString( goCmd ); } if( keysToPush != NULL ) { KeyAddString( keysToPush ); } #ifdef __WIN__ if( lineToGoTo != 0 ) { SetCurrentLine( lineToGoTo ); NewCursor( CurrentWindow, EditVars.NormalCursorType ); } #endif AutoSaveInit(); HalfPageLines = WindowAuxInfo( CurrentWindow, WIND_INFO_TEXT_LINES ) / 2 - 1; #if defined( _M_X64 ) VarAddGlobalStr( "OSX64", "1" ); #elif defined( _M_IX86 ) && !defined( _M_I86 ) VarAddGlobalStr( "OS386", "1" ); #endif if( EditVars.StatusString == NULL ) { EditVars.StatusString = DupString( "L:$6L$nC:$6C" ); } UpdateStatusWindow(); #ifdef __WIN__ if( CurrentInfo == NULL ) { // no file loaded - screen is disconcertenly empty - reassure DisplayFileStatus(); } #endif NewCursor( CurrentWindow, EditVars.NormalCursorType ); #if defined( __NT__ ) && !defined( __WIN__ ) { SetConsoleActiveScreenBuffer( OutputHandle ); } #endif } /* doInitializeEditor */