int loadgame_simple () { char home[MAX_PATH], path[MAX_PATH]; int rc = 0; if (get_app_dir (home, MAX_PATH) < 0) { message_box ("Error loading game."); return err_BadFileOpen; } sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav", home, game.crc, game.id, 0); erase_both(); stop_sound(); close_window(); if ((rc = load_game (path)) == err_OK) { message_box ("Game restored."); game.exit_all_logics = 1; menu_enable_all(); } else { message_box ("Error restoring game."); } return rc; }
int loadgame_dialog () { char home[MAX_PATH], path[MAX_PATH]; int rc, slot = 0; int hm, vm, hp, vp; /* box margins */ int w; hm = 2; vm = 3; hp = hm * CHAR_COLS; vp = vm * CHAR_LINES; w = (40 - 2 * hm) - 1; if (get_app_dir (home, MAX_PATH) < 0) { message_box ("Error loading game."); return err_BadFileOpen; } sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id); erase_both(); stop_sound(); draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp); print_text ("Select a game which you wish to\nrestore:", 0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR); print_text ("Press ENTER to select, ESC cancels", 0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR); slot = select_slot (path); if (slot < 0) { message_box ("Game NOT restored."); return err_OK; } sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav", home, game.crc, game.id, slot); if ((rc = load_game (path)) == err_OK) { message_box ("Game restored."); game.exit_all_logics = 1; menu_enable_all(); } else { message_box ("Error restoring game."); } return rc; }
int loadgame_simple () { char home[MAX_PATH], path[MAX_PATH]; int rc = 0; printf("here?\n"); #ifdef DREAMCAST uint8 addr, port, unit; addr = maple_first_vmu(); if (addr) { maple_create_port (addr, &port, &unit); sprintf (g_vmu_port, "%c%d", port + 'a', unit); } else { message_box("No VMU found."); return err_OK; } sprintf(path, VMU_PATH, g_vmu_port, game.id, slot); #else if (get_app_dir (home, MAX_PATH) < 0) { message_box ("Error loading game."); return err_BadFileOpen; } sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav", home, game.crc, game.id, 0); #endif erase_both(); stop_sound(); close_window(); if ((rc = load_game (path)) == err_OK) { message_box ("Game restored."); game.exit_all_logics = 1; menu_enable_all(); } else { message_box ("Error restoring game."); } return rc; }
u8 *cmd_restart_game(u8 *c) { u16 snd_state; u16 user_result; u16 input_state; sound_stop(); input_state = input_edit_status(); input_edit_on(); if (flag_test(F16_RESTARTMODE) != 0) user_result = 1; else user_result = message_box("Press ENTER to restart\nthe game.\n\nPress ESC to continue\nthis game."); if ( user_result != 0) { cmd_cancel_line(0); snd_state = flag_test(F09_SOUND); //clear_memory(); // shouldn't be necessary game_init(); volumes_close(); flag_set(F06_RESTART); if ( snd_state != 0) flag_set(F09_SOUND); state.ticks = 0; if (trace_logic != 0) logic_load_2(trace_logic); menu_enable_all(); } if ( (user_result != 0) || (input_state != 0) ) input_edit_off(); if (user_result != 0) return 0; else return c; }
int loadgame_dialog () { #ifndef PALMOS char home[MAX_PATH], path[MAX_PATH]; int rc, slot = 0; int hm, vm, hp, vp; /* box margins */ int w; hm = 2; vm = 3; hp = hm * CHAR_COLS; vp = vm * CHAR_LINES; w = (40 - 2 * hm) - 1; #ifdef DREAMCAST uint8 addr, port, unit; addr = maple_first_vmu(); if (addr) { maple_create_port (addr, &port, &unit); sprintf (g_vmu_port, "%c%d", port + 'a', unit); } else { message_box("No VMU found."); return err_OK; } #else if (get_app_dir (home, MAX_PATH) < 0) { message_box ("Error loading game."); return err_BadFileOpen; } # ifdef CIBYL sprintf (path, "recordstore://%05X.%s:", game.crc, game.id); # else sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id); # endif #endif erase_both(); stop_sound(); draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp); print_text ("Select a game which you wish to\nrestore:", 0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR); print_text ("Press ENTER to select, ESC cancels", 0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR); slot = select_slot (path); if (slot < 0) { message_box ("Game NOT restored."); return err_OK; } #ifdef DREAMCAST sprintf(path, VMU_PATH, g_vmu_port, game.id, slot); #elif CIBYL sprintf (path, "recordstore://%05X.%s:%d", game.crc, game.id, slot+1); printf("path: %s\n", path); #else sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav", home, game.crc, game.id, slot); #endif if ((rc = load_game (path)) == err_OK) { message_box ("Game restored."); game.exit_all_logics = 1; menu_enable_all(); } else { message_box ("Error restoring game."); } return rc; #endif /* PALMOS */ }
u8 *cmd_restore_game(u8 *c) { u8 *code_ret; // result to pass at the end u8 newline_orig; // d0d orig FILE *rest_stream; //u8 msg[200]; u8 *msg; clock_state = 1; code_ret = c; newline_orig = msgstate.newline_char; msgstate.newline_char = '@'; if (save_dir == 0) save_dir = vstring_new(0, 200); if (save_filename == 0) save_filename = vstring_new(0, 250); if (state_get_info('r') != 0) { if (strlen(save_filename->data) > strlen(save_dir->data)) msg = alloca(200 + strlen(save_filename->data)); else msg = alloca(200 + strlen(save_dir->data)); if (state_name_auto[0] == 0) { sprintf(msg, "About to restore the game\ndescribed as:\n\n%s\n\nfrom file:\n %s\n\n%s", save_description, save_filename->data, "Press ENTER to continue.\nPress ESC to cancel."); message_box_draw(msg, 0, 0x23, 0); if ( user_bolean_poll() == 0) goto rest_end; } dir_preset_change(DIR_PRESET_GAME); rest_stream = fopen(save_filename->data, "rb"); if ( rest_stream == 0) { sprintf(msg, "Can't open file:\n %s", save_filename->data); message_box(msg); } else { fseek(rest_stream, 0x1F, SEEK_SET); if (state_read(rest_stream, &state) == 0) goto loc2630; if (state_read(rest_stream, objtable) == 0) goto loc2630; if (state_read(rest_stream, inv_obj_table) == 0) goto loc2630; if (state_read(rest_stream, inv_obj_string) == 0) goto loc2630; if (state_read(rest_stream, script_head) == 0) goto loc2630; if (state_read(rest_stream, scan_start_list) != 0) goto loc2647; loc2630: fclose(rest_stream); message_box("Error in restoring game.\nPress ENTER to quit."); agi_exit(); // can't recover.. we possibly just overwrote some of the // structures with stuff loc2647: fclose(rest_stream); decrypt_string(inv_obj_string, inv_obj_string+inv_obj_string_size); state.var[V20_COMPUTER] = computer_type; state.var[V26_MONITORTYPE] = display_type; state.var[V08_FREEMEM] = 10; if (computer_type == 0) state.var[V22_SNDTYPE] = 1; else { state.var[V22_SNDTYPE] = 3; flag_set(F11_NEWLOGIC0); } state_reload(); control_state_clear(); flag_set(F12_RESTORE); volumes_close(); code_ret = 0; menu_enable_all(); } } rest_end: cmd_close_window(0); msgstate.newline_char = newline_orig; clock_state = 0; return code_ret; }