static test_result c (int cmd, int obj, int expected, UINT8 *p) { int location; int match; test_report ("(%d)%s %d => ", cmd, logic_names_cmd[cmd].name, obj); execute_agi_command (cmd, p); location = object_get_location(obj); test_report ("new location %d", location); if (!(match = (expected == location))) { test_report (" [Expected: %d]", expected); } return match ? TEST_OK : TEST_FAIL; }
static int show_items() { unsigned int x, i; for (x = i = 0; x < game.num_objects; x++) { if (object_get_location(x) == EGO_OWNED) { /* add object to our list! */ intobj[i] = x; print_item(i, STATUS_FG, STATUS_BG); i++; } } if (i == 0) { _text->print_text(NOTHING_MSG, 0, NOTHING_X, NOTHING_Y, 40, STATUS_FG, STATUS_BG); } return i; }
int save_game (char* s, char* d) { SINT16 i; struct image_stack_element* ptr = image_stack; FILE* f = fopen (s, "wb"); if(!f) return err_BadFileOpen; write_bytes (f, strSig, 8); write_string (f, d); write_uint8 (f, (UINT8)SAVEGAME_VERSION); write_uint8 (f, (UINT8)game.state); /* game.name */ write_string (f, game.id); /* game.crc */ for (i = 0; i < MAX_FLAGS; i++) write_uint8 (f, game.flags[i]); for (i = 0; i < MAX_VARS; i++) write_uint8 (f, game.vars[i]); write_sint16 (f, (SINT8)game.horizon); write_sint16 (f, (SINT16)game.line_status); write_sint16 (f, (SINT16)game.line_user_input); write_sint16 (f, (SINT16)game.line_min_print); /* game.cursor_pos */ /* game.input_buffer */ /* game.echo_buffer */ /* game.keypress */ write_sint16 (f, (SINT16)game.input_mode); write_sint16 (f, (SINT16)game.lognum); write_sint16 (f, (SINT16)game.player_control); write_sint16 (f, (SINT16)game.quit_prog_now); write_sint16 (f, (SINT16)game.status_line); write_sint16 (f, (SINT16)game.clock_enabled); write_sint16 (f, (SINT16)game.exit_all_logics); write_sint16 (f, (SINT16)game.picture_shown); write_sint16 (f, (SINT16)game.has_prompt); write_sint16 (f, (SINT16)game.game_flags); /* Reversed to keep compatibility with old savegames */ write_sint16 (f, (SINT16)!game.input_enabled); for (i = 0; i < _HEIGHT; i++) write_uint8 (f, game.pri_table[i]); /* game.msg_box_ticks */ /* game.block */ /* game.window */ /* game.has_window */ write_sint16 (f, (SINT16)game.gfx_mode); write_uint8 (f, game.cursor_char); write_sint16 (f, (SINT16)game.color_fg); write_sint16 (f, (SINT16)game.color_bg); /* game.hires (#ifdef USE_HIRES) */ /* game.sbuf */ /* game.ego_words */ /* game.num_ego_words */ write_sint16 (f, (SINT16)game.num_objects); for (i = 0; i < (SINT16)game.num_objects; i++) write_sint16 (f, (SINT16)object_get_location(i)); /* game.ev_keyp */ for (i = 0; i < MAX_STRINGS; i++) write_string (f, game.strings[i]); /* record info about loaded resources */ for (i = 0; i < MAX_DIRS; i++) { write_uint8 (f, game.dir_logic[i].flags); write_sint16 (f, (SINT16)game.logics[i].sIP); write_sint16 (f, (SINT16)game.logics[i].cIP); } for (i = 0; i < MAX_DIRS; i++) write_uint8(f, game.dir_pic[i].flags); for (i = 0; i < MAX_DIRS; i++) write_uint8(f, game.dir_view[i].flags); for (i = 0; i < MAX_DIRS; i++) write_uint8(f, game.dir_sound[i].flags); /* game.pictures */ /* game.logics */ /* game.views */ /* game.sounds */ for(i = 0; i < MAX_VIEWTABLE; i++) { struct vt_entry* v = &game.view_table[i]; write_uint8(f, v->step_time); write_uint8(f, v->step_time_count); write_uint8(f, v->entry); write_sint16(f, v->x_pos); write_sint16(f, v->y_pos); write_uint8(f, v->current_view); /* v->view_data */ write_uint8(f, v->current_loop); write_uint8(f, v->num_loops); /* v->loop_data */ write_uint8(f, v->current_cel); write_uint8(f, v->num_cels); /* v->cel_data */ /* v->cel_data_2 */ write_sint16(f, v->x_pos2); write_sint16(f, v->y_pos2); /* v->s */ write_sint16(f, v->x_size); write_sint16(f, v->y_size); write_uint8(f, v->step_size); write_uint8(f, v->cycle_time); write_uint8(f, v->cycle_time_count); write_uint8(f, v->direction); write_uint8(f, v->motion); write_uint8(f, v->cycle); write_uint8(f, v->priority); write_uint16(f, v->flags); write_uint8(f, v->parm1); write_uint8(f, v->parm2); write_uint8(f, v->parm3); write_uint8(f, v->parm4); } /* Save image stack */ for (i = 0; i < image_stack_pointer; i++) { ptr = &image_stack[i]; write_uint8 (f, ptr->type); write_sint16 (f, ptr->parm1); write_sint16 (f, ptr->parm2); write_sint16 (f, ptr->parm3); write_sint16 (f, ptr->parm4); write_sint16 (f, ptr->parm5); write_sint16 (f, ptr->parm6); write_sint16 (f, ptr->parm7); } write_uint8(f, 0); fclose(f); return err_OK; }