int main(int argc, char **argv) { int arg_idx = 1; fileio_prop_t *prop; if ((argc < 3) || (argc > 4)) { printf("usage: %s [-1] infile outfile\n", argv[0]); exit(1); } fileio_init(); if (strcmp(argv[1], "-1") == 0) { fileio_set_kctype(FILEIO_KC85_1); arg_idx++; } if (fileio_load_file(argv[arg_idx], &prop) < 0) { printf("can't load file '%s'\n", argv[arg_idx]); return 1; } if (fileio_save_wav_prop(argv[arg_idx + 1], prop) < 0) { printf("can't save file '%s'\n", argv[arg_idx + 1]); return 1; } return 0; }
/* * listings_init * * Module initialization. */ lstgctx_t listings_init (scopectx_t kwdscope, logctx_t logctx) { lstgctx_t ctx = malloc(sizeof(struct lstgctx_s)); name_t *onp, *offp; int i; if (ctx != 0) { memset(ctx, 0, sizeof(struct lstgctx_s)); ctx->cur_state = &ctx->main_state; ctx->fio = fileio_init(logctx); memset(ctx->header1, ' ', sizeof(ctx->header1)); memcpy(ctx->header1+PAGENO_POS, "Page", 4); memset(ctx->header2, ' ', sizeof(ctx->header2)); ctx->main_state.listopts[LISTOPT_SRC] = 1; } for (i = 0; i < sizeof(loptswitch)/sizeof(loptswitch[0]); i++) { if (i == 1 || i == 4) { // REQUIRE and LIBRARY value_toggle_declare(kwdscope, &loptswitch[i], listopt_handler, ctx, i, 0, &offp); } else { value_toggle_declare(kwdscope, &loptswitch[i], listopt_handler, ctx, i, &onp, &offp); } } switch_special_declare(kwdscope, LEXTYPE_SWITCH_LIST, list_switch_handler, ctx); return ctx; } /* listings_init */
/* * blissc_init * * Initializes the driver, setting up the context block. * This should be first routine called by a driver program. */ blissc_driverctx_t blissc_init (jmp_buf retenv) { blissc_driverctx_t ctx; ctx = malloc(sizeof(struct blissc_driverctx_s)); if (ctx == 0) return 0; memset(ctx, 0, sizeof(struct blissc_driverctx_s)); ctx->strctx = strings_init(); ctx->logctx = logging_init(retenv); ctx->fioctx = fileio_init(ctx->logctx); ctx->outtype = BLISS_K_OUTPUT_OBJECT; ctx->optlevel = -1; // unset return ctx; } /* blissc_init */
void realmain(int argc, char **argv) { char b[256]; struct stat statbuf; /* vars from oldmain */ buffer *buf = NULL; char path[1024]; int i; setlocale(LC_NUMERIC, "C"); common_init("Egon Animator %s. No Warranty"); sprintf(b, "%s/%ld", siag_basedir, (long)getpid()); mkdir(b, 0700); sprintf(b, "%s/egon.scm", siag_basedir); egonrc = MwStrdup(b); init_interpreters(); siod_interpreter = init_parser(argc, argv); init_python_parser(); init_guile_parser(); init_ruby_parser(); waitforchild(0); init_position(); init_cmds(); buf = new_buffer("noname.egon", "noname.egon"); sprintf(path, "%s/egon/egon.scm", datadir); if (stat(path, &statbuf)) { fprintf(stderr, "Can't find the runtime library (egon.scm).\n"); fprintf(stderr, "Expected it in %s\n", path); fprintf(stderr, "SIAGHOME (if set) is '%s'\n", datadir); fprintf(stderr, "Please read installation instructions.\n"); exit(EXIT_FAILURE); } setvar(cintern("libdir"), strcons(-1, libdir), NIL); setvar(cintern("datadir"), strcons(-1, datadir), NIL); setvar(cintern("docdir"), strcons(-1, docdir), NIL); /* load runtime library */ sprintf(b, "(load \"%s/egon/egon.scm\")", datadir); execute(b); init_windows(buf, &argc, argv); setlocale(LC_NUMERIC, "C"); /* possibly hosed by X */ /* load user customizations, if any */ if (!stat(egonrc, &statbuf)) { sprintf(b, "(load \"%s\")", egonrc); execute(b); } execute("(init-windows)"); execute("(create-menus)"); fileio_init(); for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { strcpy(path, argv[i]); free_buffer(w_list->buf); buf = new_buffer(buffer_name(argv[i]), path); loadmatrix(path, buf, guess_file_format(path)); buf->change = FALSE; w_list->buf = buf; } } pr_scr_flag = TRUE; execute("(popup-editor)"); /* this works, for reasons beyond my comprehension */ execute("(print-version)"); execute("(print-version)"); activate_window(w_list); #ifdef HAVE_LIBTCL Tcl_Main(argc, argv, Tcl_AppInit); #else mainloop(); #endif }
void running_machine::start() { /* initialize basic can't-fail systems here */ fileio_init(this); config_init(this); input_init(this); output_init(this); state_init(this); state_save_allow_registration(this, true); palette_init(this); render_init(this); ui_init(this); generic_machine_init(this); generic_video_init(this); generic_sound_init(this); /* initialize the timers and allocate a soft_reset timer this must be done before cpu_init so that CPU's can allocate timers */ timer_init(this); m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); /* init the osd layer */ osd_init(this); /* initialize the base time (needed for doing record/playback) */ time(&m_base_time); /* initialize the input system and input ports for the game this must be done before memory_init in order to allow specifying callbacks based on input port tags */ time_t newbase = input_port_init(this, m_game.ipt); if (newbase != 0) m_base_time = newbase; /* intialize UI input */ ui_input_init(this); /* initialize the streams engine before the sound devices start */ streams_init(this); /* first load ROMs, then populate memory, and finally initialize CPUs these operations must proceed in this order */ rom_init(this); memory_init(this); watchdog_init(this); /* allocate the gfx elements prior to device initialization */ gfx_init(this); /* initialize natural keyboard support */ inputx_init(this); /* initialize image devices */ image_init(this); /* start up the devices */ m_devicelist.start_all(); /* call the game driver's init function this is where decryption is done and memory maps are altered so this location in the init order is important */ ui_set_startup_text(this, "Initializing...", true); if (m_game.driver_init != NULL) (*m_game.driver_init)(this); /* finish image devices init process */ image_postdevice_init(this); /* start the video and audio hardware */ video_init(this); tilemap_init(this); crosshair_init(this); sound_init(this); /* initialize the debugger */ if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(this); /* call the driver's _START callbacks */ if (m_config.m_machine_start != NULL) (*m_config.m_machine_start)(this); if (m_config.m_sound_start != NULL) (*m_config.m_sound_start)(this); if (m_config.m_video_start != NULL) (*m_config.m_video_start)(this); /* set up the cheat engine */ cheat_init(this); /* set up the hiscore engine */ hiscore_init(this); /* disallow save state registrations starting here */ state_save_allow_registration(this, false); }
int main (int argc, char *argv[]) { const char *snapshot; atexit(shutdown_sdl); if (SDL_Init( #ifdef __EMSCRIPTEN__ // It seems there is an issue with emscripten SDL2: SDL_Init does not work if TIMER and/or HAPTIC is tried to be intialized or just "EVERYTHING" is used!! SDL_INIT_EVERYTHING & ~(SDL_INIT_TIMER | SDL_INIT_HAPTIC) #else SDL_INIT_EVERYTHING #endif ) != 0) { ERROR_WINDOW("Fatal SDL initialization problem: %s", SDL_GetError()); return 1; } if (config_init(argc, argv)) { #ifdef __EMSCRIPTEN__ ERROR_WINDOW("Error with config parsing. Please check the (javascript) console of your browser to learn about the error."); #endif return 1; } guarded_exit = 1; // turn on guarded exit, with custom de-init stuffs DEBUGPRINT("EMU: sleeping = \"%s\", timing = \"%s\"" NL, __SLEEP_METHOD_DESC, __TIMING_METHOD_DESC ); fileio_init( #ifdef __EMSCRIPTEN__ "/", #else app_pref_path, #endif "files"); if (screen_init()) return 1; if (xepgui_init()) return 1; audio_init(config_getopt_int("audio")); z80ex_init(); set_ep_cpu(CPU_Z80); ep_pixels = nick_init(); if (ep_pixels == NULL) return 1; snapshot = config_getopt_str("snapshot"); if (strcmp(snapshot, "none")) { if (ep128snap_load(snapshot)) snapshot = NULL; } else snapshot = NULL; if (!snapshot) { if (roms_load()) return 1; primo_rom_seg = primo_search_rom(); ep_set_ram_config(config_getopt_str("ram")); } mouse_setup(config_getopt_int("mousemode")); ep_reset(); kbd_matrix_reset(); joy_sdl_event(NULL); // this simply inits joy layer ... #ifdef CONFIG_SDEXT_SUPPORT if (!snapshot) sdext_init(); #endif #ifdef CONFIG_EXDOS_SUPPORT wd_exdos_reset(); wd_attach_disk_image(config_getopt_str("wdimg")); #endif #ifdef CONFIG_W5300_SUPPORT w5300_init(NULL); #endif ticks = SDL_GetTicks(); balancer = 0; set_cpu_clock(DEFAULT_CPU_CLOCK); emu_timekeeping_start(); audio_start(); if (config_getopt_int("fullscreen")) screen_set_fullscreen(1); DEBUGPRINT(NL "EMU: entering into main emulation loop" NL); sram_ready = 1; if (strcmp(config_getopt_str("primo"), "none") && !snapshot) { // TODO: da stuff ... primo_emulator_execute(); OSD("Primo Emulator Mode"); } if (snapshot) ep128snap_set_cpu_and_io(); console_monitor_ready(); // OK to run monitor on console now! #ifdef __EMSCRIPTEN__ emscripten_set_main_loop(xep128_emulation, 50, 1); #else for (;;) xep128_emulation(); #endif printf("EXITING FROM main()?!" NL); return 0; }
void running_machine::start() { // initialize basic can't-fail systems here fileio_init(this); config_init(this); input_init(this); output_init(this); state_init(this); state_save_allow_registration(this, true); palette_init(this); render_init(this); ui_init(this); generic_machine_init(this); generic_video_init(this); generic_sound_init(this); // initialize the timers and allocate a soft_reset timer // this must be done before cpu_init so that CPU's can allocate timers timer_init(this); m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); // init the osd layer osd_init(this); // initialize the base time (needed for doing record/playback) time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = input_port_init(this, m_game.ipt); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(this); // initialize the streams engine before the sound devices start streams_init(this); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(this); memory_init(this); watchdog_init(this); // allocate the gfx elements prior to device initialization gfx_init(this); // initialize natural keyboard support inputx_init(this); // initialize image devices image_init(this); // start up the devices m_devicelist.start_all(); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(this, "Initializing...", true); if (m_game.driver_init != NULL) (*m_game.driver_init)(this); // finish image devices init process image_postdevice_init(this); // start the video and audio hardware video_init(this); tilemap_init(this); crosshair_init(this); sound_init(this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(this); // call the driver's _START callbacks if (m_config.m_machine_start != NULL) (*m_config.m_machine_start)(this); if (m_config.m_sound_start != NULL) (*m_config.m_sound_start)(this); if (m_config.m_video_start != NULL) (*m_config.m_video_start)(this); // if we're coming in with a savegame request, process it now const char *savegame = options_get_string(&m_options, OPTION_STATE); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options_get_bool(&m_options, OPTION_AUTOSAVE) && (m_game.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine if (options_get_bool(&m_options, OPTION_CHEAT)) cheat_init(this); // disallow save state registrations starting here state_save_allow_registration(this, false); }
static void init_machine(running_machine *machine) { mame_private *mame = machine->mame_data; int num; /* initialize basic can't-fail systems here */ cpuintrf_init(machine); sndintrf_init(machine); fileio_init(machine); config_init(machine); output_init(machine); state_init(machine); state_save_allow_registration(TRUE); drawgfx_init(machine); palette_init(machine); render_init(machine); ui_init(machine); generic_machine_init(machine); generic_video_init(machine); mame->rand_seed = 0x9d14abd7; /* initialize the base time (if not doing record/playback) */ if (!Machine->record_file && !Machine->playback_file) time(&mame->base_time); else mame->base_time = 0; /* init the osd layer */ if (osd_init(machine) != 0) fatalerror("osd_init failed"); /* initialize the input system */ /* this must be done before the input ports are initialized */ if (code_init(machine) != 0) fatalerror("code_init failed"); /* initialize the input ports for the game */ /* this must be done before memory_init in order to allow specifying */ /* callbacks based on input port tags */ if (input_port_init(machine, machine->gamedrv->ipt) != 0) fatalerror("input_port_init failed"); /* load the ROMs if we have some */ /* this must be done before memory_init in order to allocate memory regions */ rom_init(machine, machine->gamedrv->rom); /* initialize the timers and allocate a soft_reset timer */ /* this must be done before cpu_init so that CPU's can allocate timers */ timer_init(machine); mame->soft_reset_timer = timer_alloc(soft_reset); /* initialize the memory system for this game */ /* this must be done before cpu_init so that set_context can look up the opcode base */ if (memory_init(machine) != 0) fatalerror("memory_init failed"); /* now set up all the CPUs */ if (cpuexec_init(machine) != 0) fatalerror("cpuexec_init failed"); if (cpuint_init(machine) != 0) fatalerror("cpuint_init failed"); #ifdef MESS /* initialize the devices */ devices_init(machine); #endif /* start the save/load system */ saveload_init(machine); /* call the game driver's init function */ /* this is where decryption is done and memory maps are altered */ /* so this location in the init order is important */ ui_set_startup_text("Initializing...", TRUE); if (machine->gamedrv->driver_init != NULL) (*machine->gamedrv->driver_init)(machine); /* start the audio system */ if (sound_init(machine) != 0) fatalerror("sound_init failed"); /* start the video hardware */ if (video_init(machine) != 0) fatalerror("video_init failed"); /* start the cheat engine */ if (options.cheat) cheat_init(machine); /* call the driver's _START callbacks */ if (machine->drv->machine_start != NULL && (*machine->drv->machine_start)(machine) != 0) fatalerror("Unable to start machine emulation"); if (machine->drv->sound_start != NULL && (*machine->drv->sound_start)(machine) != 0) fatalerror("Unable to start sound emulation"); if (machine->drv->video_start != NULL && (*machine->drv->video_start)(machine) != 0) fatalerror("Unable to start video emulation"); /* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */ for (num = 0; num < MAX_MEMORY_REGIONS; num++) if (mame->mem_region[num].flags & ROMREGION_DISPOSE) free_memory_region(machine, num); #ifdef MAME_DEBUG /* initialize the debugger */ if (machine->debug_mode) mame_debug_init(machine); #endif }