void Atari_Initialise(int *argc, char *argv[]) { #ifdef SOUND Sound_Initialise(argc, argv); #endif if (gron(argc, argv)) { perror("Graphics initialization failed"); exit(1); } if(initinput()) { perror("Input initialization failed"); exit(1); } /* backlight */ REG_bat = REG_ac = REG_disp = 2 * 60 * 60 * 1000; /* 2hrs should do it */ backlight_xchg(); SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, (void *) &bat_timeout, 0); SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, 60 * 60 * 2, NULL, SPIF_SENDCHANGE); clearkb(); }
void CleanUp(void) { GXCloseDisplay(); GXCloseInput(); if(theOSystem) delete theOSystem; backlight_xchg(); SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, bat_timeout, NULL, SPIF_SENDCHANGE); }
int Atari_Exit(int run_monitor) { backlight_xchg(); /* restore backlight settings */ SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, bat_timeout, NULL, SPIF_SENDCHANGE); /* monitor is not avaliable in this port */ if(run_monitor) return 1; #ifdef BUFFERED_LOG Aflushlog(); #endif uninitinput(); groff(); #ifdef SOUND Sound_Exit(); #endif return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd ) { LPTSTR wndname = _T("PocketStella"); WNDCLASS wc = { CS_HREDRAW | CS_VREDRAW, WindowProc, 0, 0, hInstance, NULL, NULL, (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, wndname}; RegisterClass(&wc); hWnd = CreateWindow(wndname, wndname, WS_VISIBLE | WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL); if (!hWnd) return 1; SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); /* backlight */ REG_bat = REG_ac = REG_disp = 2 * 60 * 60 * 1000; /* 2hrs should do it */ backlight_xchg(); SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, (void *) &bat_timeout, 0); SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, 60 * 60 * 2, NULL, SPIF_SENDCHANGE); // pump the messages to get the window up MSG msg; while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } LOGFONT f = {11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("")}; HFONT hFnt = CreateFontIndirect(&f); HDC hDC = GetDC(hWnd); SelectObject(hDC, hFnt); RECT RWnd; GetClipBox(hDC, &RWnd); SetTextColor(hDC, 0xA0A0A0); SetBkColor(hDC, 0); DrawText(hDC, _T("PocketStella Initializing..."), -1, &RWnd, DT_CENTER | DT_VCENTER); ReleaseDC(hWnd, hDC); DeleteObject(hFnt); theOSystem = new OSystemWinCE(((string) getcwd()) + '\\'); SettingsWinCE theSettings(theOSystem); theOSystem->settings().loadConfig(); theOSystem->settings().validate(); bool loaddefaultkeys = (theOSystem->settings().getString("keymap") == EmptyString); theOSystem->create(); if (loaddefaultkeys) { // setup the default keybindings the first time we're run theOSystem->eventHandler().addKeyMapping(Event::JoystickZeroFire, kEmulationMode, SDLK_F1); theOSystem->eventHandler().addKeyMapping(Event::LauncherMode, kEmulationMode, SDLK_BACKSPACE); theOSystem->eventHandler().addKeyMapping(Event::ConsoleReset, kEmulationMode, SDLK_F6); theOSystem->eventHandler().addKeyMapping(Event::ConsoleSelect, kEmulationMode, SDLK_F5); theOSystem->eventHandler().addKeyMapping(Event::UIPgUp, kMenuMode, SDLK_LEFT); theOSystem->eventHandler().addKeyMapping(Event::UIPgDown, kMenuMode, SDLK_RIGHT); theOSystem->eventHandler().addKeyMapping(Event::UISelect, kMenuMode, SDLK_F1); theOSystem->eventHandler().addKeyMapping(Event::UICancel, kMenuMode, SDLK_BACKSPACE); } if ( !GXOpenDisplay(hWnd, GX_FULLSCREEN) || !GXOpenInput() ) { CleanUp(); return 1; } KeySetup(); string romfile = ((string) getcwd()) + ((string) "\\") + theSettings.getString("GameFilename"); if (!FilesystemNode::fileExists(romfile)) theOSystem->createLauncher(); else theOSystem->createConsole(romfile); theOSystem->mainLoop(); CleanUp(); return 0; }