int Atari_Exit(int run_monitor) { /* restore to text mode */ ShutdownVgaEnvironment(); key_delete(); /* enable keyboard in monitor */ if (run_monitor) { #ifdef SOUND Sound_Pause(); #endif if (monitor()) { #ifdef MONITOR_BREAK if (!break_step) /*do not enter videomode when stepping through the code*/ #endif SetupVgaEnvironment(); #ifdef SOUND Sound_Continue(); #endif return 1; /* return to emulation */ } } #ifdef SOUND Sound_Exit(); #endif Aflushlog(); return 0; }
/** * main * This function initializes all graphical variables as well as opens the input * file and calls a function which populates a 2D array accordingly. It then * calls run(), which takes care of the actual running of the Game of Life. * Finally, it restores the video mode to the original state and releases * keyboard control. **/ int main(int argc, char *argv[]) { //this array stores the current life state int model[COLUMNS][ROWS] = {0}; key_init(); //takes control of keyboard input init_graphics(); //switches to XGA my_video_ds = __dpmi_allocate_ldt_descriptors(1); __dpmi_set_segment_base_address(my_video_ds,ADDR); ADDR = 0; /* basis now zero from selector */ __dpmi_set_segment_limit(my_video_ds,(width*height)|0xfff); //the following reads in a file if one was given and populates the grid if (argc==2) { FILE *fp = fopen(argv[1], "r"); if (fp == 0) { printf("Error - invalid filename\n" ); return 0; } else { populate(model, fp); } } run(model); //runs the program close_graphics(); //restores video mode to original state key_delete(); //releases control over the keyboard return 0; }
int input_interface(t_interface *in, char *dst) { static char buf[4096] = {0}; static int index = 0; int key; key = wgetch(WIN(w_root)); if ( ' ' <= key && key <= '~' && index < 4096) return (key_insert(buf, key, &index, in)); else if ((key == 263 || key == 127) && index > 0) return (key_delete(buf, &index, in)); else if (key == '\n' && index > 0) return (key_send(buf, dst, &index, in)); else if (key == KEY_LEFT) { memcpy(dst, "/window left\0", 13); return (1); } else if (key == KEY_RIGHT) { memcpy(dst, "/window right\0", 14); return (1); } return (0); }
static void ini_parse_sections_and_keys(Ini *ini, const char *data) { Key *key; Section *section; char *line; while ((line = sgetline(&data)) != NULL) { if (isingnorableline(line)) continue; /* キーとして解釈 */ if ((key = key_parse(line)) != NULL) { free(line); if (section_add_key(ini->current, key)) { key_delete(key); return; } continue; } /* セクションとして解釈 */ if ((section = section_parse(line)) != NULL) { ini->current = section; free(line); if (ini_add_section(ini, ini->current)) { section_delete(ini->current); return; } continue; } free(line); return; /* 無効な文字列の場合にここまで来る */ } }