int main(int argc, char **argv) { #if HAVE_WINDOWS_H /* Handle Windows console signals myself. If not, then closing the console window would cause emulator crash due to the sound subsystem being active. */ if(!SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE)) { Log_print("ERROR: Could not set console control handler"); return 1; } #endif /* HAVE_WINDOWS_H */ /* initialise Atari800 core */ if (!Atari800_Initialise(&argc, argv)) return 3; /* main loop */ for (;;) { INPUT_key_code = PLATFORM_Keyboard(); SDL_INPUT_Mouse(); Atari800_Frame(); if (Atari800_display_screen) PLATFORM_DisplayScreen(); } }
int main(int argc, char **argv) { /* initialise Atari800 core */ if (!Atari800_Initialise(&argc, argv)) return 3; /* main loop */ for (;;) { INPUT_key_code = PLATFORM_Keyboard(); Atari800_Frame(); if (Atari800_display_screen) PLATFORM_DisplayScreen(); if (JAVANVM_CheckThreadStatus()) { Atari800_Exit(FALSE); exit(0); } } }
static int GetKeyPress(void) { int keycode; if (UI_alt_function >= 0) return 0x1b; /* escape - go to Main Menu */ PLATFORM_DisplayScreen(); for (;;) { static int rep = KB_DELAY; if (PLATFORM_Keyboard() == AKEY_NONE) { rep = KB_DELAY; break; } if (rep == 0) { rep = KB_AUTOREPEAT; break; } rep--; Atari800_Sync(); } do { #ifdef DIRECTX DoEvents(); #endif Atari800_Sync(); keycode = PLATFORM_Keyboard(); switch (keycode) { case AKEY_WARMSTART: UI_alt_function = UI_MENU_RESETW; return 0x1b; /* escape */ case AKEY_COLDSTART: UI_alt_function = UI_MENU_RESETC; return 0x1b; /* escape */ case AKEY_EXIT: UI_alt_function = UI_MENU_EXIT; return 0x1b; /* escape */ case AKEY_UI: #ifdef DIRECTX UI_Run(); #else if (UI_alt_function >= 0) /* Alt+letter, not F1 */ #endif return 0x1b; /* escape */ break; case AKEY_SCREENSHOT: UI_alt_function = UI_MENU_PCX; return 0x1b; /* escape */ case AKEY_SCREENSHOT_INTERLACE: UI_alt_function = UI_MENU_PCXI; return 0x1b; /* escape */ default: UI_alt_function = -1; /* forget previous Main Menu shortcut */ break; } } while (keycode < 0); return UI_BASIC_key_to_ascii[keycode]; }
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int nshowcmd) { //*********************************************** // Convert WinMain() style command line arguments // to main() style arguments (argc, *argv[]) // This maintains compatibility with the former // main() entry point's parameters. //*********************************************** char **argv = NULL; int argc = 1; char *app_path = new char[MAX_PATH]; strcpy(app_path, GetCommandLine()); if (app_path[0] == '\"') { app_path = (app_path+1); char *lastdit = strchr(app_path, '\"'); *lastdit = '\x0'; } if ( *lpcmdline != '\x0' ) { char *cmdlinecopy = new char[strlen(lpcmdline)+1]; strcpy(cmdlinecopy, lpcmdline); char *c = cmdlinecopy; while(c) { ++argc; c = strchr((c+1),' '); } argv = new char*[argc]; argv[0] = app_path; if(argc > 1) { argv[1] = cmdlinecopy; char *c = strchr(cmdlinecopy, ' '); int n = 2; while(c) { *c = '\x0'; argv [n] = (c+1); ++n; c = strchr((c+1), ' '); } } } else { argv = new char *[1]; argv[0] = app_path; } //********************************************* // Process commandline and activate console // if -console switch is set. //********************************************* int i,j; for (i = j = 1; i < argc; i++) { if (strcmp(argv[i], "-console") == 0) { useconsole = TRUE; } else if (strcmp(argv[i], "-help") == 0) { help_only = TRUE; } } if (useconsole || help_only) { AllocConsole(); // start a console window freopen("CONIN$","rb",stdin); // reopen stdin handle as console window input freopen("CONOUT$","wb",stdout); // reopen stout handle as console window output freopen("CONOUT$","wb",stderr); // reopen stderr handle as console window output } else // not using console { // console is supressed, so stream console output to a file stdout_stream = freopen("atari800.txt", "w", stdout); if (stdout_stream == NULL) fprintf(stdout, "Error opening atari800.txt\n"); } //********************************************* // Begin main processing //********************************************* MSG msg; POINT mouse; Win32_Init(); myInstance = GetModuleHandle(NULL); if (help_only) { /* initialize the Atari800 for help only */ Atari800_Initialise(&argc, argv); Log_print("\t-console Show the Atari800 console window"); Log_print("\n"); system("PAUSE"); return 0; } /* initialise Atari800 core for use */ if (!Atari800_Initialise(&argc, argv)) return 3; msg.message = WM_NULL; /* main loop */ for (;;) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (msg.message == WM_QUIT) break; if (!bActive) continue; INPUT_key_code = PLATFORM_Keyboard(); // support mouse device modes // only supported in fullscreen modes for now if (GetScreenMode() == FULLSCREEN) { GetCursorPos(&mouse); INPUT_mouse_delta_x = mouse.x - MOUSE_CENTER_X; INPUT_mouse_delta_y = mouse.y - MOUSE_CENTER_Y; if (INPUT_mouse_delta_x | INPUT_mouse_delta_y) SetCursorPos(MOUSE_CENTER_X, MOUSE_CENTER_Y); } Atari800_Frame(); if (Atari800_display_screen) PLATFORM_DisplayScreen(); } return msg.wParam; }