void Blitters_Init() { ConsolePrint(Msg_Get(MSG_Blitters_Loading)); Blitters.list = NULL; Blitters.current = NULL; // Open and read file t_tfile * tf; if ((tf = tfile_read (Blitters.filename)) == NULL) Quit_Msg("%s", meka_strerror()); ConsolePrint("\n"); // Parse each line int line_cnt = 0; for (t_list* lines = tf->data_lines; lines; lines = lines->next) { const char* line = (char*)lines->elem; line_cnt += 1; int i, j; char s1 [256], s2 [256]; for (i = 0, j = 0; line [i] != 0 && line [i] != ';'; i ++) if ((line [0] == '[') || (line [i] != ' ' && line [i] != '\t')) s2 [j ++] = line [i]; s2 [j] = 0; if (StrIsNull (s2)) continue; strcpy(s1, s2); StrLower(s1); switch (Blitters_Parse_Line (s1, s2)) { case MEKA_ERR_UNKNOWN: tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Unrecognized), line_cnt); case MEKA_ERR_MISSING: tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Missing), line_cnt); case MEKA_ERR_VALUE_INCORRECT: tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Incorrect_Value), line_cnt); } } // Free file data tfile_free(tf); // Requires at least 1 blitter if (Blitters.count == 0) Quit_Msg("%s", Msg_Get(MSG_Blitters_Error_Not_Enough)); // Current blitter if (Blitters.blitter_configuration_name != NULL) Blitters.current = Blitters_FindBlitterByName(Blitters.blitter_configuration_name); if (Blitters.current == NULL) Blitters.current = (t_blitter*)Blitters.list->elem; // first }
// Reload current ROM file bool Reload_ROM() { if (StrIsNull(g_env.Paths.MediaImageFile)) { Msg(MSGT_USER, "%s", Msg_Get(MSG_LoadROM_Reload_No_ROM)); return false; } if (Load_ROM(LOAD_MODE_GUI, FALSE)) { Msg(MSGT_USER, "%s", Msg_Get(MSG_LoadROM_Reload_Reloaded)); return true; } return false; }
void Filenames_Init_ROM() { // ROM (when parsed from command line) if (StrIsNull(g_env.Paths.MediaImageFile)) { strcpy(g_env.Paths.BatteryBackedMemoryFile, ""); return; } // Save/OnBoard memory filename { char temp[FILENAME_LEN]; strcpy(temp, g_env.Paths.MediaImageFile); StrPath_RemoveExtension(temp); StrPath_RemoveDirectory(temp); sprintf(g_env.Paths.BatteryBackedMemoryFile, "%s/%s.sav", g_env.Paths.SavegameDirectory, temp); } }
// Load messages from MEKA.MSG file (path given in structure) // Return a MEKA_ERR_xxx code int Messages_Init (void) { t_tfile * tf; t_list * lines; int line_cnt; char * p; Messages.Lang_Cur = Messages.Lang_Default = NULL; Messages.Langs = NULL; // Note: this is one of the few cases were the string has to be hardcoded. // That is of course because the messages/localization system is not // initialized as of yet.. ConsolePrint("Loading MEKA.MSG (messages).. "); // Open and read file -------------------------------------------------------- tf = tfile_read (Messages.FileName); if (tf == NULL) Quit_Msg("MISSING!\nTry re-installing your version of Meka."); ConsolePrint("\n"); // Parse each line ----------------------------------------------------------- line_cnt = 0; for (lines = tf->data_lines; lines; lines = lines->next) { char *line = (char*)lines->elem; line_cnt += 1; // Cut Comments p = strchr (line, ';'); if (p != NULL) *p = EOSTR; StrTrim (line); if (StrIsNull (line)) continue; // Parse Line and handle errors // ConsolePrintf ("%d: %s--\n", line_cnt, line); switch (Messages_Init_Parse_Line(line)) { case MEKA_ERR_MISSING: ConsolePrintf ("On line %d: No language defined for storing message !", line_cnt); tfile_free(tf); Quit(); break; case MEKA_ERR_UNKNOWN: ConsolePrintf ("On line %d: Unknown message \"%s\", skipping it.\n", line_cnt, line); // tfile_free(tf); // Quit(); break; case MEKA_ERR_SYNTAX: ConsolePrintf ("On line %d: Syntax error.\n%s\n", line_cnt, line); tfile_free(tf); Quit(); break; } } // Free file data tfile_free(tf); // Verify language completion { if (Messages.Lang_Cur == NULL) Quit_Msg("No language defined. Try re-installing your version of Meka."); Messages.Lang_Cur = Messages.Lang_Default; for (t_list* langs = Messages.Langs; langs; langs = langs->next) { t_lang* lang = (t_lang*)langs->elem; if (Lang_Post_Check (lang) != MEKA_ERR_OK) if (lang == Messages.Lang_Default) Quit_Msg("This is the default language, so we need to abort."); } } // Ok return (MEKA_ERR_OK); }
bool Load_ROM_Command_Line() { if (StrIsNull(g_env.Paths.MediaImageFile)) return false; return Load_ROM(LOAD_MODE_COMMANDLINE, true); }