void cfg_load() { eeprom_busy_wait(); /* check for magic number */ uint8_t magic = eeprom_read_byte((const uint8_t *)EEPROM_MAGIC_ADDR); if (magic != EEPROM_MAGIC) { /* no data previously stored; set defaults and save */ cfg_set_defaults(); cfg_save(); } else { /* data previously stored; read it */ eeprom_busy_wait(); eeprom_read_block(profile1,(const void *)EEPROM_PROF1_ADDR,TC_NUM_PARAMS); eeprom_busy_wait(); eeprom_read_block(profile2,(const void *)EEPROM_PROF2_ADDR,TC_NUM_PARAMS); /* sanity check */ uint8_t i; for (i = 0; i < TC_NUM_PARAMS; i++) { /* if the value is corrupt, restore the default */ uint8_t maxval = pgm_read_byte(&(params[i]->numvals)); if (profile1[i] >= maxval) profile1[i] = pgm_read_byte(&(params[i]->defaultval)); if (profile2[i] >= maxval) profile2[i] = pgm_read_byte(&(params[i]->defaultval)); } } }
/*********************************************************************** * * Function: flash_image_save * * Purpose: Moves image in memory to FLASH application load region * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Always returns TRUE. * * Notes: None * **********************************************************************/ BOOL_32 flash_image_save(void) { UNS_32 fblock, ffblock; INT_32 sector, numsecs, nblks; FLASH_SAVE_T flashsavdat; /* Set first block pat boot loader */ ffblock = fblock = sysinfo.sysrtcfg.bl_num_blks; /* Save programmed FLASH data */ flashsavdat.block_first = fblock; flashsavdat.num_bytes = sysinfo.lfile.num_bytes; flashsavdat.loadaddr = sysinfo.lfile.loadaddr; flashsavdat.startaddr = (UNS_32) sysinfo.lfile.startaddr; flashsavdat.valid = TRUE; /* Get starting sector and number of sectors to program */ numsecs = sysinfo.lfile.num_bytes / sysinfo.nandgeom->data_bytes_per_page; if ((numsecs * sysinfo.nandgeom->data_bytes_per_page) < sysinfo.lfile.num_bytes) { numsecs++; } flashsavdat.secs_used = numsecs; nblks = numsecs / sysinfo.nandgeom->pages_per_block; if ((nblks * sysinfo.nandgeom->pages_per_block) < numsecs) { nblks++; } flashsavdat.blocks_used = nblks; /* Erase necessary blocks first */ while (nblks > 0) { if (flash_is_bad_block(ffblock) == FALSE) { flash_erase_block(ffblock); nblks--; } ffblock++; } /* Burn image into FLASH */ sector = conv_to_sector(fblock, 0); if (mem_to_nand(sector, (UNS_8 *) sysinfo.lfile.loadaddr, (numsecs * sysinfo.nandgeom->data_bytes_per_page)) == FALSE) { term_dat_out_crlf(nsaeerr_msg); } else { /* Update saved NAND configuration */ syscfg.fsave = flashsavdat; cfg_save(&syscfg); } return TRUE; }
void create_menu_entry_splash_callname_screen(void) { mn_create_single_timed_ack(wt_splash, wt_splash_callname); global_addl_config.boot_splash = 2; cfg_save(); }
void create_menu_entry_datef_alt_screen(void) { mn_create_single_timed_ack(wt_datef,wt_datef_alt); global_addl_config.datef = 5; cfg_save(); }
void create_menu_entry_promtg_enable_screen(void) { mn_create_single_timed_ack(wt_promtg,wt_enable); global_addl_config.promtg = 1; cfg_save(); }
void create_menu_entry_splash_manual_screen(void) { mn_create_single_timed_ack(wt_splash, wt_splash_manual); global_addl_config.boot_splash = 0; cfg_save(); }
void create_menu_entry_userscsv_disable_screen(void) { mn_create_single_timed_ack(wt_userscsv,wt_disable); global_addl_config.userscsv = 0; cfg_save(); }
void create_menu_entry_debug_disable_screen(void) { mn_create_single_timed_ack(wt_debug,wt_disable); global_addl_config.debug = 0; cfg_save(); }
void create_menu_entry_netmon_enable_screen(void) { mn_create_single_timed_ack(wt_netmon,wt_enable); global_addl_config.netmon = 1; cfg_save(); }
void create_menu_entry_micbargraph_disable_screen(void) { mn_create_single_timed_ack(wt_micbargraph,wt_disable); global_addl_config.micbargraph = 0; cfg_save(); }
/*********************************************************************** * * Function: cmd_rstcfg * * Purpose: Restores default system configuration * * Processing: * Call cfg_default to restore default configuation data. * * Parameters: None * * Outputs: None * * Returns: Always TRUE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_rstcfg(void) { cfg_default(&syscfg); key_prompt_set(syscfg.prmpt); cfg_save(&syscfg); return TRUE; }
void create_menu_entry_rbeep_disable_screen(void) { mn_create_single_timed_ack(wt_rbeep,wt_disable); global_addl_config.rbeep = 0; cfg_save(); }
void create_menu_entry_demo_disable_screen(void) { mn_create_single_timed_ack(wt_demoscr, wt_demoscr_disable); global_addl_config.boot_demo = 1; cfg_save(); }
void create_menu_entry_userscsv_enable_screen(void) { mn_create_single_timed_ack(wt_userscsv,wt_enable); global_addl_config.userscsv = 1; cfg_save(); cfg_set_radio_name(); }
/*********************************************************************** * * Function: cfg_user_reset * * Purpose: Reset user configuration data * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Nothing * * Notes: None * **********************************************************************/ void cfg_user_reset(void) { s1l_board_cfg.armclk = 208000000; s1l_board_cfg.hclkdiv = 2; s1l_board_cfg.pclkdiv = 16; clock_adjust(); cfg_save(&syscfg); }
/*********************************************************************** * * Function: cmd_baud * * Purpose: Sets new baud rate * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: TRUE if the baud rate change was good, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_baud(void) { UNS_32 nb; nb = cmd_get_field_val(1); if ((nb == 115200) || (nb == 57600) || (nb == 38400) || (nb == 19200) || (nb == 9600)) { term_setbaud(nb); syscfg.baudrate = nb; cfg_save(&syscfg); } return TRUE; }
void sub_shc_popexec(int value) { shc_node *item = shc_root; config_setting_t *root = config_lookup(&CONFIG, "shortcuts"); char bname[1024]; int i = 0; memset(bname, 0, sizeof(bname)); for (i = 0; item != NULL && i < shc_selection; item = item->next, i++); if (!item || !root) return; switch (value) { case 0: { for (i = config_setting_length(root); i--;) { config_setting_t *elem = config_setting_get_elem(root, i); config_setting_t *member = config_setting_get_member(elem, "path"); if (member) { if (!strcmp(config_setting_get_string(member),item->path)) { sub_game_remove_shortcut(root, i); msgbox(SDL_GetVideoSurface(),NULL, "My Shortcuts", "Shortcut has been deleted.", OK); cfg_save(); msgbox_retval(); return; } } } msgbox(SDL_GetVideoSurface(),NULL,"System Error","Unable to delete Shortcut.", OK); msgbox_retval(); } break; default: break; } }
/*********************************************************************** * * Function: cmd_prompt * * Purpose: prompt command * * Processing: * Parse the string elements for the prompt command and set the new * prompt and timeout values. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was processed, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_prompt(void) { UNS_8 tmpprmpt [16]; UNS_32 to; /* Get new prompt */ str_copy(tmpprmpt, (void *) cmd_get_field_val(1)); /* Get new timeout */ to = cmd_get_field_val(2); str_copy(syscfg.prmpt, tmpprmpt); syscfg.prmpt_to = to; key_prompt_set(syscfg.prmpt); cfg_save(&syscfg); return TRUE; }
int HandleAppEvents(void *userdata, SDL_Event *event) { switch (event->type) { case SDL_APP_LOWMEMORY: return 0; case SDL_APP_WILLENTERBACKGROUND: /* Prepare your app to go into the background. Stop loops, etc. This gets called when the user hits the home button, or gets a call. */ return 0; case SDL_APP_DIDENTERBACKGROUND: /* This will get called if the user accepted whatever sent your app to the background. If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops. When you get this, you have 5 seconds to save all your state or the app will be terminated. Your app is NOT active at this point. */ /* snd_pause(1); */ m_minimized = 1; return 0; case SDL_APP_WILLENTERFOREGROUND: /* This call happens when your app is coming back to the foreground. Restore all your state here. */ return 0; case SDL_APP_DIDENTERFOREGROUND: /* Restart your loops here. Your app is interactive and getting CPU again. */ /* snd_pause(0); */ m_minimized = 0; return 0; case SDL_APP_TERMINATING: cfg_save(); game_done(0); gfx_video_done(); gfx_done(); return 0; default: /* No special processing, add it to the event queue */ return 1; } }
/*********************************************************************** * * Function: cmd_script * * Purpose: Sets up, enables, or disables startup scripting * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: TRUE if the command was accepted, otherwise FALSE * * Notes: None * **********************************************************************/ static BOOL_32 cmd_script(void) { BOOL_32 update = FALSE, parsed = FALSE; UNS_8 *str = get_parsed_entry(1); if (parse_get_entry_count() == 2) { /* on, off, or setup commands? */ if (str_cmp(str, "on") == 0) { if ((syscfg.scr.number_entries > 0) && (syscfg.scr.enabled == FALSE)) { syscfg.scr.enabled = TRUE; update = TRUE; } parsed = TRUE; } else if (str_cmp(str, "off") == 0) { if (syscfg.scr.enabled == TRUE) { syscfg.scr.enabled = FALSE; update = TRUE; } parsed = TRUE; } else if (str_cmp(str, "setup") == 0) { syscfg.scr.enabled = TRUE; update = parsed = script_capture(); } else term_dat_out_crlf((UNS_8 *) "Invalid script command, type help script for more " "info"); if (update) cfg_save(&syscfg); } return parsed; }
void create_menu_entry_edit_dmr_id_screen_store(void) { uint32_t new_dmr_id = 0; wchar_t *bf; #if 0 printf("your enter: "); printhex2((char *) md380_menu_edit_buf, 14); printf("\n"); #endif bf = md380_menu_edit_buf; while (*bf != 0) { new_dmr_id *= 10; new_dmr_id += (*bf++) - '0'; } if ( new_dmr_id > 0xffffff ) { return; } #if 0 printf("\n%d\n", new_dmr_id); #endif global_addl_config.dmrid = new_dmr_id ; cfg_save(); cfg_fix_dmrid(); md380_menu_id = md380_menu_id - 1; md380_menu_depth = md380_menu_depth - 1; if (global_addl_config.userscsv == 1) { cfg_set_radio_name(); } #ifdef CONFIG_MENU md380_create_menu_entry(md380_menu_id, md380_menu_edit_buf, MKTHUMB(md380_menu_entry_back), MKTHUMB(md380_menu_entry_back), 6, 1, 1); #endif }
void start_demo(void) { mikoconfig->rem_lives = 2; mikoconfig->rem_bombs = 3; mikoconfig->start_lives = 2; mikoconfig->start_bombs = 3; mikoconfig->bgm_mode = snd_bgm_mode; mikoconfig->rank = RANK_NORMAL; mikoconfig->continues_used = 0; mikoconfig->unused_3 = 0; mikoconfig->demo_num = demo_num; mikoconfig->shottype = 0; cfg_save(); text_clear(); graph_pi_free(&pi_slot_headers[0], pi_slot_buffers[0]); graph_pi_free(&pi_slot_headers[1], pi_slot_buffers[1]); graph_pi_free(&pi_slot_headers[2], pi_slot_buffers[2]); gaiji_restore(); super_free(); game_exit(); execl("main", "main", 0, 0); }
void toggle_auto_tab(GtkWidget *caller){ gboolean state=gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(caller)); gtk_source_view_set_auto_indent(GTK_SOURCE_VIEW(view),(gboolean)state); cfg_set_auto_tab((int) state); cfg_save(); }
void toggle_linenumber(GtkWidget *caller){ gboolean state=gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(caller)); gtk_source_view_set_show_line_numbers (view,(gboolean)state); cfg_set_show_line((int) state); cfg_save(); }
void toggle_keep_above(GtkWidget *caller){ gtk_window_set_keep_above (GTK_WINDOW(window),gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(caller))); cfg_save(); }
/*********************************************************************** * * Function: boot_manager * * Purpose: Handle boot configuation and options * * Processing: * See function. * * Parameters: * allow_boot : TRUE to allow the system to autoboot * * Outputs: None * * Returns: Nothing * * Notes: None * **********************************************************************/ void boot_manager(BOOL_32 allow_boot) { UNS_8 key, str[255]; int i, idx; UNS_32 secsmt; BOOL_32 usedef = FALSE; /* Get runtime configuration */ get_rt_s1lsys_cfg(&sysinfo.sysrtcfg); /* Query FLASH */ sysinfo.nandgeom = flash_init(); /* Get S1L configuration */ if (cfg_override() != FALSE) { cfg_default(&syscfg); usedef = TRUE; } else if (cfg_load(&syscfg) == FALSE) { cfg_default(&syscfg); syscfg.scr.number_entries = 0; cfg_save(&syscfg); usedef = TRUE; } /* Initial system setup */ sys_up(); if (sysinfo.nandgeom == NULL) { term_dat_out_crlf(nanderr_msg); } /* Set saved baud rate */ term_setbaud(syscfg.baudrate); /* Default configuration used? */ if (usedef != FALSE) { term_dat_out_crlf(cfggdef_msg); } /* Display system header */ term_dat_out_crlf((UNS_8 *) ""); term_dat_out_crlf(sysinfo.sysrtcfg.system_name); term_dat_out(bdat_msg); term_dat_out((UNS_8 *) __DATE__); term_dat_out((UNS_8 *) " "); term_dat_out_crlf((UNS_8 *) __TIME__); /* No file currently loaded in memory */ sysinfo.lfile.loadaddr = 0xFFFFFFFF; sysinfo.lfile.flt = FLT_NONE; sysinfo.lfile.num_bytes = 0; sysinfo.lfile.startaddr = (PFV) 0xFFFFFFFF; sysinfo.lfile.loaded = FALSE; /* Initialize commands */ cmd_core_add_commands(); cmd_image_add_commands(); cmd_nand_add_commands(); ucmd_init(); /* Initialize line prompt and parser */ key_line_init(syscfg.prmpt); /* Prompt usually appears */ menuexit = FALSE; /* Use built in script capability? */ if ((syscfg.scr.enabled == TRUE) && (syscfg.scr.number_entries > 0)) { term_dat_out_crlf((UNS_8 *) "Running built-in script...\n"); i = idx = 0; while (i < syscfg.scr.number_entries) { /* Execute commands */ term_dat_out((UNS_8 *) "-S>"); term_dat_out_crlf(&syscfg.scr.script_data[idx]); cmd_process(&syscfg.scr.script_data[idx]); idx = idx + syscfg.scr.entry_size[i] + 1; i++; } } else { /* In prompt bypass mode? */ if (syscfg.aboot.abootsrc != SRC_NONE) menuexit = allow_boot; if ((syscfg.prmpt_to > 0) && (menuexit == TRUE)) { secsmt = get_seconds() + syscfg.prmpt_to; term_dat_out_crlf(kp_msg); while (get_seconds() < secsmt) { if (term_dat_in_ready() > 0) { term_dat_in(&key, 1); menuexit = FALSE; secsmt = get_seconds(); } } } /* Perform autoboot if possible */ if (menuexit == TRUE) { menuexit = autoboot(); } } while (menuexit == FALSE) { key_get_command(str); str_upper_to_lower(str); cmd_process(str); } /* Bring down some system items */ sys_down(); /* Execute program */ jumptoprog(sysinfo.lfile.startaddr); }
/*********************************************************************** * * Function: cmd_aboot * * Purpose: Sets autoboot source * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Always returns TRUE * * Notes: None * **********************************************************************/ BOOL_32 cmd_aboot(void) { UNS_8 *curp; UNS_32 addr; BOOL_32 processed = TRUE, ready = FALSE; INT_32 nexidx; ABOOT_SETUP_T abs; abs.fname [0] = '\0'; if (parse_get_entry_count() >= 3) { /* Get source */ curp = get_parsed_entry(1); nexidx = 2; if (str_cmp(curp, "term") == 0) { /* Clear break */ term_break(); abs.abootsrc = SRC_TERM; } else if (str_cmp(curp, "blk") == 0) { abs.abootsrc = SRC_BLKDEV; /* Get filename */ curp = get_parsed_entry(2); memcpy(abs.fname, curp, str_size(curp)); abs.fname[str_size(curp)] = '\0'; nexidx = 3; } else if (str_cmp(curp, "flash") == 0) { abs.abootsrc = SRC_NAND; } else if (str_cmp(curp, "none") == 0) { abs.abootsrc = SRC_NONE; } else { term_dat_out_crlf(invalsrc_msg); processed = FALSE; } /* Get file type */ curp = get_parsed_entry(nexidx); abs.flt = FLT_NONE; if (str_cmp(curp, "elf") == 0) { abs.flt = FLT_ELF; } else if (str_cmp(curp, "raw") == 0) { abs.flt = FLT_RAW; } else if (str_cmp(curp, "bin") == 0) { abs.flt = FLT_BIN; } else if (str_cmp(curp, "srec") == 0) { abs.flt = FLT_SREC; } else { abs.flt = FLT_NONE; term_dat_out(unkft_msg); term_dat_out_crlf(curp); processed = FALSE; } /* Next index */ nexidx++; /* Handle each file type */ if (processed == TRUE) { switch (abs.flt) { case FLT_RAW: /* Get load address */ curp = get_parsed_entry(nexidx); ready = str_hex_to_val(curp, &addr); if (ready == TRUE) { abs.loadaddr = addr; abs.startaddr = addr; } else { term_dat_out_crlf(rawna_msg); } /* Start address */ nexidx++; curp = get_parsed_entry(nexidx); if (curp != NULL) { ready &= str_hex_to_val(curp, &addr); if (ready == TRUE) { abs.startaddr = addr; } } break; case FLT_BIN: ready = FALSE; /* TBD not supported yet */ processed = TRUE; break; case FLT_SREC: ready = TRUE; processed = TRUE; break; case FLT_ELF: ready = FALSE; /* TBD not supported yet */ processed = TRUE; break; default: break; } } } if (ready == TRUE) { syscfg.aboot = abs; cfg_save(&syscfg); term_dat_out_crlf(bsgood_msg); } else { term_dat_out_crlf(bsbad_msg); } return TRUE; }
int main(int argc, char *argv[]) { #ifdef _USE_UNPACK int clean_tmp = 0; #endif int err = 0; int i; #ifdef __APPLE__ macosx_init(); #endif #ifndef S60 putenv("SDL_MOUSE_RELATIVE=0"); /* test this! */ #endif #ifdef _WIN32_WCE libwince_init(argv[0], 1); wince_init(argv[0]); #else #ifdef S60 extern char s60_data[]; strcpy(game_cwd, s60_data); #else #ifdef _WIN32 strcpy(game_cwd, dirname(argv[0])); #else if (!getcwd(game_cwd, sizeof(game_cwd))) fprintf(stderr,"Warning: can not get current dir\n."); #endif #endif #endif unix_path(game_cwd); setdir(game_cwd); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-vsync")) vsync_sw = 1; else if (!strcmp(argv[i], "-nosound")) nosound_sw = 1; else if (!strcmp(argv[i], "-fullscreen")) fullscreen_sw = 1; else if (!strcmp(argv[i], "-mode")) { if ((i + 1) < argc) mode_sw = argv[++i]; else mode_sw = "-1x-1"; } else if (!strcmp(argv[i], "-window")) window_sw = 1; else if (!strcmp(argv[i], "-debug")) { if (!debug_sw) debug_init(); debug_sw = 1; } else if (!strcmp(argv[i], "-owntheme")) owntheme_sw = 1; else if (!strcmp(argv[i], "-noautosave")) noauto_sw = 1; else if (!strcmp(argv[i], "-game")) { if ((i + 1) < argc) game_sw = argv[++i]; else game_sw = ""; } else if (!strcmp(argv[i], "-theme")) { if ((i + 1) < argc) theme_sw = argv[++i]; else theme_sw = ""; } else if (!strcmp(argv[i], "-nostdgames")) { nostdgames_sw = 1; #ifdef _LOCAL_APPDATA } else if (!strcmp(argv[i], "-appdata")) { if ((i + 1) < argc) appdata_sw = argv[++i]; else appdata_sw = ""; #endif } else if (!strcmp(argv[i], "-chunksize")) { if ((i + 1) < argc) chunksize_sw = atoi(argv[++i]); else chunksize_sw = DEFAULT_CHUNKSIZE; } else if (!strcmp(argv[i], "-gamespath")) { if ((i + 1) < argc) games_sw = argv[++i]; else games_sw = ""; } else if (!strcmp(argv[i], "-themespath")) { if ((i + 1) < argc) themes_sw = argv[++i]; else themes_sw = ""; } else if (!strcmp(argv[i], "-idf")) { if ((i + 1) < argc) idf_sw = argv[++i]; else { fprintf(stderr,"No data directory specified.\n"); err = 1; goto out; } } else if (!strcmp(argv[i], "-encode")) { if ((i + 1) < argc) encode_sw = argv[++i]; else { fprintf(stderr,"No lua file specified.\n"); err = 1; goto out; } if ((i + 1) < argc) encode_output = argv[++i]; else encode_output = "lua.enc"; } else if (!strcmp(argv[i], "-version")) { version_sw = 1; } else if (!strcmp(argv[i], "-nopause")) { nopause_sw = 1; } else if (!strcmp(argv[i], "-software")) { software_sw = 1; #ifdef _USE_UNPACK } else if (!strcmp(argv[i], "-install")) { if ((i + 1) < argc) { char *file = argv[++i]; char *p; if (games_sw) p = games_sw; else p = game_local_games_path(1); if (setup_zip(file, p)) { err = 1; goto out; } } #endif } else if (!strcmp(argv[i], "-quit")) { exit(0); } else if (!strcmp(argv[i], "-hinting")) { if ((i + 1) < argc) hinting_sw = atoi(argv[++i]); else hinting_sw = 1; } else if (!strcmp(argv[i], "-lua") || !strcmp(argv[i], "-luac")) { if ((i + 1) < argc) { lua_exec = !strcmp(argv[i], "-lua"); lua_sw = argv[++ i]; opt_index = i + 1; break; } else { fprintf(stderr, "No lua script.\n"); err = 1; goto out; } } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) { usage(); goto out; } else if (argv[i][0] == '-') { fprintf(stderr,"Unknown option: %s\n", argv[i]); usage(); err = 1; goto out; } else if (!start_idf(argv[i])) { fprintf(stderr, "Adding idf: %s\n", argv[i]); } else if (!run_game(argv[i])) { fprintf(stderr, "Opening game: %s\n", argv[i]); } #ifdef _USE_UNPACK else { char *p; if (games_sw) p = games_sw; else p = game_tmp_path(); if (setup_zip(argv[i], p)) { err = 1; goto out; } clean_tmp = 1; } #endif } cfg_load(); if (opt_debug == 1 && debug_sw == 0) { debug_sw = 1; debug_init(); } if (opt_vsync == 1 && vsync_sw == 0) vsync_sw = 1; if (version_sw) { fprintf(stdout, VERSION"\n"); goto out; } if (lua_sw) { err = instead_init_lua(dirname(lua_sw)); if (err) goto out; if (!err) err = instead_loadscript(lua_sw, argc - opt_index, argv + opt_index, lua_exec); instead_done(); goto out; } if (encode_sw) { err = instead_encode(encode_sw, encode_output); goto out; } if (idf_sw) { char *p = malloc(strlen(idf_sw) + 5); if (p) { char *b; strcpy(p, idf_sw); b = basename(p); strcat(b, ".idf"); idf_create(b, idf_sw); free(p); } else idf_create("data.idf", idf_sw); goto out; } menu_langs_lookup(dirpath(LANG_PATH)); if (!langs_nr) { fprintf(stderr, "No languages found in: %s.\n", dirpath(LANG_PATH)); err = 1; goto out; } if (!opt_lang || !opt_lang[0]) opt_lang = game_locale(); if (menu_lang_select(opt_lang) && menu_lang_select(LANG_DEF)) { fprintf(stderr, "Can not load default language.\n"); err = 1; goto out; } if (games_sw) games_lookup(games_sw); if (owntheme_sw && !opt_owntheme) { opt_owntheme = 2; } if (!nostdgames_sw && games_lookup(dirpath(GAMES_PATH))) fprintf(stderr, "No games found in: %s.\n", GAMES_PATH); if (themes_sw) themes_lookup(themes_sw); if (!nostdthemes_sw) { themes_lookup(dirpath(THEMES_PATH)); themes_lookup(game_local_themes_path()); } if (!nostdgames_sw) games_lookup(game_local_games_path(0)); if (start_idf_sw) { char *d, *b; char *dd, *bb; static char idf_game[255]; d = strdup(start_idf_sw); b = strdup(start_idf_sw); if (d && b) { dd = dirname(d); bb = basename(b); if (!games_replace(dirpath(dd), bb)) { game_sw = idf_game; strncpy(idf_game, bb, sizeof(idf_game) - 1); idf_game[sizeof(idf_game) - 1] = 0; } } if (d) free(d); if (b) free(b); } if (noauto_sw && opt_autosave) opt_autosave = 2; if (window_sw) opt_fs = 0; if (fullscreen_sw) opt_fs = 1; if (mode_sw) parse_mode(mode_sw, opt_mode); if (game_sw) { FREE(opt_game); opt_game = game_sw; } if (theme_sw) { FREE(opt_theme); opt_theme = theme_sw; } if (opt_theme) game_theme_select(opt_theme); if (!curtheme_dir) game_theme_select(DEFAULT_THEME); /* Initialize SDL */ if (gfx_init() < 0) return -1; #ifdef _USE_GTK gtk_init(&argc, &argv); /* must be called AFTER SDL_Init when using SDL2 */ #endif if (gfx_video_init() || input_init()) return -1; if (game_init(opt_game)) { game_error(); } game_loop(); cfg_save(); game_done(0); gfx_video_done(); #ifndef ANDROID gfx_done(); #endif out: if (debug_sw) debug_done(); #ifdef _USE_GTK /* gtk_main_quit (); */ #endif #ifdef _USE_UNPACK if (clean_tmp) remove_dir(game_tmp_path()); #endif #if defined(ANDROID) || defined(IOS) exit(err); #endif return err; }
uint8_t setup_handle_key(uint8_t key) { uint8_t ret = 0; switch (key) { case K_UP: { int8_t oldparam = currparam; currparam--; if (currparam < -1) currparam = TC_NUM_PARAMS; setup_print_line(oldparam); setup_print_line(currparam); break; } case K_DOWN: { int8_t oldparam = currparam; currparam++; if (currparam > TC_NUM_PARAMS) currparam = -1; setup_print_line(oldparam); setup_print_line(currparam); break; } case '\n': { if (currparam == TC_NUM_PARAMS) /* save and quit */ { /* copy the temp settings back */ memcpy(profile1, profile1temp, TC_NUM_PARAMS); memcpy(profile2, profile2temp, TC_NUM_PARAMS); config = (profilenumber) ? profile2 : profile1; cfg_save(); ret = SETUP_SAVE; } else if (currparam == -1) /* change profile */ { currprof = !currprof; config = (currprof) ? profile2temp : profile1temp; setup_redraw(); } else { uint8_t maxval = pgm_read_byte(&(params[currparam]->numvals)); config[currparam]++; if (config[currparam] >= maxval) config[currparam] = 0; setup_print_line(currparam); } break; } case '\x1B': /* ESC */ case K_NUMLK: { config = (profilenumber) ? profile2 : profile1; ret = SETUP_CANCEL; break; } } return ret; }
int main(void) { unsigned char ret; if(snd_pmd_resident()) { snd_mmd_resident(); if(game_init_op()) { zun_error(ERROR_OUT_OF_MEMORY); return 1; } extra_unlocked = score_cleared_load(); if(cfg_load() == 1) { return 1; } } else { return 1; } gaiji_backup(); gaiji_entry_bfnt("MIKOFT.bft"); if(mikoconfig->demo_num == 0) { demo_num = 1; snd_kaja_func(KAJA_SONG_STOP, 0); } else { demo_num = mikoconfig->demo_num + 1; if(demo_num > 3) { demo_num = 1; } score_duration = 350; score_menu(); graph_showpage(0); graph_accesspage(0); } input = 0; snd_active = snd_bgm_mode; if(!mikoconfig->demo_num && snd_midi_possible) { char midi_active = snd_midi_active; snd_midi_active = 1; snd_load("gminit.m", SND_LOAD_SONG); snd_kaja_func(KAJA_SONG_PLAY, 0); snd_midi_active = midi_active; } op_animate(); pi_slot_load(2, "ts3.pi"); pi_slot_load(1, "ts2.pi"); input = 0; idle_frames = 0; while(!quit) { input_sense(); if(in_option == 0) { main_update_and_render(); } else if(in_option == 1) { option_update_and_render(); } mikoconfig->frame++; idle_frames++; frame_delay(1); } ret = mikoconfig->op_main_retval; mikoconfig_sgm = 0; cfg_save(); text_clear(); graph_clear(); game_exit_to_dos(); gaiji_restore(); return ret; }