int main(void) { //Main loop, runs once but can have an infinit loop in it cli(); /* First we need to set the hardaware up, this is a macro in global.h which takes care of calling the various funtions that setup the registers to the proper seting, and also pulls the CPU_POW pin high if debug in GLOBAL.h is set, then debug keys will be sent out through the serial port when this function is called */ bios(); //if we're in debug mode, make sure you send stuff saying we got to the main code #if DEBUG uart_sendint(MAIN_KEY); #if DEBUG_BEG uart_sendstr("0x6 - Main code checkpoint..."); #endif #endif sei(); init_out('D', 5); //infinit loop that doesn't stop running. (always true since 1 is always 1 ) while(1) { pwm1A(led); }; return 0; //never reached since 1 is always true }
void init_save() { init_out(xyz_filename, &xyz_file, "w" ); init_out(dcd_filename, &dcd_file, "wb" ); if( dcd_file ) { dcd_tab = (float*) malloc( sizeof(float) * size * DIMS0 ); CHMEM(dcd_tab); init_dcd( bdsteps / save_dcd_freq ); } init_out(enr_filename, &enr_file, "w" ); if( enr_file ) init_enr(); init_out( pqr_filename, &pqr_file, "w" );/*pqr is closed after save*/ if( pqr_filename ) { char* buff = add_suffix( pqr_filename, PQR_SUFFIX); init_out( buff, &pqr_file_hi, "w" ); free(buff); } }
void init_out_ar( STR filename, FILE** out_file, const char* open_type, int prev_size ) { if( !prev_size )/* in previous session wasn't defined*/ { init_out( filename, out_file, open_type ); } else { if( filename ) { FILE* f = fopen( filename, "rb" ); long int size_f; if( !f ) UNERR("Can't read file"); /* get file size*/ if( fseek( f, 0, SEEK_END ) ) UNERR("Can't read file"); size_f = ftell( f ); if( fseek( f, 0, SEEK_SET ) ) UNERR("Can't read file"); if( size_f >= prev_size ) { char* buffor = (char*)malloc( prev_size ); if( fread( buffor, 1, prev_size, f ) != prev_size ) UNERR("Can't read file"); fclose(f); *out_file = fopen( filename, open_type ); if( !*out_file ) UNERR("Can't open file"); if( fwrite( buffor, 1, prev_size, *out_file ) != prev_size ) UNERR("Can't write to file"); fflush( *out_file ); free(buffor); } else { fclose( f ); warning( filename, __FILE__, __LINE__ ); warning( "File too small, no output", __FILE__, __LINE__ ); } } else { warning( "Filename was override by null", __FILE__, __LINE__ ); } } }
int main(int argc, char *argv[]) { char read_only = 0; char new_dbfile = 0; char autostarted = 0; unsigned long timeout = 0; unsigned long output_mins = 0; unsigned long past = 0; unsigned long out_delay = 0; char cntr; printf("Sleepwatch version 0.1, Copyright (C) 2016 Philip Manke\n" "Gnomovision comes with ABSOLUTELY NO WARRANTY; for details\n" "type 'sleepwatch -g'. This is free software, and you are welcome\n" "to redistribute it under certain conditions;\n" "read the file 'COPYING' for details.\n\n"); for (cntr = 1; cntr < argc; cntr++) { if (argv[cntr][0] == '-') { switch (argv[cntr][1]) { case 'a': { autostarted = 1; } break; case 'd': { if (argv[cntr][2] == '=') { dbfile = (char *)calloc(strlen(&argv[cntr][3]) + 1, sizeof(char)); strncpy(dbfile, &argv[cntr][3], strlen(&argv[cntr][3])); } else { printf("Unknown argument: %s !\n", argv[cntr]); return 1; } } break; case 'f': { if (argv[cntr][2] == '=') { output = (char *)calloc(strlen(&argv[cntr][3]) + 1, sizeof(char)); strncpy(output, &argv[cntr][3], strlen(&argv[cntr][3])); } else { printf("Unknown argument: %s !\n", argv[cntr]); return 1; } } break; case 'g': { printf("NO WARRANTY\n\n" "11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS " "NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY " "APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE " "COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM " "\"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR " "IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES " "OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE " "ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM " "IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME " "THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n" "12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO " "IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO " "MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, " "BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, " "INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR " "INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO " "LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES " "SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM " "TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR " "OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH " "DAMAGES.\n"); } break; case 'n': { new_dbfile = 1; printf("Starting new database.\n"); } break; case 'l': { if (argv[cntr][2] == '=') { logfile = (char *)calloc(strlen(&argv[cntr][3]) + 1, sizeof(char)); strncpy(logfile, &argv[cntr][3], strlen(&argv[cntr][3])); } else { printf("Unknown argument: %s !\n", argv[cntr]); return 1; } } break; case 'o': { if (argv[cntr][2] == '=') { output_mins = strtoul(&argv[cntr][3], NULL, 0); } else { printf("Unknown argument: %s !\n", argv[cntr]); return 1; } } break; case 'p': { if (argv[cntr][2] == '=') { past = strtoul(&argv[cntr][3], NULL, 0); } else { printf("Unknown argument: %s !\n", argv[cntr]); return 1; } } break; case 'r': { read_only = 1; printf("Only outputting data. Monitoring disabled.\n"); } break; case 't': { if (argv[cntr][2] == '=') { timeout = strtoul(&argv[cntr][3], NULL, 0); printf("Timeout enabled. Shutting down after %lu minutes...\n", timeout); } else { printf("Unknown argument: %s !\n", argv[cntr]); return 1; } } break; case 'w': { if (argv[cntr][2] == '=') { out_delay = strtoul(&argv[cntr][3], NULL, 0); } else { printf("Unknown argument: %s !\n", argv[cntr]); return 1; } } break; default: { printf("Unknown option: %c !\n", argv[cntr][1]); print_usage(); return 1; } break; } } else { printf("Unknown argument: %s !\n", argv[cntr]); print_usage(); return 1; } } // check file paths or set defaults // output file if (output == NULL) { output = (char *)calloc(strlen(DEFAULT_OUTPUT) + 1, sizeof(char)); strncpy(output, DEFAULT_OUTPUT, strlen(DEFAULT_OUTPUT)); } if (test_path(output) == 1) { printf( "ERROR! Path for output file not valid or insufficient permissions!"); cleanup(); return 1; } else { remove(output); } // database file if (dbfile == NULL) { dbfile = (char *)calloc(strlen(DEFAULT_DB) + 1, sizeof(char)); strncpy(dbfile, DEFAULT_DB, strlen(DEFAULT_DB)); } int ret = test_path(dbfile); if (ret == 1) { printf( "ERROR! Path for database file not valid or insufficient permissions!"); cleanup(); return 1; } if (ret == 2) { new_dbfile = 1; } // log file if (logfile == NULL) { logfile = (char *)calloc(strlen(DEFAULT_LOG) + 1, sizeof(char)); strncpy(logfile, DEFAULT_LOG, strlen(DEFAULT_LOG)); } if (test_path(logfile) == 1) { printf("ERROR! Path for log file not valid or insufficient permissions!"); cleanup(); return 1; } // set output fimeframe default if (output_mins == 0) { output_mins = DEFAULT_OUTPUT_MINS; } // sets output update delay default if (out_delay == 0) { out_delay = DEFAULT_OUT_DELAY; } out_delay *= 1000; // convert timeout from minutes to unit of 100 milliseconds if set if (timeout) { timeout *= 600; } unsigned int to = (unsigned int)past; unsigned int from = (unsigned int)(past + output_mins); // initialize the modules printf("Initializing...\n"); init_log(logfile); if (new_dbfile) { remove(dbfile); } init_db(dbfile, new_dbfile); init_watch(!read_only); init_out(output, out_delay, &from, &to, read_only); printf("Running... "); if (!read_only) { char running = 1; OTHR *thread = (OTHR *)malloc(sizeof(OTHR)); pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; thread->spinlock = &mutex; if (!autostarted) { // start thread to check for user input start_other_thread(thread, 0, &check_q); } // main loop printf("Press 'Q'-Enter to stop!\n"); while (running) { if (!autostarted) { pthread_mutex_lock(thread->spinlock); running = thread->running; pthread_mutex_unlock(thread->spinlock); } sleep_milliseconds(100); if (timeout > 0) { timeout--; if (timeout == 0) { printf("Timeout! Stopping...\n"); logm("Timeout hit! Stopping...\n"); if (!autostarted) { pthread_cancel(thread->t_id); } running = 0; } } } free(thread); pthread_mutex_destroy(&mutex); } else { printf("\n"); refresh_out_time(); } cleanup(); return 0; }
main(int argc , char *argv[]) { inpfname = argv[1]; int runno, itno, antno; double time_used; read_data(inpfname); print_data(); init_out(inpfname); time_used = elapsed_time( VIRTUAL ); printf("Initialization took %.10f seconds\n",time_used); for(runno=0;runno<runs;runno++) { seed = (long int ) time(NULL); start_timers(); initialize_ants_variables(runno); initialize_trail(); for(itno=0; bestant.ofn != 436.00 && itno<ncmax ;itno++) { iteration_init(itno); find_values(); analysis( itno); update_stats(itno,runno); #if (usels == 1) if(lswithitbest ==1) { ls(&itbestval,itno); lsstats(itno,runno); } if(lswithbest ==1) { ls(&bestval,itno); lsstats(itno,runno); } #endif trail(); if(!(itno%statsafterit)) { print_itstats(itno ,runno);} }//end of nc max iterations update_stats(itno,runno); report_run(runno); }//end of runs final_stats(); freememory(); }//end of main
int main(int argc, char **argv) { int c; uint8_t header[HASH_SIZE]; uint8_t content[HASH_SIZE]; int empty_moov_pos; int prev_pos; for (;;) { c = getopt(argc, argv, "wh"); if (c == -1) break; switch (c) { case 'w': write_file = 1; break; default: case 'h': help(); return 0; } } av_register_all(); md5 = av_md5_alloc(); if (!md5) return 1; // Write a fragmented file with an initial moov that actually contains some // samples. One moov+mdat with 1 second of data and one moof+mdat with 1 // second of data. init_out("non-empty-moov"); av_dict_set(&opts, "movflags", "frag_keyframe", 0); init(0, 0); mux_gops(2); finish(); close_out(); // Write a similar file, but with b-frames and audio preroll, handled // via an edit list. init_out("non-empty-moov-elst"); av_dict_set(&opts, "movflags", "frag_keyframe", 0); av_dict_set(&opts, "use_editlist", "1", 0); init(1, 1); mux_gops(2); finish(); close_out(); // Use b-frames but no audio-preroll, but without an edit list. // Due to avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO, the dts // of the first audio packet is > 0, but it is set to zero since edit // lists aren't used, increasing the duration of the first packet instead. init_out("non-empty-moov-no-elst"); av_dict_set(&opts, "movflags", "frag_keyframe", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(1, 0); mux_gops(2); finish(); close_out(); format = "ismv"; // Write an ISMV, with b-frames and audio preroll. init_out("ismv"); av_dict_set(&opts, "movflags", "frag_keyframe", 0); init(1, 1); mux_gops(2); finish(); close_out(); format = "mp4"; // An initial moov that doesn't contain any samples, followed by two // moof+mdat pairs. init_out("empty-moov"); av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); mux_gops(2); finish(); close_out(); memcpy(content, hash, HASH_SIZE); // Similar to the previous one, but with input that doesn't start at // pts/dts 0. avoid_negative_ts behaves in the same way as // in non-empty-moov-no-elst above. init_out("empty-moov-no-elst"); av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0); init(1, 0); mux_gops(2); finish(); close_out(); // Same as the previous one, but disable avoid_negative_ts (which // would require using an edit list, but with empty_moov, one can't // write a sensible edit list, when the start timestamps aren't known). // This should trigger a warning - we check that the warning is produced. init_count_warnings(); init_out("empty-moov-no-elst-no-adjust"); av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0); av_dict_set(&opts, "avoid_negative_ts", "0", 0); init(1, 0); mux_gops(2); finish(); close_out(); reset_count_warnings(); check(num_warnings > 0, "No warnings printed for unhandled start offset"); // Verify that delay_moov produces the same as empty_moov for // simple input init_out("delay-moov"); av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); mux_gops(2); finish(); close_out(); check(!memcmp(hash, content, HASH_SIZE), "delay_moov differs from empty_moov"); // Test writing content that requires an edit list using delay_moov init_out("delay-moov-elst"); av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0); init(1, 1); mux_gops(2); finish(); close_out(); // Test writing a file with one track lacking packets, with delay_moov. skip_write_audio = 1; init_out("delay-moov-empty-track"); av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0); init(0, 0); mux_gops(2); // The automatic flushing shouldn't output anything, since we're still // waiting for data for some tracks check(out_size == 0, "delay_moov flushed prematurely"); // When closed (or manually flushed), all the written data should still // be output. finish(); close_out(); check(out_size > 0, "delay_moov didn't output anything"); // Check that manually flushing still outputs things as expected. This // produces two fragments, while the one above produces only one. init_out("delay-moov-empty-track-flush"); av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0); init(0, 0); mux_gops(1); av_write_frame(ctx, NULL); // Force writing the moov check(out_size > 0, "No moov written"); av_write_frame(ctx, NULL); mux_gops(1); av_write_frame(ctx, NULL); finish(); close_out(); skip_write_audio = 0; // Verify that the header written by delay_moov when manually flushed // is identical to the one by empty_moov. init_out("empty-moov-header"); av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); close_out(); memcpy(header, hash, HASH_SIZE); init_out("empty-moov-content"); mux_gops(2); // Written 2 seconds of content, with an automatic flush after 1 second. check(out_size > 0, "No automatic flush?"); empty_moov_pos = prev_pos = out_size; // Manually flush the second fragment av_write_frame(ctx, NULL); check(out_size > prev_pos, "No second fragment flushed?"); prev_pos = out_size; // Check that an extra flush doesn't output any more data av_write_frame(ctx, NULL); check(out_size == prev_pos, "More data written?"); close_out(); memcpy(content, hash, HASH_SIZE); // Ignore the trailer written here finish(); init_out("delay-moov-header"); av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); check(out_size == 0, "Output written during init with delay_moov"); mux_gops(1); // Write 1 second of content av_write_frame(ctx, NULL); // Force writing the moov close_out(); check(!memcmp(hash, header, HASH_SIZE), "delay_moov header differs from empty_moov"); init_out("delay-moov-content"); av_write_frame(ctx, NULL); // Flush the first fragment check(out_size == empty_moov_pos, "Manually flushed content differs from automatically flushed, %d vs %d", out_size, empty_moov_pos); mux_gops(1); // Write the rest of the content av_write_frame(ctx, NULL); // Flush the second fragment close_out(); check(!memcmp(hash, content, HASH_SIZE), "delay_moov content differs from empty_moov"); finish(); // Verify that we can produce an identical second fragment without // writing the first one. First write the reference fragments that // we want to reproduce. av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash", 0); init(0, 0); mux_gops(1); av_write_frame(ctx, NULL); // Output the first fragment init_out("empty-moov-second-frag"); mux_gops(1); av_write_frame(ctx, NULL); // Output the second fragment close_out(); memcpy(content, hash, HASH_SIZE); finish(); // Produce the same second fragment without actually writing the first // one before. av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); av_dict_set(&opts, "avoid_negative_ts", "0", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); skip_gops(1); init_out("empty-moov-second-frag-discont"); mux_gops(1); av_write_frame(ctx, NULL); // Output the second fragment close_out(); check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs"); finish(); // Produce the same thing by using delay_moov, which requires a slightly // different call sequence. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); init(0, 0); skip_gops(1); mux_gops(1); av_write_frame(ctx, NULL); // Output the moov init_out("delay-moov-second-frag-discont"); av_write_frame(ctx, NULL); // Output the second fragment close_out(); check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs"); finish(); // Test discontinously written fragments with b-frames (where the // assumption of starting at pts=0 works) but not with audio preroll // (which can't be guessed). av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash", 0); init(1, 0); mux_gops(1); init_out("delay-moov-elst-init"); av_write_frame(ctx, NULL); // Output the moov close_out(); memcpy(header, hash, HASH_SIZE); av_write_frame(ctx, NULL); // Output the first fragment init_out("delay-moov-elst-second-frag"); mux_gops(1); av_write_frame(ctx, NULL); // Output the second fragment close_out(); memcpy(content, hash, HASH_SIZE); finish(); av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); init(1, 0); skip_gops(1); mux_gops(1); // Write the second fragment init_out("delay-moov-elst-init-discont"); av_write_frame(ctx, NULL); // Output the moov close_out(); check(!memcmp(hash, header, HASH_SIZE), "discontinuously written header differs"); init_out("delay-moov-elst-second-frag-discont"); av_write_frame(ctx, NULL); // Output the second fragment close_out(); check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs"); finish(); // Test discontinously written fragments with b-frames and audio preroll, // properly signaled. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash", 0); init(1, 1); mux_gops(1); init_out("delay-moov-elst-signal-init"); av_write_frame(ctx, NULL); // Output the moov close_out(); memcpy(header, hash, HASH_SIZE); av_write_frame(ctx, NULL); // Output the first fragment init_out("delay-moov-elst-signal-second-frag"); mux_gops(1); av_write_frame(ctx, NULL); // Output the second fragment close_out(); memcpy(content, hash, HASH_SIZE); finish(); av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); init(1, 1); signal_init_ts(); skip_gops(1); mux_gops(1); // Write the second fragment init_out("delay-moov-elst-signal-init-discont"); av_write_frame(ctx, NULL); // Output the moov close_out(); check(!memcmp(hash, header, HASH_SIZE), "discontinuously written header differs"); init_out("delay-moov-elst-signal-second-frag-discont"); av_write_frame(ctx, NULL); // Output the second fragment close_out(); check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs"); finish(); // Test VFR content, with sidx atoms (which declare the pts duration // of a fragment, forcing overriding the start pts of the next one). // Here, the fragment duration in pts is significantly different from // the duration in dts. The video stream starts at dts=-10,pts=0, and // the second fragment starts at dts=155,pts=156. The trun duration sum // of the first fragment is 165, which also is written as // baseMediaDecodeTime in the tfdt in the second fragment. The sidx for // the first fragment says earliest_presentation_time = 0 and // subsegment_duration = 156, which also matches the sidx in the second // fragment. For the audio stream, the pts and dts durations also don't // match - the input stream starts at pts=-2048, but that part is excluded // by the edit list. init_out("vfr"); av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0); init_fps(1, 1, 3); mux_frames(gop_size/2); duration /= 10; mux_frames(gop_size/2); mux_gops(1); finish(); close_out(); // Test VFR content, with cleared duration fields. In these cases, // the muxer must guess the duration of the last packet of each // fragment. As long as the framerate doesn't vary (too much) at the // fragment edge, it works just fine. Additionally, when automatically // cutting fragments, the muxer already know the timestamps of the next // packet for one stream (in most cases the video stream), avoiding // having to use guesses for that one. init_count_warnings(); clear_duration = 1; init_out("vfr-noduration"); av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0); init_fps(1, 1, 3); mux_frames(gop_size/2); duration /= 10; mux_frames(gop_size/2); mux_gops(1); finish(); close_out(); clear_duration = 0; reset_count_warnings(); check(num_warnings > 0, "No warnings printed for filled in durations"); av_free(md5); return check_faults > 0 ? 1 : 0; }
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR, int nCmdShow) { MSG msg; WNDCLASS wndclass,wndclass2; short seed; if (!hPrevInstance) { wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(10)); wndclass.hCursor = NULL; wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName = MAKEINTRESOURCE(1); wndclass.lpszClassName = szAppName; RegisterClass(&wndclass); wndclass2.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW; wndclass2.lpfnWndProc = WndProc; wndclass2.cbClsExtra = 0; wndclass2.cbWndExtra = 0; wndclass2.hInstance = hInstance; wndclass2.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(10)); wndclass2.hCursor = NULL; wndclass2.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wndclass2.lpszMenuName = NULL; wndclass2.lpszClassName = szWinName; RegisterClass(&wndclass2); } mainPtr = CreateWindow (szAppName, "Classic Blades of Exile Scenario Editor", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 0, 0, 536, 478, NULL, NULL, hInstance, NULL); if (!hPrevInstance) { // initialize //center_window(mainPtr); Get_Path(file_path_name); store_hInstance = hInstance; accel = LoadAccelerators(hInstance, MAKEINTRESOURCE(1)); loadSettingsFromFile(); seed = (short) GetCurrentTime(); srand(seed); data_store = new piles_of_stuff_dumping_type; max_window(mainPtr); GetWindowRect(mainPtr,&windRect); SetTimer(mainPtr,1,20,NULL); ShowWindow(mainPtr,nCmdShow); Set_up_win (); init_lb(); init_rb(); init_town(1); init_out(); init_scenario(); font = CreateFont(12,0,0,0,0, 0,0,0, 0,0, 0,0,0,"MS Sans Serif"); small_bold_font = CreateFont(12,0,0,0,700, 0,0,0, 0,0, 0,0,0,"MS Sans Serif"); italic_font = CreateFont(12,0,0,0,0, 1,0,0, 0,0, 0,0,0,"MS Sans Serif"); underline_font = CreateFont(12,0,0,0,0, 0,1,0, 0,0, 0,0,0,"MS Sans Serif"); bold_font = CreateFont(14,0,0,0,700, 0,0,0, 0,0, 0,0,0,"MS Sans Serif"); tiny_font = font; load_sounds(); right_sbar_rect.top = RIGHT_AREA_UL_Y; right_sbar_rect.left = RIGHT_AREA_UL_X + RIGHT_AREA_WIDTH - 16 ; right_sbar_rect.bottom = RIGHT_AREA_UL_Y + RIGHT_AREA_HEIGHT; right_sbar_rect.right = RIGHT_AREA_UL_X + RIGHT_AREA_WIDTH ; right_sbar = CreateWindow("scrollbar",NULL, WS_CHILD | WS_TABSTOP | SBS_VERT, right_sbar_rect.left + ulx,right_sbar_rect.top + uly, right_sbar_rect.right - right_sbar_rect.left, right_sbar_rect.bottom - right_sbar_rect.top, mainPtr,(HMENU) 1,store_hInstance,NULL); init_screen_locs(); set_up_start_screen(); file_initialize(); check_colors(); cursor_stay(); update_item_menu(); shut_down_menus(0); cd_init_dialogs(); } event_handled = FALSE; while(GetMessage(&msg,NULL,0,0)) { if (event_handled == FALSE) { if (!TranslateAccelerator(mainPtr, accel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } } delete data_store; saveSettingsToFile(); return msg.wParam; }